fix(cli): persist /verbose toggle across CLI sessions (#3312)#3827
Closed
NkAntony777 wants to merge 1 commit into
Closed
fix(cli): persist /verbose toggle across CLI sessions (#3312)#3827NkAntony777 wants to merge 1 commit into
NkAntony777 wants to merge 1 commit into
Conversation
The /verbose (and Ctrl+O) toggle previously reset to off on every CLI launch because the in-memory showReasoning bool was never written back to the config. Adds a new optional ui.show_thinking field (default false, backward-compatible), wires it into newChatTUI's load path, and persists the toggle off the bubbletea event loop on every flip. The save targets the user config (config.UserConfigPath), not the project-local reasonix.toml, because show_thinking is a personal viewing preference — writing it to a project file that may be git-committed would leak the user's setting to every collaborator. The toggle captures show into a local before spawning the goroutine and passes it as a function argument, so the Go memory model's happens-before edge protects the save goroutine from racing the Update goroutine's write to m.showReasoning. (Go doesn't tear bools, but the race detector would still flag the pattern.) Extracts applyConfig from chatREPL so the load path is unit-testable without going through the full bubbletea bootstrap, and adds a RenderScopeProject render test for the new field's scope-aware emission. Coverage: - TestToggleVerboseReasoningPersistsShowThinking (full on/off round-trip via disk) - TestPersistShowThinkingNoConfigIsNoop (nil cfg guard) - TestApplyConfigRespectsShowThinking (load path opens reasoning) - TestApplyConfigKeepsTermuxVerboseOn (OR semantics with Termux default) - TestApplyConfigNilIsNoop (defensive nil guard) - TestProjectRenderShowThinkingScoped (render scopes covered)
Owner
|
Thanks for the careful work here, including the clean config rendering compatibility — the diagnosis of #3312 was exactly right. In the end the |
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.
Summary
The
/verbose(and Ctrl+O) toggle previously reset to off on every CLIlaunch because the in-memory
showReasoningbool was never writtenback to the config. This adds an optional
ui.show_thinkingfield(default
false, fully backward-compatible) and persists every flipoff the bubbletea event loop so the next session opens with the
reasoning block in the same state.
Fixes #3312.
Changes
internal/config/config.go— newUIConfig.ShowThinking boolwithtoml:"show_thinking", defaults tofalse.internal/config/render.go—RenderTOMLForScopeemitsshow_thinking = trueonly when set, with a commented-out placeholder only inRenderScopeFullso unmodified project configs stay byte-identical.internal/cli/cli.go—chatREPLnow calls a newm.applyConfig(cfg)helper.internal/cli/chat_tui.go—applyConfig(cfg)method: seeds the TUI from a loaded config, using OR semantics so a persistedShowThinking=truedoes not stomp the Termux native-scrollback default.toggleVerboseReasoningspawns a goroutine that callspersistShowThinking(show), capturingshowinto a local first so the save goroutine reads a stable value (no race with the Update goroutine's write tom.showReasoning).persistShowThinking(show bool) errormethod: writes the preference to the user-level config viaSaveTo(config.UserConfigPath()).Design notes
Why user config, not project config.
show_thinkingis a personalviewing preference; writing it to a project-local
reasonix.tomlthatmay be git-committed would leak the user's setting to every
collaborator on the repo. The same rationale as
NotificationsConfiget al. — viewing preferences belong in
~/.config/reasonix/config.toml.Note: a project
reasonix.tomlwithshow_thinking = falsewillsilently win on the next load (project > user priority in
Load),which matches the long-standing merge semantics.
Why async save. The bubbletea
Update()goroutine must not blockon disk I/O.
SaveTo's atomic temp+rename makes racing writes safe ondisk (last-writer-wins, never a torn file); a coalescer/debouncer is
left as a possible follow-up.
Scope of the fix. Per the issue, the
--show-thinkingflag innon-interactive
runmode and the desktop app's reasoning toggle(
internal/serve/,desktop/) are out of scope and explicitlyunaffected. The web/desktop frontends have their own
TextSink.showReasoningfield.Tests
New tests (all passing):
TestToggleVerboseReasoningPersistsShowThinkingisolateUserConfig+LoadForEditTestPersistShowThinkingNoConfigIsNoopTestApplyConfigRespectsShowThinkingTestApplyConfigKeepsTermuxVerboseOnTestApplyConfigNilIsNoopapplyConfigTestProjectRenderShowThinkingScopedRenderScopeProjectemits the key only when setThe
applyConfigextraction is the testability-driven refactor thatcloses the gap identified in review: previously, deleting the four
applyConfiglines would still pass every existing test. The newTestApplyConfigRespectsShowThinkingcovers that regression.Manual verification
go build ./cmd/reasonix./reasonix chat(orreasonix.exeon Windows)/verbose→ notice "verbose on — thinking text will be shown"/quit~/.config/reasonix/config.toml(or%AppData%\reasonix\config.tomlon Windows):/verboseagain → notice "verbose off"Out of scope
Savefails (currentlyslog.Warn; the in-TUI notice fires regardless of save success — matches the project's existing preference-persistence pattern, e.g./effort).