Refuse cross-worktree global fallback for browser text insertion (#5093) (#6563)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil
2026-06-28 15:58:15 -07:00
committed by GitHub
co-authored by Orca
parent b916248294
commit da48fa71dd
4 changed files with 200 additions and 40 deletions
@@ -505,4 +505,27 @@ describe('RuntimeBrowserCommands headless offscreen routing', () => {
})
expect(closeTab).not.toHaveBeenCalled()
})
it('forwards an unresolved worktree to the bridge unchanged for keyboard inserttext', async () => {
const { RuntimeBrowserCommands } = await import('./orca-runtime-browser')
// Why: when no --worktree is passed (or cwd is outside a managed worktree),
// worktreeId arrives undefined. The bridge — not the runtime — owns the
// cross-worktree guard, so verify the undefined scope is threaded through
// intact rather than silently widened here.
const keyboardInsertText = vi.fn().mockResolvedValue({ inserted: true })
const bridge = {
getRegisteredTabs: vi.fn(() => new Map([['page-1', 100]])),
keyboardInsertText
} as unknown as AgentBrowserBridge
const commands = new RuntimeBrowserCommands(
createHost({
getAgentBrowserBridge: () => bridge,
getAuthoritativeWindow: vi.fn(() => ({ webContents: { send: vi.fn() } }) as never)
})
)
await commands.browserKeyboardInsertText({ text: 'hello' })
expect(keyboardInsertText).toHaveBeenCalledWith('hello', undefined, undefined)
})
})