Skip to content

feat(sidebar): main keeps the list's time rules on one clock, checked against the window (dark) - #30104

Merged
Jinwoo-H merged 12 commits into
mainfrom
jinwoo/sidebar-main-timers
Oct 17, 2026
Merged

Jinwoo-H merged 12 commits into
mainfrom
jinwoo/sidebar-main-timers

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 24 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​652 $\color{#cf222e}{\Huge{\mathbf{−}}}$​25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​627
Prod 73 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1176 $\color{#cf222e}{\Huge{\mathbf{−}}}$​241 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​935

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

  • Before: the window owns the three-second settle, the Smart "has seen a live signal" latch, the sleeping-workspace grace, and the "Recent" grace for new workspaces. A phone or a second device would have to keep its own clock and could reach a different order.
  • After (normal builds): behaviour is exactly as before. The new background code is compiled out. The only live changes are pure moves: the Smart comparator and attention scoring, plus the small helpers they use, move from the renderer into 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.
  • After (builds with ORCA_SIDEBAR_INPUTS=main, dev and test only):
    • src/main/runtime/sidebar-inputs/sidebar-clock.ts is 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.ts produces sortSnapshot { mode, epoch, sampledAt, rankedIds, smartLatched, cause } with host-qualified ids, and retention { 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.
    • The runtime layer orca-runtime-sidebar-temporal.ts feeds 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.
    • Mounting the list sends 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.
    • When a new workspace's five-minute "Recent" grace ends, main re-sorts at that moment. This fixes the known quirk where nothing re-sorted then. It happens only with the switch on, and the shadow check skips those re-sorts.
    • New RPCs: sidebarInputs.temporal (read) and sidebarSession.begin. Both are registered only with the switch on, and both are host-owned in the ownership map.
    • Shadow check: sidebar-temporal compares 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.tsx runs 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 a sidebar-temporal mismatch.

  • 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:sqlite is 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH: rows without a stamped host take their repo's execution host, so the same id on two hosts never collides.
  • Folder workspaces go through the same listing.
  • Paired-server rows are left out of the comparison; their host owns them.
  • Known gaps for the cutover PR:
    • Main cannot tell a terminal started by activating a workspace from any other first terminal, so it may re-sort where the window does not.
    • Window-only metadata writes, such as activity stamps, reach main's next sample but do not restart its settle window.
    • There is one session per host: the last window to mount its list owns it.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

… 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.
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ca802e7e-8563-4c4f-9e92-b13c90fbd2b1
📥 Commits

Reviewing files that changed from the base of the PR and between 266c539 and 6e37e94.

⛔ Files ignored due to path filters: 1
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing: 96
  • config/tsconfig.tc.web.json
  • src/main/orcad/orcad-entry.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/sidebar-inputs.ts
  • 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/orca-runtime-workspace-review-facts.ts
  • src/main/runtime/sidebar-inputs/runtime-smart-sort-sources.test.ts
  • src/main/runtime/sidebar-inputs/runtime-smart-sort-sources.ts
  • src/main/runtime/sidebar-inputs/sidebar-clock.test.ts
  • src/main/runtime/sidebar-inputs/sidebar-clock.ts
  • src/main/runtime/sidebar-inputs/sidebar-temporal-owner.test.ts
  • src/main/runtime/sidebar-inputs/sidebar-temporal-owner.ts
  • src/main/runtime/sidebar-inputs/smart-sort-agent-entries.test.ts
  • src/main/runtime/sidebar-inputs/smart-sort-agent-entries.ts
  • src/main/runtime/sidebar-inputs/workspace-activity-facts-producer.test.ts
  • src/main/runtime/sidebar-inputs/workspace-activity-facts-producer.ts
  • src/main/startup/main-process-runtime-service.ts
  • src/renderer/src/components/activity/activity-event-builder-sources.ts
  • src/renderer/src/components/activity/useActivityUnreadCount.ts
  • src/renderer/src/components/agent-child-row-text.ts
  • src/renderer/src/components/cmd-j/palette-live-status.tsx
  • src/renderer/src/components/dashboard/DashboardAgentRow.tsx
  • src/renderer/src/components/dashboard/agent-row-pane-live-title.ts
  • src/renderer/src/components/dashboard/dashboard-row-bucket.ts
  • src/renderer/src/components/dashboard/useDashboardData.ts
  • src/renderer/src/components/dashboard/worktree-agent-rows-cache.ts
  • src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.test.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-original-pane.ts
  • src/renderer/src/components/sidebar/stale-agent-row-unverifiable.test.ts
  • src/renderer/src/components/sidebar/useWorktreeAgentRows.ts
  • src/renderer/src/components/sidebar/visible-worktrees.ts
  • src/renderer/src/components/sidebar/workspace-kanban-worktree-groups.ts
  • src/renderer/src/components/sidebar/workspace-lineage-menu-actions.ts
  • src/renderer/src/components/sidebar/workspace-view-evaluator-parity.test.ts
  • src/renderer/src/components/sidebar/worktree-agent-activity-summary.ts
  • src/renderer/src/components/sidebar/worktree-agent-rows.ts
  • src/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsx
  • src/renderer/src/components/sidebar/worktree-list/drag/use-status-mutations.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-sleeping-sweep-retention.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.main-parity.test.tsx
  • src/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.test.tsx
  • src/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-visible-worktrees.ts
  • src/renderer/src/components/sidebar/worktree-manual-order-catalog.ts
  • src/renderer/src/components/sidebar/worktree-sort-label-ordering.test.ts
  • src/renderer/src/components/sidebar/worktree-subagent-child-rows.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/components/status-bar/workspace-space-presentation.ts
  • src/renderer/src/components/terminal-pane/use-manual-terminal-worktree-parking.ts
  • src/renderer/src/components/use-worktree-jump-palette-recent-tabs.ts
  • src/renderer/src/components/use-worktree-jump-palette-worktrees.ts
  • src/renderer/src/components/worktree-jump-palette-recent-inclusion.test.ts
  • src/renderer/src/components/worktree-jump-palette-recent-inclusion.ts
  • src/renderer/src/lib/active-agent-note-target.ts
  • src/renderer/src/lib/agent-row-dot-state.ts
  • src/renderer/src/lib/agent-row-stopping-label.ts
  • src/renderer/src/lib/agent-row-tool-preview.test.ts
  • src/renderer/src/lib/agent-row-tool-preview.ts
  • src/renderer/src/lib/agent-status.ts
  • src/renderer/src/lib/notes-send-agent-targets.ts
  • src/renderer/src/lib/recent-workspace-tab-rows.test.ts
  • src/renderer/src/lib/recent-workspace-tab-rows.ts
  • src/renderer/src/lib/running-agent-targets.ts
  • src/renderer/src/lib/sidebar-list-session.ts
  • src/renderer/src/lib/sidebar-shadow/sidebar-temporal-shadow.ts
  • src/renderer/src/lib/sidebar-shadow/window-sidebar-temporal-readout.ts
  • src/renderer/src/lib/sidebar-shadow/workspace-activity-shadow.ts
  • src/renderer/src/lib/web-runtime-worktree-terminal-after-wake.ts
  • src/renderer/src/lib/worktree-activity-state.ts
  • src/renderer/src/lib/worktree-status.ts
  • src/renderer/src/main.tsx
  • src/renderer/src/store/slices/agent-status-live-entry-builder.ts
  • src/renderer/src/store/slices/agent-status-live-facts.ts
  • src/renderer/src/store/slices/agent-status-runtime-orchestration.test.ts
  • src/renderer/src/store/slices/agent-status-verdict-copies.test.ts
  • src/renderer/src/store/slices/store-active-worktree-selection.test.ts
  • src/renderer/src/store/slices/worktrees/session/set-active-worktree.ts
  • src/renderer/src/store/terminals/terminal-exited-pane-liveness.test.ts
  • src/shared/agent-row-decay-state.ts
  • src/shared/agent-status-live-entry-state-history.ts
  • src/shared/host-operation-ownership.ts
  • src/shared/migration-unsupported-agent-entry.test.ts
  • src/shared/migration-unsupported-agent-entry.ts
  • src/shared/rpc-contract/sidebar-session-params.ts
  • src/shared/runtime-pane-title-leaf-id.test.ts
  • src/shared/runtime-pane-title-leaf-id.ts
  • src/shared/sidebar-list/sidebar-temporal-snapshot.ts
  • src/shared/sidebar-list/smart-attention-host-observed-end.test.ts
  • src/shared/sidebar-list/smart-attention.test.ts
  • src/shared/sidebar-list/smart-attention.ts
  • src/shared/sidebar-list/smart-sort-agent-change.ts
  • src/shared/sidebar-list/smart-sort.test.ts
  • src/shared/sidebar-list/smart-sort.ts
  • src/shared/tab-has-live-pty.test.ts
  • src/shared/tab-has-live-pty.ts
💤 Files with no reviewable changes: 3
  • src/shared/tab-has-live-pty.ts
  • src/main/runtime/sidebar-inputs/orca-runtime-workspace-review-facts.ts
  • src/shared/tab-has-live-pty.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

📝 Walkthrough

The change adds shared sidebar ranking and attention logic, plus a main-process temporal owner that publishes sort and sleeping-workspace retention snapshots. New RPC methods begin sidebar sessions and read snapshots. The renderer starts sessions, records sort and retention state, and compares it with Main snapshots. Tests cover deadline scheduling, sorting, retention, and parity. Several imports now resolve through shared modules.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 6e37e

This change adds a dev/test-only sidebar timing owner that is compiled out when the switch is off. Normal builds should behave as before, and no concrete merge-blocking risk was found.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 50 files. (43 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: moving sidebar timing rules to a shared main-process clock and checking them against the window. The parenthetical qualifier is slightly informal but rema…
Description check Passed The description includes all required sections and gives clear scope, rationale, implementation details, testing evidence, known gaps, and checklist completion. The Linked Issue section explains that …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title clearly identifies the main change: moving sidebar timing rules to a shared main-process clock and checking them against the window. The parenthetical qualifier is slightly informal but remains relevant.

Full details: Description check

Explanation

The description includes all required sections and gives clear scope, rationale, implementation details, testing evidence, known gaps, and checklist completion. The Linked Issue section explains that this is an internal series, which matches the template's maintainer exception.

Full details: Docstring Coverage

Explanation

Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 50 files. (43 skipped: 1 unsupported, 42 over the file limit.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f60f0e0e-b3f5-44e0-a9e2-f613f7615e10
📥 Commits

Reviewing files that changed from the base of the PR and between 6fcc183 and 266c539.

⛔ Files ignored due to path filters: 1
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing: 96
  • config/tsconfig.tc.web.json
  • src/main/orcad/orcad-entry.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/sidebar-inputs.ts
  • 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/orca-runtime-workspace-review-facts.ts
  • src/main/runtime/sidebar-inputs/runtime-smart-sort-sources.test.ts
  • src/main/runtime/sidebar-inputs/runtime-smart-sort-sources.ts
  • src/main/runtime/sidebar-inputs/sidebar-clock.test.ts
  • src/main/runtime/sidebar-inputs/sidebar-clock.ts
  • src/main/runtime/sidebar-inputs/sidebar-temporal-owner.test.ts
  • src/main/runtime/sidebar-inputs/sidebar-temporal-owner.ts
  • src/main/runtime/sidebar-inputs/smart-sort-agent-entries.test.ts
  • src/main/runtime/sidebar-inputs/smart-sort-agent-entries.ts
  • src/main/runtime/sidebar-inputs/workspace-activity-facts-producer.test.ts
  • src/main/runtime/sidebar-inputs/workspace-activity-facts-producer.ts
  • src/main/startup/main-process-runtime-service.ts
  • src/renderer/src/components/activity/activity-event-builder-sources.ts
  • src/renderer/src/components/activity/useActivityUnreadCount.ts
  • src/renderer/src/components/agent-child-row-text.ts
  • src/renderer/src/components/cmd-j/palette-live-status.tsx
  • src/renderer/src/components/dashboard/DashboardAgentRow.tsx
  • src/renderer/src/components/dashboard/agent-row-pane-live-title.ts
  • src/renderer/src/components/dashboard/dashboard-row-bucket.ts
  • src/renderer/src/components/dashboard/useDashboardData.ts
  • src/renderer/src/components/dashboard/worktree-agent-rows-cache.ts
  • src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.test.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-original-pane.ts
  • src/renderer/src/components/sidebar/stale-agent-row-unverifiable.test.ts
  • src/renderer/src/components/sidebar/useWorktreeAgentRows.ts
  • src/renderer/src/components/sidebar/visible-worktrees.ts
  • src/renderer/src/components/sidebar/workspace-kanban-worktree-groups.ts
  • src/renderer/src/components/sidebar/workspace-lineage-menu-actions.ts
  • src/renderer/src/components/sidebar/workspace-view-evaluator-parity.test.ts
  • src/renderer/src/components/sidebar/worktree-agent-activity-summary.ts
  • src/renderer/src/components/sidebar/worktree-agent-rows.ts
  • src/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsx
  • src/renderer/src/components/sidebar/worktree-list/drag/use-status-mutations.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-sleeping-sweep-retention.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.main-parity.test.tsx
  • src/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.test.tsx
  • src/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-visible-worktrees.ts
  • src/renderer/src/components/sidebar/worktree-manual-order-catalog.ts
  • src/renderer/src/components/sidebar/worktree-sort-label-ordering.test.ts
  • src/renderer/src/components/sidebar/worktree-subagent-child-rows.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/components/status-bar/workspace-space-presentation.ts
  • src/renderer/src/components/terminal-pane/use-manual-terminal-worktree-parking.ts
  • src/renderer/src/components/use-worktree-jump-palette-recent-tabs.ts
  • src/renderer/src/components/use-worktree-jump-palette-worktrees.ts
  • src/renderer/src/components/worktree-jump-palette-recent-inclusion.test.ts
  • src/renderer/src/components/worktree-jump-palette-recent-inclusion.ts
  • src/renderer/src/lib/active-agent-note-target.ts
  • src/renderer/src/lib/agent-row-dot-state.ts
  • src/renderer/src/lib/agent-row-stopping-label.ts
  • src/renderer/src/lib/agent-row-tool-preview.test.ts
  • src/renderer/src/lib/agent-row-tool-preview.ts
  • src/renderer/src/lib/agent-status.ts
  • src/renderer/src/lib/notes-send-agent-targets.ts
  • src/renderer/src/lib/recent-workspace-tab-rows.test.ts
  • src/renderer/src/lib/recent-workspace-tab-rows.ts
  • src/renderer/src/lib/running-agent-targets.ts
  • src/renderer/src/lib/sidebar-list-session.ts
  • src/renderer/src/lib/sidebar-shadow/sidebar-temporal-shadow.ts
  • src/renderer/src/lib/sidebar-shadow/window-sidebar-temporal-readout.ts
  • src/renderer/src/lib/sidebar-shadow/workspace-activity-shadow.ts
  • src/renderer/src/lib/web-runtime-worktree-terminal-after-wake.ts
  • src/renderer/src/lib/worktree-activity-state.ts
  • src/renderer/src/lib/worktree-status.ts
  • src/renderer/src/main.tsx
  • src/renderer/src/store/slices/agent-status-live-entry-builder.ts
  • src/renderer/src/store/slices/agent-status-live-facts.ts
  • src/renderer/src/store/slices/agent-status-runtime-orchestration.test.ts
  • src/renderer/src/store/slices/agent-status-verdict-copies.test.ts
  • src/renderer/src/store/slices/store-active-worktree-selection.test.ts
  • src/renderer/src/store/slices/worktrees/session/set-active-worktree.ts
  • src/renderer/src/store/terminals/terminal-exited-pane-liveness.test.ts
  • src/shared/agent-row-decay-state.ts
  • src/shared/agent-status-live-entry-state-history.ts
  • src/shared/host-operation-ownership.ts
  • src/shared/migration-unsupported-agent-entry.test.ts
  • src/shared/migration-unsupported-agent-entry.ts
  • src/shared/rpc-contract/sidebar-session-params.ts
  • src/shared/runtime-pane-title-leaf-id.test.ts
  • src/shared/runtime-pane-title-leaf-id.ts
  • src/shared/sidebar-list/sidebar-temporal-snapshot.ts
  • src/shared/sidebar-list/smart-attention-host-observed-end.test.ts
  • src/shared/sidebar-list/smart-attention.test.ts
  • src/shared/sidebar-list/smart-attention.ts
  • src/shared/sidebar-list/smart-sort-agent-change.ts
  • src/shared/sidebar-list/smart-sort.test.ts
  • src/shared/sidebar-list/smart-sort.ts
  • src/shared/tab-has-live-pty.test.ts
  • src/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.

Comment on lines +88 to +104
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
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.ts

Repository: 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) ?? ''
         )
       }

@Jinwoo-H
Jinwoo-H merged commit a039e90 into main Oct 17, 2026
88 of 90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant