Files
orca/mobile/src/worktree/worktree-list-snapshot.ts
T
Brennan BensonandNeil ec4687c434 feat(agents): distinguish Claude background monitoring (takes over #14205) (#16201)
* feat(agents): distinguish Claude background monitoring

Adds an optional `workingMode: 'monitoring'` discriminator for a Claude
session whose lead turn finished but which still has background shell tasks
or session crons registered. The wire state stays `working`, so older peers
that never read the field keep rendering Working.

(cherry picked from commit d5d54b4bdd)

Rebased onto current main (554 commits of drift) by Brennan Benson;
conflicts resolved by keeping both sides where main and this branch made
independent additions to the same construct.

* fix(sidebar): keep monitoring status visible

(cherry picked from commit fd6b38654d)

* test(agents): cover Claude monitoring drain

(cherry picked from commit ce4d61ebf8)

* test(mobile): avoid unresolved renderer test type

(cherry picked from commit bbcfa35ff9)

* feat(agents): render Claude monitoring as a static turquoise dot

Replaces the yellow Radio glyph from #14205 with a static dot in a new
--agent-monitoring token (#8abeb7), defined once for light and once for
dark like --workspace-status-done, so the status keeps its identity when
the theme flips. Deliberately a fixed UI value: it never reads terminal
theme state at runtime.

Adds the turn-boundary notification pins. The monitoring predicate and
the turnCompletedAt stamp are computed from the same "lead said done but
the pane resolves to working" expression, so a rename can silently drop
the stamp and kill a completion notification that works today with
nothing else going red.

* revert(agents): restore the yellow Radio glyph for monitoring

Brennan chose #14205's original treatment over the turquoise dot, so the visual
goes back to nwparker's: lucide Radio in text-yellow-500 across the sidebar,
dashboard dot, cmd-j palette and agent-map ring.

Reverts only the visual surface. The turn-boundary notification pins stay — the
monitoring predicate and the turnCompletedAt stamp share an expression, so a
rename can silently drop the stamp and kill a completion that works today with
nothing else going red. The --agent-monitoring token is removed with its last
consumer rather than left dead in main.css.

---------

Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
2026-08-24 15:24:32 -07:00

121 lines
4.3 KiB
TypeScript

import type { RuntimeWorktreeAgentRow } from '../../../src/shared/runtime-types'
import type { Worktree } from './workspace-list-sections'
export function areWorktreeListsEqual(
left: readonly Worktree[],
right: readonly Worktree[]
): boolean {
if (left === right) {
return true
}
if (left.length !== right.length) {
return false
}
for (let index = 0; index < left.length; index += 1) {
if (!areWorktreesEqual(left[index]!, right[index]!)) {
return false
}
}
return true
}
function areWorktreesEqual(left: Worktree, right: Worktree): boolean {
return (
left.worktreeId === right.worktreeId &&
left.repoId === right.repoId &&
left.repo === right.repo &&
left.branch === right.branch &&
(left.hostId ?? null) === (right.hostId ?? null) &&
(left.terminalPlatform ?? null) === (right.terminalPlatform ?? null) &&
left.displayName === right.displayName &&
(left.workspaceStatus ?? null) === (right.workspaceStatus ?? null) &&
(left.sortOrder ?? null) === (right.sortOrder ?? null) &&
(left.manualOrder ?? null) === (right.manualOrder ?? null) &&
(left.lastActivityAt ?? null) === (right.lastActivityAt ?? null) &&
(left.createdAt ?? null) === (right.createdAt ?? null) &&
left.path === right.path &&
(left.isArchived ?? false) === (right.isArchived ?? false) &&
(left.isMainWorktree ?? false) === (right.isMainWorktree ?? false) &&
(left.hasHostSidebarActivity ?? false) === (right.hasHostSidebarActivity ?? false) &&
(left.worktreeInstanceId ?? null) === (right.worktreeInstanceId ?? null) &&
(left.lineageWorktreeInstanceId ?? null) === (right.lineageWorktreeInstanceId ?? null) &&
(left.parentWorktreeInstanceId ?? null) === (right.parentWorktreeInstanceId ?? null) &&
(left.parentWorktreeId ?? null) === (right.parentWorktreeId ?? null) &&
areStringArraysEqual(left.childWorktreeIds ?? [], right.childWorktreeIds ?? []) &&
left.liveTerminalCount === right.liveTerminalCount &&
left.hasAttachedPty === right.hasAttachedPty &&
left.preview === right.preview &&
left.unread === right.unread &&
(left.lastOutputAt ?? null) === (right.lastOutputAt ?? null) &&
left.isPinned === right.isPinned &&
(left.isActive ?? false) === (right.isActive ?? false) &&
(left.linkedIssue ?? null) === (right.linkedIssue ?? null) &&
(left.linkedLinearIssue ?? null) === (right.linkedLinearIssue ?? null) &&
(left.linkedGitLabMR ?? null) === (right.linkedGitLabMR ?? null) &&
(left.linkedGitLabIssue ?? null) === (right.linkedGitLabIssue ?? null) &&
(left.comment ?? '') === (right.comment ?? '') &&
(left.status ?? null) === (right.status ?? null) &&
(left.workingMode ?? null) === (right.workingMode ?? null) &&
arePullRequestsEqual(left.linkedPR, right.linkedPR) &&
areAgentRowsEqual(left.agents ?? [], right.agents ?? [])
)
}
function areStringArraysEqual(left: readonly string[], right: readonly string[]): boolean {
if (left === right) {
return true
}
if (left.length !== right.length) {
return false
}
for (let index = 0; index < left.length; index += 1) {
if (left[index] !== right[index]) {
return false
}
}
return true
}
function arePullRequestsEqual(left: Worktree['linkedPR'], right: Worktree['linkedPR']): boolean {
if (left === right) {
return true
}
if (!left || !right) {
return false
}
return left.number === right.number && left.state === right.state
}
function areAgentRowsEqual(
left: readonly RuntimeWorktreeAgentRow[],
right: readonly RuntimeWorktreeAgentRow[]
): boolean {
if (left === right) {
return true
}
if (left.length !== right.length) {
return false
}
for (let index = 0; index < left.length; index += 1) {
const a = left[index]!
const b = right[index]!
if (
a.paneKey !== b.paneKey ||
a.parentPaneKey !== b.parentPaneKey ||
a.state !== b.state ||
a.workingMode !== b.workingMode ||
a.agentType !== b.agentType ||
a.prompt !== b.prompt ||
a.lastAssistantMessage !== b.lastAssistantMessage ||
a.toolName !== b.toolName ||
a.toolInput !== b.toolInput ||
a.interrupted !== b.interrupted ||
a.stateStartedAt !== b.stateStartedAt ||
a.updatedAt !== b.updatedAt
) {
return false
}
}
return true
}