-
Notifications
You must be signed in to change notification settings - Fork 981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[workspace]Hide the assistant entry when there isn't data2summary agent #9277
Changes from 5 commits
4b7cf42
ef1ab32
01dda91
79802a8
67c1c2b
3e37c55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fix: | ||
- Hide the assistant entry when there isn't data2summary agent ([#9277](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9277)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,6 @@ import { QueryAssistContextType } from '../../../common/query_assist'; | |
import sparkleHollowSvg from '../../assets/sparkle_hollow.svg'; | ||
import sparkleSolidSvg from '../../assets/sparkle_solid.svg'; | ||
import { FeedbackStatus } from '../../../common/query_assist'; | ||
import { checkAgentsExist } from '../utils/get_is_summary_agent'; | ||
import { DATA2SUMMARY_AGENT_CONFIG_ID } from '../utils/constant'; | ||
|
||
export interface QueryContext { | ||
question: string; | ||
|
@@ -72,9 +70,8 @@ export const QueryAssistSummary: React.FC<QueryAssistSummaryProps> = (props) => | |
const [loading, setLoading] = useState(false); // track loading state | ||
const [feedback, setFeedback] = useState(FeedbackStatus.NONE); | ||
const [isEnabledByCapability, setIsEnabledByCapability] = useState(false); | ||
const [isSummaryAgentAvailable, setIsSummaryAgentAvailable] = useState(false); | ||
const selectedDataset = useRef(query.queryString.getQuery()?.dataset); | ||
const { question$, isQuerySummaryCollapsed } = useQueryAssist(); | ||
const { question$, isQuerySummaryCollapsed, isSummaryAgentAvailable } = useQueryAssist(); | ||
const METRIC_APP = `query-assist`; | ||
const afterFeedbackTip = i18n.translate('queryEnhancements.queryAssist.summary.afterFeedback', { | ||
defaultMessage: | ||
|
@@ -209,26 +206,6 @@ export const QueryAssistSummary: React.FC<QueryAssistSummaryProps> = (props) => | |
}); | ||
}, [props.core]); | ||
|
||
useEffect(() => { | ||
setIsSummaryAgentAvailable(false); | ||
const fetchSummaryAgent = async () => { | ||
try { | ||
const summaryAgentStatus = await checkAgentsExist( | ||
props.http, | ||
DATA2SUMMARY_AGENT_CONFIG_ID, | ||
selectedDataset.current?.dataSource?.id | ||
); | ||
setIsSummaryAgentAvailable(summaryAgentStatus.exists); | ||
} catch (error) { | ||
// eslint-disable-next-line no-console | ||
console.error(error); | ||
} | ||
}; | ||
if (isEnabledByCapability) { | ||
fetchSummaryAgent(); | ||
} | ||
}, [selectedDataset.current?.dataSource?.id, props.http, isEnabledByCapability]); | ||
Comment on lines
-212
to
-230
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there case that assistant is not installed but we turn on result summary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this summary agent work correctly if the dashboard assistant was disabled before this code change? After this change, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will perform the check in https://github.com/opensearch-project/dashboards-assistant/blob/d9266cf6dbe3af769433241bd47adedc4e482f2c/public/plugin.tsx#L285-L320 to see if the assistant is enabled. If it is, the action context menu will be rendered, and action context menu will call API to check if summary agent exists. |
||
|
||
const onFeedback = useCallback( | ||
(satisfied: boolean) => { | ||
if (feedback !== FeedbackStatus.NONE) return; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The fixing of unit tests seems not related to the current PR. Shall we separate a PR to fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will revert this commit. thanks~