fix(desktop): keep the launch target when New Workspace is pressed on its own screen
Summary
- Pressing ⌘N or New Workspace while already on the new-workspace screen no longer changes the selected host.
Why / Context
Found on the canary after #9287. From a cloud workspace, pressing ⌘N (or clicking New Workspace) twice flipped Device from Cloud to this device.
- The first press opens
/new-workspace?projectId=<repo>&host=cloud. #9287 made that a one-open pin carried in the URL, not saved. - The second press is made on
/new-workspace, where there is no viewed workspace to hand off.openNewWorkspace()navigated withsearch: undefined, which drops the current search, so thehost=cloudpin was lost. - The screen then fell back to the saved
lastHostId, which is this device for anyone who never picked Cloud from the chip.
How It Works
useOpenNewWorkspace reads whether /new-workspace is the current route. openNewWorkspace returns early when called there with no project and no host. A handoff that names a project or host (issue/PR launches, the Cloud "+") still navigates and applies.
Manual QA Checklist
- From a cloud workspace, press ⌘N twice → stays on Cloud with the same repo
- Same with the sidebar and title-bar New Workspace buttons
- On the new-workspace screen, click the Cloud "+" for another repo → that repo is applied
- From a non-workspace page, ⌘N still opens the screen on the saved host
Testing
bun test src/rendererinapps/desktop(7544 pass), including two new cases inuseOpenNewWorkspace.test.ts: a repeat open on the screen does not navigate; a handoff on the screen still does.bun run typecheck(desktop),biome check.- Not run in the app (same constraint as #9287); the canary repro above is the check.
Summary by cubic
Fixes the new-workspace screen dropping its pinned host when New Workspace (or ⌘N) is pressed again on it. Previously, a second press navigated with no search params, losing the host=cloud pin from the first open and falling back to the saved host (this device). Opening the screen it's already on with nothing to hand off is now a no-op; a handoff that names a project or host still navigates and applies.
Summary by CodeRabbit
- Bug Fixes
- Avoided unnecessary navigation when users request the new-workspace screen without specifying a project or host, keeping them on the screen they are already viewing.
- Preserved navigation when a project and host are provided, including both selections in the destination.