Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/site/content/docs/agents/hibernation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Orca only hibernates an agent terminal when **all** of the following are true:

A terminal that fails any check stays running. Each agent pane is checked and hibernated on its own, so a finished pane can sleep while a sibling pane or tab in the same worktree keeps running.

Manual sleep is different: it stops the whole worktree at once. Sleep a worktree from the sidebar (including **Sleep with Descendants** when nested children exist). See [Worktrees](/docs/model/worktrees). Manual sleep keeps **finished** and **interrupted** resumable sessions so reopening the worktree can still relaunch with the same resume flags — it does not wipe those session records just because the pane was no longer "live."
Manual sleep is different: it stops the whole worktree at once. Sleep a worktree from the sidebar (use **Sleep → With Descendants** when nested children exist). See [Worktrees](/docs/model/worktrees). Manual sleep keeps **finished** and **interrupted** resumable sessions so reopening the worktree can still relaunch with the same resume flags — it does not wipe those session records just because the pane was no longer "live."

## Tuning the idle window

Expand Down
2 changes: 1 addition & 1 deletion docs/site/content/docs/model/worktrees.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ A **Search** button at the top of the sidebar opens [Worktree Jump Palette](/doc

You can pin a worktree to the top of its project to keep long-running work in view, and right-clicking a worktree exposes archive / sleep / delete actions. To start deletion from the keyboard, hover a worktree or folder workspace and press `Cmd-Shift-Backspace` on macOS or `Ctrl-Shift-Backspace` on Windows / Linux; the normal confirmation dialog still appears. Hold `Cmd` (`Ctrl` on Linux/Windows) while clicking to add worktrees to a multi-selection, or hold `Shift` to select a contiguous range — right-clicking any selected worktree applies the action to every worktree in the selection. Repo rows themselves can be reordered by drag.

When a worktree has nested child worktrees (for example from orchestration or `worktree create` with a parent), the context menu can also offer **Sleep with Descendants (N)** and **Delete with Descendants…**. Sleep with descendants closes active panels on the selected workspace and every validated nested child in the same project, repo, and host — only workspaces with live terminals or browser tabs are targeted for sleep. Delete with descendants makes the existing cascading delete explicit. Stale lineage links, cycles, and children across host or repo boundaries are excluded.
When a worktree has nested child worktrees (for example from orchestration or `worktree create` with a parent), **Sleep** in the context menu becomes a submenu with **This Workspace** and **With Descendants (N)**, and **Delete with Descendants…** makes the deletion scope explicit before listing the descendants in its confirmation dialog. Sleeping with descendants closes active panels on the selected workspace and every validated nested child in the same project, repo, and host — only workspaces with live terminals or browser tabs are targeted for sleep. Deleting a parent makes the existing cascading delete explicit. Stale lineage links, cycles, and children across host or repo boundaries are excluded.

A parent worktree shows its nested children under an **N children** chip; click the chip to show or hide them. To do the same from the keyboard, assign **Toggle Child Workspaces** under [Settings → Shortcuts](/docs/settings). It acts on the worktree under the pointer, or on the active worktree when nothing is hovered, and does exactly what that card's chip does. On a card with no chip of its own (it has no children, or a sidebar filter hides all of them), it uses the chip on the card's parent instead, and does nothing if there is none.

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineFixture } from '../../../../component-fixtures/component-fixture'
import type { Repo } from '../../../../../../shared/repo-types'
import type { Worktree } from '../../../../../../shared/worktree/types'
import type { ProjectGroup } from '../../../../../../shared/project-group-types'
import WorktreeContextMenu from './WorktreeContextMenu'

const repo: Repo = {
Expand Down Expand Up @@ -33,12 +34,41 @@ const worktree: Worktree = {
lastActivityAt: 1
}

function menuFixture(fixtureRepo: Repo, fixtureWorktree: Worktree = worktree) {
const childWorktree: Worktree = {
...worktree,
id: 'orca::/preview/orca/release-notes',
instanceId: 'release-notes-instance',
path: '/preview/orca/release-notes',
displayName: 'Write release notes',
branch: 'release-notes'
}

function menuFixture(
fixtureRepo: Repo,
fixtureWorktree: Worktree = worktree,
extra: { children?: Worktree[]; projectGroups?: ProjectGroup[] } = {}
) {
const children = extra.children ?? []
return defineFixture({
width: 360,
width: extra.projectGroups ? 720 : 360,
store: {
repos: [fixtureRepo],
worktreesByRepo: { [fixtureRepo.id]: [fixtureWorktree] }
projectGroups: extra.projectGroups ?? [],
worktreesByRepo: { [fixtureRepo.id]: [fixtureWorktree, ...children] },
worktreeLineageById: Object.fromEntries(
children.map((child) => [
child.id,
{
worktreeId: child.id,
worktreeInstanceId: child.instanceId ?? '',
parentWorktreeId: fixtureWorktree.id,
parentWorktreeInstanceId: fixtureWorktree.instanceId ?? '',
origin: 'manual' as const,
capture: { source: 'manual-action' as const, confidence: 'explicit' as const },
createdAt: 1
}
])
)
},
render: () => (
<div className="h-[640px] bg-background p-4 text-foreground">
Expand All @@ -47,7 +77,7 @@ function menuFixture(fixtureRepo: Repo, fixtureWorktree: Worktree = worktree) {
</WorktreeContextMenu>
</div>
),
interact: (frame) => {
interact: async (frame) => {
frame.querySelector('[data-worktree-context-menu-scope]')?.dispatchEvent(
new MouseEvent('contextmenu', {
bubbles: true,
Expand All @@ -56,11 +86,38 @@ function menuFixture(fixtureRepo: Repo, fixtureWorktree: Worktree = worktree) {
clientY: 40
})
)
if (extra.projectGroups) {
await new Promise(requestAnimationFrame)
const trigger = Array.from(
frame.ownerDocument.querySelectorAll<HTMLElement>(
'[data-slot="dropdown-menu-sub-trigger"]'
)
).find((item) => item.textContent === 'Project Group')
trigger?.focus()
trigger?.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true }))
}
}
})
}

export const open = menuFixture(repo)
export const withChild = menuFixture(repo, worktree, { children: [childWorktree] })
const projectGroups: ProjectGroup[] = ['Releases', 'Experiments'].map((name, index) => ({
id: name.toLowerCase(),
name,
parentPath: null,
parentGroupId: null,
createdFrom: 'manual',
tabOrder: index,
isCollapsed: false,
color: null,
createdAt: 1,
updatedAt: 1
}))
export const groupedProject = menuFixture({ ...repo, projectGroupId: 'releases' }, worktree, {
projectGroups
})
export const ungroupedProject = menuFixture(repo, worktree, { projectGroups })
export const folderProject = menuFixture({ ...repo, kind: 'folder' })
export const folderWorkspace = menuFixture(repo, { ...worktree, id: 'folder:release' })
export const recipeVm = menuFixture(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { Trash2 } from 'lucide-react'
import { DropdownMenuItem, DropdownMenuShortcut } from '@/components/ui/dropdown-menu'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { useOptionalShortcutLabel } from '@/hooks/useShortcutLabel'
import { useTranslate } from '@/i18n/use-translate'
import type { WorktreeContextMenuModel } from './use-worktree-context-menu-model'

export function WorktreeContextMenuDeleteItems({ model }: { model: WorktreeContextMenuModel }) {
const t = useTranslate()
const deleteShortcut = useOptionalShortcutLabel('workspace.delete')
const {
batchDeleteWorktrees,
contextDeletePending,
deleteLabel,
folderWorkspaceId,
handleDelete,
isMultiContext,
lineageDescendantCount,
removesProject,
worktree
} = model
const projectMissing = !isMultiContext && worktree.isMainWorktree && !removesProject
const label = contextDeletePending
? t('auto.components.sidebar.WorktreeContextMenu.b42391d8bf', 'Deleting…')
: isMultiContext
? deleteLabel
: folderWorkspaceId
? t('auto.components.sidebar.WorktreeContextMenu.250de158fd', 'Remove Workspace')
: removesProject
? t('auto.components.sidebar.WorktreeContextMenu.f5ac91531d', 'Remove Project from Orca')
: lineageDescendantCount > 0
? t(
'auto.components.sidebar.WorktreeContextMenu.deleteWithDescendants',
'Delete with Descendants…'
)
: t('auto.components.sidebar.WorktreeContextMenu.f4475537d8', 'Delete')
return (
<>
{/* Git cannot remove primary checkouts; keep disabled Delete beside the enabled Remove Project action. */}
{!isMultiContext && removesProject ? (
<Tooltip>
<TooltipTrigger asChild>
<div>
<DropdownMenuItem variant="destructive" disabled>
<Trash2 className="size-3.5" />
{t('auto.components.sidebar.WorktreeContextMenu.deleteWorktree', 'Delete Worktree')}
</DropdownMenuItem>
</div>
</TooltipTrigger>
<TooltipContent side="right" sideOffset={8} className="max-w-[200px] text-pretty">
{t(
'auto.components.sidebar.WorktreeContextMenu.primaryDeleteDisabled',
"Primary worktree — can't be deleted. Remove the project instead."
)}
</TooltipContent>
</Tooltip>
) : null}
{/* Use Radix’s direct title prop for project-removal copy; wrapper elements break flat roving-keyboard navigation. */}
<DropdownMenuItem
variant="destructive"
onSelect={handleDelete}
disabled={
contextDeletePending ||
projectMissing ||
(isMultiContext && batchDeleteWorktrees.length === 0)
}
title={
projectMissing
? t(
'auto.components.sidebar.WorktreeContextMenu.e091caab15',
'The project could not be found'
)
: undefined
}
>
<Trash2 className="size-3.5" />
{label}
{!isMultiContext && !removesProject && deleteShortcut ? (
<DropdownMenuShortcut>{deleteShortcut}</DropdownMenuShortcut>
) : null}
</DropdownMenuItem>
</>
)
}
Loading
Loading