Skip to content
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

Merged
merged 6 commits into from
Feb 25, 2025

Conversation

Qxisylolo
Copy link
Contributor

@Qxisylolo Qxisylolo commented Jan 27, 2025

Description

This pr hides the assistant entry when there isn't data2summary agent.

Screenshot

No agent:
截屏2025-01-27 13 44 44
Has agent:
截屏2025-01-27 13 45 13

Testing the changes

Changelog

  • fix: Hide the assistant entry when there isn't data2summary agent

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Signed-off-by: Qxisylolo <qianxisy@amazon.com>
Copy link

codecov bot commented Jan 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.70%. Comparing base (ec6d7df) to head (3e37c55).
Report is 35 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9277   +/-   ##
=======================================
  Coverage   61.70%   61.70%           
=======================================
  Files        3816     3815    -1     
  Lines       91829    91819   -10     
  Branches    14543    14543           
=======================================
- Hits        56666    56660    -6     
+ Misses      31507    31505    -2     
+ Partials     3656     3654    -2     
Flag Coverage Δ
Linux_1 28.99% <ø> (ø)
Linux_2 56.46% <ø> (ø)
Linux_3 39.18% <ø> (+<0.01%) ⬆️
Linux_4 28.89% <100.00%> (-0.01%) ⬇️
Windows_1 29.00% <ø> (ø)
Windows_2 56.41% <ø> (ø)
Windows_3 39.18% <ø> (ø)
Windows_4 28.89% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

question$?: BehaviorSubject<string>;
}

const QueryAssistWrapper: React.FC<QueryAssistWrapperProps> = (props) => {
const [visible, setVisible] = useState(false);
const [question, setQuestion] = useState('');
const [isQuerySummaryCollapsed, setIsQuerySummaryCollapsed] = useState(true);
const [isSummaryAgentAvailable, setIsSummaryAgentAvailable] = useState(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about we using useObservable(props.isSummaryAgentAvailable$)?

Copy link
Contributor Author

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 been updated. but would it be more organized to update state of isSummaryAgentAvailable together with isQuerySummaryCollapsed and question together in useEffect?

Comment on lines -212 to -230
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]);
Copy link
Member

@SuZhou-Joe SuZhou-Joe Jan 27, 2025

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The 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 isSummaryAgentAvailable$ will be updated out of query enhancements, right? Just want to confirm if it's dependent on the dashboard assistant before.

Copy link
Contributor Author

@Qxisylolo Qxisylolo Feb 7, 2025

Choose a reason for hiding this comment

The 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.

Qxisylolo and others added 3 commits February 5, 2025 14:26
Signed-off-by: Qxisylolo <qianxisy@amazon.com>
Signed-off-by: Qxisylolo <qianxisy@amazon.com>
@@ -108,7 +113,6 @@ describe('QueryStringManager', () => {
test('clearQueryHistory clears the query history', () => {
service.addToQueryHistory({ query: 'test query 1', language: 'sql' });
service.addToQueryHistory({ query: 'test query 2', language: 'sql' });
expect(service.getQueryHistory()).toHaveLength(2);
Copy link
Contributor

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?

Copy link
Contributor Author

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~

Signed-off-by: Qxisylolo <qianxisy@amazon.com>
@SuZhou-Joe SuZhou-Joe merged commit 46ee60c into opensearch-project:main Feb 25, 2025
71 of 73 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Feb 25, 2025
…nt (#9277)

* fix summary entry when no agent in workspace

Signed-off-by: Qxisylolo <qianxisy@amazon.com>

* Changeset file for PR #9277 created/updated

* resolve comments

Signed-off-by: Qxisylolo <qianxisy@amazon.com>

* fix test

Signed-off-by: Qxisylolo <qianxisy@amazon.com>

* separate test

Signed-off-by: Qxisylolo <qianxisy@amazon.com>

---------

Signed-off-by: Qxisylolo <qianxisy@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: SuZhou-Joe <suzhou@amazon.com>
(cherry picked from commit 46ee60c)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants