Skip to content

feat(discover): register page context for AI chatbot in classic Disco…#12278

Merged
wanglam merged 1 commit into
opensearch-project:mainfrom
tq0905:feat/adapt-discover-page-for-ai
Jun 25, 2026
Merged

feat(discover): register page context for AI chatbot in classic Disco…#12278
wanglam merged 1 commit into
opensearch-project:mainfrom
tq0905:feat/adapt-discover-page-for-ai

Conversation

@tq0905

@tq0905 tq0905 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description

This change wires the contextProvider plugin into the classic Discover page so the
AI chatbot becomes aware of the user's current page state.

When Discover renders, it now registers a page context describing the current query,
query language, dataset, and time range. This brings classic Discover to parity with
the Explore experience, where the chatbot can already reason about the active query
context.

Implementation notes:

  • contextProvider is added as an optional plugin/dependency of Discover, so the
    feature degrades gracefully when AI features are disabled. A NOOP fallback hook is
    used when the plugin is unavailable, keeping the hook call unconditional (no
    conditional-hook violations).
  • Classic Discover stores its query one level deeper (_q.query) compared to Explore
    (_q), which the convert mapping accounts for.

Issues Resolved

N/A

Screenshot

N/A

Testing the changes

  1. Build/run OpenSearch Dashboards with AI/chat features enabled.
  2. Open the classic Discover page and set a query, pick a dataset, and adjust the time range.
  3. Open the AI chatbot and confirm it can reference the current query, language, dataset,
    and time range
    .
  4. Disable the contextProvider (AI features off) and confirm Discover still loads and
    functions normally (NOOP fallback path).

Check List

  • New functionality includes testing.
  • Commits are signed per the DCO using --signoff

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

PR Code Analyzer ❗

AI-powered 'Code-Diff-Analyzer' found issues on commit 84d8d53.

PathLineSeverityDescription
src/plugins/discover/opensearch_dashboards.json19highNew optional plugin dependency 'contextProvider' added to the plugin manifest. Per mandatory rule, all dependency/module additions must be flagged regardless of apparent legitimacy. Maintainers should verify this plugin is the expected internal artifact and not a hijacked or substituted module.
src/plugins/discover/public/build_services.ts63highNew import of 'ContextProviderStart' from '../../context_provider/public' and wiring into DiscoverServices. This introduces a new runtime dependency on the context_provider plugin. Maintainers should confirm the context_provider plugin's origin and that it does not transmit the forwarded page context (query, time range, dataset) to any external endpoint.
src/plugins/discover/public/plugin.ts82highNew import of 'ContextProviderStart' from '../../context_provider/public' and addition to DiscoverStartPlugins interface. Same supply-chain flag as build_services.ts — verify the plugin artifact and its downstream handling of the context data it receives.

The table above displays the top 10 most important findings.

Total: 3 | Critical: 0 | High: 3 | Medium: 0 | Low: 0


Pull Requests Author(s): Please update your Pull Request according to the report above.

Repository Maintainer(s): You can bypass diff analyzer by adding label skip-diff-analyzer after reviewing the changes carefully, then re-run failed actions. To re-enable the analyzer, remove the label, then re-run all actions.


⚠️ Note: The Code-Diff-Analyzer helps protect against potentially harmful code patterns. Please ensure you have thoroughly reviewed the changes beforehand.

Thanks.

…ver page

Signed-off-by: tq0905 <1352711780@qq.com>
@tq0905 tq0905 force-pushed the feat/adapt-discover-page-for-ai branch from 018e369 to 84d8d53 Compare June 25, 2026 08:41
@wanglam wanglam merged commit 592e3a7 into opensearch-project:main Jun 25, 2026
78 of 80 checks passed
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.

3 participants