Skip to content

Fixed an issue where AI features are visible in the UI even when LLM_…#9727

Merged
akshay-joshi merged 2 commits intopgadmin-org:masterfrom
dpage:fix_ai_feature_visibility
Mar 16, 2026
Merged

Fixed an issue where AI features are visible in the UI even when LLM_…#9727
akshay-joshi merged 2 commits intopgadmin-org:masterfrom
dpage:fix_ai_feature_visibility

Conversation

@dpage
Copy link
Contributor

@dpage dpage commented Mar 10, 2026

…ENABLED is set to False. Fixes #9709

Summary by CodeRabbit

  • Bug Fixes

    • AI features (AI Assistant tab, AI Reports menus, AI Preferences) now correctly hide when AI is disabled at the system level.
  • Improvements

    • Safer Query Tool handling to prevent runtime errors during tab focus/navigation.
    • Added a browser-level configuration flag so AI menus and UI elements are shown only when system-enabled.

@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7b60ca8c-b832-4dca-8ed2-3d845ec58ce6

📥 Commits

Reviewing files that changed from the base of the PR and between ffbe097 and cdb7990.

📒 Files selected for processing (2)
  • docs/en_US/release_notes_9_14.rst
  • web/pgadmin/llm/__init__.py

Walkthrough

Passes the backend LLM_ENABLED flag to the frontend and uses it to conditionally register AI preferences, menus, and the AI Assistant tab; initialization and menu registration are gated on the system-level LLM status.

Changes

Cohort / File(s) Summary
Configuration Exposure
web/pgadmin/browser/__init__.py, web/pgadmin/browser/templates/browser/js/utils.js
Adds llm_enabled to template context and initializes pgAdmin.llm_enabled in frontend config.
Feature Gating
web/pgadmin/llm/__init__.py, web/pgadmin/llm/static/js/ai_tools.js
LLM preferences registration exits early when system LLM is disabled; AI menus are registered only when system LLM status is confirmed. Adds registerMenus() and adjusts init flow.
UI Conditionals
web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx
AI Assistant tab is included only when pgAdmin.llm_enabled is truthy; added optional chaining on docker access and visibility checks.
Documentation
docs/en_US/release_notes_9_14.rst
Adds release-note entry for bug fix (Issue #9709) about AI features being visible when LLM_ENABLED is False.

Sequence Diagram(s)

sequenceDiagram
    participant Config as System Config
    participant PyInit as Python: browser/__init__.py
    participant JSUtils as JavaScript: utils.js
    participant LLMModule as Python: llm/__init__.py
    participant AITools as JavaScript: ai_tools.js
    participant QueryTool as JS: QueryToolComponent

    Config->>PyInit: read LLM_ENABLED
    PyInit->>JSUtils: render template with llm_enabled
    JSUtils->>JSUtils: set pgAdmin.llm_enabled

    alt System LLM disabled
        LLMModule->>LLMModule: skip register_preferences()
        AITools->>AITools: skip registerMenus() / defer registration
        QueryTool->>QueryTool: omit AI Assistant tab
    else System LLM enabled
        LLMModule->>LLMModule: register_preferences()
        AITools->>AITools: call registerMenus()
        QueryTool->>QueryTool: include AI Assistant tab
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • yogeshmahajan-1903
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: preventing AI features visibility when LLM_ENABLED is disabled, which is the core objective of this PR.
Linked Issues check ✅ Passed The PR addresses all requirements from issue #9709: it respects LLM_ENABLED config, hides the AI Assistant pane when disabled, and prevents AI menus/preferences from registering.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective of controlling AI feature visibility based on LLM_ENABLED. Optional chaining additions are necessary safety improvements for the conditional logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dpage
Copy link
Contributor Author

dpage commented Mar 12, 2026

The test failure here is the flakey test fixed in #9723

@akshay-joshi akshay-joshi merged commit 23bd335 into pgadmin-org:master Mar 16, 2026
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Activity state of AI

2 participants