Skip to content

fix(desktop): reopen a chat on the browser tab the user left it on - #7793

Open
waleedlatif1 wants to merge 3 commits into
stagingfrom
fix/browser-tab-restore-on-chat-switch
Open

fix(desktop): reopen a chat on the browser tab the user left it on#7793
waleedlatif1 wants to merge 3 commits into
stagingfrom
fix/browser-tab-restore-on-chat-switch

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Reopening a chat landed on the last browser tab instead of the one the user left it on. The resource strip treated its own last-tab fallback as a selection and pushed it onto the desktop app, overriding the tab the desktop remembers per chat (which also survives relaunch).
  • The shared desktop-tab hook now switches the native tab only for an explicit selection. When the strip is on its fallback and that fallback is a browser or terminal tab, it adopts the desktop's active tab instead, without claiming the selection for the user so agent activity still behaves the same on chat open.
  • A selected tab that has not landed yet (reload with the tab in the URL) is switched to once the desktop's tab list arrives, instead of never.
  • Chat hydration no longer writes a browser or terminal tab into the URL as a fallback; it still pins the last server-held resource.

Type of Change

  • Bug fix

Testing

  • Added hook tests for reopen-adopts-native-tab (browser + terminal), stale selection, non-tab fallback left alone, and deferred switch on reload; verified each fails without the fix.
  • bun run type-check, bun run lint, bun run check:audits (46 audits), all home-surface tests (67 files) pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

🤖 Generated with Claude Code

https://claude.ai/code/session_0139YonWmiZUnPMTHoH4PtAJ

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.
@vercel

vercel Bot commented Sep 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 12, 2026 10:03am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The pull request appears safe to merge, with both previous findings resolved and no actionable new defects identified.

Summary

  • Distinguishes explicit resource selection from the strip’s fallback.
  • Passively adopts the desktop’s remembered active tab after chat hydration.
  • Retries an explicit selection when the corresponding native tab appears.
  • Avoids restoring a tab that was just closed from the resource strip.
  • Adds browser and terminal hook coverage for restoration, hydration ordering, stale selections, and deferred switching.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Chat opens] --> B[Wait for chat hydration]
    B --> C{Explicit selected resource?}
    C -->|Yes and native tab is live| D[Switch native tab without claiming]
    C -->|Yes but tab is not live| E[Wait for native tab list]
    E --> D
    C -->|No| F{Fallback is a browser or terminal tab?}
    F -->|No| G[Keep existing resource]
    F -->|Yes| H[Read desktop active tab]
    H --> I[Passively restore matching resource]
    D --> J[Ignore requested native switch landing]
    I --> K[Leave selection ownership unclaimed]
Loading

Reviews (3) · Last reviewed commit: "fix(desktop): show a selected tab that a..."

Comment thread apps/sim/app/workspace/[workspaceId]/home/hooks/use-desktop-tab-resources.ts Outdated
…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
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

Comment thread apps/sim/app/workspace/[workspaceId]/home/hooks/use-desktop-tab-resources.ts Outdated
The effect that shows an explicitly selected tab was keyed on the
selection alone, so a selection made before the desktop app published
its tab list was dropped rather than applied when the tab arrived. It is
now keyed on that tab being live as well, which covers the late arrival
without a retry ref to arm and disarm.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139YonWmiZUnPMTHoH4PtAJ
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

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.

1 participant