Repository navigation
fix(tui): retain unavailable saved session model selection - #53822
Open
kitlangton wants to merge 1 commit into
Open
kitlangton wants to merge 1 commit into
kitlangton wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Why
When an existing session's saved model is temporarily missing from the model catalog (for example while a remote provider catalog is reloading or unreachable),
sessionSelectionfilters out the saved selection withisModelValidand falls through tonewSessionModel(). If the user submits a prompt during that window, the TUI commits a durablemodel-switchedrecord to the session, permanently replacing the session's model with the fallback even after the original catalog recovers.What Changes
Existing sessions retain their saved or session-agent model selection (and variant) even when the model is not currently present in
models(). New-session fallback resolution (args.model, configured default, andpreferences.recent) still skips unavailable models.provider/model-ais temporarily absent selects the first available fallbackprovider/fallback, reportsavailable() === true, and writes a durablemodel-switchedevent on submit.provider/model-awith its saved variant,available()returnsfalse, and the prompt submit guard blocks withModel unavailableinstead of switching the session's model.flowchart TD A[Resolve sessionSelection] --> B{Draft or durable session model exists?} B -- Yes --> C[Retain saved model and variant] C --> D{Present in models catalog?} D -- Yes --> E[available = true, submit allowed] D -- No --> F[available = false, submit blocked with Model unavailable] B -- No --> G[Fallback to newSessionModel via isModelValid]Demo
pr-53822-v4.mp4
Scope
This PR owns existing-session model retention in
packages/tui/src/context/local.tsx. Remote configuration caching and cold-start discovery recovery live in separatepackages/corePRs.Verification
test/context/local-selection.test.tsx: 9 tests pass (27 assertions), covering retained unavailable session selections alongside thenewSessionModelvalidity filter for CLI and recent models.opencode-driveverification confirmed that submitting a prompt during a remote catalog 503 outage no longer appends amodel-switchedevent and preserves the session's original model once the catalog recovers.