fix(desktop): reopen a chat on the browser tab the user left it on - #7793
fix(desktop): reopen a chat on the browser tab the user left it on#7793waleedlatif1 wants to merge 2 commits into
Conversation
The resource strip pushed its own last-tab fallback onto the desktop app whenever a chat opened without an explicit selection, overriding the tab the desktop remembers the user was on. The shared desktop-tab hook now switches the native tab only for an explicit selection, adopts the desktop's active tab when the strip is on its fallback, and defers a selected tab that has not landed yet until it does. Chat hydration no longer writes a browser or terminal tab into the URL as a fallback.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
…lection Review round on the reopen fix. A late first report of the desktop app's active tab carries the tab it remembers, not a switch the user made, so it is adopted rather than claimed and agent activity can still take the view on chat open. A move away from a tab the desktop was already showing stays the user's own. Adoption now waits for the chat history to be applied, so the arrival order of the tab list and the history no longer decides which resource a chat opens on, and it skips a tab the strip has already dropped, so closing the shown tab cannot write the closed id back. Closing the shown tab selects its neighbour the way the desktop app picks the next native tab, instead of flashing through the strip's last tab. The two wrapper hooks now share one options type with the strip, and the adopt rule lives in a single helper. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139YonWmiZUnPMTHoH4PtAJ
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
| useEffect(() => { | ||
| if (!activeResourceId || activeResourceId === activeTabIdRef.current) return | ||
| if (!tabsRef.current.some((tab) => tab.id === activeResourceId)) return | ||
| requestedTabIdRef.current = activeResourceId | ||
| switchTabRef.current(activeResourceId, scopeIdRef.current) | ||
| }, [activeResourceId]) | ||
| if (!selectedResourceId || selectedResourceId === activeTabIdRef.current) return | ||
| if (!tabsRef.current.some((tab) => tab.id === selectedResourceId)) return | ||
| requestedTabIdRef.current = selectedResourceId | ||
| switchTabRef.current(selectedResourceId, scopeIdRef.current) | ||
| }, [selectedResourceId]) |
There was a problem hiding this comment.
On reload, an explicitly selected browser or terminal tab can be in the URL before the desktop publishes its native tab list. This effect returns while the selected tab is absent and only reruns when selectedResourceId changes. Because tab-list projection no longer retries the selection, a tab that arrives later is never activated and the chat remains on a different native tab.
Summary
Type of Change
Testing
bun run type-check,bun run lint,bun run check:audits(46 audits), all home-surface tests (67 files) pass.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_0139YonWmiZUnPMTHoH4PtAJ