fix: only show model switch success when persist succeeds (fixes #1435) #1465
+181
−1
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
Fixes #1435 - Model switch via
/modelcommand reports success but doesn't actually switch.Root Cause Analysis
In
src/auto-reply/reply/directive-handling.impl.ts, thehandleDirectiveOnlyfunction has two separate code blocks:Block 1 (lines 291-397): Session state persistence
Block 2 (lines 450-463): User feedback message generation
The bug: Block 2 runs regardless of whether Block 1 executed. So when
sessionEntry,sessionStore, orsessionKeyis missing:/statusstill shows old modelThe Fix
Track whether the persist actually happened:
Behavior Change
Testing
Added unit tests covering all edge cases in
directive-handling.impl.model-persist.test.ts:How to Verify
/model <some-model>/statusshows old modelFiles Changed
src/auto-reply/reply/directive-handling.impl.ts- 5 lines changed (the fix)src/auto-reply/reply/directive-handling.impl.model-persist.test.ts- new file (174 lines, unit tests)AI Disclosure
Minimal, surgical fix. No unrelated changes. Tests cover all edge cases.