Fix hidden browser automation paintability (#2851)
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable max-lines -- Why: this file groups every CLI browser-command test (page targeting, profiles, waits, viewport) so test-fixture imports and the runtime-client mock stay shared in one place. */
|
||||
import path from 'path'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const callMock = vi.fn()
|
||||
@@ -90,7 +89,7 @@ describe('orca cli browser page targeting', () => {
|
||||
expect(callMock).toHaveBeenNthCalledWith(1, 'worktree.list', { limit: 10_000 })
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'browser.snapshot', {
|
||||
page: 'page-1',
|
||||
worktree: `path:${path.resolve('/tmp/repo/feature')}`
|
||||
worktree: 'id:repo::/tmp/repo/feature'
|
||||
})
|
||||
})
|
||||
|
||||
@@ -124,7 +123,7 @@ describe('orca cli browser page targeting', () => {
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'browser.tabSwitch', {
|
||||
index: undefined,
|
||||
page: 'page-2',
|
||||
worktree: `path:${path.resolve('/tmp/repo/feature')}`
|
||||
worktree: 'id:repo::/tmp/repo/feature'
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable max-lines -- Why: computer CLI coverage shares one mocked runtime setup across command contracts. */
|
||||
import path from 'path'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const callMock = vi.fn()
|
||||
@@ -71,7 +70,7 @@ describe('orca computer CLI handlers', () => {
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(1, 'worktree.list', { limit: 10_000 })
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'computer.listApps', {
|
||||
worktree: `path:${path.resolve('/tmp/repo')}`
|
||||
worktree: 'id:repo::/tmp/repo'
|
||||
})
|
||||
})
|
||||
|
||||
@@ -142,7 +141,7 @@ describe('orca computer CLI handlers', () => {
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'computer.getAppState', {
|
||||
app: 'Finder',
|
||||
worktree: `path:${path.resolve('/tmp/repo')}`,
|
||||
worktree: 'id:repo::/tmp/repo',
|
||||
noScreenshot: true,
|
||||
restoreWindow: true
|
||||
})
|
||||
@@ -176,7 +175,7 @@ describe('orca computer CLI handlers', () => {
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'computer.listWindows', {
|
||||
app: 'Finder',
|
||||
worktree: `path:${path.resolve('/tmp/repo')}`
|
||||
worktree: 'id:repo::/tmp/repo'
|
||||
})
|
||||
const output = vi.mocked(console.log).mock.calls[0][0]
|
||||
expect(output).toContain('[0] id:42 "Recents"')
|
||||
@@ -241,7 +240,7 @@ describe('orca computer CLI handlers', () => {
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'computer.drag', {
|
||||
app: 'Finder',
|
||||
worktree: `path:${path.resolve('/tmp/repo')}`,
|
||||
worktree: 'id:repo::/tmp/repo',
|
||||
fromElementIndex: undefined,
|
||||
toElementIndex: undefined,
|
||||
fromX: 1,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable max-lines -- Why: file CLI coverage shares one mocked runtime setup across command contracts. */
|
||||
import path from 'path'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const callMock = vi.fn()
|
||||
@@ -83,7 +82,7 @@ describe('orca file CLI handlers', () => {
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(1, 'worktree.list', { limit: 10_000 })
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'files.open', {
|
||||
worktree: `path:${path.resolve('/tmp/repo')}`,
|
||||
worktree: 'id:repo::/tmp/repo',
|
||||
relativePath: 'src/App.tsx'
|
||||
})
|
||||
expect(vi.mocked(console.log).mock.calls[0][0]).toBe('Opened src/App.tsx.')
|
||||
@@ -160,20 +159,20 @@ describe('orca file CLI handlers', () => {
|
||||
await main(['file', 'open-changed'], '/tmp/repo/src')
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'git.status', {
|
||||
worktree: `path:${path.resolve('/tmp/repo')}`
|
||||
worktree: 'id:repo::/tmp/repo'
|
||||
})
|
||||
expect(callMock).toHaveBeenNthCalledWith(3, 'files.openDiff', {
|
||||
worktree: `path:${path.resolve('/tmp/repo')}`,
|
||||
worktree: 'id:repo::/tmp/repo',
|
||||
relativePath: 'src/App.tsx',
|
||||
staged: false
|
||||
})
|
||||
expect(callMock).toHaveBeenNthCalledWith(4, 'files.openDiff', {
|
||||
worktree: `path:${path.resolve('/tmp/repo')}`,
|
||||
worktree: 'id:repo::/tmp/repo',
|
||||
relativePath: 'package.json',
|
||||
staged: true
|
||||
})
|
||||
expect(callMock).toHaveBeenNthCalledWith(5, 'files.openDiff', {
|
||||
worktree: `path:${path.resolve('/tmp/repo')}`,
|
||||
worktree: 'id:repo::/tmp/repo',
|
||||
relativePath: 'docs/new.md',
|
||||
staged: false
|
||||
})
|
||||
|
||||
+17
-14
@@ -182,7 +182,10 @@ describe('orca cli worktree awareness', () => {
|
||||
it('shows the enclosing worktree for `worktree current`', async () => {
|
||||
queueFixtures(
|
||||
callMock,
|
||||
worktreeListFixture([buildWorktree('/tmp/repo/feature', 'feature/foo')]),
|
||||
worktreeListFixture([
|
||||
buildWorktree('/tmp/repo/feature', 'feature/foo'),
|
||||
buildWorktree('/tmp/repo/feature', 'feature/foo', 'abc', 'duplicate-repo')
|
||||
]),
|
||||
okFixture('req_1', {
|
||||
worktree: {
|
||||
id: 'repo::/tmp/repo/feature',
|
||||
@@ -197,7 +200,7 @@ describe('orca cli worktree awareness', () => {
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(1, 'worktree.list', { limit: 10_000 })
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'worktree.show', {
|
||||
worktree: `path:${path.resolve('/tmp/repo/feature')}`
|
||||
worktree: 'id:repo::/tmp/repo/feature'
|
||||
})
|
||||
expect(logSpy).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
@@ -245,7 +248,7 @@ describe('orca cli worktree awareness', () => {
|
||||
)
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'worktree.set', {
|
||||
worktree: `path:${path.resolve('/tmp/repo/feature')}`,
|
||||
worktree: 'id:repo::/tmp/repo/feature',
|
||||
displayName: undefined,
|
||||
linkedIssue: undefined,
|
||||
comment: 'hello',
|
||||
@@ -332,7 +335,7 @@ describe('orca cli worktree awareness', () => {
|
||||
displayName: undefined,
|
||||
linkedIssue: undefined,
|
||||
comment: undefined,
|
||||
parentWorktree: `path:${path.resolve('/tmp/repo/parent')}`,
|
||||
parentWorktree: 'id:repo::/tmp/repo/parent',
|
||||
noParent: false
|
||||
})
|
||||
})
|
||||
@@ -437,7 +440,7 @@ describe('orca cli worktree awareness', () => {
|
||||
runHooks: false,
|
||||
activate: true,
|
||||
parentWorktree: undefined,
|
||||
cwdParentWorktree: `path:${path.resolve('/tmp/repo')}`,
|
||||
cwdParentWorktree: 'id:repo-1::/tmp/repo',
|
||||
noParent: false,
|
||||
callerTerminalHandle: undefined
|
||||
})
|
||||
@@ -541,7 +544,7 @@ describe('orca cli worktree awareness', () => {
|
||||
comment: undefined,
|
||||
runHooks: false,
|
||||
activate: false,
|
||||
parentWorktree: `path:${path.resolve('/tmp/repo/parent')}`,
|
||||
parentWorktree: 'id:repo-1::/tmp/repo/parent',
|
||||
noParent: false,
|
||||
callerTerminalHandle: undefined
|
||||
})
|
||||
@@ -666,7 +669,7 @@ describe('orca cli worktree awareness', () => {
|
||||
runHooks: false,
|
||||
activate: false,
|
||||
parentWorktree: undefined,
|
||||
cwdParentWorktree: `path:${path.resolve('/tmp/repo')}`,
|
||||
cwdParentWorktree: 'id:repo-1::/tmp/repo',
|
||||
noParent: false,
|
||||
callerTerminalHandle: 'term_parent'
|
||||
})
|
||||
@@ -882,7 +885,7 @@ describe('orca cli worktree awareness', () => {
|
||||
runHooks: true,
|
||||
activate: true,
|
||||
parentWorktree: undefined,
|
||||
cwdParentWorktree: `path:${path.resolve('/tmp/repo')}`,
|
||||
cwdParentWorktree: 'id:repo-1::/tmp/repo',
|
||||
noParent: false,
|
||||
callerTerminalHandle: undefined
|
||||
})
|
||||
@@ -1273,7 +1276,7 @@ describe('orca cli worktree awareness', () => {
|
||||
await main(['worktree', 'show', '--worktree', 'current', '--json'], '/tmp/repo/feature/src')
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'worktree.show', {
|
||||
worktree: `path:${path.resolve('/tmp/repo/feature')}`
|
||||
worktree: 'id:repo::/tmp/repo/feature'
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1397,7 +1400,7 @@ describe('orca cli worktree awareness', () => {
|
||||
await main(['terminal', 'list', '--worktree', 'active', '--json'], '/tmp/repo/feature/src')
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'terminal.list', {
|
||||
worktree: `path:${path.resolve('/tmp/repo/feature')}`,
|
||||
worktree: 'id:repo::/tmp/repo/feature',
|
||||
limit: undefined
|
||||
})
|
||||
})
|
||||
@@ -1610,7 +1613,7 @@ describe('orca cli worktree awareness', () => {
|
||||
prompt: 'Review open changes',
|
||||
agentId: 'codex',
|
||||
repo: undefined,
|
||||
workspace: `path:${path.resolve('/tmp/repo/feature')}`,
|
||||
workspace: 'id:repo-1::/tmp/repo/feature',
|
||||
workspaceMode: 'existing',
|
||||
baseBranch: undefined,
|
||||
reuseSession: undefined,
|
||||
@@ -1823,7 +1826,7 @@ describe('orca cli worktree awareness', () => {
|
||||
2,
|
||||
'automation.create',
|
||||
expect.objectContaining({
|
||||
workspace: `path:${path.resolve('/tmp/repo/feature')}`,
|
||||
workspace: 'id:repo-1::/tmp/repo/feature',
|
||||
workspaceMode: 'existing',
|
||||
reuseSession: true
|
||||
})
|
||||
@@ -1950,7 +1953,7 @@ describe('orca cli worktree awareness', () => {
|
||||
prompt: 'Review open changes',
|
||||
agentId: 'codex',
|
||||
repo: undefined,
|
||||
workspace: `path:${path.resolve('/tmp/repo/feature')}`,
|
||||
workspace: 'id:repo-1::/tmp/repo/feature',
|
||||
workspaceMode: 'existing',
|
||||
baseBranch: undefined,
|
||||
timezone: undefined,
|
||||
@@ -1982,7 +1985,7 @@ describe('orca cli worktree awareness', () => {
|
||||
prompt: undefined,
|
||||
agentId: undefined,
|
||||
repo: undefined,
|
||||
workspace: `path:${path.resolve('/tmp/repo/feature')}`,
|
||||
workspace: 'id:repo-1::/tmp/repo/feature',
|
||||
workspaceMode: undefined,
|
||||
baseBranch: undefined,
|
||||
reuseSession: undefined,
|
||||
|
||||
@@ -69,10 +69,10 @@ export async function resolveCurrentWorktreeSelector(
|
||||
}
|
||||
|
||||
// Why: users expect "active/current" to mean the enclosing managed worktree
|
||||
// even from nested subdirectories. The CLI resolves that shell-local concept
|
||||
// to the deepest matching worktree root, then hands the runtime a normal
|
||||
// path selector so selector semantics stay centralized in one layer.
|
||||
return buildCurrentWorktreeSelector(enclosingWorktree.path)
|
||||
// even from nested subdirectories. Resolve to the concrete runtime id here:
|
||||
// duplicate repo registrations can expose the same Git worktree path, and a
|
||||
// path selector would throw selector_ambiguous after losing the repo id.
|
||||
return `id:${enclosingWorktree.id}`
|
||||
}
|
||||
|
||||
export async function getOptionalWorktreeSelector(
|
||||
|
||||
Reference in New Issue
Block a user