Skip to content

feat(extensions): context sharing namespaces (navigation, explore, dashboard, dataset)#40444

Open
EnxDev wants to merge 6 commits into
enxdev/feat/chatbot-permissionsfrom
enxdev/feat/chatbot-context-sharing
Open

feat(extensions): context sharing namespaces (navigation, explore, dashboard, dataset)#40444
EnxDev wants to merge 6 commits into
enxdev/feat/chatbot-permissionsfrom
enxdev/feat/chatbot-context-sharing

Conversation

@EnxDev
Copy link
Copy Markdown
Contributor

@EnxDev EnxDev commented May 26, 2026

SUMMARY

Adds host namespaces that extensions can call to read Superset context: current page type, active dashboard filters, explore chart info, and dataset metadata.

What this introduces:

  • navigationonDidChangePage: Event<PageType> fires on every route change; routing signal only (no entity context)
  • dashboardgetContext() returns active filters from the Redux store
  • exploregetContext() returns chart name, datasource, and current form data
  • datasetgetContext() returns datasource UID and name from explore state
  • All namespaces are exposed on window.superset for extension use

Extensions compose context themselves from whichever namespaces they need. Surface namespaces (explore, dashboard, dataset) own entity-level context; navigation is a routing signal only.

Stack:

  1. Contribution point
  2. Frontend API entry point
  3. Eager loading
  4. Admin UI
  5. Backend settings & permissions ← merged first
  6. This PR — context sharing namespaces

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — API surface only, no visible UI change.

TESTING INSTRUCTIONS

  1. On a dashboard page: window.superset.dashboard.getContext() → returns { filters: [...] }
  2. On an explore page: window.superset.explore.getContext() → returns { chartName, datasourceUid, formData }
  3. Navigate between pages: verify navigation.onDidChangePage fires with the correct PageType string
  4. On a non-explore page: window.superset.explore.getContext() → returns null

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 26, 2026

Bito Automatic Review Skipped - Branch Excluded

Bito didn't auto-review because the source or target branch is excluded from automatic reviews.
No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change the branch exclusion settings here, or contact your Bito workspace admin at evan@preset.io.

@EnxDev EnxDev changed the base branch from enxdev/feat/chatbot-permissions to enxdev/chat-prototype May 26, 2026 14:22
@github-actions github-actions Bot added risk:db-migration PRs that require a DB migration api Related to the REST API dependencies:npm packages and removed embedded labels May 26, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 26, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit d1aa512
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a15ac4ccd851500097249dc
😎 Deploy Preview https://deploy-preview-40444--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread superset-frontend/src/core/explore/index.ts
Comment thread superset-frontend/src/core/dashboard/index.ts
Comment thread superset-frontend/src/core/dataset/index.ts Outdated
Comment thread superset-frontend/src/core/dataset/index.ts Outdated
Comment thread superset-frontend/src/core/dashboard/index.ts
Comment thread superset-frontend/src/core/explore/index.ts
@EnxDev EnxDev force-pushed the enxdev/feat/chatbot-context-sharing branch from d1aa512 to 2223cc3 Compare May 26, 2026 14:33
EnxDev and others added 2 commits May 26, 2026 16:49
…ions

Adds ExtensionSettings and ExtensionEnabled models with migration.
GET /api/v1/extensions/settings is public; PUT is restricted to Admin
role via security_manager.is_admin(). Uses dialect-aware ON CONFLICT DO
UPDATE upserts and @transaction() for safe concurrent writes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…shboard, dataset)

Adds four stable namespaces to @apache-superset/core that give extensions
host-managed access to page context without coupling to Redux internals:

- navigation: getPageType(), onDidChangePage (routing signal only)
- explore: getCurrentChart(), onDidChangeChart (ChartContext from Redux)
- dashboard: getCurrentDashboard(), onDidChangeDashboard (DashboardContext
  with active native filter values from Redux)
- dataset: getCurrentDataset(), onDidChangeDataset (push model)

All four are wired into window.superset via ExtensionsStartup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@EnxDev EnxDev force-pushed the enxdev/feat/chatbot-context-sharing branch from 2223cc3 to 8f03c5a Compare May 26, 2026 14:49
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.72%. Comparing base (b0d2619) to head (ffd1a53).

Files with missing lines Patch % Lines
superset-frontend/src/views/contributions.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                    @@
##           enxdev/chat-prototype   #40444      +/-   ##
=========================================================
+ Coverage                  64.18%   67.72%   +3.53%     
=========================================================
  Files                       2592     1850     -742     
  Lines                     139036    76990   -62046     
  Branches                   32282    24688    -7594     
=========================================================
- Hits                       89244    52141   -37103     
+ Misses                     48260    24849   -23411     
+ Partials                    1532        0    -1532     
Flag Coverage Δ
hive ?
mysql ?
postgres ?
presto ?
python 100.00% <ø> (+39.56%) ⬆️
sqlite ?
unit 100.00% <ø> (ø)

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…to prevent stale returns

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
EnxDev and others added 3 commits May 28, 2026 00:12
…y, and tests

- Add CREATE_NEW_SLICE and SLICE_UPDATED to exploreChangePredicate so
  onDidChangeChart fires when a chart is saved for the first time
- Remove dataset namespace: no producer exists yet; ships it once a
  caller is wired in DatasetCreation or equivalent
- Remove ...supersetCore spread from window.superset assignment so
  un-contracted symbols from @apache-superset/core are not leaked onto
  the global object; list namespaces explicitly instead
- Add defensive array copy for filter values in buildDashboardContext
  so extension mutations cannot affect Redux state
- Lazy-initialize currentPageType in navigation to avoid module-load
  window.location access (throws in non-browser test environments)
- Fix /sqllab exact-match missing from derivePageType
- Add unit tests: navigation (7), explore (9), dashboard (11) — 27 tests
  covering page-type gating, dispose semantics, predicate coverage, and
  defensive copy invariant

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…fy no-use-before-define

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…phaned host impl

The host removed dataset from window.superset but the SDK still exported
the typed contract. An extension importing dataset from @apache-superset/core
would get a fully typed namespace whose runtime calls throw at access time,
which is worse than not shipping it.

Removes:
- packages/superset-core/src/dataset/index.ts (SDK type declarations)
- export * as dataset from './dataset' in superset-core/src/index.ts
- "./dataset" subpath from superset-core/package.json exports
- src/core/dataset/index.ts (orphaned host implementation)

The namespace will be re-introduced once a producer (DatasetCreation or
equivalent) calls setCurrentDataset to back the contract at runtime.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@EnxDev EnxDev changed the base branch from enxdev/chat-prototype to enxdev/feat/chatbot-permissions May 28, 2026 14:09
@EnxDev EnxDev force-pushed the enxdev/feat/chatbot-permissions branch from c9f2978 to ae674f2 Compare May 29, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API dependencies:npm packages risk:db-migration PRs that require a DB migration size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant