Files
orca/src/main/runtime/rpc/methods/worktree-create-args.test.ts
T
Jinjing 2ac23c29be Add parent worktree selection when creating workspace (#15420)
* feat: select parent worktree for nesting when creating workspace

Enable users to pick a parent workspace in the composer's Advanced drawer,
organizing newly created worktrees hierarchically in the sidebar. The backend
validates lineage relationships and gracefully retries without the parent if
it becomes unavailable during creation.

* feat: select parent worktree for nesting when creating workspace

- Record app-picked parents as manual actions, not CLI-flag equivalents,
  ensuring the same user action carries consistent cleanup semantics across hosts
- Gracefully retry without parent if the selection goes stale, warn the
  user instead of failing
- Refactor create into modules: parent resolution, payload building,
  state merge

* Allow selecting parent worktree when creating workspace

- New parent worktree picker filtered by execution host and project
- Preserve concurrent local writes to lineage by comparing per-record state instead of key-set membership

* Allow selecting parent worktree when creating workspace

- Rename "Parent workspace" label to "Parent worktree"
- Filter candidates by execution host and project to prevent nesting across hosts
- Wire parentWorktreeId through composer state and creation request pipeline
- Update translations and add new copy for nesting-related messages
2026-08-27 19:38:01 -07:00

45 lines
1.8 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { buildManagedWorktreeCreateArgs } from './worktree-create-args'
import { WorktreeCreate } from './worktree-create-schemas'
const PROVENANCE = {
automationProvenance: undefined,
cliProvenance: undefined,
creatorProvenance: { kind: 'host' as const }
}
const build = (params: Record<string, unknown>) =>
buildManagedWorktreeCreateArgs(WorktreeCreate.parse(params), PROVENANCE)
describe('buildManagedWorktreeCreateArgs', () => {
it('omits name provenance when the client did not claim a generated name', () => {
// Why: absent must mean user-typed. A truthy default would let the host permanently retire
// names people chose on purpose — the pool contains ordinary words like "orca" and "molly".
expect(build({ repo: 'id:repo-1', name: 'nautilus' })).not.toHaveProperty('nameWasGenerated')
expect(
build({ repo: 'id:repo-1', name: 'nautilus', nameWasGenerated: false })
).not.toHaveProperty('nameWasGenerated')
})
it('forwards the flag when the client fell back to a generated name', () => {
expect(build({ repo: 'id:repo-1', name: 'nautilus', nameWasGenerated: true })).toMatchObject({
nameWasGenerated: true
})
})
it('carries the parent-pick provenance only when the client marked it manual', () => {
// Why: older clients never send it, and those creates really are CLI-flag equivalents.
expect(
build({ repo: 'id:repo-1', name: 'child', parentWorkspace: 'folder:f1' }).lineage
).not.toHaveProperty('parentWorkspaceOrigin')
expect(
build({
repo: 'id:repo-1',
name: 'child',
parentWorkspace: 'folder:f1',
parentWorkspaceOrigin: 'manual'
}).lineage
).toMatchObject({ parentWorkspaceOrigin: 'manual' })
})
})