fix(app): restore saved model & permission picks in new session#1391
Open
jlixfeld wants to merge 1 commit into
Open
fix(app): restore saved model & permission picks in new session#1391jlixfeld wants to merge 1 commit into
jlixfeld wants to merge 1 commit into
Conversation
The new-session screen persisted the user's model and permission picks to the draft (MMKV) but never read them back: the mount effect always reseeded the picker indices from the agent defaults, so a selection silently reset to the default on every remount (most visible on iOS, where navigation remounts the screen). Machine/path/agent restored fine; model and permission did not. Distinguish "never picked" from an explicit "default" pick by making the draft's modelMode/permissionMode nullable (null = unset). Add a pure resolveModeIndex helper that prefers the saved pick when still available for the current agent, else the agent default, else index 0, and use it in the reset effect. Covered by resolveModeIndex.test.ts. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
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.
Problem
The new-session screen persists the user's model and permission picks to the draft (MMKV) —
useNewSessionDrafteven documents that it restores them — but it never reads them back. The mount effect always reseeds the picker indices from the agent defaults, so a selection silently resets to the default on every remount. This is most visible on iOS, where navigation remounts the screen, so users report "iOS doesn't save model settings." Machine / path / agent restore correctly; model and permission don't.Root cause
new/index.tsxreset effect:draft.modelMode/draft.permissionModeare written on pick but never consulted here. The draft's initial'default'value also collides with the literal'default'model/permission key, so "never picked" couldn't be told apart from an explicit "default" pick.Fix
modelMode/permissionModenullable (null= unset), so an explicit "default" pick is distinct from never having picked.resolveModeIndex(modes, draftKey, fallbackKey)helper: prefer the saved pick when still available for the current agent, else the agent default, else index 0.Selecting a different agent still falls back to that agent's default (a pick from another agent won't be in its mode list). Setting a global default in Settings → Agent Defaults still applies for users who never picked in the new-session screen.
Tests
resolveModeIndex.test.tscovers: restore saved pick, explicit-defaultvs unset, fallback to agent default, cross-agent fallback, and the index-0 floor. Full suite green;pnpm typecheckclean.🤖 Generated with Claude Code