Skip to content

fix(web): save the dashboard's Quality tab settings (#1671) - #1676

Merged
doobidoo merged 6 commits into
doobidoo:mainfrom
dodoshell:fix/quality-settings-save
Oct 26, 2026
Merged

doobidoo merged 6 commits into
doobidoo:mainfrom
dodoshell:fix/quality-settings-save

Conversation

@dodoshell

@dodoshell dodoshell commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

The Quality tab in the dashboard settings now saves. Picking a provider or flipping the boost toggle and pressing Save & Restart writes MCP_QUALITY_AI_PROVIDER / MCP_QUALITY_BOOST_ENABLED to .env and restarts the server, and the tab shows the real values when it opens.

Why

Fixes #1671. Nothing read #quality-provider or #quality-boost-enabled, so the tab was display-only; the boost checkbox was checked in the HTML although the server default is off, and #current-provider-info was a hardcoded string.

What's in here:

  • POST /api/config/quality in web/api/configuration.py, behind require_admin_access like the credentials endpoint. It only accepts the two keys above, checks them against the choices ENV_CATEGORIES["quality"] already declares (so it can't drift from the Environment tab), strips control characters before writing, logs an AUDIT: line and schedules _restart_server_delayed.
  • A provider whose API key isn't set (groq → GROQ_API_KEY, gemini → GEMINI_API_KEY) is refused with a 400 before anything is written. Without that, the restart never comes back: QualityConfig.validate() aborts startup with "Groq provider selected but GROQ_API_KEY not set". I hit exactly that while testing.
  • The saved values are also put into os.environ. load_dotenv(override=False) had already copied the old .env values into the process environment, and the restart (Popen on Windows, execv elsewhere) inherits it, so the freshly written .env lost to the old value. That's how I first saw "saved, restarted, still auto".
  • app.js: the tab loads both values from /api/config/env when it opens, with the controls and Save disabled until that answers (boost read with the same spellings as safe_get_bool_env(), unset = off), fills the Current Provider box from the selected option, and posts on Save & Restart, then shows the existing restart overlay. The new strings are in all seven i18n/*.json files.

How it was verified

# with the src/ change stashed
.venv/bin/pytest tests/web/api/test_quality_settings_issue1671.py -q
13 failed, 3 warnings in 1.05s

# on this branch
.venv/bin/pytest tests/web/api/test_quality_settings_issue1671.py -q
13 passed, 3 warnings in 0.85s

The tests mount the real configuration router with the real require_admin_access (only the scope is supplied) against a temp .env; only _restart_server_delayed is replaced. They cover: non-admin → 403, unknown key / bad choice / bad boolean / empty body → 400 with .env untouched, a valid save rewriting only its own lines, a boost-only save leaving an openai-compatible provider line alone, groq refused without its key and accepted once it's there, an empty GROQ_API_KEY in the process environment winning over the one in .env (as at startup), the os.environ hand-off, and a newline in a value not adding a line to .env. I also removed each guard in the endpoint one at a time and checked that a test goes red for each.

In the browser (sqlite-vec instance on a scratch .env, Edge headless): the tab loads auto / boost off; choosing Groq without a key shows the 400 message and leaves .env alone; saving Local SLM with boost on writes both keys, shows the restart overlay, and after the server is back the tab opens with Local SLM and the box ticked. With MCP_QUALITY_AI_PROVIDER=openai-compatible in .env, the dropdown comes up empty and disabled, the box shows openai-compatible, and Save posts only MCP_QUALITY_BOOST_ENABLED; the provider line stays as it was.

Tab on open (auto, boost off) Groq without GROQ_API_KEY
1-loaded 2-groq-refused
After Save & Restart Back up: Local SLM, boost on
3-restarting 4-after-restart
openai-compatible in .env
5-openai-compatible

pre_pr_check.sh (run on Windows): everything passes except the test suite step, which has the same ~18 failures on main with this change stashed (unix SIGKILL test, chronological API tests, a few quality API tests, and two that flip between runs). None of them touch configuration.py or the dashboard.

Changelog fragment

changelog.d/1671.fixed.md

Notes for the reviewer

  • openai-compatible isn't offered on this tab (it's neither in the dropdown nor in the ENV_CATEGORIES choices); that's Dashboard: quality provider settings lack openai-compatible and its base URL/model/key #1668. If .env already uses it, the dropdown is disabled and Save only sends the boost toggle, so the provider is left alone.
  • While doing this I noticed the Credentials tab calls this.apiCall(url, { method: 'POST', body }), but apiCall takes (endpoint, method, data), so Test and Save there fail with "'[object Object]' is not a valid HTTP method". I copied that pattern at first and the browser test caught it. I left the Credentials tab alone to keep this PR on Dashboard: Quality tab settings are never saved (provider, boost toggle, current provider) #1671; happy to send a separate fix.
  • Saving overwrites a value that was set in the real shell environment for the restarted process. I think that's what someone pressing Save expects, but say if you'd rather refuse in that case.

Agent Disclosure

I used Claude Code to help with this change, and I went through the diff, the tests and the description myself before opening this.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with no new actionable issues and the numbered previous finding fixed.

Summary

The Quality tab now loads and saves its provider and boost settings through an admin-only endpoint, then restarts the server.

  • The Quality tab saves its provider and search-boost settings.

Diagram

sequenceDiagram
    participant Tab as Quality tab
    participant API as Configuration API
    participant Env as .env and process environment
    participant Server
    Tab->>API: Load current settings
    API-->>Tab: Provider and boost values
    Tab->>API: Save settings
    API->>API: Check admin access and values
    API->>Env: Save accepted settings
    API-->>Tab: Restart scheduled
    API->>Server: Restart
Loading

Reviews (6) · Last reviewed commit: "fix(web): let an empty process value win..." · Reviewed by Greptile

The provider dropdown and the boost toggle on the Quality tab were never
read, the toggle rendered checked although boosting is off by default,
and the Current Provider box was hardcoded.

Add an admin-only POST /api/config/quality that writes
MCP_QUALITY_AI_PROVIDER and MCP_QUALITY_BOOST_ENABLED to .env and
restarts the server, and wire the tab to it: it now loads both values
from /api/config/env and has a Save & Restart button.

Values are checked against the choices ENV_CATEGORIES already lists. A
provider whose key is missing is refused before anything is written,
since QualityConfig.validate() would stop the restarted server from
starting. The saved values also go into os.environ: load_dotenv copied
the old .env values there, and the restarted process inherits them.
Keep the tab's controls and Save disabled until /config/env has answered,
so a slow or failed load can no longer write the HTML defaults over the
configured values; a failed load says so and reopening the tab retries.

Read the boost flag with the spellings safe_get_bool_env() accepts, and
check provider keys with startup's precedence: a variable present in the
process environment wins over .env even when it is empty.

Sanitize the setting names in the audit log line.
@doobidoo
doobidoo enabled auto-merge (squash) October 25, 2026 18:41
…oo#1671)

_write_credential_to_env() appended a missing key straight after the last
line, so a .env that ends without a newline got the new assignment glued
to its final setting. Terminate that line first. The credentials save
goes through the same helper and benefits too.
auto-merge was automatically disabled October 25, 2026 19:07

Head branch was pushed to by a user without write access

@doobidoo
doobidoo enabled auto-merge (squash) October 25, 2026 19:51
doobidoo
doobidoo previously approved these changes Oct 25, 2026
greptile-apps[bot]
greptile-apps Bot previously approved these changes Oct 25, 2026
@doobidoo

Copy link
Copy Markdown
Owner

@dodoshell please follow up with resolving the code reviews.

…obidoo#1671)

GET /api/config/env took `os.getenv(key) or env_vars.get(key)`, so a variable
set to an empty string in the process environment fell through to .env. At
startup load_dotenv(override=False) keeps the empty value, so the Quality tab
could show boost on while the server ran with it off, and saving a provider
change would then switch boost on. Use the same precedence as the provider
key check.
auto-merge was automatically disabled October 25, 2026 22:28

Head branch was pushed to by a user without write access

@dodoshell
dodoshell dismissed stale reviews from greptile-apps[bot] and doobidoo via 3b346a6 October 25, 2026 22:28
@doobidoo
doobidoo merged commit e15728d into doobidoo:main Oct 26, 2026
24 of 36 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.

Dashboard: Quality tab settings are never saved (provider, boost toggle, current provider)

3 participants