Skip to content

Conversation

@leeweisern
Copy link

@leeweisern leeweisern commented Jan 14, 2026

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

@github-actions
Copy link
Contributor

Hey! Your PR title Fix favorites persistence on startup doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@leeweisern leeweisern changed the title Fix favorites persistence on startup fix(opencode): preserve model favorites on startup Jan 14, 2026
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@leeweisern
Copy link
Author

I have saved favourite models, but new updates overwrites them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Favorite models get wiped on startup due to race condition

1 participant