Fix floating workspace link routing (#2825)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo Hong
2026-05-25 23:19:02 -07:00
committed by GitHub
co-authored by Orca
parent 0f13c5d7bb
commit 34fa2b212d
2 changed files with 22 additions and 1 deletions
@@ -1,4 +1,5 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../shared/constants'
import { openHttpLink, registerHttpLinkStoreAccessor } from './http-link-routing'
const openUrlMock = vi.fn()
@@ -52,6 +53,20 @@ describe('openHttpLink', () => {
expect(openUrlMock).not.toHaveBeenCalled()
})
it('routes floating workspace links into Orca without changing the active repo worktree', () => {
storeState.settings = { openLinksInApp: true }
openHttpLink('https://example.com/', { worktreeId: FLOATING_TERMINAL_WORKTREE_ID })
expect(setActiveWorktreeMock).not.toHaveBeenCalled()
expect(createBrowserTabMock).toHaveBeenCalledWith(
FLOATING_TERMINAL_WORKTREE_ID,
'https://example.com/',
{ activate: true }
)
expect(openUrlMock).not.toHaveBeenCalled()
})
it('routes to the system browser when openLinksInApp is off', () => {
storeState.settings = { openLinksInApp: false }
+7 -1
View File
@@ -1,3 +1,5 @@
import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../shared/constants'
export type OpenHttpLinkOptions = {
worktreeId?: string | null
forceSystemBrowser?: boolean
@@ -40,7 +42,11 @@ export function openHttpLink(url: string, opts: OpenHttpLinkOptions = {}): void
// history entry — the user isn't changing worktrees, they're opening a tab
// in the one they're already in. activateAndRevealWorktree is reserved for
// file-link jumps that genuinely switch worktrees.
state.setActiveWorktree(worktreeId)
if (worktreeId !== FLOATING_TERMINAL_WORKTREE_ID) {
// Why: the floating workspace uses a synthetic worktree id. Promoting it
// to the global activeWorktreeId deselects the real repo workspace.
state.setActiveWorktree(worktreeId)
}
state.createBrowserTab(worktreeId, url, { activate: true })
return
}