Skip to content

fix(web): open new session in one tab, not two - #72

Merged
karngyan merged 1 commit into
mainfrom
worktree-fix-double-session-open
Aug 17, 2026
Merged

fix(web): open new session in one tab, not two#72
karngyan merged 1 commit into
mainfrom
worktree-fix-double-session-open

Conversation

@karngyan

Copy link
Copy Markdown
Contributor

What

Creating a session from the UI produced two sessions: one in the current tab and one in a newly opened tab. This drops the popup-blocked fallback in useOpenNewSession so the new tab is the only path.

Why

window.open(href, '_blank', 'noopener') returns null on every call. That is specified behaviour, not a popup block: noopener severs the handle the caller would otherwise get back. So the fallback if (tab === null) void router.navigate({ to: href }) fired unconditionally, the popup opened and this tab navigated, and /new spawned a session in each.

This is option 1 from the issue, listed there as preferred: a genuinely blocked popup is rare, and the browser's own blocked-popup UI is the recovery. The hook's doc comment now records why there is deliberately no fallback, so it does not get reintroduced.

Test

New web/src/sessions/open-new-session.test.tsx pins both halves:

  • the hook opens /new?... in a tab with _blank and noopener, once
  • the current tab does not navigate even though window.open returned null

The second test fails against the old code (the fallback navigates the test router to /new) and passes deterministically against the new. Also rewords a comment in web/src/routes/new-session.test.tsx that described the removed fallback as the way an already-connected tab arrives.

pnpm vitest run: 68 files, 1359 tests, all passing. pnpm run lint clean.

Closes#69

🤖 Generated with Claude Code

With noopener set, window.open returns null on every call. That is
specified behaviour, not a popup block, so the popup-blocked fallback
navigated this tab unconditionally and every click spawned two
sessions. Drop the fallback: the tab is the only path, and a genuinely
blocked popup is recoverable through the browser's own UI.
Closes#69
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@karngyan
karngyan merged commit 83036d8 into mainAug 17, 2026
1 check passed
Sign up for freeto 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.

New session from the UI starts two: one in this tab and one in a new one

1 participant

@karngyan