-
Notifications
You must be signed in to change notification settings - Fork 29
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
Hide the assistant entry when there isn't data2summary agent #417
base: main
Are you sure you want to change the base?
Hide the assistant entry when there isn't data2summary agent #417
Conversation
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
// The action button should be not displayed when there is no action and result summary disabled. | ||
if (actionsRef.current.length === 0 && !resultSummaryEnabled) { | ||
// The action button should be not displayed when there is no action and result summary disabled or there is no data2Summary agent | ||
if (!isSummaryAgentAvailable || (actionsRef.current.length === 0 && !resultSummaryEnabled)) { |
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: I'd recommend moving isSummaryAgentAvailable
behind !resultSummaryEnabled
because we need to make a network request to get the status.
async function checkAgentsExist( | ||
http: HttpSetup, | ||
agentConfigName: string | string[], | ||
dataSourceId?: string | ||
) { | ||
const response = await http.get(AGENT_API.CONFIG_EXISTS, { | ||
query: { agentConfigName, dataSourceId }, | ||
}); | ||
return response; | ||
} |
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.
We should move this function out of render function.
return null; | ||
} | ||
|
||
// The action button should be disabled when context menu has no item and result summary disabled. | ||
// The action button should be disabled when context menu has no item and result summary disabled | ||
const actionDisabled = (panels.value?.[0]?.items ?? []).length === 0 && !resultSummaryEnabled; |
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.
const actionDisabled = (panels.value?.[0]?.items ?? []).length === 0 && !resultSummaryEnabled; | |
const actionDisabled = (panels.value?.[0]?.items ?? []).length === 0 && !resultSummaryEnabled && !isSummaryAgentAvailable; |
Do we need to add check on isSummaryAgentAvailable
?
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.
I add this check at first, but if there isn't agent, should we hide the button instead of disabling 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.
I think it is OK that we check on both places, but sure it is good enough if we will hide the button if no summary agent is available on target data source.
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.
update~ and thanks for all the comments
useEffect(() => { | ||
const fetchSummaryAgent = async () => { | ||
try { | ||
const summaryAgentStatus = await checkAgentsExist( |
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.
Do we need to call props.isSummaryAgentAvailable$.next(false)
before making the call to check if agent exists? if we switch from data source A(agent configured) to data source B (agent not configured) and the call somehow failed, the status will be incorrect.
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.
yes, it's import, sorry I forget it., updated~
Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: Qxisylolo <[email protected]>
// The action button should be not displayed when there is no action and result summary disabled. | ||
if (actionsRef.current.length === 0 && !resultSummaryEnabled) { | ||
// The action button should be not displayed when there is no action and result summary disabled or there is no data2Summary agent | ||
if ((!resultSummaryEnabled && actionsRef.current.length === 0) || !isSummaryAgentAvailable) { |
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.
Shall we need to allow other actions to be displayed if the summary agent is not available? The other actions won't be displayed if the summary agent is not available after the current change. Is it possible to not register the summary action if the summary agent is not available?
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.
The other action includes anomaly detection suggestion and generate visualization, right? If yes, They should be displayed even if their agents are configured, should not be impacted by summary agent.
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.
Thanks for the comments, already updated, now the UI context bar will be disabled only when there isn't actions and result summary disabled or or no data2Summary agent is available
Signed-off-by: Qxisylolo <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #417 +/- ##
==========================================
- Coverage 87.46% 85.03% -2.44%
==========================================
Files 65 72 +7
Lines 1891 2105 +214
Branches 473 518 +45
==========================================
+ Hits 1654 1790 +136
- Misses 236 313 +77
- Partials 1 2 +1 ☔ View full report in Codecov by Sentry. |
@@ -39,6 +43,26 @@ export const ActionContextMenu = (props: Props) => { | |||
}); | |||
const resultSummaryEnabled = useObservable(props.resultSummaryEnabled$, false); | |||
const isQuerySummaryCollapsed = useObservable(props.isQuerySummaryCollapsed$, false); | |||
const isSummaryAgentAvailable = useObservable(props.isSummaryAgentAvailable$, false); |
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.
I prefer to add a shouldShowSummarizationAction
flag here. Something like
const shouldShowSummarizationAction = resultSummaryEnabled && isSummaryAgentAvailable;
We always need to check resultSummaryEnabled
and isSummaryAgentAvailable
when we need to determine if this action can be displayed. I'm suggest to combine them in same flag. It can improve the code readability.
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.
yes, it's a good advice, update~
Signed-off-by: Qxisylolo <[email protected]>
Description
This pr hides the assistant entry when there isn't data2summary agent
!! This pr is a hard dependency that should be merged after opensearch-project/OpenSearch-Dashboards#9277 has been merged.
has agent:
![截屏2025-01-27 13 45 13](https://private-user-images.githubusercontent.com/176376408/406818783-f8ef17a1-5386-4552-8876-3759f24ab1cd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2ODk3MTMsIm5iZiI6MTczOTY4OTQxMywicGF0aCI6Ii8xNzYzNzY0MDgvNDA2ODE4NzgzLWY4ZWYxN2ExLTUzODYtNDU1Mi04ODc2LTM3NTlmMjRhYjFjZC5wbmc_WC1BbXotQWxnb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QW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.QDGRMuDbKwMMmW2FBxA4VyFsnoEaw7taXdXWA-F_Qpc)
no agent:
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.