Repository navigation
fix(settings): persist SessionStart toggles and accept zero context counts via POST /api/settings - #5393
Conversation
…ounts via POST /api/settings
[Medium impact] The PR appears safe to merge; the previous toggle issue is fixed and no new blocking issue was found. SummaryThe PR lets
Reviews (2) · Last reviewed commit: "fix(settings): reject falsy non-boolean ..." · Reviewed by Greptile |
|
Merged, thank you @0xABCD01! Saving One thing left for a follow-up if you want it: the viewer's context settings still use |
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, andCLAUDE_MEM_WELCOME_HINT_ENABLEDare read by the context renderer (src/cli/handlers/context.ts,SearchRoutes.ts) and have defaults inSettingsDefaultsManager, but they were missing from the POST write whitelist inSettingsRoutes.handleUpdateSettings, so a save that changed them returned success and wrote nothing. They are now whitelisted, and added to thebooleanSettingsvalidation list so they take the same"true"/"false"check as the sibling context toggles.2. Zero was rejected for the two context counts.
validateSettingsrequiredCLAUDE_MEM_CONTEXT_OBSERVATIONSin 1..200 andCLAUDE_MEM_CONTEXT_SESSION_COUNTin 1..50, failing the whole save on"0". The renderer accepts 0 for both:parseContextCountValueallows any whole number >= 0 andContextConfigLoaderuses it directly, andtests/context/context-count-bounds.test.tsalready 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_COUNTalready validated 0..20 in the same function.)Tests:
tests/settings-routes-settings-document.test.tsgains 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 typecheckclean.Not in this diff: the committed bundles are not rebuilt, as in other contributor PRs. Two follow-ups the maintainer may want separately:
ContextSettingsModalstill gives both count inputsmin="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_PROJECTSis 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.