feat(web): support Cmd+Click on new-session buttons to open in new tab#1288
feat(web): support Cmd+Click on new-session buttons to open in new tab#1288
Conversation
…ate session Detect `?action=create` to open CreateSessionDialog and `?action=create-in-dir&workDir=xxx` to directly create a session in the specified directory. Params are consumed after use to prevent re-triggering on refresh. Entire-Checkpoint: c0496aeaab22
The top-level "+" button opens a new tab with `?action=create`. The grouped-view "+" button opens a new tab with `?action=create-in-dir&workDir=xxx`. Tooltips updated with modifier-key hint. Entire-Checkpoint: 92c17dd2c99c
Opens a new tab with `?action=create` when modifier key is held. Tooltip updated with modifier-key hint. Entire-Checkpoint: 5cb94db2865a
Entire-Checkpoint: 5b2c427a42e0
Entire-Checkpoint: cb947d4bc3b3
There was a problem hiding this comment.
Pull request overview
This PR adds support for Cmd+Click (Mac) / Ctrl+Click (Windows/Linux) on all "new session" + buttons to open the create-session flow in a new browser tab. It does so by constructing a URL with ?action=create or ?action=create-in-dir&workDir=xxx params and opening that URL via window.open(..., "_blank"). The receiving tab reads those params on mount in App.tsx, performs the appropriate action, and then cleans the params from the URL.
Changes:
App.tsx— Adds auseEffectthat reads?action=create/?action=create-in-dirURL params on page load to auto-open the dialog or silently create a session, then removes the params.sessions.tsx— Top-level+button and per-group "New session here" button both grow Cmd/Ctrl+Click handling and updated tooltips.chat-conversation.tsx— Empty-state "Create new session" button gains the same Cmd/Ctrl+Click logic and tooltip update.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
web/src/App.tsx |
Adds URL-param–driven effect to auto-open dialog or create a session on page load |
web/src/features/sessions/sessions.tsx |
Adds Cmd/Ctrl+Click handling + updated tooltips on two + buttons |
web/src/features/chat/components/chat-conversation.tsx |
Adds Cmd/Ctrl+Click handling + updated tooltip on empty-state button |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| </KbdGroup> | ||
| </div> | ||
| <div className="flex items-center gap-2 text-xs text-muted-foreground"> | ||
| <span>{newSessionShortcutModifier}+Click open in new tab</span> |
There was a problem hiding this comment.
The tooltip text "{newSessionShortcutModifier}+Click open in new tab" is missing the word "to" — it should read "{newSessionShortcutModifier}+Click to open in new tab".
| <span>{newSessionShortcutModifier}+Click open in new tab</span> | |
| <span>{newSessionShortcutModifier}+Click to open in new tab</span> |
| if (action === "create") { | ||
| setShowCreateDialog(true); | ||
| } else if (action === "create-in-dir") { | ||
| const workDir = params.get("workDir"); | ||
| if (workDir) { | ||
| createSession(workDir); | ||
| } | ||
| } else { | ||
| return; | ||
| } | ||
| params.delete("action"); | ||
| params.delete("workDir"); | ||
| const url = new URL(window.location.href); | ||
| url.search = params.toString(); | ||
| window.history.replaceState({}, "", url.toString()); |
There was a problem hiding this comment.
There are two related issues with the create-in-dir branch:
-
Unhandled promise rejection:
createSession(workDir)is called withoutawaitand without error handling. SinceuseEffectcallbacks cannot beasync, the promise rejection is silently swallowed. If the API call fails (e.g. network error, invalid directory), the user gets no feedback. The effect should use an inner async IIFE and wrap the call in try/catch to surface errors (e.g. viatoast.error). -
Params consumed when no action is taken: When
action === "create-in-dir"butworkDirisnull/empty (e.g. a manually crafted URL),createSessionis never called, but the URL params are still removed (lines 129–133 run). The user receives no feedback and no retry is possible. Areturnshould guard line 129 whenworkDiris missing, or an error should be displayed.
| </KbdGroup> | ||
| </div> | ||
| <div className="flex items-center gap-2 text-xs text-muted-foreground"> | ||
| <span>{newSessionShortcutModifier}+Click open in new tab</span> |
There was a problem hiding this comment.
The tooltip text "{newSessionShortcutModifier}+Click open in new tab" is missing a verb — it should read something like "{newSessionShortcutModifier}+Click to open in new tab". The same phrasing issue appears in all three tooltip locations in this PR: sessions.tsx lines 676 and 884, and chat-conversation.tsx line 167.
| <span>{newSessionShortcutModifier}+Click open in new tab</span> | |
| <span>{newSessionShortcutModifier}+Click to open in new tab</span> |
| <TooltipContent side="right">New session here</TooltipContent> | ||
| <TooltipContent className="flex flex-col items-center gap-1" side="right"> | ||
| <span>New session here</span> | ||
| <span className="text-xs text-muted-foreground">{newSessionShortcutModifier}+Click open in new tab</span> |
There was a problem hiding this comment.
The tooltip text "{newSessionShortcutModifier}+Click open in new tab" is missing the word "to" — it should read "{newSessionShortcutModifier}+Click to open in new tab".
| <span className="text-xs text-muted-foreground">{newSessionShortcutModifier}+Click open in new tab</span> | |
| <span className="text-xs text-muted-foreground">{newSessionShortcutModifier}+Click to open in new tab</span> |
Entire-Checkpoint: 3dcde4c73a04
| setShowCreateDialog(true); | ||
| } else if (action === "create-in-dir") { | ||
| const workDir = params.get("workDir"); | ||
| if (!workDir) return; // invalid params, ignore silently |
There was a problem hiding this comment.
🟡 URL action params not cleaned up when create-in-dir is missing workDir
When the URL contains ?action=create-in-dir but no workDir parameter, the early return on line 123 skips the URL cleanup code (lines 130–134). The action parameter remains in the URL permanently.
Root Cause and Impact
The cleanup logic at web/src/App.tsx:130-134 only runs if the code doesn't hit an early return. The return on line 123 exits the effect before reaching the params.delete("action") call.
This means if a user navigates to ?action=create-in-dir (without workDir), the action param stays in the URL. On every page refresh, the effect re-runs, hits the same early return, and the stale param persists. While this is an edge case (the app always constructs URLs with workDir present at web/src/features/sessions/sessions.tsx:871-872), it violates the stated design goal of "Params are consumed after use to prevent re-triggering on refresh."
| if (!workDir) return; // invalid params, ignore silently | |
| if (!workDir) { | |
| // Fall through to cleanup below | |
| } else { | |
| createSession(workDir).catch(() => { | |
| // Errors are already handled globally via sessionsError → toast | |
| }); | |
| } |
Was this helpful? React with 👍 or 👎 to provide feedback.
Signed-off-by: Young E <49367723+YoungY620@users.noreply.github.com>
Related Issue
N/A
Description
Support Cmd+Click (Mac) / Ctrl+Click (Windows/Linux) on all "+" new-session buttons to open the create-session flow in a new browser tab.
Changes:
web/src/App.tsx: Detect?action=createand?action=create-in-dir&workDir=xxxURL params on page load to auto-open the create dialog or directly create a session in the specified directory. Params are consumed after use to prevent re-triggering on refresh.web/src/features/sessions/sessions.tsx: Top-level "+" button and grouped-view "New session here" button both support Cmd+Click to open a new tab. Tooltips updated with modifier-key hint.web/src/features/chat/components/chat-conversation.tsx: Empty-state "Create new session" button supports Cmd+Click to open a new tab. Tooltip updated with modifier-key hint.Checklist
make gen-changelogto update the changelog.make gen-docsto update the user documentation.