Fix #280: persist /model, /verbose, expanded-view across restarts#312
Open
ericleepi314 wants to merge 1 commit into
Open
Fix #280: persist /model, /verbose, expanded-view across restarts#312ericleepi314 wants to merge 1 commit into
ericleepi314 wants to merge 1 commit into
Conversation
) The three side-effect handlers were TODO stubs — /model, /verbose, and the expanded-view toggle reset on every restart. - _persist_user_settings: single writer chokepoint (global config "settings" section + cache invalidate, fail-soft); the three advisor handlers deduped onto it (~70 lines of triplicated boilerplate) - /model now actually persists: ModelCommand._apply and the TUI picker route through persist_model_choice (reactive store when wired, else direct write) — previously nothing wrote main_loop_model in production, so the handler never fired - multi-provider guard: the model is persisted PAIRED with its provider key (new AppState.main_loop_provider + settings.model_provider, the advisor_model/advisor_provider precedent); get_persisted_model restores it only when the launch provider matches, so a model chosen on provider A can never feed provider B an invalid id - entrypoints (TUI/headless/REPL) resolve startup model as cli option > persisted choice > provider default_model; get_persisted_model reads the config layers directly because the merged schema bakes in DEFAULT_SETTINGS.model - verbose/expanded_view seed back into get_default_app_state - test_model_command gets the theme/vim-style config isolation fixture (without it the new persist call would write the developer's real ~/.clawcodex/config.json during tests) Closes #280 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #280
Summary
The AppState side-effect handlers for
main_loop_model,verbose, andexpanded_viewwere TODO stubs — all three preferences reset on restart (TS persists them viaonChangeAppState.ts:123-136).Write side
_persist_user_settings(**values)— single writer chokepoint (global configsettingssection + cache invalidate, fail-soft). The three pre-existing advisor handlers were deduped onto it (~70 lines of triplicated boilerplate removed, semantics pinned by tests)./modelactually persists now (critic-found gap: nothing in production wrotemain_loop_modelto the reactive store, so the handler was unreachable).ModelCommand._applyand the TUI picker route throughpersist_model_choice— via the store when wired (fires the router), else a direct settings write (the/advisorpattern). The contradicted module docstring is fixed.Multi-provider guard (critic-found)
The persisted model is paired with its provider key (
AppState.main_loop_provider+settings.model_provider— theadvisor_model/advisor_providerprecedent).get_persisted_model(provider_name)restores the model only when the launch provider matches; unpaired/legacy or mismatched → provider's own default. Without this, a model persisted on provider A would feed provider B an invalid model id (TS's single-provider world can't hit this).Read side
cli option > persisted choice > provider default_model.get_persisted_modelreads the config layers directly — the merged schema bakes inDEFAULT_SETTINGS.model, which must not override provider defaults for users who never ran/model.get_default_app_state()seedsverboseandexpanded_view(validated) from settings.Test safety
test_model_command.pygot the established config-isolation fixture — without it the new persist call would have written the developer's real~/.clawcodex/config.jsonduring tests.Test plan
/modelend-to-end: real AnthropicProvider set → restored foranthropic, None forglm🤖 Generated with Claude Code