Repository navigation
feat(sidebar): main keeps the list's time rules on one clock, checked against the window (dark) - #30104
Conversation
… src/shared/sidebar-list Main needs them to own the frozen order. Renderer helpers they depend on move with them; the window imports the shared copies. No behaviour change.
The window's sort memo and the palette's Smart sort now call rankWorktreesForSort, so main can produce the same order from its own records. The pure state-history step moves to shared for the same reason. No behaviour change.
… against the window in dev and test
…ndow begins a session
…al owner behind ORCA_SIDEBAR_INPUTS
… so the snapshot schema compiles out
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f60f0e0e-b3f5-44e0-a9e2-f613f7615e10
⛔ Files ignored due to path filters: 1
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing: 96
config/tsconfig.tc.web.jsonsrc/main/orcad/orcad-entry.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/sidebar-inputs.tssrc/main/runtime/sidebar-inputs/orca-runtime-sidebar-temporal.tssrc/main/runtime/sidebar-inputs/orca-runtime-workspace-activity-facts.tssrc/main/runtime/sidebar-inputs/orca-runtime-workspace-review-facts.tssrc/main/runtime/sidebar-inputs/runtime-smart-sort-sources.test.tssrc/main/runtime/sidebar-inputs/runtime-smart-sort-sources.tssrc/main/runtime/sidebar-inputs/sidebar-clock.test.tssrc/main/runtime/sidebar-inputs/sidebar-clock.tssrc/main/runtime/sidebar-inputs/sidebar-temporal-owner.test.tssrc/main/runtime/sidebar-inputs/sidebar-temporal-owner.tssrc/main/runtime/sidebar-inputs/smart-sort-agent-entries.test.tssrc/main/runtime/sidebar-inputs/smart-sort-agent-entries.tssrc/main/runtime/sidebar-inputs/workspace-activity-facts-producer.test.tssrc/main/runtime/sidebar-inputs/workspace-activity-facts-producer.tssrc/main/startup/main-process-runtime-service.tssrc/renderer/src/components/activity/activity-event-builder-sources.tssrc/renderer/src/components/activity/useActivityUnreadCount.tssrc/renderer/src/components/agent-child-row-text.tssrc/renderer/src/components/cmd-j/palette-live-status.tsxsrc/renderer/src/components/dashboard/DashboardAgentRow.tsxsrc/renderer/src/components/dashboard/agent-row-pane-live-title.tssrc/renderer/src/components/dashboard/dashboard-row-bucket.tssrc/renderer/src/components/dashboard/useDashboardData.tssrc/renderer/src/components/dashboard/worktree-agent-rows-cache.tssrc/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.test.tsxsrc/renderer/src/components/right-sidebar/ai-vault-original-pane.tssrc/renderer/src/components/sidebar/stale-agent-row-unverifiable.test.tssrc/renderer/src/components/sidebar/useWorktreeAgentRows.tssrc/renderer/src/components/sidebar/visible-worktrees.tssrc/renderer/src/components/sidebar/workspace-kanban-worktree-groups.tssrc/renderer/src/components/sidebar/workspace-lineage-menu-actions.tssrc/renderer/src/components/sidebar/workspace-view-evaluator-parity.test.tssrc/renderer/src/components/sidebar/worktree-agent-activity-summary.tssrc/renderer/src/components/sidebar/worktree-agent-rows.tssrc/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsxsrc/renderer/src/components/sidebar/worktree-list/drag/use-status-mutations.tssrc/renderer/src/components/sidebar/worktree-list/listing/use-sleeping-sweep-retention.tssrc/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.main-parity.test.tsxsrc/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.test.tsxsrc/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.tssrc/renderer/src/components/sidebar/worktree-list/listing/use-visible-worktrees.tssrc/renderer/src/components/sidebar/worktree-manual-order-catalog.tssrc/renderer/src/components/sidebar/worktree-sort-label-ordering.test.tssrc/renderer/src/components/sidebar/worktree-subagent-child-rows.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.tssrc/renderer/src/components/status-bar/workspace-space-presentation.tssrc/renderer/src/components/terminal-pane/use-manual-terminal-worktree-parking.tssrc/renderer/src/components/use-worktree-jump-palette-recent-tabs.tssrc/renderer/src/components/use-worktree-jump-palette-worktrees.tssrc/renderer/src/components/worktree-jump-palette-recent-inclusion.test.tssrc/renderer/src/components/worktree-jump-palette-recent-inclusion.tssrc/renderer/src/lib/active-agent-note-target.tssrc/renderer/src/lib/agent-row-dot-state.tssrc/renderer/src/lib/agent-row-stopping-label.tssrc/renderer/src/lib/agent-row-tool-preview.test.tssrc/renderer/src/lib/agent-row-tool-preview.tssrc/renderer/src/lib/agent-status.tssrc/renderer/src/lib/notes-send-agent-targets.tssrc/renderer/src/lib/recent-workspace-tab-rows.test.tssrc/renderer/src/lib/recent-workspace-tab-rows.tssrc/renderer/src/lib/running-agent-targets.tssrc/renderer/src/lib/sidebar-list-session.tssrc/renderer/src/lib/sidebar-shadow/sidebar-temporal-shadow.tssrc/renderer/src/lib/sidebar-shadow/window-sidebar-temporal-readout.tssrc/renderer/src/lib/sidebar-shadow/workspace-activity-shadow.tssrc/renderer/src/lib/web-runtime-worktree-terminal-after-wake.tssrc/renderer/src/lib/worktree-activity-state.tssrc/renderer/src/lib/worktree-status.tssrc/renderer/src/main.tsxsrc/renderer/src/store/slices/agent-status-live-entry-builder.tssrc/renderer/src/store/slices/agent-status-live-facts.tssrc/renderer/src/store/slices/agent-status-runtime-orchestration.test.tssrc/renderer/src/store/slices/agent-status-verdict-copies.test.tssrc/renderer/src/store/slices/store-active-worktree-selection.test.tssrc/renderer/src/store/slices/worktrees/session/set-active-worktree.tssrc/renderer/src/store/terminals/terminal-exited-pane-liveness.test.tssrc/shared/agent-row-decay-state.tssrc/shared/agent-status-live-entry-state-history.tssrc/shared/host-operation-ownership.tssrc/shared/migration-unsupported-agent-entry.test.tssrc/shared/migration-unsupported-agent-entry.tssrc/shared/rpc-contract/sidebar-session-params.tssrc/shared/runtime-pane-title-leaf-id.test.tssrc/shared/runtime-pane-title-leaf-id.tssrc/shared/sidebar-list/sidebar-temporal-snapshot.tssrc/shared/sidebar-list/smart-attention-host-observed-end.test.tssrc/shared/sidebar-list/smart-attention.test.tssrc/shared/sidebar-list/smart-attention.tssrc/shared/sidebar-list/smart-sort-agent-change.tssrc/shared/sidebar-list/smart-sort.test.tssrc/shared/sidebar-list/smart-sort.tssrc/shared/tab-has-live-pty.test.tssrc/shared/tab-has-live-pty.ts
💤 Files with no reviewable changes: 1
- src/main/runtime/sidebar-inputs/orca-runtime-workspace-review-facts.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| override syncWindowGraph(...args: Parameters<Runtime['syncWindowGraph']>) { | ||
| if (!this.sidebarTemporal.running) { | ||
| return super.syncWindowGraph(...args) | ||
| } | ||
| const before = this.readSidebarGraphSortCauses() | ||
| const result = super.syncWindowGraph(...args) | ||
| const after = this.readSidebarGraphSortCauses() | ||
| // A title's reading counts both ways; a tab only re-sorts when it gains its first terminal. | ||
| const resorts = (key: string): boolean => | ||
| key.startsWith('title:') | ||
| ? (before.get(key) ?? '') !== (after.get(key) ?? '') | ||
| : after.has(key) && !before.has(key) | ||
| if ([...new Set([...before.keys(), ...after.keys()])].some(resorts)) { | ||
| this.sidebarTemporal.noteSortInputChange() | ||
| } | ||
| return result | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n 'noteSortInputChange|noteRowsChange|syncWindowGraph|readSidebarGraphSortCauses|onWorktree|onChange' src/main/runtime/sidebar-inputs/orca-runtime-sidebar-temporal.ts src/main/runtime/sidebar-inputs/orca-runtime-workspace-activity-facts.ts src/main/runtime/sidebar-inputs/sidebar-temporal-owner.ts
sed -n '1,173p' src/main/runtime/sidebar-inputs/orca-runtime-sidebar-temporal.tsRepository: stablyai/orca
Length of output: 9432
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- notification and graph references ---'
rg -n -F --glob '*.ts' -e 'noteSortInputChange' -e 'noteRowsChange' -e 'syncWindowGraph' -e 'buildRuntimeSmartSortSources' -e 'SmartSort' src | sed -n '1,260p'
printf '%s\n' '--- relevant sidebar input files ---'
rg --files src | rg 'sidebar.*(sort|input|temporal)|smart-sort|workspace-activity|runtime.*sidebar'
printf '%s\n' '--- shared smart sort and renderer response candidates ---'
rg -n -F --glob '*.ts' -e 'sortEpoch' -e 'getSidebarTemporalSnapshot' -e 'SidebarSort' -e 'smartSort' -e 'Smart' src/shared src/renderer src/main 2>/dev/null | sed -n '1,320p'
printf '%s\n' '--- graph method declarations and direct calls ---'
rg -n -F --glob '*.ts' -e 'syncWindowGraph(' src | sed -n '1,220p'Repository: stablyai/orca
Length of output: 41594
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- shared smart sort files ---'
sed -n '1,280p' src/shared/sidebar-list/smart-sort.ts
sed -n '1,240p' src/shared/sidebar-list/smart-sort-phase.ts
sed -n '1,280p' src/main/runtime/sidebar-inputs/runtime-smart-sort-sources.ts
printf '%s\n' '--- temporal owner ---'
sed -n '1,220p' src/main/runtime/sidebar-inputs/sidebar-temporal-owner.ts
printf '%s\n' '--- renderer sidebar temporal/sort references ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'sortEpoch' -e 'beginSidebarListSession' -e 'getSidebarTemporalSnapshot' -e 'sidebarTemporal' -e 'syncWindowGraph' src/renderer src/shared | sed -n '1,260p'
printf '%s\n' '--- renderer agent live facts ---'
sed -n '1,180p' src/renderer/src/store/slices/agent-status-live-facts.ts
printf '%s\n' '--- runtime graph implementation and callers outside tests ---'
rg -n -F --glob '*.ts' -g '!**/*.test.ts' -g '!**/*.spec.ts' -e 'syncWindowGraph' -e 'new OrcaRuntimeWithSidebarTemporal' -e 'sidebarFactsRuntime' src/main src/renderer src/preload | sed -n '1,240p'Repository: stablyai/orca
Length of output: 41908
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- smart attention PTY semantics ---'
rg -n -F --glob '*.ts' -e 'function buildAttentionByWorktree' -e 'ptyIdsByTabId' -e 'tabHasLivePty' -e 'live' src/shared/sidebar-list/smart-attention.ts src/shared/tab-has-live-pty.ts
sed -n '1,300p' src/shared/sidebar-list/smart-attention.ts
printf '%s\n' '--- temporal owner apply and snapshot path ---'
sed -n '180,340p' src/main/runtime/sidebar-inputs/sidebar-temporal-owner.ts
printf '%s\n' '--- renderer graph publication ---'
sed -n '160,235p' src/renderer/src/runtime/sync-runtime-graph/graph-publication.ts
printf '%s\n' '--- exact temporal notification call inventory ---'
rg -n -F --glob '*.ts' -g '!**/*.test.ts' -g '!**/*.spec.ts' -e 'noteSortInputChange(' -e 'noteRowsChange(' src/main src/renderer src/shared | sed -n '1,180p'Repository: stablyai/orca
Length of output: 22406
Notify the temporal owner for every live-PTY transition.
The shared Smart ranking uses live PTY presence for every worktree. A stale agent entry can rank as Class 4 while its PTY is live and Class 5 after the PTY disappears. readSidebarGraphSortCauses() tracks PTYs only for the active worktree, and the non-title comparison detects only additions. A non-active worktree PTY can therefore appear or disappear without noteSortInputChange(), leaving main’s Smart snapshot stale until another change.
Suggested fix
- const resorts = (key: string): boolean =>
- key.startsWith('title:')
- ? (before.get(key) ?? '') !== (after.get(key) ?? '')
- : after.has(key) && !before.has(key)
+ const resorts = (key: string): boolean =>
+ key.startsWith('title:')
+ ? (before.get(key) ?? '') !== (after.get(key) ?? '')
+ : before.has(key) !== after.has(key)
@@
- if (leaf.worktreeId === active) {
- if (leaf.ptyId) {
- causes.set(`pty:${leaf.tabId}`, 'live')
- }
- } else if (leaf.paneTitle) {
+ if (leaf.ptyId) {
+ causes.set(`pty:${leaf.tabId}`, 'live')
+ }
+ if (leaf.worktreeId !== active && leaf.paneTitle) {
causes.set(
`title:${leaf.tabId}:${leaf.paneRuntimeId}`,
detectAgentStatusFromTitle(leaf.paneTitle) ?? ''
)
}
ELI5
The sidebar list makes a few decisions based on time: it waits three seconds after a burst of changes before re-sorting, it remembers whether Smart sort has seen any agent activity yet, and it briefly keeps a "sleeping" workspace visible while its terminal reconnects. Today only the desktop window makes these decisions. This PR teaches Orca's background process to make the same decisions on one shared timer. In builds with the new sidebar switch on, it checks its answers against the window's. Nothing you see changes.
What Changed
src/shared/sidebar-list/. The window now sorts through one shared function,rankWorktreesForSort, and its rule for which agent status changes restart the settle window is now shared as well. The goldens are byte-identical.ORCA_SIDEBAR_INPUTS=main, dev and test only):src/main/runtime/sidebar-inputs/sidebar-clock.tsis one timer queue, keyed by deadline. Settle, retention expiry, the create-grace boundary and agent freshness each hold at most one deadline there. The activity-facts producer's own freshness timer (feat(sidebar): main produces per-workspace activity facts, checked against the window in dev and test #29980) moved onto it.sidebar-temporal-owner.tsproducessortSnapshot { mode, epoch, sampledAt, rankedIds, smartLatched, cause }with host-qualified ids, andretention { retainedIds, retentionDecidedAt }. It reuses the shared reducers from refactor(sidebar): move the sidebar's time rules into shared pure reducers #29943 and the moved comparator. It never saves ranks.orca-runtime-sidebar-temporal.tsfeeds it from what main already has: hook-store rows, graph syncs (pane-title readings and a tab's first terminal), catalog change events, view settings, and the activity facts. The settle window restarts only where the window's own sort counter would bump.sidebarSession.begin, and main resets the latch and the retention to cold. This keeps today's reset-on-unmount. Main serves no ranks for the new session until its first sample lands. A paired web client never resets the host's session.sidebarInputs.temporal(read) andsidebarSession.begin. Both are registered only with the switch on, and both are host-owned in the ownership map.sidebar-temporalcompares main's ranks and retention with the window's own, for locally owned rows only. It already caught one real bug: main read the wrong Hide sleeping field. That is fixed here.Why
Main has to own these decisions before a phone can draw the same list from main's inputs (design section 2). Running them in shadow first shows any disagreement before anything depends on them. One deadline queue keeps the timers in one place, so each fire is easy to reason about. I chose moving the comparator over keeping a second copy in main, because two copies would drift.
Linked Issue
N/A (internal series; design PR 6)
Visual Proof
N/A. No visible change: switch-off builds compile the new code out, and switch-on builds only compare.
Testing
Unit:
sidebar-clock.test.ts,sidebar-temporal-owner.test.ts(settle burst, structural settle, mode switch, latch and reset on a new session, create-grace boundary, superseded sample, retention through a gap and on its own deadline, idle before begin and after dispose),smart-sort-agent-entries.test.ts,runtime-smart-sort-sources.test.ts.Parity:
use-sort-order.main-parity.test.tsxruns the real window hooks and main's owner on one fake clock: a Recent burst settles at the same moment to the same order, Smart latches on the same signal and both go cold on remount, and the same sleeping rows are kept and released.Hidden-app e2e with the switch on (
ORCA_BACKGROUND_LAUNCH=1, CDP only): sidebar-agent-row-identity, sidebar-folder-keyboard-navigation, sidebar-measured-row-scroll, sidebar-review-facts, paired-server-rows-shadow, and paired-mobile-desktop-mirror-workspace-visibility. All pass with 0 shadow mismatches. Positive control (not committed): reversing main's ranks is caught as asidebar-temporalmismatch.Switch-off build: no owner, clock, RPC handler or ranking code ships. The only leftover is an unused zod schema declaration in the renderer, the same as the desktop-facts schema today.
Cost at settle with 423 rows (main, synchronous part): Smart p50 0.34 ms and p99 2.0 ms; Recent p50 0.10 ms; one retention pass 0.06 ms. The rows themselves come from the existing 1 s worktree listing cache.
pnpm tc, changed-code quality gate, focus-read ratchet, RPC catalog check and oxfmt all pass. The local failures that remain also fail on the base commit:node:sqliteis missing in the local test runner.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
An Opus elegance and bug review ran on the diff, and a second one on the fix delta. Findings applied: the owner stays idle until a session begins; a repo change re-sorts at once, as the window does; create-grace samples are marked so the shadow skips them; retention ids are always host-qualified; the begin RPC goes through a runtime method. Not applied: resetting the settle state on begin, because the window keeps its settle state in the store across remounts.
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)