-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Closed
Description
Description
Favorite models saved via the TUI are lost after updates or restarts.
Steps to Reproduce
- Open the model selector and add models to favorites (ctrl+f)
- Close opencode
- Reopen opencode (or update to a new version)
- Favorites are gone
Root Cause
There is a race condition in packages/opencode/src/cli/cmd/tui/context/local.tsx:
modelStoreinitializes withfavorite: [](empty array)model.jsonis read asynchronously viafile.json().then(...)- Before the file read completes, actions like
--modelflag or session variant changes callsave() save()writes the empty in-memory state to disk, wiping persisted favorites
Key trigger points:
app.tsx:241-254---modelflag triggerslocal.model.set(..., { recent: true })inonMountprompt/index.tsx:132-151- Session changes triggerlocal.model.variant.set()early
Expected Behavior
Favorites should persist across restarts and updates.
Proposed Fix
- Defer
model.jsonwrites until state is ready (pendingSaveflag) - Merge persisted data with in-memory state on load (instead of overwriting)
- Flush any queued save after file load completes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels