Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

@ammar-agent ammar-agent commented Dec 14, 2025

Summary

Fix model-switch thinking level restore and stop Review/diff “refresh” behavior on Cycle Model.

Changes

  • Refactor usePersistedState to use React 18 useSyncExternalStore (stable localStorage-backed store)
  • Remove the keyed ThinkingProvider remount workaround (prevents subtree unmount/remount)
  • Add regression tests: model switch restores per-model thinking + does not remount children

Risk

Medium: usePersistedState is a shared primitive. Mitigated by stable snapshot caching and added tests.

Testing

  • make static-check
  • make typecheck
  • bun test src/browser

Generated with mux • Model: anthropic:claude-sonnet-4-20250514 • Thinking: low

@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

ThinkingProvider was reading the model non-reactively, so when the model
changed (e.g., via Cycle Model), the thinking level wasn't updated.

Fix: Subscribe to model changes via usePersistedState with listener mode,
so when the model changes, we derive the new thinking key and load the
correct stored value for that model.

---
_Generated with `mux` • Model: `anthropic:claude-sonnet-4-20250514` • Thinking: `low`_
@ammar-agent ammar-agent force-pushed the fix-thinking-model-sync branch 2 times, most recently from c93df67 to 2ec9200 Compare December 14, 2025 02:35
- Key ThinkingProviderInner by per-model thinking key to avoid one-render stale thinking state during model switches (e.g. Cycle Model)
- Add regression test: switching models restores per-model thinking level
@ammar-agent ammar-agent force-pushed the fix-thinking-model-sync branch from 2ec9200 to 61e2a2d Compare December 14, 2025 02:44
- Rework usePersistedState to use React 18 useSyncExternalStore
- Cache localStorage snapshots by raw string to prevent render loops
- Remove ThinkingProvider remount workaround (prevents Review/diff refresh)
- Add regression tests for model switching + no child remount

---
_Generated with  • Model:  • Thinking: _
@ammario ammario merged commit d78c608 into main Dec 14, 2025
20 checks passed
@ammario ammario deleted the fix-thinking-model-sync branch December 14, 2025 03:20
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.

2 participants