You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "EnxDev (via GitHub)" <gi...@apache.org> on 2026/06/11 08:27:06 UTC
[PR] refactor(chatbot): drop extension settings layer; resolve last-loaded chatbot [superset]
EnxDev opened a new pull request, #40968:
URL: https://github.com/apache/superset/pull/40968
### SUMMARY
Removes the extension admin-settings layer entirely and simplifies chatbot resolution to **last-loaded wins**.
After the earlier scope-reduction (Extensions admin page + settings *write* path removed), the only remaining use of `GET /api/v1/extensions/settings` was reading `active_chatbot_id` — a pin **nothing in the product could set** (it had become DB-edit-only). Keeping a read endpoint for an unsettable value was a half-removed remnant. This PR drops the whole layer and resolves the active chatbot purely from the view registry: **the most-recently-registered (last-loaded) chatbot wins** the singleton `superset.chatbot` slot.
**Frontend**
- `getActiveChatbot()` takes no arguments and returns the **last-registered** chatbot (was: first-registered + optional admin pin).
- `ChatbotMount` resolves from the view registry alone — no settings fetch, no loading gate, no settings-store subscription.
- Removed the settings store from `core/extensions` (`ExtensionSettings` type, `SETTINGS_ENDPOINT`, load/subscribe/snapshot). Kept the `extensions` namespace.
**Backend**
- Removed the `GET /settings` route + `can_get_settings` permission.
- Deleted the settings command package, `ExtensionSettingsDAO`/`get_extension_settings`, and the `ExtensionSettings` model (+ its registration import).
- New migration `e2f3a4b5c6d7` drops the `extension_settings` table (reversible).
Net: **−383/+62**, ~320 lines deleted.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
_N/A — no visible UI change. The chatbot bubble renders as before; only the selection policy and the (already UI-less) settings plumbing change._
### TESTING INSTRUCTIONS
**Backend**
```bash
pytest tests/unit_tests/extensions/ # 41 passing (3 settings tests removed)
```
- `GET /api/v1/extensions/settings` now returns **404/405** (route removed).
- Migration: `superset db upgrade` drops `extension_settings`; `superset db downgrade` recreates it (reversible).
**Frontend** (`ENABLE_EXTENSIONS` on, a chatbot extension on disk)
- Chatbot bubble still renders via `ChatbotMount`.
- With two chatbot extensions registered, the **last to register** owns the bubble.
- `npm run test -- src/core/chatbot src/components/ChatbotMount`
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [x] Required feature flags: `ENABLE_EXTENSIONS`
- [x] Changes UI _(chatbot selection policy; no admin pin)_
- [x] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [x] Migration is atomic, supports rollback & is backwards-compatible
- [x] Confirm DB migration upgrade and downgrade tested
- [x] Runtime estimates and downtime expectations provided _(single `DROP TABLE extension_settings`; near-instant, no downtime)_
- [ ] Introduces new feature or API
- [x] Removes existing feature or API _(extension settings endpoint + admin chatbot pin)_
**Behavior change:** there is no admin chatbot pin anymore — when multiple chatbot extensions load, the last to register takes the singleton bubble.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor(chatbot): drop extension settings layer; resolve last-loaded chatbot [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40968:
URL: https://github.com/apache/superset/pull/40968#issuecomment-4678712478
<!-- Bito Reply -->
The flagged issue is correct. The current implementation of `getRegisteredViewIds` uses a `Set` to store IDs, which preserves insertion order but does not update the order when an existing ID is re-registered. Consequently, `getActiveChatbot` (which selects the last element of the array) fails to reflect the most recent registration if an existing chatbot is re-registered.
To resolve this, you should ensure that re-registering an existing ID moves it to the end of the registration sequence. You can achieve this by removing the ID from the `Set` before adding it again in `registerView` (or by using an array and `splice` to reorder).
**superset-frontend/src/core/views/index.ts**
```
const ids = locationIndex.get(location) ?? new Set();
if (ids.has(id)) {
ids.delete(id);
}
ids.add(id);
locationIndex.set(location, ids);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor(chatbot): drop extension settings layer; resolve last-loaded chatbot [superset]
Posted by "EnxDev (via GitHub)" <gi...@apache.org>.
EnxDev merged PR #40968:
URL: https://github.com/apache/superset/pull/40968
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor(chatbot): drop extension settings layer; resolve last-loaded chatbot [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #40968:
URL: https://github.com/apache/superset/pull/40968#issuecomment-4678745602
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/40968?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:warning: Please [upload](https://docs.codecov.com/docs/codecov-uploader) report for BASE (`enxdev/chat-prototype@09c09f3`). [Learn more](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#section-missing-base-commit) about missing BASE report.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## enxdev/chat-prototype #40968 +/- ##
========================================================
Coverage ? 55.44%
========================================================
Files ? 2652
Lines ? 143567
Branches ? 33130
========================================================
Hits ? 79607
Misses ? 63244
Partials ? 716
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/40968/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [presto](https://app.codecov.io/gh/apache/superset/pull/40968/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.09% <ø> (?)` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/40968/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.09% <ø> (?)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/40968?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor(chatbot): drop extension settings layer; resolve last-loaded chatbot [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #40968:
URL: https://github.com/apache/superset/pull/40968#discussion_r3394882608
##########
superset-frontend/src/core/views/index.ts:
##########
@@ -75,6 +75,11 @@ const registerView: typeof viewsApi.registerView = (
viewRegistry.set(id, { view, location, provider });
const ids = locationIndex.get(location) ?? new Set();
+ // Re-registering an existing id must reflect its new recency. A Set preserves
+ // first-insertion order and `add` is a no-op for an existing member, so delete
+ // first to move the id to the end. Consumers that select the most-recently
+ // registered view (e.g. the chatbot resolver) depend on this ordering.
+ ids.delete(id);
ids.add(id);
Review Comment:
**Suggestion:** Re-registration is now a supported path, but this change only updates ordering and does not make disposal instance-safe. If the same view id is registered twice, disposing the older `Disposable` will still remove the newer active registration (because disposal is keyed only by `id`), which can make the chatbot disappear unexpectedly after hot-reload/re-init flows. Tie each registration to a unique token/version and make `dispose()` a no-op when it is not disposing the currently registered instance. [stale reference]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Chatbot bubble vanishes after extension reload or teardown.
- ⚠️ Re-registered views can be removed by stale disposables.
- ⚠️ Extensions cannot safely re-register views with same id.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Login with extensions enabled so the frontend mounts `App` and `ExtensionsStartup`,
which sets `window.superset.views = views` and calls
`ExtensionsLoader.getInstance().initializeExtensions()` when
`FeatureFlag.EnableExtensions` is on (`superset-frontend/src/views/App.tsx:24` shows
`<ChatbotMount />` under the flag;
`superset-frontend/src/extensions/ExtensionsStartup.tsx:88-113` sets `window.superset` and
initializes extensions).
2. In an extension module loaded by `ExtensionsLoader.loadModule()`
(`superset-frontend/src/extensions/ExtensionsLoader.ts:118-177`), its `activate(context)`
implementation registers a chatbot view twice under the same id, pushing both disposables
into `context.subscriptions`, e.g.
`context.subscriptions.push(window.superset.views.registerView({ id: 'core.chatbot', ...
}, CHATBOT_LOCATION, providerV1));` followed later by another `registerView` with the same
`id` but a different provider; both calls return `Disposable` instances created at
`superset-frontend/src/core/views/index.ts:88-93`.
3. The second `registerView` overwrites the first entry for that `id` in `viewRegistry`
and updates `locationIndex` ordering (`viewRegistry.set(id, { view, location, provider })`
at `superset-frontend/src/core/views/index.ts:75` and the recency-handling block at lines
77-84), so the active chatbot now points to the new provider, as consumed by
`getActiveChatbot()` (`superset-frontend/src/core/chatbot/index.ts:56-70`) and
`ChatbotMount` (`superset-frontend/src/components/ChatbotMount/index.ts:50-59`).
4. When the extension later tears down its first registration by calling `dispose()` on
the older `Disposable` from `context.subscriptions`, that `dispose` executes the callback
defined at `superset-frontend/src/core/views/index.ts:88-93`, which looks up
`viewRegistry.get(id)` using only the shared `id` and then calls `viewRegistry.delete(id)`
and `locationIndex.get(registeredLocation)?.delete(id)`. Because `viewRegistry` now holds
the newer registration under the same `id`, this stale disposal removes the current active
chatbot entry, causing `getRegisteredViewIds(CHATBOT_LOCATION)` to return an array without
that id (`superset-frontend/src/core/views/index.ts:12-15`), `getActiveChatbot()` to
return `undefined` (`superset-frontend/src/core/chatbot/index.ts:56-60`), and
`ChatbotMount` to render nothing
(`superset-frontend/src/components/ChatbotMount/index.ts:58-62`), making the chatbot
bubble disappear even though the extension believes its latest registration is still
active. This is possible for any view id, not just `core.chatbot`, because `Disposable`
instances are not tied to a unique registration token.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ecc002a2eaac4e15b13ca248a6d5506e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=ecc002a2eaac4e15b13ca248a6d5506e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/core/views/index.ts
**Line:** 78:83
**Comment:**
*Stale Reference: Re-registration is now a supported path, but this change only updates ordering and does not make disposal instance-safe. If the same view id is registered twice, disposing the older `Disposable` will still remove the newer active registration (because disposal is keyed only by `id`), which can make the chatbot disappear unexpectedly after hot-reload/re-init flows. Tie each registration to a unique token/version and make `dispose()` a no-op when it is not disposing the currently registered instance.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40968&comment_hash=ff1b63a6d24fbe79b0244ee382dac54b62322ed867290c42945cad7c0d35f50e&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40968&comment_hash=ff1b63a6d24fbe79b0244ee382dac54b62322ed867290c42945cad7c0d35f50e&reaction=dislike'>👎</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor(chatbot): drop extension settings layer; resolve last-loaded chatbot [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #40968:
URL: https://github.com/apache/superset/pull/40968#discussion_r3395329664
##########
superset-frontend/src/core/views/index.ts:
##########
@@ -75,6 +75,11 @@ const registerView: typeof viewsApi.registerView = (
viewRegistry.set(id, { view, location, provider });
const ids = locationIndex.get(location) ?? new Set();
+ // Re-registering an existing id must reflect its new recency. A Set preserves
+ // first-insertion order and `add` is a no-op for an existing member, so delete
+ // first to move the id to the end. Consumers that select the most-recently
+ // registered view (e.g. the chatbot resolver) depend on this ordering.
+ ids.delete(id);
ids.add(id);
Review Comment:
✅ **Customized review instruction saved!**
**Instruction:**
> Do not flag stale-disposal or re-registration safety issues in the view registry unless a runtime dispose/deactivate path exists; in the current architecture, view registrations are reset on full page reload and re-registration is not a supported runtime flow.
**Applied to:**
- `superset-frontend/src/core/views/**`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor(chatbot): drop extension settings layer; resolve last-loaded chatbot [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40968:
URL: https://github.com/apache/superset/pull/40968#issuecomment-4678641632
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor(chatbot): drop extension settings layer; resolve last-loaded chatbot [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #40968:
URL: https://github.com/apache/superset/pull/40968#issuecomment-4678663704
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | af5eca38f5b955b73a16e0c04970d904c4cfcc76 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a2a715b4ad3cf0008b54f08 |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-40968--superset-docs-preview.netlify.app](https://deploy-preview-40968--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcpJDoAgDADAv_QsERWX-AOfUWhdEgWCjdEY_y63OcwLMYUjCowABdiE3q3Z7G_iq3Qrig2iKIWoThbZ_HKqHR9OeRPHPTwT5d9hjX3VWoPUuFlrPdjWzHqA7wc) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-40968--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor(chatbot): drop extension settings layer; resolve last-loaded chatbot [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #40968:
URL: https://github.com/apache/superset/pull/40968#discussion_r3394450588
##########
superset-frontend/src/core/chatbot/index.ts:
##########
@@ -48,31 +48,22 @@ export interface ActiveChatbot {
*
* Selection policy:
* - If no chatbot is registered, returns `undefined` — the corner stays empty.
- * - If `adminSelectedId` matches a registered chatbot, that one wins.
- * - Otherwise the first-registered chatbot is used as a fallback.
- * The active chatbot pin is set only via the backend DB; when no pin is set
- * (active_chatbot_id is null), the fallback is the first-registered chatbot.
+ * - Otherwise the most-recently-registered (last-loaded) chatbot wins. When a
+ * second chatbot extension loads, it takes over the singleton bubble.
*
- * @param adminSelectedId The id stored in the DB "Default chatbot" setting, if any.
* @returns The active chatbot's id and provider, or `undefined` if none.
*/
-export const getActiveChatbot = (
- adminSelectedId?: string | null,
-): ActiveChatbot | undefined => {
+export const getActiveChatbot = (): ActiveChatbot | undefined => {
const registeredIds = getRegisteredViewIds(CHATBOT_LOCATION);
if (registeredIds.length === 0) {
return undefined;
}
- // When the DB pin names a registered candidate, use it; otherwise fall back
- // to the first registered chatbot in registration order.
- // `getRegisteredViewIds` and `getViewProvider` read the same synchronous
- // registry maps, so a candidate id always has a live provider; the final
+ // `getRegisteredViewIds` returns ids in registration order, so the last entry
+ // is the most-recently-loaded chatbot. `getViewProvider` reads the same
+ // synchronous registry maps, so the id always has a live provider; the final
// guard is cheap defensiveness, not a fallback path.
- const selectedId =
- adminSelectedId && registeredIds.includes(adminSelectedId)
- ? adminSelectedId
- : registeredIds[0];
+ const selectedId = registeredIds[registeredIds.length - 1];
Review Comment:
**Suggestion:** The new last-loaded policy assumes `getRegisteredViewIds()` is ordered by latest registration event, but that index is backed by a `Set` in `core/views` where re-registering an existing id does not move it to the end. If a chatbot with an existing id registers again after another chatbot, this code can still select the older id order and return the wrong active chatbot. Update selection to track true recency (for example, refresh ordering on re-register in the registry, or store a registration sequence/timestamp per entry and select by that). [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Chatbot bubble may show older chatbot after extension reload.
- ⚠️ Extension developers cannot rely on documented last-loaded selection.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Observe the view registry implementation in
`superset-frontend/src/core/views/index.ts`: `locationIndex` is defined as `const
locationIndex: Map<string, Set<string>> = new Map();` at lines 35–40, and `registerView`
at lines 63–80 calls `const ids = locationIndex.get(location) ?? new Set(); ids.add(id);
locationIndex.set(location, ids);` without ever removing and re-adding an existing id at
the same location.
2. Note that `getRegisteredViewIds` in the same file at lines 68–71 returns
`Array.from(ids)` for a given location, so the ordering of ids is the original insertion
order of the `Set`, and calling `ids.add(existingId)` again does not move that id to the
end of the sequence.
3. Confirm how the active chatbot is resolved in
`superset-frontend/src/core/chatbot/index.ts`: `getActiveChatbot` at lines 56–69 calls
`getRegisteredViewIds(CHATBOT_LOCATION)` (line 57) and then selects the last entry via
`const selectedId = registeredIds[registeredIds.length - 1];` (line 66), with the comment
at lines 49–52 stating the selection policy is "the most-recently-registered (last-loaded)
chatbot wins."
4. To reproduce the mismatch, add a Jest test alongside the existing ones in
`superset-frontend/src/components/ChatbotMount/ChatbotMount.test.tsx` (which already
registers multiple chatbots via `views.registerView` at lines 53–67) that: (a) registers
`{ id: 'first.chatbot' }` at `CHATBOT_LOCATION`, (b) registers `{ id: 'second.chatbot' }`
at `CHATBOT_LOCATION`, and then (c) registers `{ id: 'first.chatbot' }` again at
`CHATBOT_LOCATION` using `views.registerView` exported from `src/core`. When this test
renders `<ChatbotMount />` (which calls `getActiveChatbot()` at
`src/components/ChatbotMount/index.tsx:31,45–59`), `getActiveChatbot` still sees
`getRegisteredViewIds('core.chatbot') === ['first.chatbot', 'second.chatbot']` (because
the `Set` did not reorder), so it returns `selectedId === 'second.chatbot'` even though
the last registration event was for `'first.chatbot'`, violating the documented
"last-loaded wins" policy.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=72c04b35a0a149eabf05eef7e429887f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=72c04b35a0a149eabf05eef7e429887f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/core/chatbot/index.ts
**Line:** 62:66
**Comment:**
*Logic Error: The new last-loaded policy assumes `getRegisteredViewIds()` is ordered by latest registration event, but that index is backed by a `Set` in `core/views` where re-registering an existing id does not move it to the end. If a chatbot with an existing id registers again after another chatbot, this code can still select the older id order and return the wrong active chatbot. Update selection to track true recency (for example, refresh ordering on re-register in the registry, or store a registration sequence/timestamp per entry and select by that).
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40968&comment_hash=8e9ce3f6cec7beee283feb345f617f5e93d064393d2f86d92192aa9ae98a605f&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40968&comment_hash=8e9ce3f6cec7beee283feb345f617f5e93d064393d2f86d92192aa9ae98a605f&reaction=dislike'>👎</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor(chatbot): drop extension settings layer; resolve last-loaded chatbot [superset]
Posted by "EnxDev (via GitHub)" <gi...@apache.org>.
EnxDev commented on code in PR #40968:
URL: https://github.com/apache/superset/pull/40968#discussion_r3395326799
##########
superset-frontend/src/core/views/index.ts:
##########
@@ -75,6 +75,11 @@ const registerView: typeof viewsApi.registerView = (
viewRegistry.set(id, { view, location, provider });
const ids = locationIndex.get(location) ?? new Set();
+ // Re-registering an existing id must reflect its new recency. A Set preserves
+ // first-insertion order and `add` is a no-op for an existing member, so delete
+ // first to move the id to the end. Consumers that select the most-recently
+ // registered view (e.g. the chatbot resolver) depend on this ordering.
+ ids.delete(id);
ids.add(id);
Review Comment:
Re-registration of a view id is not a runtime path in this branch — the loader never disposes views (lifecycle deferred, deactivateExtension removed), and extension add/delete takes effect on a full page reload that resets the registry. So neither the ordering-on-reregister nor the stale-disposal scenario is reachable. Reverted the recency/token handling; it should land alongside a disposing deactivate path if that's introduced.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org