Skip to content

fix(settings): persist SessionStart toggles and accept zero context counts via POST /api/settings - #5393

Merged
thedotmack merged 2 commits into
thedotmack:mainfrom
0xABCD01:fix/5392-settings-sessionstart
Nov 5, 2026
Merged

thedotmack merged 2 commits into
thedotmack:mainfrom
0xABCD01:fix/5392-settings-sessionstart

Conversation

@0xABCD01

@0xABCD01 0xABCD01 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #5392

POST /api/settings could not turn off parts of the SessionStart block, in two ways.

1. Three toggles were silently dropped. CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT, CLAUDE_MEM_MEMORY_INSTRUCTIONS_ENABLED, and CLAUDE_MEM_WELCOME_HINT_ENABLED are read by the context renderer (src/cli/handlers/context.ts, SearchRoutes.ts) and have defaults in SettingsDefaultsManager, but they were missing from the POST write whitelist in SettingsRoutes.handleUpdateSettings, so a save that changed them returned success and wrote nothing. They are now whitelisted, and added to the booleanSettings validation list so they take the same "true"/"false" check as the sibling context toggles.

2. Zero was rejected for the two context counts. validateSettings required CLAUDE_MEM_CONTEXT_OBSERVATIONS in 1..200 and CLAUDE_MEM_CONTEXT_SESSION_COUNT in 1..50, failing the whole save on "0". The renderer accepts 0 for both: parseContextCountValue allows any whole number >= 0 and ContextConfigLoader uses it directly, and tests/context/context-count-bounds.test.ts already pins 0 as preserved — a hand-edited "0" in settings.json worked, the API just refused to write it. Both ranges are now 0..200 and 0..50, with the error messages updated to match. (CLAUDE_MEM_CONTEXT_FULL_COUNT already validated 0..20 in the same function.)

Tests: tests/settings-routes-settings-document.test.ts gains a SessionStart describe block — the three toggles persist when posted, a non-boolean toggle value is rejected, "0" is accepted and persisted for both counts, and 201 / 51 / -1 / non-numeric are still rejected. The new tests fail on main (5 pass / 4 fail in that file) and pass here. Combined run over the settings, context, and worker-API suites: 307 pass / 0 fail. npm run typecheck clean.

Not in this diff: the committed bundles are not rebuilt, as in other contributor PRs. Two follow-ups the maintainer may want separately: ContextSettingsModal still gives both count inputs min="1" with "(1-200)" / "(1-50)" tooltips, and the configuration docs list the same ranges — the API now accepts 0, the viewer and docs still describe 1 as the floor. One more from the same sweep: CLAUDE_MEM_CONTEXT_PROJECTS is read at SessionStart and documented, but is likewise not writable via POST. I left it out on purpose — it widens context scope to every project rather than turning anything off, so it reads as deliberately file-only; flagging it in case it should be treated the same way.

@greptile-apps

greptile-apps Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous toggle issue is fixed and no new blocking issue was found.

Summary

The PR lets POST /api/settings save three SessionStart toggles and accept zero observation and session counts.

  • Settings saves now preserve all three SessionStart switches.
  • SessionStart settings can now use zero observations or sessions.

Reviews (2) · Last reviewed commit: "fix(settings): reject falsy non-boolean ..." · Reviewed by Greptile

@thedotmack
thedotmack merged commit d30d41d into thedotmack:main Nov 5, 2026
16 checks passed
@thedotmack

Copy link
Copy Markdown
Owner

Merged, thank you @0xABCD01! Saving CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT, CLAUDE_MEM_MEMORY_INSTRUCTIONS_ENABLED or CLAUDE_MEM_WELCOME_HINT_ENABLED through POST /api/settings now actually writes them, so the SessionStart block can be turned off from the API, and 0 is accepted for the observation and session counts the same way the renderer reads them. Good catch on the falsy values in your second commit: 0, "" or null used to report success and change nothing, and now get a 400. Your 10 tests passed here on your branch merged with main.

One thing left for a follow-up if you want it: the viewer's context settings still use min="1" and say "(1-200)" / "(1-50)" (src/ui/viewer/components/ContextSettingsModal.tsx), so 0 can only be set through the API or settings.json for now.

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.

POST /api/settings can't turn off the SessionStart block: 3 keys dropped, 0 rejected for two counts

2 participants