[PR #8356] fix(opencode): preserve model favorites on startup #12718

Closed
opened 2026-02-16 18:17:37 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8356

State: closed
Merged: No


Fixes #8375

Summary

  • defer model.json writes until model state is ready to avoid overwriting saved favorites
  • merge and normalize persisted recents/favorites/variants with in-memory state on load

Root Cause

Race condition in local.tsx: save() can run before model.json is loaded, writing empty favorites to disk.

Changes

  • Add pendingSave flag to queue writes until ready
  • Add isModelEntry, normalizeModelList, normalizeVariant helpers for defensive parsing
  • Merge loaded state with in-memory state (preserves early user actions)
  • Flush queued save after file load completes
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8356 **State:** closed **Merged:** No --- Fixes #8375 ## Summary - defer `model.json` writes until model state is ready to avoid overwriting saved favorites - merge and normalize persisted recents/favorites/variants with in-memory state on load ## Root Cause Race condition in `local.tsx`: `save()` can run before `model.json` is loaded, writing empty favorites to disk. ## Changes - Add `pendingSave` flag to queue writes until ready - Add `isModelEntry`, `normalizeModelList`, `normalizeVariant` helpers for defensive parsing - Merge loaded state with in-memory state (preserves early user actions) - Flush queued save after file load completes
yindo added the pull-request label 2026-02-16 18:17:37 -05:00
yindo closed this issue 2026-02-16 18:17:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12718