Convert agents view from full-page navigation to companion overlay panel

Agents is now a non-modal side panel (like the workspace board) that stays open alongside the main workspace, keeping the sidebar and navigation active. The experimental gate is removed and the feature is always available.

- Add Agents button to sidebar toolbar (always visible, shows unread badge)
- Implement AgentsDrawer as a Sheet-based companion panel
- Add spatial canvas view with orchestration DAG layout and node visualization
- Add status filter dropdown and group collapse/expand controls
- Add orchestration lineage nesting (parent/child relationships in list rows)
- Add view mode toggle (list/canvas) and responsive detail panel
- Support both list and canvas rendering paths with shared lineage resolution
- Update terminal portal system to keep agents panel active across all views
- Remove experimentalActivity setting and related sidebar navigation entry
- Map legacy persisted 'activity' activeView to 'terminal' (agents no longer a top-level view)
- Coordinate workspace board and agents panel exclusivity (only one open at a time)
This commit is contained in:
Jinjing
2026-07-19 04:47:06 -07:00
parent 5848550b5e
commit 05f7f0ec2e
33 changed files with 2891 additions and 612 deletions
+5 -13
View File
@@ -47,7 +47,6 @@ import { isRemoteWorkspaceSnapshotApplyInProgress, useIpcEvents } from './hooks/
import { useAutomationDispatchEvents } from './hooks/useAutomationDispatchEvents'
import RetainedAgentsSyncGate from './components/dashboard/RetainedAgentsSyncGate'
import { AgentHibernationGate } from './components/AgentHibernationGate'
import { ActivityTitlebarControls } from './components/activity/ActivityTitlebarControls'
import Sidebar from './components/Sidebar'
import { shutdownBufferCaptures } from './components/terminal-pane/shutdown-buffer-captures'
import { dispatchWindowCloseRequest } from './components/window-close-request-coordinator'
@@ -312,7 +311,6 @@ const WorktreeCreationPanel = lazy(
)
const TaskPage = lazy(() => import('./components/TaskPage'))
const AutomationsPage = lazy(() => import('./components/automations/AutomationsPage'))
const ActivityPrototypePage = lazy(() => import('./components/activity/ActivityPrototypePage'))
const Settings = lazy(() => import('./components/settings/Settings'))
const SkillsPage = lazy(() => import('./components/skills/SkillsPage'))
const WorkspaceSpacePage = lazy(() => import('./components/workspace-space/WorkspaceSpacePage'))
@@ -1532,13 +1530,10 @@ function App(): React.JSX.Element {
const hasTabBar = tabCount >= 2
const showTitlebarExpandButton = workspaceChromeActive && !hasTabBar && effectiveActiveTabExpanded
// Why: Activity and Space are full-page navigation surfaces — same
// treatment as Settings — so the worktree sidebar is removed for those views.
const showSidebar =
activeView !== 'settings' &&
activeView !== 'activity' &&
activeView !== 'space' &&
activeView !== 'skills'
// Why: Space is a full-page navigation surface — same treatment as Settings —
// so the worktree sidebar is removed for those views. Agents is a companion
// overlay and keeps the sidebar (like the workspace board).
const showSidebar = activeView !== 'settings' && activeView !== 'space' && activeView !== 'skills'
// Why: Tasks/Landing keep the full titlebar only when the sidebar is
// collapsed; with it open, mirror workspace view so titlebar-left sits flush
// above nav. Creation layout suppresses the full-width titlebar.
@@ -2173,9 +2168,7 @@ function App(): React.JSX.Element {
const titlebarMainStrip = (
<>
{activeView === 'activity' ? (
<ActivityTitlebarControls />
) : creationLayoutActive ? null : (
{creationLayoutActive ? null : (
<div
id="titlebar-tabs"
className={`flex flex-1 min-w-0 self-stretch${!workspaceChromeActive ? ' invisible pointer-events-none' : ''}`}
@@ -2448,7 +2441,6 @@ function App(): React.JSX.Element {
{activeView === 'skills' ? <SkillsPage /> : null}
{activeView === 'tasks' ? <TaskPage /> : null}
{activeView === 'automations' ? <AutomationsPage /> : null}
{activeView === 'activity' ? <ActivityPrototypePage /> : null}
{activeView === 'space' ? <WorkspaceSpacePage /> : null}
{activeView === 'mobile' ? <MobilePage /> : null}
{activeView === 'terminal' &&
+47
View File
@@ -1689,6 +1689,53 @@
}
}
/* Why: Agents is a companion overlay, not a drawer. The generic left-sheet
slide translates the full width (and from far left once offset to the
sidebar edge), which feels wrong for a quick panel toggle. */
.agents-panel-sheet-content[data-state='open'] {
animation-name: agents-panel-sheet-in;
animation-duration: 80ms;
animation-timing-function: ease-out;
}
.agents-panel-sheet-content[data-state='closed'] {
animation-name: agents-panel-sheet-out;
animation-duration: 60ms;
animation-timing-function: ease-in;
}
.agents-panel-sheet-content {
box-shadow: inset 1px 0 0 color-mix(in srgb, var(--border) 80%, transparent);
backdrop-filter: none;
}
@keyframes agents-panel-sheet-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes agents-panel-sheet-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.agents-panel-sheet-content[data-state='open'],
.agents-panel-sheet-content[data-state='closed'] {
animation: none;
}
}
/* Why: board-origin cards use pointer drag so Shift+scroll can keep firing;
these replace the native drag cursor and ghost affordance. */
[data-workspace-board-pointer-draggable='true'] {
+3 -3
View File
@@ -331,9 +331,9 @@ function Terminal(): React.JSX.Element | null {
// activeTabId here used to flash the wrong terminal — selectThread updates
// the store in multiple steps and intermediate renders briefly pointed the
// portal at the new worktree's stale last-active tab.
const activityTerminalPortals: ActivityTerminalPortalTarget[] = useActivityTerminalPortals(
activeView === 'activity'
)
// Why: Agents is a companion overlay, so portals are active whenever the
// panel publishes targets — not only when activeView was 'activity'.
const activityTerminalPortals: ActivityTerminalPortalTarget[] = useActivityTerminalPortals(true)
const foregroundTerminalTabIds = useMemo(() => {
const ids = new Set<string>()
if (activeView === 'terminal' && activeTabType === 'terminal' && activeTabId) {
@@ -0,0 +1,384 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { Expand, LocateFixed, Minus, Network, Plus } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { cn } from '@/lib/utils'
import { translate } from '@/i18n/i18n'
import { ACTIVITY_CANVAS_STATUS_SURFACE, ActivityCanvasNodeCard } from './ActivityCanvasNodeCard'
import { buildDemoCanvasThreads } from './activity-canvas-demo-threads'
import {
type ActivityCanvasAgentState,
type ActivityCanvasLayout,
type ActivityCanvasThreadInput,
layoutActivityCanvas
} from './activity-canvas-layout'
export type { ActivityViewMode } from './ActivityCanvasNodeCard'
export { ActivityViewModeToggle } from './ActivityCanvasNodeCard'
const MIN_ZOOM = 0.35
const MAX_ZOOM = 1.75
const ZOOM_STEP = 0.12
function clamp(n: number, min: number, max: number): number {
return Math.min(max, Math.max(min, n))
}
export function ActivityAgentsCanvas({
threads,
selectedPaneKey,
onSelectPaneKey,
className
}: {
threads: ActivityCanvasThreadInput[]
selectedPaneKey: string | null
onSelectPaneKey: (paneKey: string | null) => void
className?: string
}): React.JSX.Element {
const viewportRef = useRef<HTMLDivElement | null>(null)
const [zoom, setZoom] = useState(0.9)
const [pan, setPan] = useState({ x: 24, y: 24 })
// Demo nodes are not real panes; keep selection local so the sample graph
// still shows a selected ring without mutating Activity thread state.
const [demoSelectedPaneKey, setDemoSelectedPaneKey] = useState<string | null>(null)
const dragRef = useRef<{
pointerId: number
startX: number
startY: number
originX: number
originY: number
moved: boolean
} | null>(null)
const usingDemo = threads.length === 0
const layoutThreads = useMemo(
() => (usingDemo ? buildDemoCanvasThreads() : threads),
[threads, usingDemo]
)
const layout: ActivityCanvasLayout = useMemo(
() => layoutActivityCanvas(layoutThreads),
[layoutThreads]
)
const effectiveSelectedPaneKey = usingDemo ? demoSelectedPaneKey : selectedPaneKey
const fitView = useCallback(() => {
const el = viewportRef.current
if (!el) {
return
}
const pad = 48
const vw = el.clientWidth
const vh = el.clientHeight
if (vw <= 0 || vh <= 0) {
return
}
const scale = clamp(
Math.min((vw - pad * 2) / layout.width, (vh - pad * 2) / layout.height),
MIN_ZOOM,
1
)
setZoom(scale)
setPan({
x: (vw - layout.width * scale) / 2,
y: Math.max(16, (vh - layout.height * scale) / 2)
})
}, [layout.height, layout.width])
useEffect(() => {
fitView()
}, [fitView, layout.nodes.length])
const onWheel = (event: React.WheelEvent<HTMLDivElement>): void => {
if (event.ctrlKey || event.metaKey) {
event.preventDefault()
const delta = event.deltaY > 0 ? -ZOOM_STEP : ZOOM_STEP
setZoom((z) => clamp(z + delta, MIN_ZOOM, MAX_ZOOM))
return
}
setPan((p) => ({ x: p.x - event.deltaX, y: p.y - event.deltaY }))
}
const onPointerDown = (event: React.PointerEvent<HTMLDivElement>): void => {
if (event.button !== 0) {
return
}
// Only start pan from the empty field, not from a node.
if ((event.target as HTMLElement).closest('[data-testid="activity-canvas-node"]')) {
return
}
dragRef.current = {
pointerId: event.pointerId,
startX: event.clientX,
startY: event.clientY,
originX: pan.x,
originY: pan.y,
moved: false
}
event.currentTarget.setPointerCapture(event.pointerId)
}
const onPointerMove = (event: React.PointerEvent<HTMLDivElement>): void => {
const drag = dragRef.current
if (!drag || drag.pointerId !== event.pointerId) {
return
}
const dx = event.clientX - drag.startX
const dy = event.clientY - drag.startY
if (Math.abs(dx) + Math.abs(dy) > 3) {
drag.moved = true
}
setPan({ x: drag.originX + dx, y: drag.originY + dy })
}
const onPointerUp = (event: React.PointerEvent<HTMLDivElement>): void => {
const drag = dragRef.current
if (!drag || drag.pointerId !== event.pointerId) {
return
}
dragRef.current = null
if (!drag.moved) {
if (usingDemo) {
setDemoSelectedPaneKey(null)
} else {
onSelectPaneKey(null)
}
}
}
const statusLegend = useMemo(() => {
const counts = new Map<ActivityCanvasAgentState, number>()
for (const node of layout.nodes) {
counts.set(node.thread.agentState, (counts.get(node.thread.agentState) ?? 0) + 1)
}
return (Object.keys(ACTIVITY_CANVAS_STATUS_SURFACE) as ActivityCanvasAgentState[])
.filter((state) => (counts.get(state) ?? 0) > 0)
.map((state) => ({
state,
count: counts.get(state) ?? 0,
...ACTIVITY_CANVAS_STATUS_SURFACE[state]
}))
}, [layout.nodes])
return (
<div
className={cn('relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden', className)}
data-testid="activity-agents-canvas"
>
<div
ref={viewportRef}
className={cn(
'relative min-h-0 flex-1 cursor-grab overflow-hidden bg-background active:cursor-grabbing',
// Dot field — orca-viz canvas texture without inventing new tokens.
'[background-image:radial-gradient(circle,color-mix(in_srgb,var(--border)_80%,transparent)_1px,transparent_1px)]',
'[background-size:18px_18px]'
)}
onWheel={onWheel}
onPointerDown={onPointerDown}
onPointerMove={onPointerMove}
onPointerUp={onPointerUp}
onPointerCancel={onPointerUp}
>
<div
className="absolute origin-top-left will-change-transform"
style={{
width: layout.width,
height: layout.height,
transform: `translate(${pan.x}px, ${pan.y}px) scale(${zoom})`
}}
>
{layout.clusters.map((cluster) => (
<div
key={cluster.id}
className="pointer-events-none absolute rounded-2xl border border-dashed border-border/80 bg-muted/20"
style={{
left: cluster.x,
top: cluster.y,
width: cluster.width,
height: cluster.height
}}
>
<div className="absolute -top-2.5 left-3 rounded-full border border-border bg-background/90 px-2 py-0.5 text-[10px] font-semibold tracking-wide text-muted-foreground uppercase backdrop-blur">
{cluster.label}
</div>
</div>
))}
<svg
className="pointer-events-none absolute inset-0 overflow-visible"
width={layout.width}
height={layout.height}
aria-hidden
>
<defs>
<marker
id="activity-canvas-arrow"
viewBox="0 0 10 10"
refX="8"
refY="5"
markerWidth="6"
markerHeight="6"
orient="auto-start-reverse"
>
<path d="M 0 0 L 10 5 L 0 10 z" className="fill-muted-foreground/70" />
</marker>
</defs>
{layout.edges.map((edge) => (
<path
key={edge.id}
d={edge.path}
fill="none"
className="stroke-muted-foreground/55"
strokeWidth={1.5}
markerEnd="url(#activity-canvas-arrow)"
/>
))}
</svg>
{layout.nodes.map((node) => (
<ActivityCanvasNodeCard
key={node.id}
node={node}
selected={effectiveSelectedPaneKey === node.thread.paneKey}
onSelect={() => {
if (usingDemo) {
setDemoSelectedPaneKey(node.thread.paneKey)
return
}
onSelectPaneKey(node.thread.paneKey)
}}
/>
))}
</div>
<div className="pointer-events-none absolute inset-x-0 top-0 flex items-start justify-between gap-2 p-3">
<div className="pointer-events-auto max-w-[min(420px,70%)] rounded-xl border border-border bg-background/90 px-3 py-2 text-xs shadow-sm backdrop-blur">
<div className="flex items-center gap-1.5 font-semibold text-foreground">
<Network className="size-3.5 text-muted-foreground" />
{usingDemo
? translate(
'auto.components.activity.ActivityAgentsCanvas.demoTitle',
'Canvas preview (sample data)'
)
: translate(
'auto.components.activity.ActivityAgentsCanvas.liveTitle',
'Agents canvas'
)}
</div>
<div className="mt-0.5 text-muted-foreground">
{usingDemo
? translate(
'auto.components.activity.ActivityAgentsCanvas.demoHint',
'No live agents match filters — showing a sample orchestration graph. Start agents to replace this with real data.'
)
: translate(
'auto.components.activity.ActivityAgentsCanvas.liveHint',
'{{linked}} linked · {{isolated}} isolated · fill = status · stripe = agent',
{
linked: layout.linkedCount,
isolated: layout.isolatedCount
}
)}
</div>
{statusLegend.length > 0 ? (
<div className="mt-2 flex flex-wrap gap-2">
{statusLegend.map((item) => (
<span key={item.state} className="inline-flex items-center gap-1.5 text-[10px]">
<span
className="size-2 rounded-sm"
style={{ background: item.accent }}
aria-hidden
/>
<span className="text-muted-foreground">
{item.label.toLowerCase()} ({item.count})
</span>
</span>
))}
</div>
) : null}
</div>
<div className="pointer-events-auto flex items-center gap-1 rounded-full border border-border bg-background/90 p-1 shadow-sm backdrop-blur">
<Tooltip>
<TooltipTrigger asChild>
<Button
type="button"
variant="ghost"
size="icon-xs"
aria-label="Zoom out"
onClick={() => setZoom((z) => clamp(z - ZOOM_STEP, MIN_ZOOM, MAX_ZOOM))}
>
<Minus className="size-3.5" />
</Button>
</TooltipTrigger>
<TooltipContent>Zoom out</TooltipContent>
</Tooltip>
<span className="min-w-[3rem] text-center text-[10px] tabular-nums text-muted-foreground">
{Math.round(zoom * 100)}%
</span>
<Tooltip>
<TooltipTrigger asChild>
<Button
type="button"
variant="ghost"
size="icon-xs"
aria-label="Zoom in"
onClick={() => setZoom((z) => clamp(z + ZOOM_STEP, MIN_ZOOM, MAX_ZOOM))}
>
<Plus className="size-3.5" />
</Button>
</TooltipTrigger>
<TooltipContent>Zoom in</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Button
type="button"
variant="ghost"
size="icon-xs"
aria-label="Fit view"
onClick={fitView}
>
<Expand className="size-3.5" />
</Button>
</TooltipTrigger>
<TooltipContent>Fit view</TooltipContent>
</Tooltip>
{effectiveSelectedPaneKey ? (
<Tooltip>
<TooltipTrigger asChild>
<Button
type="button"
variant="ghost"
size="icon-xs"
aria-label="Clear selection"
onClick={() => {
if (usingDemo) {
setDemoSelectedPaneKey(null)
} else {
onSelectPaneKey(null)
}
}}
>
<LocateFixed className="size-3.5" />
</Button>
</TooltipTrigger>
<TooltipContent>Clear selection</TooltipContent>
</Tooltip>
) : null}
</div>
</div>
{layout.nodes.length === 0 ? (
<div className="pointer-events-none absolute inset-0 flex items-center justify-center text-sm text-muted-foreground">
{translate(
'auto.components.activity.ActivityAgentsCanvas.empty',
'No agent activity to place on the canvas.'
)}
</div>
) : null}
</div>
</div>
)
}
@@ -0,0 +1,184 @@
import React from 'react'
import { List, Network } from 'lucide-react'
import { AgentIcon } from '@/lib/agent-catalog'
import { agentTypeToIconAgent, formatAgentTypeLabel } from '@/lib/agent-status'
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'
import { cn } from '@/lib/utils'
import { translate } from '@/i18n/i18n'
import type { ActivityCanvasAgentState, ActivityCanvasNode } from './activity-canvas-types'
export type ActivityViewMode = 'list' | 'canvas'
export const ACTIVITY_CANVAS_STATUS_SURFACE: Record<
ActivityCanvasAgentState,
{ surface: string; accent: string; label: string }
> = {
working: {
surface:
'bg-amber-500/12 text-amber-950 border-amber-500/35 dark:bg-amber-400/12 dark:text-amber-50 dark:border-amber-400/30',
accent: 'rgb(245 158 11)',
label: 'WORKING'
},
blocked: {
surface:
'bg-red-500/12 text-red-950 border-red-500/35 dark:bg-red-400/12 dark:text-red-50 dark:border-red-400/30',
accent: 'rgb(239 68 68)',
label: 'BLOCKED'
},
waiting: {
surface:
'bg-orange-500/12 text-orange-950 border-orange-500/35 dark:bg-orange-400/12 dark:text-orange-50 dark:border-orange-400/30',
accent: 'rgb(249 115 22)',
label: 'WAITING'
},
done: {
surface:
'bg-emerald-500/12 text-emerald-950 border-emerald-500/35 dark:bg-emerald-400/12 dark:text-emerald-50 dark:border-emerald-400/30',
accent: 'rgb(16 185 129)',
label: 'DONE'
},
interrupted: {
surface:
'bg-neutral-500/12 text-neutral-900 border-neutral-500/30 dark:bg-neutral-400/10 dark:text-neutral-50 dark:border-neutral-400/25',
accent: 'rgb(115 115 115)',
label: 'INTERRUPTED'
}
}
export function ActivityViewModeToggle({
value,
onChange,
className
}: {
value: ActivityViewMode
onChange: (mode: ActivityViewMode) => void
className?: string
}): React.JSX.Element {
return (
<ToggleGroup
type="single"
value={value}
onValueChange={(next) => {
if (next === 'list' || next === 'canvas') {
onChange(next)
}
}}
variant="outline"
size="sm"
spacing={0}
className={cn('shrink-0', className)}
aria-label={translate(
'auto.components.activity.ActivityAgentsCanvas.viewMode',
'Agents view mode'
)}
>
<ToggleGroupItem value="list" className="h-8 gap-1.5 px-2.5 text-xs" aria-label="List view">
<List className="size-3.5" />
<span className="hidden sm:inline">List</span>
</ToggleGroupItem>
<ToggleGroupItem
value="canvas"
className="h-8 gap-1.5 px-2.5 text-xs"
aria-label="Canvas view"
>
<Network className="size-3.5" />
<span className="hidden sm:inline">Canvas</span>
</ToggleGroupItem>
</ToggleGroup>
)
}
export function ActivityCanvasNodeCard({
node,
selected,
onSelect
}: {
node: ActivityCanvasNode
selected: boolean
onSelect: () => void
}): React.JSX.Element {
const theme = ACTIVITY_CANVAS_STATUS_SURFACE[node.thread.agentState]
const title =
node.thread.paneTitle.trim().length > 0 ? node.thread.paneTitle : node.thread.workspaceTitle
const subtitle =
title !== node.thread.workspaceTitle ? node.thread.workspaceTitle : node.thread.projectLabel
return (
<button
type="button"
data-testid="activity-canvas-node"
data-pane-key={node.id}
data-selected={selected ? 'true' : undefined}
data-isolated={node.isolated ? 'true' : undefined}
onClick={(event) => {
event.stopPropagation()
onSelect()
}}
className={cn(
'group absolute flex cursor-pointer flex-col gap-1 rounded-xl border py-2 pr-2.5 pl-4 text-left shadow-sm transition-[transform,box-shadow] hover:-translate-y-0.5 hover:shadow-md',
theme.surface,
selected && 'outline-2 outline-offset-2 outline-ring shadow-md'
)}
style={{
left: node.x,
top: node.y,
width: node.width,
height: node.height
}}
>
{/* Agent stripe — identity channel; status owns the fill (orca-viz rule). */}
<span
aria-hidden
className="absolute top-2 bottom-2 left-1.5 w-[4px] rounded-full"
style={{
background: node.agent.colour,
boxShadow: `0 0 10px 0 color-mix(in srgb, ${node.agent.colour} 55%, transparent)`
}}
/>
<span
aria-hidden
className="pointer-events-none absolute inset-0 rounded-xl"
style={{
background: `linear-gradient(to right, color-mix(in srgb, ${theme.accent} 18%, transparent), transparent 62%)`
}}
/>
<div className="relative flex min-w-0 items-center gap-1.5">
<span
className="inline-flex size-5 shrink-0 items-center justify-center rounded-md text-[9px] font-bold tracking-wide text-white"
style={{ background: node.agent.colour }}
title={node.agent.monogram}
>
{node.agent.monogram}
</span>
<b className="text-[9px] font-bold tracking-[0.09em] uppercase opacity-80">{theme.label}</b>
<span className="ml-auto inline-flex shrink-0 items-center gap-1">
{node.thread.unread ? (
<span className="size-1.5 rounded-full bg-primary" title="Unread" />
) : null}
{node.thread.agentState === 'working' ? (
<span
aria-hidden
className="size-2 rounded-full border-2 border-t-transparent [animation:spin_1s_steps(12,end)_infinite] motion-reduce:animate-none"
style={{ borderColor: theme.accent, borderTopColor: 'transparent' }}
/>
) : null}
</span>
</div>
<div className="relative line-clamp-2 text-[11.5px] leading-tight font-medium">{title}</div>
<div className="relative mt-auto flex min-w-0 items-center gap-1.5">
<span className="inline-flex shrink-0">
<AgentIcon agent={agentTypeToIconAgent(node.thread.agentType)} size={12} />
</span>
<span className="truncate text-[10px] opacity-70">
{formatAgentTypeLabel(node.thread.agentType)}
{subtitle ? ` · ${subtitle}` : ''}
</span>
</div>
</button>
)
}
@@ -11,8 +11,12 @@ import { formatAgentTypeLabel } from '@/lib/agent-status'
import type { RetainedAgentEntry } from '@/store/slices/agent-status'
import {
ACTIVITY_SEARCH_QUERY_MAX_BYTES,
ACTIVITY_STATUS_GROUP_ORDER,
activityThreadResponseRenderPreview,
activityThreadMatchesSearchQuery,
activityThreadMatchesStatusFilter,
createDefaultActivityStatusFilter,
createDefaultCollapsedActivityGroups,
handleActivityFilterFocusShortcut,
isActivityFilterFocusShortcut,
shouldIgnoreActivityFilterFocusShortcutTarget,
@@ -21,7 +25,9 @@ import {
buildAgentPaneThreads,
getActivityThreadGroup,
groupActivityThreadsByStatus,
isActivitySearchQueryTooLarge
isActivitySearchQueryTooLarge,
toggleActivityGroupCollapsed,
toggleActivityStatusFilter
} from './ActivityPrototypePage'
import { makePaneKey } from '../../../../shared/stable-pane-id'
@@ -912,3 +918,73 @@ describe('activity filter focus shortcut', () => {
).toBe(false)
})
})
describe('activity status filter and collapse helpers', () => {
it('defaults to every status enabled and collapses done/interrupted groups', () => {
expect([...createDefaultActivityStatusFilter()]).toEqual([...ACTIVITY_STATUS_GROUP_ORDER])
expect([...createDefaultCollapsedActivityGroups()].sort()).toEqual(['done', 'interrupted'])
})
it('filters threads by enabled agent status groups', () => {
const workingEntry: AgentStatusEntry = {
state: 'working',
updatedAt: 2_000,
stateStartedAt: 2_000,
paneKey: PANE_KEY,
terminalTitle: 'Claude',
stateHistory: [],
agentType: 'claude',
prompt: 'ship it'
}
const doneEntry: AgentStatusEntry = {
state: 'done',
updatedAt: 1_000,
stateStartedAt: 1_000,
paneKey: PANE_KEY_2,
terminalTitle: 'Codex',
stateHistory: [],
agentType: 'codex',
prompt: 'done work'
}
const { events, liveAgentByPaneKey } = buildActivityEvents({
agentStatusByPaneKey: {
[PANE_KEY]: workingEntry,
[PANE_KEY_2]: doneEntry
},
retainedAgentsByPaneKey: {},
tabsByWorktree: { 'wt-1': [makeTab(), { ...makeTab(), id: 'tab-2', ptyId: 'pty-2' }] },
worktreeMap: new Map([['wt-1', makeWorktree()]]),
repoMap: new Map([['repo-1', makeRepo()]]),
acknowledgedAgentsByPaneKey: {},
now: 3_000
})
const threads = buildAgentPaneThreads({ events, liveAgentByPaneKey })
const workingOnly = new Set(['working'] as const)
expect(
threads
.filter((thread) => activityThreadMatchesStatusFilter(thread, workingOnly))
.map((t) => t.paneKey)
).toEqual([PANE_KEY])
expect(
threads.filter((thread) =>
activityThreadMatchesStatusFilter(thread, createDefaultActivityStatusFilter())
)
).toHaveLength(threads.length)
})
it('toggles status filter membership and collapsed group keys', () => {
const withoutDone = toggleActivityStatusFilter(
createDefaultActivityStatusFilter(),
'done',
false
)
expect(withoutDone.has('done')).toBe(false)
expect(toggleActivityStatusFilter(withoutDone, 'done', true).has('done')).toBe(true)
const collapsed = createDefaultCollapsedActivityGroups()
const expandedDone = toggleActivityGroupCollapsed(collapsed, 'done')
expect(expandedDone.has('done')).toBe(false)
expect(toggleActivityGroupCollapsed(expandedDone, 'done').has('done')).toBe(true)
})
})
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,4 @@
import { ArrowLeft, Bell } from 'lucide-react'
import { ArrowLeft, Bot } from 'lucide-react'
import { useAppStore } from '@/store'
import { Badge } from '@/components/ui/badge'
@@ -42,7 +42,7 @@ export function ActivityTitlebarControls(): React.JSX.Element {
)}
</TooltipContent>
</Tooltip>
<Bell className="size-3.5 shrink-0 text-muted-foreground" />
<Bot className="size-3.5 shrink-0 text-muted-foreground" />
<span className="truncate text-xs font-medium">
{translate('auto.components.activity.ActivityTitlebarControls.d6a8de3934', 'agents')}
</span>
@@ -0,0 +1,194 @@
import React, { useEffect, useRef } from 'react'
import { X } from 'lucide-react'
import { useAppStore } from '@/store'
import { Button } from '@/components/ui/button'
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle
} from '@/components/ui/sheet'
import { useActivityUnreadCount } from './useActivityUnreadCount'
import ActivityPrototypePage from './ActivityPrototypePage'
import { translate } from '@/i18n/i18n'
type AgentsDrawerProps = {
leftSidebarStyle?: React.CSSProperties
open: boolean
statusBarVisible: boolean
onOpenChange: (open: boolean) => void
}
const WORKSPACE_TOP_CHROME_HEIGHT = 36
const STATUS_BAR_RESERVE_HEIGHT = 24
const AGENTS_PANEL_KEEP_OPEN_SELECTOR = [
'[data-agents-panel-trigger]',
'[data-radix-popper-content-wrapper]',
'[data-slot="dropdown-menu-content"]',
'[data-slot="context-menu-content"]',
'[data-slot="popover-content"]',
'[data-slot="dialog-content"]',
'[data-slot="dialog-overlay"]',
'[data-sonner-toast]',
'[role="dialog"][data-state="open"]',
'[role="alertdialog"][data-state="open"]',
'[role="menu"][data-state="open"]'
].join(', ')
function isAgentsPanelKeepOpenTarget(target: EventTarget | null): boolean {
const element =
target instanceof Element ? target : target instanceof Node ? target.parentElement : null
return Boolean(element?.closest(AGENTS_PANEL_KEEP_OPEN_SELECTOR))
}
export default function AgentsDrawer({
leftSidebarStyle,
open,
statusBarVisible,
onOpenChange
}: AgentsDrawerProps): React.JSX.Element {
const sidebarOpen = useAppStore((s) => s.sidebarOpen)
const sidebarWidth = useAppStore((s) => s.sidebarWidth)
const unreadCount = useActivityUnreadCount(open, 'agent-events')
const contentRef = useRef<HTMLDivElement | null>(null)
const drawerLeftCss = sidebarOpen
? `var(--workspace-sidebar-live-width, ${sidebarWidth}px)`
: '0px'
const drawerBottom = `${statusBarVisible ? STATUS_BAR_RESERVE_HEIGHT : 0}px`
useEffect(() => {
if (!open) {
return
}
const handlePointerDown = (event: PointerEvent): void => {
const content = contentRef.current?.closest<HTMLElement>('[data-slot="sheet-content"]')
if (!content) {
return
}
if (event.target instanceof Node && content.contains(event.target)) {
return
}
if (isAgentsPanelKeepOpenTarget(event.target)) {
return
}
const rect = content.getBoundingClientRect()
if (event.clientX > rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom) {
onOpenChange(false)
}
}
document.addEventListener('pointerdown', handlePointerDown, true)
return () => document.removeEventListener('pointerdown', handlePointerDown, true)
}, [onOpenChange, open])
return (
<Sheet open={open} onOpenChange={onOpenChange} modal={false}>
<SheetContent
side="left"
showCloseButton={false}
className="agents-panel-sheet-content bg-background p-0 sm:max-w-none"
// Why: keep the non-interactive scrim snappy; content uses a near-instant
// fade via .agents-panel-sheet-content instead of the left-sheet slide.
overlayClassName="duration-75 data-[state=open]:duration-75 data-[state=closed]:duration-75"
overlayStyle={{
top: WORKSPACE_TOP_CHROME_HEIGHT,
bottom: drawerBottom,
left: drawerLeftCss,
pointerEvents: 'none'
}}
style={
{
...leftSidebarStyle,
// Why: companion panel expands from the sidebar edge (same as the
// workspace board) instead of replacing the main navigation surface.
left: drawerLeftCss,
top: WORKSPACE_TOP_CHROME_HEIGHT,
bottom: drawerBottom,
height: 'auto',
width: `min(calc(100vw - ${drawerLeftCss}), 1294px)`
} as React.CSSProperties
}
data-agents-panel-sheet=""
onOpenAutoFocus={(event) => {
// Why: avoid auto-focusing the first control (and its tooltip) on open.
event.preventDefault()
}}
onPointerDownOutside={(event) => {
const originalEvent = event.detail.originalEvent
const target = originalEvent.target
if (isAgentsPanelKeepOpenTarget(target)) {
event.preventDefault()
return
}
const liveDrawerLeft =
contentRef.current
?.closest<HTMLElement>('[data-slot="sheet-content"]')
?.getBoundingClientRect().left ?? (sidebarOpen ? sidebarWidth : 0)
const pointerX =
'clientX' in originalEvent && typeof originalEvent.clientX === 'number'
? originalEvent.clientX
: null
if (pointerX !== null && pointerX < liveDrawerLeft) {
// Why: keep the workspace sidebar interactive while the panel stays open.
event.preventDefault()
}
}}
onInteractOutside={(event) => {
const originalEvent = event.detail.originalEvent
const target = originalEvent.target
if (isAgentsPanelKeepOpenTarget(target)) {
event.preventDefault()
return
}
const liveDrawerLeft =
contentRef.current
?.closest<HTMLElement>('[data-slot="sheet-content"]')
?.getBoundingClientRect().left ?? (sidebarOpen ? sidebarWidth : 0)
const pointerX =
'clientX' in originalEvent && typeof originalEvent.clientX === 'number'
? originalEvent.clientX
: null
if (pointerX !== null && pointerX < liveDrawerLeft) {
event.preventDefault()
}
}}
>
<SheetHeader className="border-b border-border px-4 py-3 pr-14">
<SheetTitle className="flex items-center gap-2 text-sm">
<span>{translate('auto.components.activity.AgentsDrawer.title', 'Agents')}</span>
{unreadCount > 0 ? (
<span className="rounded-full bg-accent px-2 py-0.5 text-[10px] font-medium text-muted-foreground">
{unreadCount} {translate('auto.components.activity.AgentsDrawer.unread', 'unread')}
</span>
) : null}
</SheetTitle>
<SheetDescription className="sr-only">
{translate(
'auto.components.activity.AgentsDrawer.description',
'Browse agent sessions by status and open their terminals.'
)}
</SheetDescription>
</SheetHeader>
<div className="absolute right-3 top-2.5 flex items-center gap-1">
<Button
variant="ghost"
size="icon-xs"
aria-label={translate('auto.components.activity.AgentsDrawer.close', 'Close')}
onClick={() => onOpenChange(false)}
>
<X className="size-3.5" />
</Button>
</div>
<div ref={contentRef} className="flex min-h-0 flex-1 flex-col overflow-hidden">
{open ? <ActivityPrototypePage /> : null}
</div>
</SheetContent>
</Sheet>
)
}
@@ -0,0 +1,100 @@
import type { ActivityCanvasThreadInput } from './activity-canvas-types'
/** Sample graph used when the live agent feed is empty so the canvas is reviewable. */
export function buildDemoCanvasThreads(): ActivityCanvasThreadInput[] {
const now = Date.now()
return [
{
paneKey: 'demo:orchestrator',
paneTitle: 'Coordinate agents view prototype',
workspaceTitle: 'prototype-new-agents-view',
projectLabel: 'orca',
agentType: 'claude',
agentState: 'working',
agentStateLabel: 'Working',
responsePreview: 'Dispatching canvas layout + list toggle…',
latestTimestamp: now - 30_000,
unread: false,
parentPaneKey: null,
monogram: 'OR'
},
{
paneKey: 'demo:a1',
paneTitle: 'Scaffold list/canvas view toggle',
workspaceTitle: 'prototype-new-agents-view',
projectLabel: 'orca',
agentType: 'claude',
agentState: 'done',
agentStateLabel: 'Done',
responsePreview: 'ToggleGroup wired into the filter bar.',
latestTimestamp: now - 120_000,
unread: false,
parentPaneKey: 'demo:orchestrator'
},
{
paneKey: 'demo:a2',
paneTitle: 'Build agents canvas layout',
workspaceTitle: 'prototype-new-agents-view',
projectLabel: 'orca',
agentType: 'codex',
agentState: 'working',
agentStateLabel: 'Working',
responsePreview: 'Placing forest + isolated grid…',
latestTimestamp: now - 20_000,
unread: true,
parentPaneKey: 'demo:orchestrator'
},
{
paneKey: 'demo:a3',
paneTitle: 'Style nodes like orca-viz',
workspaceTitle: 'prototype-new-agents-view',
projectLabel: 'orca',
agentType: 'claude',
agentState: 'waiting',
agentStateLabel: 'Waiting for input',
responsePreview: 'Need review on stripe colours.',
latestTimestamp: now - 45_000,
unread: true,
parentPaneKey: 'demo:orchestrator'
},
{
paneKey: 'demo:a4',
paneTitle: 'Wire selection → terminal detail',
workspaceTitle: 'prototype-new-agents-view',
projectLabel: 'orca',
agentType: 'gemini',
agentState: 'blocked',
agentStateLabel: 'Blocked',
responsePreview: 'Blocked on portal target mount.',
latestTimestamp: now - 90_000,
unread: false,
parentPaneKey: 'demo:a2'
},
{
paneKey: 'demo:solo-1',
paneTitle: 'Explore login race fix',
workspaceTitle: 'mobile-auth',
projectLabel: 'app',
agentType: 'cursor',
agentState: 'done',
agentStateLabel: 'Done',
responsePreview: 'PR opened.',
latestTimestamp: now - 3_600_000,
unread: false,
parentPaneKey: null
},
{
paneKey: 'demo:solo-2',
paneTitle: 'Docs pass for agents view',
workspaceTitle: 'prototype-new-agents-view',
projectLabel: 'orca',
agentType: 'claude',
agentState: 'interrupted',
agentStateLabel: 'Interrupted',
responsePreview: 'Stopped mid-draft.',
latestTimestamp: now - 7_200_000,
unread: false,
parentPaneKey: null
}
]
}
@@ -0,0 +1,88 @@
import { describe, expect, it } from 'vitest'
import {
assignAgentLooks,
layoutActivityCanvas,
type ActivityCanvasThreadInput
} from './activity-canvas-layout'
import { buildDemoCanvasThreads } from './activity-canvas-demo-threads'
function thread(
partial: Partial<ActivityCanvasThreadInput> & Pick<ActivityCanvasThreadInput, 'paneKey'>
): ActivityCanvasThreadInput {
return {
paneTitle: partial.paneTitle ?? partial.paneKey,
workspaceTitle: partial.workspaceTitle ?? 'ws',
projectLabel: partial.projectLabel ?? 'proj',
agentType: partial.agentType ?? 'claude',
agentState: partial.agentState ?? 'working',
agentStateLabel: partial.agentStateLabel ?? 'Working',
responsePreview: partial.responsePreview ?? '',
latestTimestamp: partial.latestTimestamp ?? 1,
unread: partial.unread ?? false,
parentPaneKey: partial.parentPaneKey ?? null,
...partial
}
}
describe('layoutActivityCanvas', () => {
it('packs agents with no edges into an isolated cluster', () => {
const layout = layoutActivityCanvas([
thread({ paneKey: 'a', latestTimestamp: 3 }),
thread({ paneKey: 'b', latestTimestamp: 2 }),
thread({ paneKey: 'c', latestTimestamp: 1 })
])
expect(layout.linkedCount).toBe(0)
expect(layout.isolatedCount).toBe(3)
expect(layout.edges).toHaveLength(0)
expect(layout.clusters).toHaveLength(1)
expect(layout.nodes.every((n) => n.isolated)).toBe(true)
})
it('places parent above children and draws parent→child edges', () => {
const layout = layoutActivityCanvas([
thread({ paneKey: 'root', parentPaneKey: null }),
thread({ paneKey: 'child-1', parentPaneKey: 'root' }),
thread({ paneKey: 'child-2', parentPaneKey: 'root' })
])
expect(layout.linkedCount).toBe(3)
expect(layout.isolatedCount).toBe(0)
expect(layout.edges).toHaveLength(2)
const root = layout.nodes.find((n) => n.id === 'root')!
const child1 = layout.nodes.find((n) => n.id === 'child-1')!
const child2 = layout.nodes.find((n) => n.id === 'child-2')!
expect(root.y).toBeLessThan(child1.y)
expect(root.y).toBeLessThan(child2.y)
expect(root.isolated).toBe(false)
})
it('ignores parentPaneKey when the parent is not in the thread set', () => {
const layout = layoutActivityCanvas([
thread({ paneKey: 'orphan', parentPaneKey: 'missing-parent' })
])
expect(layout.isolatedCount).toBe(1)
expect(layout.edges).toHaveLength(0)
})
it('assigns stable monograms with roots before children', () => {
const looks = assignAgentLooks([
thread({ paneKey: 'child', parentPaneKey: 'root' }),
thread({ paneKey: 'root', parentPaneKey: null }),
thread({ paneKey: 'solo', parentPaneKey: null })
])
expect(looks.get('root')?.monogram).toMatch(/^A\d+$/)
expect(looks.get('solo')?.monogram).toMatch(/^A\d+$/)
expect(looks.get('child')?.monogram).toMatch(/^A\d+$/)
// Roots sort before children; root + solo come first alphabetically as roots.
expect(looks.get('root')!.index).toBeLessThan(looks.get('child')!.index)
})
it('lays out the demo sample without empty geometry', () => {
const layout = layoutActivityCanvas(buildDemoCanvasThreads())
expect(layout.nodes.length).toBeGreaterThan(3)
expect(layout.edges.length).toBeGreaterThan(0)
expect(layout.width).toBeGreaterThan(200)
expect(layout.height).toBeGreaterThan(200)
})
})
@@ -0,0 +1,335 @@
/**
* Pure layout for the Activity canvas prototype.
*
* Inspired by orca-viz's DAG canvas: status keeps the hue, agent identity is a
* monogram + left stripe, and parent→child edges come from orchestration
* `parentPaneKey` when present. Agents with no edges pack into an isolated grid
* (the common case outside an active orchestration run).
*/
import {
ACTIVITY_CANVAS_NODE_HEIGHT,
ACTIVITY_CANVAS_NODE_WIDTH,
AGENT_STRIPE_COLOURS,
type ActivityCanvasAgentLook,
type ActivityCanvasCluster,
type ActivityCanvasEdge,
type ActivityCanvasLayout,
type ActivityCanvasNode,
type ActivityCanvasThreadInput
} from './activity-canvas-types'
export type {
ActivityCanvasAgentLook,
ActivityCanvasAgentState,
ActivityCanvasCluster,
ActivityCanvasEdge,
ActivityCanvasLayout,
ActivityCanvasNode,
ActivityCanvasThreadInput
} from './activity-canvas-types'
export {
ACTIVITY_CANVAS_NODE_HEIGHT,
ACTIVITY_CANVAS_NODE_WIDTH,
AGENT_STRIPE_COLOURS
} from './activity-canvas-types'
const NODE_GAP_X = 48
const NODE_GAP_Y = 56
const ISOLATED_GAP_X = 28
const ISOLATED_GAP_Y = 28
const ISOLATED_COLUMNS = 3
const TREE_ROOT_GAP_X = 80
const CANVAS_PAD = 48
export function agentLookAt(index: number): ActivityCanvasAgentLook {
const colour = AGENT_STRIPE_COLOURS[index % AGENT_STRIPE_COLOURS.length]!
return {
monogram: `A${index + 1}`,
colour,
index
}
}
function hashPaneKey(paneKey: string): number {
let hash = 0
for (let i = 0; i < paneKey.length; i++) {
hash = (hash * 31 + paneKey.charCodeAt(i)) | 0
}
return Math.abs(hash)
}
/**
* Assign monograms deterministically: coordinators first (no parent in set),
* then children in stable paneKey order so A1/A2 stay stable across re-layouts.
*/
export function assignAgentLooks(
threads: ActivityCanvasThreadInput[]
): Map<string, ActivityCanvasAgentLook> {
const paneKeys = new Set(threads.map((t) => t.paneKey))
const roots = threads
.filter((t) => !t.parentPaneKey || !paneKeys.has(t.parentPaneKey))
.sort((a, b) => a.paneKey.localeCompare(b.paneKey))
const children = threads
.filter((t) => t.parentPaneKey && paneKeys.has(t.parentPaneKey))
.sort((a, b) => a.paneKey.localeCompare(b.paneKey))
const ordered = [...roots, ...children]
const looks = new Map<string, ActivityCanvasAgentLook>()
ordered.forEach((thread, index) => {
const base = agentLookAt(index)
looks.set(thread.paneKey, {
...base,
monogram: thread.monogram ?? base.monogram
})
})
return looks
}
type ForestNode = {
thread: ActivityCanvasThreadInput
children: ForestNode[]
}
type ForestEdge = { sourceId: string; targetId: string }
function buildForest(threads: ActivityCanvasThreadInput[]): {
roots: ForestNode[]
isolated: ActivityCanvasThreadInput[]
edges: ForestEdge[]
} {
const byKey = new Map(threads.map((t) => [t.paneKey, t]))
const childIds = new Set<string>()
const edges: ForestEdge[] = []
for (const thread of threads) {
const parent = thread.parentPaneKey
if (parent && byKey.has(parent) && parent !== thread.paneKey) {
childIds.add(thread.paneKey)
edges.push({ sourceId: parent, targetId: thread.paneKey })
}
}
// Why: a node is "linked" if it participates in any edge; pure singletons
// pack into the isolated grid so a flat agent list does not look like a
// broken empty DAG (orca-viz SPEC §7.5).
const linkedIds = new Set<string>()
for (const edge of edges) {
linkedIds.add(edge.sourceId)
linkedIds.add(edge.targetId)
}
const childrenByParent = new Map<string, ActivityCanvasThreadInput[]>()
for (const edge of edges) {
const list = childrenByParent.get(edge.sourceId) ?? []
const child = byKey.get(edge.targetId)
if (child) {
list.push(child)
}
childrenByParent.set(edge.sourceId, list)
}
function toForestNode(thread: ActivityCanvasThreadInput): ForestNode {
const kids = (childrenByParent.get(thread.paneKey) ?? [])
.slice()
.sort((a, b) => a.paneKey.localeCompare(b.paneKey))
.map(toForestNode)
return { thread, children: kids }
}
const roots: ForestNode[] = []
const isolated: ActivityCanvasThreadInput[] = []
for (const thread of threads) {
if (!linkedIds.has(thread.paneKey)) {
isolated.push(thread)
continue
}
if (!childIds.has(thread.paneKey)) {
roots.push(toForestNode(thread))
}
}
roots.sort((a, b) => a.thread.paneKey.localeCompare(b.thread.paneKey))
isolated.sort((a, b) => b.latestTimestamp - a.latestTimestamp)
return { roots, isolated, edges }
}
type Placed = { id: string; x: number; y: number; depth: number }
/** Recursive tidy tree: children centered under parent, left-to-right siblings. */
function placeTree(
node: ForestNode,
depth: number,
nextLeafX: { value: number },
placed: Placed[]
): { x: number; width: number } {
if (node.children.length === 0) {
const x = nextLeafX.value
nextLeafX.value += ACTIVITY_CANVAS_NODE_WIDTH + NODE_GAP_X
placed.push({
id: node.thread.paneKey,
x,
y: depth * (ACTIVITY_CANVAS_NODE_HEIGHT + NODE_GAP_Y),
depth
})
return { x, width: ACTIVITY_CANVAS_NODE_WIDTH }
}
const childBoxes = node.children.map((child) => placeTree(child, depth + 1, nextLeafX, placed))
const first = childBoxes.at(0)!
const last = childBoxes.at(-1)!
const left = first.x
const right = last.x + last.width
const x = left + (right - left - ACTIVITY_CANVAS_NODE_WIDTH) / 2
placed.push({
id: node.thread.paneKey,
x,
y: depth * (ACTIVITY_CANVAS_NODE_HEIGHT + NODE_GAP_Y),
depth
})
return { x: left, width: right - left }
}
function edgePath(
source: { x: number; y: number; width: number; height: number },
target: { x: number; y: number; width: number; height: number }
): string {
const x1 = source.x + source.width / 2
const y1 = source.y + source.height
const x2 = target.x + target.width / 2
const y2 = target.y
const midY = (y1 + y2) / 2
return `M ${x1} ${y1} C ${x1} ${midY}, ${x2} ${midY}, ${x2} ${y2}`
}
export function layoutActivityCanvas(threads: ActivityCanvasThreadInput[]): ActivityCanvasLayout {
if (threads.length === 0) {
return {
nodes: [],
edges: [],
clusters: [],
width: 640,
height: 400,
linkedCount: 0,
isolatedCount: 0
}
}
const looks = assignAgentLooks(threads)
const { roots, isolated, edges: rawEdges } = buildForest(threads)
const placed: Placed[] = []
let cursorX = CANVAS_PAD
let treeBottom = CANVAS_PAD
for (const root of roots) {
const treePlaced: Placed[] = []
const nextLeafX = { value: 0 }
placeTree(root, 0, nextLeafX, treePlaced)
let minX = Infinity
for (const p of treePlaced) {
minX = Math.min(minX, p.x)
}
const offsetX = cursorX - (Number.isFinite(minX) ? minX : 0)
for (const p of treePlaced) {
placed.push({
...p,
x: p.x + offsetX,
y: p.y + CANVAS_PAD
})
treeBottom = Math.max(treeBottom, p.y + CANVAS_PAD + ACTIVITY_CANVAS_NODE_HEIGHT)
}
const treeWidth = nextLeafX.value
cursorX += treeWidth + TREE_ROOT_GAP_X
}
const linkedNodes: ActivityCanvasNode[] = placed.map((p) => {
const thread = threads.find((t) => t.paneKey === p.id)!
return {
id: p.id,
x: p.x,
y: p.y,
width: ACTIVITY_CANVAS_NODE_WIDTH,
height: ACTIVITY_CANVAS_NODE_HEIGHT,
isolated: false,
thread,
agent: looks.get(p.id) ?? agentLookAt(hashPaneKey(p.id) % AGENT_STRIPE_COLOURS.length)
}
})
// Isolated grid sits below the forest (or at origin when there is no forest).
const isolatedOriginY = linkedNodes.length > 0 ? treeBottom + NODE_GAP_Y + 24 : CANVAS_PAD
const isolatedOriginX = CANVAS_PAD
const isolatedNodes: ActivityCanvasNode[] = isolated.map((thread, index) => {
const col = index % ISOLATED_COLUMNS
const row = Math.floor(index / ISOLATED_COLUMNS)
return {
id: thread.paneKey,
x: isolatedOriginX + col * (ACTIVITY_CANVAS_NODE_WIDTH + ISOLATED_GAP_X),
y: isolatedOriginY + row * (ACTIVITY_CANVAS_NODE_HEIGHT + ISOLATED_GAP_Y),
width: ACTIVITY_CANVAS_NODE_WIDTH,
height: ACTIVITY_CANVAS_NODE_HEIGHT,
isolated: true,
thread,
agent: looks.get(thread.paneKey) ?? agentLookAt(index)
}
})
const nodes = [...linkedNodes, ...isolatedNodes]
const nodeById = new Map(nodes.map((n) => [n.id, n]))
const edges: ActivityCanvasEdge[] = rawEdges
.map((edge) => {
const source = nodeById.get(edge.sourceId)
const target = nodeById.get(edge.targetId)
if (!source || !target) {
return null
}
return {
id: `${edge.sourceId}->${edge.targetId}`,
sourceId: edge.sourceId,
targetId: edge.targetId,
path: edgePath(source, target)
}
})
.filter((e): e is ActivityCanvasEdge => e !== null)
const clusters: ActivityCanvasCluster[] = []
if (isolatedNodes.length > 0) {
const xs = isolatedNodes.map((n) => n.x)
const ys = isolatedNodes.map((n) => n.y)
const minX = Math.min(...xs) - 16
const minY = Math.min(...ys) - 36
const maxX = Math.max(...isolatedNodes.map((n) => n.x + n.width)) + 16
const maxY = Math.max(...isolatedNodes.map((n) => n.y + n.height)) + 16
clusters.push({
id: 'isolated',
label: `Isolated agents (${isolatedNodes.length})`,
x: minX,
y: minY,
width: maxX - minX,
height: maxY - minY
})
}
let maxX = CANVAS_PAD + 400
let maxY = CANVAS_PAD + 280
for (const n of nodes) {
maxX = Math.max(maxX, n.x + n.width + CANVAS_PAD)
maxY = Math.max(maxY, n.y + n.height + CANVAS_PAD)
}
for (const c of clusters) {
maxX = Math.max(maxX, c.x + c.width + CANVAS_PAD)
maxY = Math.max(maxY, c.y + c.height + CANVAS_PAD)
}
return {
nodes,
edges,
clusters,
width: maxX,
height: maxY,
linkedCount: linkedNodes.length,
isolatedCount: isolatedNodes.length
}
}
@@ -0,0 +1,81 @@
import type { AgentStatusState, AgentType } from '../../../../shared/agent-status-types'
export const ACTIVITY_CANVAS_NODE_WIDTH = 240
export const ACTIVITY_CANVAS_NODE_HEIGHT = 92
/** Stable palette for agent monograms — distinct from status fills. */
export const AGENT_STRIPE_COLOURS = [
'#38bdf8', // sky
'#a78bfa', // violet
'#f472b6', // pink
'#34d399', // emerald
'#fbbf24', // amber
'#fb7185', // rose
'#22d3ee', // cyan
'#c084fc' // purple
] as const
export type ActivityCanvasAgentState =
| Extract<AgentStatusState, 'working' | 'blocked' | 'waiting' | 'done'>
| 'interrupted'
export type ActivityCanvasThreadInput = {
paneKey: string
paneTitle: string
workspaceTitle: string
projectLabel: string
agentType: AgentType
agentState: ActivityCanvasAgentState
agentStateLabel: string
responsePreview: string
latestTimestamp: number
unread: boolean
/** Orchestration parent pane, when this agent was dispatched by another. */
parentPaneKey: string | null
/** Optional monogram override; otherwise assigned by stable index. */
monogram?: string
}
export type ActivityCanvasAgentLook = {
monogram: string
colour: string
index: number
}
export type ActivityCanvasNode = {
id: string
x: number
y: number
width: number
height: number
isolated: boolean
thread: ActivityCanvasThreadInput
agent: ActivityCanvasAgentLook
}
export type ActivityCanvasEdge = {
id: string
sourceId: string
targetId: string
/** Pixel geometry after layout. */
path: string
}
export type ActivityCanvasCluster = {
id: string
label: string
x: number
y: number
width: number
height: number
}
export type ActivityCanvasLayout = {
nodes: ActivityCanvasNode[]
edges: ActivityCanvasEdge[]
clusters: ActivityCanvasCluster[]
width: number
height: number
linkedCount: number
isolatedCount: number
}
@@ -0,0 +1,84 @@
import { describe, expect, it } from 'vitest'
import {
buildActivityThreadLineageItems,
resolveActivityThreadParentPaneKey,
type ActivityLineageThreadLike
} from './activity-thread-lineage'
function thread(
partial: Partial<ActivityLineageThreadLike> & Pick<ActivityLineageThreadLike, 'paneKey'>
): ActivityLineageThreadLike {
return {
paneTitle: partial.paneTitle ?? partial.paneKey,
terminalHandle: partial.terminalHandle ?? null,
parentPaneKey: partial.parentPaneKey ?? null,
parentTerminalHandle: partial.parentTerminalHandle ?? null,
coordinatorHandle: partial.coordinatorHandle ?? null,
...partial
}
}
describe('buildActivityThreadLineageItems', () => {
it('nests children under parents and reports relationship metadata', () => {
const items = buildActivityThreadLineageItems([
thread({ paneKey: 'child-b', paneTitle: 'Worker B', parentPaneKey: 'root' }),
thread({ paneKey: 'root', paneTitle: 'Coordinator' }),
thread({ paneKey: 'child-a', paneTitle: 'Worker A', parentPaneKey: 'root' }),
thread({ paneKey: 'solo', paneTitle: 'Solo' })
])
expect(items.map((item) => item.thread.paneKey)).toEqual(['root', 'child-b', 'child-a', 'solo'])
expect(items[0]?.lineage).toMatchObject({
depth: 0,
childCount: 2,
parentTitle: null
})
expect(items[1]?.lineage).toMatchObject({
depth: 1,
parentPaneKey: 'root',
parentTitle: 'Coordinator',
isFirstSibling: true,
isLastSibling: false
})
expect(items[2]?.lineage).toMatchObject({
depth: 1,
parentTitle: 'Coordinator',
isFirstSibling: false,
isLastSibling: true
})
expect(items[3]?.lineage.depth).toBe(0)
})
it('resolves parent via terminal handle when pane key is missing', () => {
const parent = thread({
paneKey: 'parent',
paneTitle: 'Parent',
terminalHandle: 'term_parent'
})
const child = thread({
paneKey: 'child',
paneTitle: 'Child',
parentTerminalHandle: 'term_parent'
})
const byPaneKey = new Map([
[parent.paneKey, parent],
[child.paneKey, child]
])
const byHandle = new Map([['term_parent', 'parent']])
expect(resolveActivityThreadParentPaneKey(child, byPaneKey, byHandle)).toBe('parent')
const items = buildActivityThreadLineageItems([child, parent])
expect(items.map((item) => item.thread.paneKey)).toEqual(['parent', 'child'])
expect(items[1]?.lineage.parentTitle).toBe('Parent')
})
it('keeps cycle participants visible as roots', () => {
const items = buildActivityThreadLineageItems([
thread({ paneKey: 'a', parentPaneKey: 'b' }),
thread({ paneKey: 'b', parentPaneKey: 'a' })
])
expect(items).toHaveLength(2)
expect(items.every((item) => item.lineage.depth === 0)).toBe(true)
})
})
@@ -0,0 +1,200 @@
/**
* Orchestration lineage for Activity list rows.
*
* Mirrors dashboard `agent-row-lineage-model`: resolve parent via
* `parentPaneKey` / terminal handles, nest children under parents, and keep
* cycle/unreachable rows visible as roots.
*/
export type ActivityLineageThreadLike = {
paneKey: string
paneTitle: string
terminalHandle?: string | null
parentPaneKey?: string | null
parentTerminalHandle?: string | null
coordinatorHandle?: string | null
}
export type ActivityThreadLineageMeta = {
depth: number
parentPaneKey: string | null
parentTitle: string | null
childCount: number
isFirstSibling: boolean
isLastSibling: boolean
}
export type ActivityThreadLineageItem<T extends ActivityLineageThreadLike> = {
thread: T
lineage: ActivityThreadLineageMeta
}
function buildPaneKeyByTerminalHandle<T extends ActivityLineageThreadLike>(
threads: readonly T[]
): Map<string, string> {
const map = new Map<string, string>()
for (const thread of threads) {
const handle = thread.terminalHandle?.trim()
if (handle && !map.has(handle)) {
map.set(handle, thread.paneKey)
}
}
return map
}
export function resolveActivityThreadParentPaneKey<T extends ActivityLineageThreadLike>(
thread: T,
byPaneKey: ReadonlyMap<string, T>,
paneKeyByTerminalHandle: ReadonlyMap<string, string>
): string | null {
const explicit = thread.parentPaneKey?.trim()
if (explicit && explicit !== thread.paneKey && byPaneKey.has(explicit)) {
return explicit
}
for (const handle of [thread.parentTerminalHandle, thread.coordinatorHandle]) {
const trimmed = handle?.trim()
if (!trimmed) {
continue
}
const parentPaneKey = paneKeyByTerminalHandle.get(trimmed)
if (parentPaneKey && parentPaneKey !== thread.paneKey && byPaneKey.has(parentPaneKey)) {
return parentPaneKey
}
}
return null
}
/**
* Flatten threads into parent-then-children order with lineage metadata for
* indentation and relationship captions in the list.
*/
export function buildActivityThreadLineageItems<T extends ActivityLineageThreadLike>(
threads: readonly T[]
): ActivityThreadLineageItem<T>[] {
if (threads.length === 0) {
return []
}
const byPaneKey = new Map<string, T>()
for (const thread of threads) {
if (!byPaneKey.has(thread.paneKey)) {
byPaneKey.set(thread.paneKey, thread)
}
}
const paneKeyByTerminalHandle = buildPaneKeyByTerminalHandle(threads)
const childrenByParent = new Map<string, T[]>()
const childPaneKeys = new Set<string>()
for (const thread of threads) {
const parentPaneKey = resolveActivityThreadParentPaneKey(
thread,
byPaneKey,
paneKeyByTerminalHandle
)
if (!parentPaneKey) {
continue
}
childPaneKeys.add(thread.paneKey)
const siblings = childrenByParent.get(parentPaneKey)
if (siblings) {
siblings.push(thread)
} else {
childrenByParent.set(parentPaneKey, [thread])
}
}
// Preserve caller order among roots / among siblings (group order, recency).
const orderIndex = new Map(threads.map((thread, index) => [thread.paneKey, index]))
const sortByCallerOrder = (a: T, b: T): number =>
(orderIndex.get(a.paneKey) ?? 0) - (orderIndex.get(b.paneKey) ?? 0)
for (const [parentPaneKey, siblings] of childrenByParent) {
childrenByParent.set(parentPaneKey, [...siblings].sort(sortByCallerOrder))
}
let rootThreads = threads.filter((thread) => !childPaneKeys.has(thread.paneKey))
if (rootThreads.length === 0) {
// Why: closed cycles must not hide every participant.
return threads.map((thread) => ({
thread,
lineage: {
depth: 0,
parentPaneKey: null,
parentTitle: null,
childCount: 0,
isFirstSibling: true,
isLastSibling: true
}
}))
}
const reachable = new Set<string>()
const visit = (thread: T, ancestors: ReadonlySet<string>): void => {
if (reachable.has(thread.paneKey) || ancestors.has(thread.paneKey)) {
return
}
reachable.add(thread.paneKey)
const nextAncestors = new Set(ancestors)
nextAncestors.add(thread.paneKey)
for (const child of childrenByParent.get(thread.paneKey) ?? []) {
visit(child, nextAncestors)
}
}
for (const root of rootThreads) {
visit(root, new Set())
}
for (const thread of threads) {
if (reachable.has(thread.paneKey)) {
continue
}
// Unreachable (partial cycle): promote to root and detach edges.
if (!rootThreads.some((root) => root.paneKey === thread.paneKey)) {
rootThreads = [...rootThreads, thread]
}
childPaneKeys.delete(thread.paneKey)
childrenByParent.delete(thread.paneKey)
for (const [parentPaneKey, siblings] of childrenByParent) {
const next = siblings.filter((sibling) => sibling.paneKey !== thread.paneKey)
if (next.length === 0) {
childrenByParent.delete(parentPaneKey)
} else if (next.length !== siblings.length) {
childrenByParent.set(parentPaneKey, next)
}
}
}
rootThreads = [...rootThreads].sort(sortByCallerOrder)
const items: ActivityThreadLineageItem<T>[] = []
const walk = (thread: T, depth: number, siblingIndex: number, siblingCount: number): void => {
const children = childrenByParent.get(thread.paneKey) ?? []
const parentPaneKey =
depth > 0
? resolveActivityThreadParentPaneKey(thread, byPaneKey, paneKeyByTerminalHandle)
: null
const parent = parentPaneKey ? byPaneKey.get(parentPaneKey) : undefined
items.push({
thread,
lineage: {
depth,
parentPaneKey,
parentTitle: parent?.paneTitle ?? null,
childCount: children.length,
isFirstSibling: siblingIndex === 0,
isLastSibling: siblingIndex === siblingCount - 1
}
})
children.forEach((child, index) => {
walk(child, depth + 1, index, children.length)
})
}
rootThreads.forEach((root, index) => {
walk(root, 0, index, rootThreads.length)
})
return items
}
@@ -0,0 +1,16 @@
export const OPEN_AGENTS_PANEL_EVENT = 'orca:open-agents-panel'
export const CLOSE_AGENTS_PANEL_EVENT = 'orca:close-agents-panel'
export function requestOpenAgentsPanel(): void {
if (typeof window === 'undefined') {
return
}
window.dispatchEvent(new Event(OPEN_AGENTS_PANEL_EVENT))
}
export function requestCloseAgentsPanel(): void {
if (typeof window === 'undefined') {
return
}
window.dispatchEvent(new Event(CLOSE_AGENTS_PANEL_EVENT))
}
@@ -0,0 +1,106 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import { CLOSE_AGENTS_PANEL_EVENT, OPEN_AGENTS_PANEL_EVENT } from './agents-panel-events'
const AGENTS_PANEL_ESCAPE_BLOCKING_OVERLAY_SELECTOR = [
'[data-slot="dropdown-menu-content"][data-state="open"]',
'[data-slot="context-menu-content"][data-state="open"]',
'[data-slot="popover-content"][data-state="open"]',
'[role="dialog"][data-state="open"]:not([data-agents-panel-sheet])',
'[role="alertdialog"][data-state="open"]',
'[role="menu"][data-state="open"]',
'[role="listbox"][data-state="open"]'
].join(', ')
export type AgentsPanelState = {
agentsPanelOpen: boolean
openAgentsPanel: () => void
closeAgentsPanel: () => void
toggleAgentsPanel: () => void
handleAgentsPanelOpenChange: (open: boolean) => void
}
export function useAgentsPanel(): AgentsPanelState {
const [agentsPanelOpen, setAgentsPanelOpen] = useState(false)
const agentsPanelOpenRef = useRef(agentsPanelOpen)
agentsPanelOpenRef.current = agentsPanelOpen
const openAgentsPanel = useCallback(() => {
if (agentsPanelOpenRef.current) {
return
}
agentsPanelOpenRef.current = true
setAgentsPanelOpen(true)
}, [])
const closeAgentsPanel = useCallback(() => {
if (!agentsPanelOpenRef.current) {
return
}
agentsPanelOpenRef.current = false
setAgentsPanelOpen(false)
}, [])
const handleAgentsPanelOpenChange = useCallback(
(open: boolean) => {
if (open) {
openAgentsPanel()
return
}
closeAgentsPanel()
},
[closeAgentsPanel, openAgentsPanel]
)
const toggleAgentsPanel = useCallback(() => {
if (agentsPanelOpenRef.current) {
closeAgentsPanel()
return
}
openAgentsPanel()
}, [closeAgentsPanel, openAgentsPanel])
useEffect(() => {
if (!agentsPanelOpen) {
return
}
const handleKeyDown = (event: KeyboardEvent): void => {
if (event.key !== 'Escape') {
return
}
// Why: Escape should dismiss nested menus/dialogs before this companion panel.
if (document.querySelector(AGENTS_PANEL_ESCAPE_BLOCKING_OVERLAY_SELECTOR)) {
return
}
event.preventDefault()
closeAgentsPanel()
}
// Why: non-modal companion panel — focus may be outside the sheet when Escape fires.
document.addEventListener('keydown', handleKeyDown, true)
return () => document.removeEventListener('keydown', handleKeyDown, true)
}, [agentsPanelOpen, closeAgentsPanel])
useEffect(() => {
const onOpen = (): void => {
openAgentsPanel()
}
const onClose = (): void => {
closeAgentsPanel()
}
window.addEventListener(OPEN_AGENTS_PANEL_EVENT, onOpen)
window.addEventListener(CLOSE_AGENTS_PANEL_EVENT, onClose)
return () => {
window.removeEventListener(OPEN_AGENTS_PANEL_EVENT, onOpen)
window.removeEventListener(CLOSE_AGENTS_PANEL_EVENT, onClose)
}
}, [closeAgentsPanel, openAgentsPanel])
return {
agentsPanelOpen,
openAgentsPanel,
closeAgentsPanel,
toggleAgentsPanel,
handleAgentsPanelOpenChange
}
}
@@ -34,9 +34,6 @@ export function ExperimentalPane({
}: ExperimentalPaneProps): React.JSX.Element {
const searchQuery = useAppStore((s) => s.settingsSearchQuery)
const showPet = matchesSettingsSearch(searchQuery, [getExperimentalSearchEntry().pet])
const showAgentsView = matchesSettingsSearch(searchQuery, [
getExperimentalSearchEntry().agentsView
])
const showNativeChat = matchesSettingsSearch(searchQuery, [
getExperimentalSearchEntry().nativeChat
])
@@ -103,51 +100,6 @@ export function ExperimentalPane({
</SearchableSetting>
) : null}
{showAgentsView ? (
<SearchableSetting
title={translate('auto.components.settings.ExperimentalPane.a05bcdaf57', 'Agents View')}
description={translate(
'auto.components.settings.ExperimentalPane.f63ea281e3',
'Threaded left-sidebar feed for agent completions and blocking states.'
)}
keywords={getExperimentalSearchEntry().agentsView.keywords}
className="space-y-3 py-2"
>
<div className="flex items-start justify-between gap-4">
<div className="min-w-0 shrink space-y-0.5">
<Label>
{translate('auto.components.settings.ExperimentalPane.a05bcdaf57', 'Agents View')}
</Label>
<p className="text-xs text-muted-foreground">
{translate(
'auto.components.settings.ExperimentalPane.0277901cf7',
'Adds an Agents entry to the left sidebar with a threaded worktree feed for completed agents, blocking questions, unread state, and worktree creation events. Experimental — the event model and UI may change.'
)}
</p>
</div>
<button
type="button"
role="switch"
aria-checked={settings.experimentalActivity}
onClick={() =>
updateSettings({
experimentalActivity: !settings.experimentalActivity
})
}
className={`relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-transparent transition-colors ${
settings.experimentalActivity ? 'bg-foreground' : 'bg-muted-foreground/30'
}`}
>
<span
className={`inline-block h-3.5 w-3.5 transform rounded-full bg-background shadow-sm transition-transform ${
settings.experimentalActivity ? 'translate-x-4' : 'translate-x-0.5'
}`}
/>
</button>
</div>
</SearchableSetting>
) : null}
{showNativeChat ? (
<NativeChatExperimentalSetting settings={settings} updateSettings={updateSettings} />
) : null}
@@ -46,55 +46,6 @@ export const getExperimentalPaneSearchEntries = createLocalizedCatalog(
)
]
},
{
title: translate('auto.components.settings.experimental.search.ccc5548ac5', 'Agents View'),
description: translate(
'auto.components.settings.experimental.search.4d63251595',
'Threaded left-sidebar feed for agent completions and blocking states.'
),
keywords: [
...translateSearchKeyword(
'auto.components.settings.experimental.search.0d24759f14',
'experimental'
),
...translateSearchKeyword(
'auto.components.settings.experimental.search.fa72e71f05',
'agents'
),
...translateSearchKeyword(
'auto.components.settings.experimental.search.92a9357d1f',
'agents view'
),
...translateSearchKeyword(
'auto.components.settings.experimental.search.244a0ecd3d',
'activity'
),
...translateSearchKeyword(
'auto.components.settings.experimental.search.d01b3882ba',
'notifications'
),
...translateSearchKeyword(
'auto.components.settings.experimental.search.10b52f79c1',
'worktrees'
),
...translateSearchKeyword(
'auto.components.settings.experimental.search.ca5d1f3f46',
'timeline'
),
...translateSearchKeyword(
'auto.components.settings.experimental.search.7b79081695',
'unread'
),
...translateSearchKeyword(
'auto.components.settings.experimental.search.8facf10138',
'bell'
),
...translateSearchKeyword(
'auto.components.settings.experimental.search.fe5688b761',
'sidebar'
)
]
},
getNativeChatExperimentalSearchEntry(),
{
title: translate(
@@ -203,9 +154,6 @@ function findEntry(title: string): SettingsSearchEntry {
export function getExperimentalSearchEntry() {
return {
pet: findEntry(translate('auto.components.settings.experimental.search.87d99e634b', 'Pet')),
agentsView: findEntry(
translate('auto.components.settings.experimental.search.ccc5548ac5', 'Agents View')
),
nativeChat: findEntry(
translate('auto.components.settings.experimental.search.nativeChat.title', 'Native chat')
),
@@ -13,7 +13,6 @@ const mocks = vi.hoisted(() => ({
state: {} as Record<string, unknown>,
openTaskPage: vi.fn(),
openAutomationsPage: vi.fn(),
openActivityPage: vi.fn(),
openMobilePage: vi.fn(),
openModal: vi.fn(),
updateSettings: vi.fn(),
@@ -35,10 +34,6 @@ vi.mock('@/store/selectors', () => ({
)
}))
vi.mock('@/components/activity/useActivityUnreadCount', () => ({
useActivityUnreadCount: () => 0
}))
vi.mock('@/hooks/useShortcutLabel', () => ({
useShortcutKeyComboDetails: () => [{ keys: ['⌘', 'J'], doubleTap: false }]
}))
@@ -77,7 +72,6 @@ vi.mock('@/components/ui/context-menu', () => ({
import {
getSetupGuideSidebarEntryReady,
shouldShowAgentsButton,
shouldShowAutomationsButton,
shouldShowMobileButton,
shouldShowSetupGuideEntry
@@ -119,7 +113,6 @@ function setSidebarState({
activeView: 'worktrees',
openTaskPage: mocks.openTaskPage,
openAutomationsPage: mocks.openAutomationsPage,
openActivityPage: mocks.openActivityPage,
openMobilePage: mocks.openMobilePage,
openModal: mocks.openModal,
updateSettings: mocks.updateSettings,
@@ -205,28 +198,6 @@ describe('SidebarNav', () => {
setSidebarState()
})
it('hides the Agents entry while settings are loading', () => {
expect(shouldShowAgentsButton(null)).toBe(false)
})
it('hides the Agents entry while the experimental Agents view is off', () => {
expect(
shouldShowAgentsButton({
...getDefaultSettings('/tmp'),
experimentalActivity: false
})
).toBe(false)
})
it('shows the Agents entry when the experimental Agents view is on', () => {
expect(
shouldShowAgentsButton({
...getDefaultSettings('/tmp'),
experimentalActivity: true
})
).toBe(true)
})
it('shows the Mobile entry by default for older settings', () => {
expect(shouldShowMobileButton(null)).toBe(true)
expect(shouldShowMobileButton({})).toBe(true)
@@ -1,10 +1,9 @@
import React from 'react'
import { Bell, CalendarClock, EyeOff, Search, Smartphone } from 'lucide-react'
import { CalendarClock, EyeOff, Search, Smartphone } from 'lucide-react'
import { useTranslation } from 'react-i18next'
import { useAppStore } from '@/store'
import { cn } from '@/lib/utils'
import type { GlobalSettings } from '../../../../shared/types'
import { useActivityUnreadCount } from '@/components/activity/useActivityUnreadCount'
import { useShortcutKeyComboDetails } from '@/hooks/useShortcutLabel'
import { ShortcutKeyCombo } from '@/components/ShortcutKeyCombo'
import { useMobileSidebarOnboardingBadge } from './mobile-sidebar-onboarding-badge'
@@ -18,12 +17,6 @@ import { translate } from '@/i18n/i18n'
export { getSetupGuideSidebarEntryReady, shouldShowSetupGuideEntry } from './SetupGuideSidebarEntry'
export function shouldShowAgentsButton(
settings: Pick<GlobalSettings, 'experimentalActivity'> | null | undefined
): boolean {
return settings?.experimentalActivity === true
}
export function shouldShowMobileButton(
settings: Pick<GlobalSettings, 'showMobileButton'> | null | undefined
): boolean {
@@ -42,18 +35,14 @@ const SidebarNav = React.memo(function SidebarNav() {
useTranslation()
const worktreePaletteShortcutCombos = useShortcutKeyComboDetails('worktree.palette')
const openAutomationsPage = useAppStore((s) => s.openAutomationsPage)
const openActivityPage = useAppStore((s) => s.openActivityPage)
const openMobilePage = useAppStore((s) => s.openMobilePage)
const openModal = useAppStore((s) => s.openModal)
const updateSettings = useAppStore((s) => s.updateSettings)
const activeView = useAppStore((s) => s.activeView)
const showAgentsButton = useAppStore((s) => shouldShowAgentsButton(s.settings))
const showAutomationsButton = useAppStore((s) => shouldShowAutomationsButton(s.settings))
const showMobileButton = useAppStore((s) => shouldShowMobileButton(s.settings))
const automationsActive = activeView === 'automations'
const activityActive = activeView === 'activity'
const mobileActive = activeView === 'mobile'
const activityUnreadCount = useActivityUnreadCount(showAgentsButton, 'sidebar-badge')
const mobileOnboardingBadge = useMobileSidebarOnboardingBadge(showMobileButton)
const hideAutomationsButton = React.useCallback(() => {
void updateSettings({ showAutomationsButton: false })
@@ -98,35 +87,6 @@ const SidebarNav = React.memo(function SidebarNav() {
<HideSidebarMenu onHide={hideAutomationsButton} />
</ContextMenu>
) : null}
{showAgentsButton ? (
<button
type="button"
onClick={openActivityPage}
aria-current={activityActive ? 'page' : undefined}
className={cn(
'flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] font-medium tracking-tight transition-colors',
activityActive
? 'bg-worktree-sidebar-accent text-worktree-sidebar-accent-foreground'
: 'text-worktree-sidebar-foreground/60 hover:bg-worktree-sidebar-foreground/8'
)}
>
<Bell
className={cn(
'size-4 shrink-0',
!activityActive && 'text-worktree-sidebar-foreground/30'
)}
strokeWidth={activityActive ? 2.25 : 1.75}
/>
<span className="flex-1">
{translate('auto.components.sidebar.SidebarNav.9c95e1ce91', 'Agents')}
</span>
{activityUnreadCount > 0 ? (
<span className="rounded-full bg-primary px-1.5 py-px text-[10px] font-semibold text-primary-foreground">
{activityUnreadCount}
</span>
) : null}
</button>
) : null}
{showMobileButton ? (
<ContextMenu>
<ContextMenuTrigger asChild>
@@ -18,6 +18,10 @@ vi.mock('@/store', () => ({
useAppStore: (selector: (state: Partial<AppState>) => unknown) => selector(mocks.state)
}))
vi.mock('@/components/activity/useActivityUnreadCount', () => ({
useActivityUnreadCount: () => 0
}))
vi.mock('@/components/ui/tooltip', () => ({
Tooltip: ({ children, open }: { children: ReactNode; open?: boolean }) => {
mocks.activeTooltipOpen = open === true
@@ -46,10 +50,15 @@ vi.mock('../orca-profiles/OrcaProfileSwitcher', () => ({
const roots: Root[] = []
async function renderToolbar(onWorkspaceBoardToggle = vi.fn()): Promise<{
async function renderToolbar(
onWorkspaceBoardToggle = vi.fn(),
onAgentsPanelToggle = vi.fn(),
agentsPanelOpen = false
): Promise<{
container: HTMLDivElement
rerender: () => Promise<void>
onWorkspaceBoardToggle: ReturnType<typeof vi.fn>
onAgentsPanelToggle: ReturnType<typeof vi.fn>
}> {
const container = document.createElement('div')
document.body.appendChild(container)
@@ -62,13 +71,15 @@ async function renderToolbar(onWorkspaceBoardToggle = vi.fn()): Promise<{
<SidebarToolbar
workspaceBoardOpen={false}
onWorkspaceBoardToggle={onWorkspaceBoardToggle}
agentsPanelOpen={agentsPanelOpen}
onAgentsPanelToggle={onAgentsPanelToggle}
/>
)
})
}
await render()
return { container, rerender: render, onWorkspaceBoardToggle }
return { container, rerender: render, onWorkspaceBoardToggle, onAgentsPanelToggle }
}
describe('SidebarToolbar moved workspace board hint', () => {
@@ -138,4 +149,40 @@ describe('SidebarToolbar moved workspace board hint', () => {
expect(html).toContain('data-placement="sidebar"')
expect(html.indexOf('Profile')).toBeLessThan(html.indexOf('Settings'))
})
it('renders an always-on Agents button next to the workspace board button', async () => {
const { container } = await renderToolbar()
const agentsButton = container.querySelector<HTMLButtonElement>('button[aria-label="Agents"]')
const boardButton = container.querySelector<HTMLButtonElement>(
'button[aria-label="Workspace board"]'
)
expect(agentsButton).not.toBeNull()
expect(boardButton).not.toBeNull()
expect(container.innerHTML.indexOf('aria-label="Agents"')).toBeLessThan(
container.innerHTML.indexOf('aria-label="Workspace board"')
)
})
it('toggles the agents companion panel from the toolbar button', async () => {
const onAgentsPanelToggle = vi.fn()
const { container } = await renderToolbar(vi.fn(), onAgentsPanelToggle, false)
const agentsButton = container.querySelector<HTMLButtonElement>('button[aria-label="Agents"]')
expect(agentsButton?.getAttribute('aria-pressed')).toBe('false')
expect(agentsButton?.hasAttribute('data-agents-panel-trigger')).toBe(true)
await act(async () => {
agentsButton?.click()
})
expect(onAgentsPanelToggle).toHaveBeenCalledOnce()
})
it('marks the agents toolbar button pressed while the panel is open', async () => {
const { container } = await renderToolbar(vi.fn(), vi.fn(), true)
const agentsButton = container.querySelector<HTMLButtonElement>('button[aria-label="Agents"]')
expect(agentsButton?.getAttribute('aria-pressed')).toBe('true')
})
})
@@ -1,7 +1,8 @@
import React from 'react'
import { Kanban } from 'lucide-react'
import { Bot, Kanban } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Tooltip, TooltipTrigger, TooltipContent } from '@/components/ui/tooltip'
import { useActivityUnreadCount } from '@/components/activity/useActivityUnreadCount'
import { ScrollToCurrentWorkspaceToolbarButton } from './ScrollToCurrentWorkspaceToolbarButton'
import { SidebarSettingsHelpMenu } from './SidebarSettingsHelpMenu'
import { OrcaProfileSwitcher } from '../orca-profiles/OrcaProfileSwitcher'
@@ -16,12 +17,16 @@ type SidebarToolbarProps = {
workspaceBoardOpen: boolean
workspaceBoardDragPreviewOpen?: boolean
onWorkspaceBoardToggle: () => void
agentsPanelOpen: boolean
onAgentsPanelToggle: () => void
}
const SidebarToolbar = React.memo(function SidebarToolbar({
workspaceBoardOpen,
workspaceBoardDragPreviewOpen = false,
onWorkspaceBoardToggle
onWorkspaceBoardToggle,
agentsPanelOpen,
onAgentsPanelToggle
}: SidebarToolbarProps) {
const [workspaceBoardMovedHintOpen, setWorkspaceBoardMovedHintOpen] = React.useState(false)
const movedHintEligibleRef = React.useRef<boolean | null>(null)
@@ -29,6 +34,7 @@ const SidebarToolbar = React.memo(function SidebarToolbar({
const hasUsedWorkspaceBoard = useAppStore((state) =>
hasFeatureInteraction(state.featureInteractions, 'workspace-board')
)
const activityUnreadCount = useActivityUnreadCount(true, 'sidebar-badge')
React.useEffect(() => {
if (!persistedUIReady) {
@@ -72,6 +78,32 @@ const SidebarToolbar = React.memo(function SidebarToolbar({
</div>
<div className="flex items-center gap-1">
<ScrollToCurrentWorkspaceToolbarButton />
<Tooltip>
<TooltipTrigger asChild>
<Button
variant={agentsPanelOpen ? 'secondary' : 'ghost'}
size="icon-xs"
type="button"
aria-label={translate('auto.components.sidebar.SidebarToolbar.agents', 'Agents')}
aria-pressed={agentsPanelOpen}
data-agents-panel-trigger=""
onClick={onAgentsPanelToggle}
className="relative text-muted-foreground"
>
<Bot className="size-3.5" />
{activityUnreadCount > 0 ? (
<span className="absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-primary px-0.5 text-[9px] font-semibold leading-none text-primary-foreground">
{activityUnreadCount > 99 ? '99+' : activityUnreadCount}
</span>
) : null}
</Button>
</TooltipTrigger>
<TooltipContent side="top" sideOffset={4}>
{agentsPanelOpen
? translate('auto.components.sidebar.SidebarToolbar.closeAgents', 'Close agents')
: translate('auto.components.sidebar.SidebarToolbar.agents', 'Agents')}
</TooltipContent>
</Tooltip>
<Tooltip open={workspaceBoardMovedHintOpen ? true : undefined}>
<TooltipTrigger asChild>
<Button
@@ -6085,8 +6085,7 @@ const WorktreeList = React.memo(function WorktreeList({
// Why: full-page navigation views are not scoped to one worktree, so no
// sidebar card should appear selected while one of them is active.
const selectedSidebarWorktreeId =
activeView === 'tasks' || activeView === 'activity' ? null : currentSidebarWorktreeId
const selectedSidebarWorktreeId = activeView === 'tasks' ? null : currentSidebarWorktreeId
// Why layout effect instead of effect: the global Cmd/Ctrl+1–9 key handler
// can fire immediately after React commits the new grouped/collapsed order.
+63 -10
View File
@@ -8,11 +8,13 @@ import SetupScriptPromptCard from './SetupScriptPromptCard'
import WorktreeList from './WorktreeList'
import SidebarToolbar from './SidebarToolbar'
import WorkspaceKanbanDrawer from './WorkspaceKanbanDrawer'
import AgentsDrawer from '@/components/activity/AgentsDrawer'
import type { VirtualizedScrollAnchor } from '@/hooks/useVirtualizedScrollAnchor'
import { cn } from '@/lib/utils'
import { FolderPlus, Loader2 } from 'lucide-react'
import { useSidebarProjectDrop } from './useSidebarProjectDrop'
import { useWorkspaceBoardPanel } from './useWorkspaceBoardPanel'
import { useAgentsPanel } from '@/components/activity/useAgentsPanel'
import { resolveLeftSidebarStyleVariables } from '@/lib/left-sidebar-appearance'
import { useSystemPrefersDark } from '@/components/terminal-pane/use-system-prefers-dark'
import { lazyWithRetry } from '@/lib/lazy-with-retry'
@@ -68,6 +70,29 @@ function Sidebar({
solidifyWorkspaceBoardFromDrag,
cancelWorkspaceBoardDragPreview
} = useWorkspaceBoardPanel()
const {
agentsPanelOpen,
toggleAgentsPanel,
handleAgentsPanelOpenChange,
closeAgentsPanel,
openAgentsPanel
} = useAgentsPanel()
// Why: both are left-edge companion sheets; stacking them is noisy and
// fights for the same viewport band next to the sidebar.
const handleWorkspaceBoardToggle = React.useCallback(() => {
if (!workspaceBoardOpen) {
closeAgentsPanel()
}
toggleWorkspaceBoard()
}, [closeAgentsPanel, toggleWorkspaceBoard, workspaceBoardOpen])
const handleAgentsPanelToggle = React.useCallback(() => {
if (!agentsPanelOpen) {
closeWorkspaceBoard()
}
toggleAgentsPanel()
}, [agentsPanelOpen, closeWorkspaceBoard, toggleAgentsPanel])
const setLiveSidebarWidth = React.useCallback((width: number) => {
document.documentElement.style.setProperty('--workspace-sidebar-live-width', `${width}px`)
@@ -120,6 +145,12 @@ function Sidebar({
}
}, [closeWorkspaceBoard, sidebarOpen, workspaceBoardRenderedOpen])
useEffect(() => {
if (!sidebarOpen && agentsPanelOpen) {
closeAgentsPanel()
}
}, [agentsPanelOpen, closeAgentsPanel, sidebarOpen])
const { containerRef, onResizeStart, isResizing } = useSidebarResize<HTMLDivElement>({
isOpen: sidebarOpen,
width: sidebarWidth,
@@ -160,7 +191,9 @@ function Sidebar({
<SidebarToolbar
workspaceBoardOpen={workspaceBoardOpen}
workspaceBoardDragPreviewOpen={workspaceBoardDragPreviewOpen}
onWorkspaceBoardToggle={toggleWorkspaceBoard}
onWorkspaceBoardToggle={handleWorkspaceBoardToggle}
agentsPanelOpen={agentsPanelOpen}
onAgentsPanelToggle={handleAgentsPanelToggle}
/>
</>
)}
@@ -211,15 +244,35 @@ function Sidebar({
{activeModal === 'forget-ssh-workspace' ? <ForgetSshWorkspaceDialog /> : null}
</React.Suspense>
{sidebarOpen ? (
<WorkspaceKanbanDrawer
leftSidebarStyle={leftSidebarStyle}
open={workspaceBoardRenderedOpen}
statusBarVisible={statusBarVisible}
dragPreview={workspaceBoardDragPreviewOpen}
preserveOpenForMenu={workspaceBoardMenuOpen}
onOpenChange={handleWorkspaceBoardOpenChange}
onMenuOpenChange={setWorkspaceBoardMenuOpen}
/>
<>
<WorkspaceKanbanDrawer
leftSidebarStyle={leftSidebarStyle}
open={workspaceBoardRenderedOpen}
statusBarVisible={statusBarVisible}
dragPreview={workspaceBoardDragPreviewOpen}
preserveOpenForMenu={workspaceBoardMenuOpen}
onOpenChange={(open) => {
if (open) {
closeAgentsPanel()
}
handleWorkspaceBoardOpenChange(open)
}}
onMenuOpenChange={setWorkspaceBoardMenuOpen}
/>
<AgentsDrawer
leftSidebarStyle={leftSidebarStyle}
open={agentsPanelOpen}
statusBarVisible={statusBarVisible}
onOpenChange={(open) => {
if (open) {
closeWorkspaceBoard()
openAgentsPanel()
return
}
handleAgentsPanelOpenChange(false)
}}
/>
</>
) : null}
</TooltipProvider>
)
+22 -2
View File
@@ -4116,7 +4116,9 @@
"a30e34eb5c": "Close workspace board",
"49f62c5665": "Workspace board",
"19e32d0e5f": "Open folder picker to add a project",
"abc62b6328": "Add Project"
"abc62b6328": "Add Project",
"agents": "Agents",
"closeAgents": "Close agents"
},
"SidebarWorkspaceFilterSection": {
"c3fa13dc2e": "Hide default branch",
@@ -12836,12 +12838,30 @@
"beb2c19173": "Unread",
"5651b216c6": "Unknown project",
"22b22034bc": "Standalone terminal unavailable in Activity.",
"afdc2139a8": "Agent terminal closed. Open a new terminal in this workspace to continue."
"afdc2139a8": "Agent terminal closed. Open a new terminal in this workspace to continue.",
"searchSessions": "Search sessions",
"clearSearch": "Clear search",
"filterByStatus": "Filter by status",
"noMatchingSessions": "No agent sessions match."
},
"ActivityTitlebarControls": {
"f915168c8e": "unread",
"d6a8de3934": "agents",
"dc708f3eff": "Close agents"
},
"ActivityAgentsCanvas": {
"demoTitle": "Canvas preview (sample data)",
"liveTitle": "Agents canvas",
"demoHint": "No live agents match filters — showing a sample orchestration graph. Start agents to replace this with real data.",
"liveHint": "{{linked}} linked · {{isolated}} isolated · fill = status · stripe = agent",
"empty": "No agent activity to place on the canvas.",
"viewMode": "Agents view mode"
},
"AgentsDrawer": {
"title": "Agents",
"unread": "unread",
"description": "Browse agent sessions by status and open their terminals.",
"close": "Close"
}
},
"confirmation": {
+22 -2
View File
@@ -4078,7 +4078,9 @@
"abc62b6328": "Agregar proyecto",
"87d0064026": "El tablero de espacios de trabajo se movió a la barra inferior",
"a30e34eb5c": "Cerrar tablero de espacios de trabajo",
"49f62c5665": "Tablero de espacios de trabajo"
"49f62c5665": "Tablero de espacios de trabajo",
"agents": "Agents",
"closeAgents": "Close agents"
},
"SidebarWorkspaceFilterSection": {
"c3fa13dc2e": "Ocultar rama predeterminada",
@@ -12813,12 +12815,30 @@
"beb2c19173": "No leído",
"5651b216c6": "Proyecto desconocido",
"22b22034bc": "Terminal independiente no disponible en Actividad.",
"afdc2139a8": "Terminal de Agent cerrada. Abre una nueva terminal en este workspace para continuar."
"afdc2139a8": "Terminal de Agent cerrada. Abre una nueva terminal en este workspace para continuar.",
"searchSessions": "Search sessions",
"clearSearch": "Clear search",
"filterByStatus": "Filter by status",
"noMatchingSessions": "No agent sessions match."
},
"ActivityTitlebarControls": {
"f915168c8e": "no leído",
"d6a8de3934": "agentes",
"dc708f3eff": "Agents cercanos"
},
"ActivityAgentsCanvas": {
"demoTitle": "Canvas preview (sample data)",
"liveTitle": "Agents canvas",
"demoHint": "No live agents match filters — showing a sample orchestration graph. Start agents to replace this with real data.",
"liveHint": "{{linked}} linked · {{isolated}} isolated · fill = status · stripe = agent",
"empty": "No agent activity to place on the canvas.",
"viewMode": "Agents view mode"
},
"AgentsDrawer": {
"title": "Agents",
"unread": "unread",
"description": "Browse agent sessions by status and open their terminals.",
"close": "Close"
}
},
"confirmation": {
+22 -2
View File
@@ -4059,7 +4059,9 @@
"abc62b6328": "プロジェクトを追加",
"87d0064026": "ワークスペースボードは下部バーに移動しました",
"a30e34eb5c": "ワークスペースボードを閉じる",
"49f62c5665": "ワークスペースボード"
"49f62c5665": "ワークスペースボード",
"agents": "Agents",
"closeAgents": "Close agents"
},
"SidebarWorkspaceFilterSection": {
"c3fa13dc2e": "デフォルトのブランチを非表示にする",
@@ -12813,12 +12815,30 @@
"beb2c19173": "未読",
"5651b216c6": "不明なプロジェクト",
"22b22034bc": "スタンドアロン terminal はアクティビティでは使用できません。",
"afdc2139a8": "Agent terminal が閉じられました。続行するには、このワークスペースで新規 terminal を開いてください。"
"afdc2139a8": "Agent terminal が閉じられました。続行するには、このワークスペースで新規 terminal を開いてください。",
"searchSessions": "Search sessions",
"clearSearch": "Clear search",
"filterByStatus": "Filter by status",
"noMatchingSessions": "No agent sessions match."
},
"ActivityTitlebarControls": {
"f915168c8e": "未読",
"d6a8de3934": "エージェント",
"dc708f3eff": "agents を閉じる"
},
"ActivityAgentsCanvas": {
"demoTitle": "Canvas preview (sample data)",
"liveTitle": "Agents canvas",
"demoHint": "No live agents match filters — showing a sample orchestration graph. Start agents to replace this with real data.",
"liveHint": "{{linked}} linked · {{isolated}} isolated · fill = status · stripe = agent",
"empty": "No agent activity to place on the canvas.",
"viewMode": "Agents view mode"
},
"AgentsDrawer": {
"title": "Agents",
"unread": "unread",
"description": "Browse agent sessions by status and open their terminals.",
"close": "Close"
}
},
"confirmation": {
+22 -2
View File
@@ -4059,7 +4059,9 @@
"abc62b6328": "프로젝트 추가",
"87d0064026": "워크스페이스 보드가 하단 바로 옮겨졌습니다",
"a30e34eb5c": "워크스페이스 보드 닫기",
"49f62c5665": "워크스페이스 보드"
"49f62c5665": "워크스페이스 보드",
"agents": "Agents",
"closeAgents": "Close agents"
},
"SidebarWorkspaceFilterSection": {
"c3fa13dc2e": "기본 브랜치 숨기기",
@@ -12813,12 +12815,30 @@
"beb2c19173": "읽지 않음",
"5651b216c6": "알 수 없는 프로젝트",
"22b22034bc": "활동에서는 독립형 terminal을 사용할 수 없습니다.",
"afdc2139a8": "Agent terminal이 닫혔습니다. 계속하려면 이 워크스페이스에서 새 terminal을 여세요."
"afdc2139a8": "Agent terminal이 닫혔습니다. 계속하려면 이 워크스페이스에서 새 terminal을 여세요.",
"searchSessions": "Search sessions",
"clearSearch": "Clear search",
"filterByStatus": "Filter by status",
"noMatchingSessions": "No agent sessions match."
},
"ActivityTitlebarControls": {
"f915168c8e": "읽지 않음",
"d6a8de3934": "에이전트",
"dc708f3eff": "agents 닫기"
},
"ActivityAgentsCanvas": {
"demoTitle": "Canvas preview (sample data)",
"liveTitle": "Agents canvas",
"demoHint": "No live agents match filters — showing a sample orchestration graph. Start agents to replace this with real data.",
"liveHint": "{{linked}} linked · {{isolated}} isolated · fill = status · stripe = agent",
"empty": "No agent activity to place on the canvas.",
"viewMode": "Agents view mode"
},
"AgentsDrawer": {
"title": "Agents",
"unread": "unread",
"description": "Browse agent sessions by status and open their terminals.",
"close": "Close"
}
},
"confirmation": {
+22 -2
View File
@@ -4059,7 +4059,9 @@
"abc62b6328": "添加项目",
"87d0064026": "工作区板已移到底部栏",
"a30e34eb5c": "关闭工作区板",
"49f62c5665": "工作区板"
"49f62c5665": "工作区板",
"agents": "Agents",
"closeAgents": "Close agents"
},
"SidebarWorkspaceFilterSection": {
"c3fa13dc2e": "隐藏默认分支",
@@ -12813,12 +12815,30 @@
"beb2c19173": "未读",
"5651b216c6": "未知项目",
"22b22034bc": "独立终端在活动中不可用。",
"afdc2139a8": "智能体终端关闭。在此工作区中打开一个新终端以继续。"
"afdc2139a8": "智能体终端关闭。在此工作区中打开一个新终端以继续。",
"searchSessions": "Search sessions",
"clearSearch": "Clear search",
"filterByStatus": "Filter by status",
"noMatchingSessions": "No agent sessions match."
},
"ActivityTitlebarControls": {
"f915168c8e": "未读",
"d6a8de3934": "智能体",
"dc708f3eff": "紧密智能体"
},
"ActivityAgentsCanvas": {
"demoTitle": "Canvas preview (sample data)",
"liveTitle": "Agents canvas",
"demoHint": "No live agents match filters — showing a sample orchestration graph. Start agents to replace this with real data.",
"liveHint": "{{linked}} linked · {{isolated}} isolated · fill = status · stripe = agent",
"empty": "No agent activity to place on the canvas.",
"viewMode": "Agents view mode"
},
"AgentsDrawer": {
"title": "Agents",
"unread": "unread",
"description": "Browse agent sessions by status and open their terminals.",
"close": "Close"
}
},
"confirmation": {
+1 -15
View File
@@ -771,28 +771,14 @@ describe('createUISlice hydratePersistedUI', () => {
expect(store.getState().activeView).toBe('terminal')
})
it('drops a persisted activity view when experimental activity is disabled', () => {
it('maps a legacy persisted activity view to terminal (agents is an overlay now)', () => {
const store = createUIStore()
store.setState({
settings: { experimentalActivity: false } as AppState['settings']
})
store.getState().hydratePersistedUI(makePersistedUI({ activeView: 'activity' }), 'startup')
expect(store.getState().activeView).toBe('terminal')
})
it('restores a persisted activity view when experimental activity is enabled', () => {
const store = createUIStore()
store.setState({
settings: { experimentalActivity: true } as AppState['settings']
})
store.getState().hydratePersistedUI(makePersistedUI({ activeView: 'activity' }), 'startup')
expect(store.getState().activeView).toBe('activity')
})
it('restores a default-on view (mobile) even when its nav button is hidden', () => {
const store = createUIStore()
store.setState({
+19 -32
View File
@@ -1,6 +1,10 @@
/* eslint-disable max-lines */
import type { StateCreator } from 'zustand'
import type { AppState } from '../types'
import {
requestCloseAgentsPanel,
requestOpenAgentsPanel
} from '../../components/activity/agents-panel-events'
import { normalizeRightSidebarRoute } from '../right-sidebar-route'
import {
findPrevLiveNonTaskStackHistoryIndex,
@@ -516,19 +520,16 @@ const TOP_LEVEL_VIEW_LOOKUP: Record<TopLevelView, true> = {
}
const KNOWN_TOP_LEVEL_VIEWS = new Set<string>(Object.keys(TOP_LEVEL_VIEW_LOOKUP))
function sanitizeHydratedActiveView(
value: PersistedUIState['activeView'],
experimentalActivityEnabled: boolean
): TopLevelView {
function sanitizeHydratedActiveView(value: PersistedUIState['activeView']): TopLevelView {
// Why: older data (pre-activeView) or a view a different build doesn't have
// falls back to terminal rather than rendering nothing.
if (typeof value !== 'string' || !KNOWN_TOP_LEVEL_VIEWS.has(value)) {
return 'terminal'
}
// Why: activity is hidden when its setting is off, so restoring it lands on a
// hidden page (same guard as closeSettingsPage). mobile/automations stay
// functional when hidden, so only activity is gated here.
if (value === 'activity' && !experimentalActivityEnabled) {
// Why: Agents is a companion overlay (like the workspace board), not a
// full-page activeView. Restore terminal so hydration never lands on a
// removed navigation surface.
if (value === 'activity') {
return 'terminal'
}
return value as TopLevelView
@@ -1447,19 +1448,13 @@ export const createUISlice: StateCreator<AppState, [], [], UISlice> = (set, get)
}
}),
openActivityPage: () => {
if (get().settings?.experimentalActivity !== true) {
return
}
set((state) => ({
activeView: 'activity',
previousViewBeforeActivity:
state.activeView === 'activity' ? state.previousViewBeforeActivity : state.activeView
}))
// Why: Agents is a non-modal companion sheet next to the sidebar (same
// shape as the workspace board), not a full-page activeView swap.
requestOpenAgentsPanel()
},
closeActivityPage: () => {
requestCloseAgentsPanel()
},
closeActivityPage: () =>
set((state) => ({
activeView: state.previousViewBeforeActivity
})),
selectedAutomationId: null,
setSelectedAutomationId: (id) => set({ selectedAutomationId: id }),
pendingAutomationRunNavigation: null,
@@ -1537,14 +1532,9 @@ export const createUISlice: StateCreator<AppState, [], [], UISlice> = (set, get)
}))
},
closeSettingsPage: () =>
set((state) => {
const previousView =
state.previousViewBeforeSettings === 'activity' &&
state.settings?.experimentalActivity !== true
? 'terminal'
: state.previousViewBeforeSettings
return { activeView: previousView }
}),
set((state) => ({
activeView: state.previousViewBeforeSettings
})),
settingsNavigationTarget: null,
openSettingsTarget: (target) => set({ settingsNavigationTarget: target }),
clearSettingsTarget: () => set({ settingsNavigationTarget: null }),
@@ -2587,10 +2577,7 @@ export const createUISlice: StateCreator<AppState, [], [], UISlice> = (set, get)
// runs on every cross-window ui:stateChanged broadcast (source 'sync', the
// default); re-applying activeView there would yank the user's current
// per-window view (navigation state, not a synced preference).
activeView:
source === 'startup'
? sanitizeHydratedActiveView(ui.activeView, s.settings?.experimentalActivity === true)
: s.activeView,
activeView: source === 'startup' ? sanitizeHydratedActiveView(ui.activeView) : s.activeView,
persistedUIReady: true
}
// Why: main rebroadcasts UI written by any client. Identical hydration must
@@ -163,11 +163,9 @@ async function enableInlineAgentCards(page: Page): Promise<void> {
}
async function enableActivityAgentsView(page: Page): Promise<void> {
await page.evaluate(async () => {
const settings = await window.api.settings.set({ experimentalActivity: true })
// Why: these specs exercise the experimental Agents page. E2E profiles use
// production defaults, where the sidebar entry is hidden unless enabled.
window.__store?.setState({ settings })
// Why: Agents is always available as a companion overlay (no experimental gate).
await page.evaluate(() => {
window.__store?.getState().closeActivityPage()
})
}