Skip to content

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

Open
dpage wants to merge 1 commit intopgadmin-org:masterfrom
dpage:fix_ai_feature_visibility
Open

Fixed an issue where AI features are visible in the UI even when LLM_…#9727
dpage wants to merge 1 commit 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

Release Notes

  • Bug Fixes

    • Resolved an issue where AI features (AI Assistant tab, AI Reports menus, and AI Preferences) remained visible in the UI when AI functionality was disabled at the system configuration level. These elements now correctly hide when the feature is not enabled.
  • Improvements

    • Enhanced stability of the Query Tool component with improved null-safety handling to prevent potential runtime errors.

@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 53cd2f5e-4193-40f0-9a67-8f24c731dd92

📥 Commits

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

📒 Files selected for processing (6)
  • docs/en_US/release_notes_9_14.rst
  • web/pgadmin/browser/__init__.py
  • web/pgadmin/browser/templates/browser/js/utils.js
  • web/pgadmin/llm/__init__.py
  • web/pgadmin/llm/static/js/ai_tools.js
  • web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx

Walkthrough

This pull request implements conditional visibility of AI features in pgAdmin based on the LLM_ENABLED configuration setting. The backend config value is passed to the frontend, exposing an llm_enabled flag in JavaScript, which then gates the registration of AI menus, preferences, and the AI Assistant panel in the Query Tool.

Changes

Cohort / File(s) Summary
Configuration Exposure
web/pgadmin/browser/__init__.py, web/pgadmin/browser/templates/browser/js/utils.js
Exposes the backend LLM_ENABLED configuration setting to the frontend by adding an llm_enabled parameter to the rendering context and initializing it as a public pgAdmin configuration flag in JavaScript.
Feature Gating
web/pgadmin/llm/__init__.py, web/pgadmin/llm/static/js/ai_tools.js
Implements conditional registration of AI features: preferences are not registered if LLM is disabled at the system level, and menus are only registered when the system-level LLM status is confirmed as enabled. Introduces registerMenus() method to decouple menu registration from initialization.
UI Conditionals
web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx
Conditionally includes the AI Assistant tab only when pgAdmin.llm_enabled is truthy; adds optional chaining operators for safer DOM element access and visibility checks.
Documentation
docs/en_US/release_notes_9_14.rst
Documents the bug fix for Issue #9709 addressing AI feature visibility when LLM_ENABLED is disabled.

Sequence Diagram(s)

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

    Config->>PyInit: LLM_ENABLED setting
    PyInit->>JSUtils: Pass llm_enabled to template
    JSUtils->>JSUtils: Initialize pgAdmin.llm_enabled flag
    
    alt LLM_ENABLED = False
        LLMModule->>LLMModule: Early return from register_preferences()
        AITools->>AITools: Skip menu registration in checkLLMStatus()
        QueryTool->>QueryTool: Do not include AI Assistant tab
    else LLM_ENABLED = True
        LLMModule->>LLMModule: Register AI preferences
        AITools->>AITools: Call registerMenus() when llmSystemEnabled = true
        QueryTool->>QueryTool: Include AI Assistant tab conditionally
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 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

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

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

1 participant