Configuring an AI provider doesn't enable AI features until pgAdmin is restarted
Describe the bug
After configuring an AI provider in Preferences, the AI features (the Query Tool's AI Assistant tab and the AI Reports menus) stay disabled until pgAdmin is restarted or the page is reloaded.
To Reproduce
- Start pgAdmin 9.19 with
LLM_ENABLED = Trueand no provider configured. - In Preferences > AI, configure a provider and save.
- Open a Query Tool, or right-click a server/database/schema: no AI Assistant tab, and the AI Reports menus remain disabled.
- Restart pgAdmin: everything is now enabled.
Expected behavior
AI features become available as soon as the provider preferences are saved (and are disabled again if the provider is removed).
Cause
The enabled state is only ever read once, at page load:
pgAdmin.llm_enabledis rendered into the page by the Jinja template atweb/pgadmin/browser/templates/browser/js/utils.js:76(fromis_llm_enabled()inbrowser/__init__.py), and the Query Tool's default layout reads it inQueryToolComponent.jsx:261.AITools.checkLLMStatus()inweb/pgadmin/llm/static/js/ai_tools.jscallsllm.statusonce frominit()and cachesllmEnabled, which the menuenablecallbacks then use.
Neither is refreshed when the ai preferences change. A fix would be to re-run the status check (and update pgAdmin.llm_enabled) from a preference-change listener.
Desktop
- pgAdmin version: 9.19 (release candidate builds)
Hi Dave, could I take this issue if it is still available?
I traced the preference-save path at 062099a: PreferencesComponent refreshes preferencesStore, and the store broadcasts updates, but AITools.init() only performs its status request once. An isolated probe of the current ai_tools.js (JSX transpiled, status responses and menu rendering mocked) showed:
- Initial provider missing:
llmEnabled=false, one status request. - Provider configured, then
init()called again: still false, still one request. - Explicit
checkLLMStatus(): true, two requests. - Provider removed, then
init()again: still true, still two requests.
This is module-level evidence, not a full UI reproduction. I'd first reproduce the preferences flow locally, then refresh the shared status when AI preferences change and test both enable and disable transitions, failed status requests, and repeated saves without duplicate menus or listeners. I would keep provider integrations and the separate layout-restoration issue #10689 out of scope.
Should already-open Query Tool tabs gain/lose the Assistant tab immediately too, or should the first change cover the report menus and newly opened Query Tools? If that scope fits, please assign #10688 to me or confirm I may take it. I haven't started the implementation.
Yes, please go ahead. Thank you!