fix(desktop): fix chat infinite re-render and model selector logo#1283
Conversation
Fix "Maximum update depth exceeded" crash when opening chat by moving tRPC mutation objects behind refs so useEffect deps stay stable. Add https://models.dev to CSP img-src so model selector logos load.
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughUpdates Content-Security-Policy to allow https://models.dev for images and refactors ChatInterface session lifecycle to use refs and an explicit sessionReady flag, decoupling connection logic from mutation isSuccess state. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Client (ChatInterface)
participant API as Session API (start/stop mutations)
participant Proxy as Proxy/Connection (config.proxyUrl)
UI->>API: startSessionRef.mutate(sessionId, cwd)
API-->>UI: start success
UI->>UI: set sessionReady = true
alt config.proxyUrl exists and sessionReady
UI->>Proxy: establish connection to proxyUrl
Proxy-->>UI: connection established
else no proxy or not ready
UI-->>UI: wait for sessionReady and proxyUrl
end
Note right of UI: on unmount -> stopSessionRef.mutate(...)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Replace dual-path doConnect (onSuccess + ref-based useEffect) with a single useEffect that watches sessionReady state + config.proxyUrl.
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
startSession,stopSession) were inuseEffectdependency arrays and get recreated every render, causing an infinite loop. Moved them behind refs and replaced the dual-path connect logic with a single reactive effect gated onsessionReadystate +config.proxyUrl.https://models.devwas missing from the Content Security Policyimg-srcdirective, so Electron blocked the external SVG fetches.Test plan
Summary by CodeRabbit
Bug Fixes
Chores