Repository navigation
feat(sidebar): the desktop window lists main's sidebar inputs behind the build switch (dark) - #30461
Conversation
…ts own writes shown until main does (dark) Co-Authored-By: Claude <[email protected]>
…old the stamped record, writes name their host (dark) Co-Authored-By: Claude <[email protected]>
…del it moved into (dark)
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
…p-reads-main # Conflicts: # src/renderer/src/main.tsx
…p-reads-main # Conflicts: # config/focus-setting-read-baseline.txt
…pell at once, not 50 ms later (dark)
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:
4b39e10e-2dde-42fd-8b8e-0be1c0c48c9d
📒 Files selected for processing: 8
config/focus-setting-read-baseline.txtsrc/main/runtime/rpc/methods/sidebar-inputs.tssrc/renderer/src/lib/sidebar-shadow/window-unread-decisions.tssrc/renderer/src/lib/sidebar-shadow/workspace-unread-shadow.tssrc/renderer/src/main.tsxsrc/renderer/src/store/slices/workspace-attention/workspace-attention-slice.tssrc/renderer/src/store/slices/workspace-attention/workspace-unread-flag.tstests/e2e/sidebar-host-unread.spec.ts
💤 Files with no reviewable changes: 4
- src/renderer/src/lib/sidebar-shadow/workspace-unread-shadow.ts
- src/renderer/src/store/slices/workspace-attention/workspace-attention-slice.ts
- src/renderer/src/main.tsx
- src/renderer/src/lib/sidebar-shadow/window-unread-decisions.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.
| 1 src/renderer/src/components/sidebar/worktree-filter-visibility.ts | ||
| 1 src/renderer/src/components/sidebar/worktree-list/listing/use-filters.ts | ||
| 1 src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts | ||
| 1 src/renderer/src/components/sidebar/worktree-list/listing/use-window-list-model.ts |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect the ratchet rules and the model's setting reads or called helpers.
rg -n -C 2 'focus-read-ratchet' . || true
sed -n '1,100p' src/renderer/src/components/sidebar/worktree-list/listing/use-window-list-model.ts
rg -n -C 2 'activeRuntimeEnvironmentId' src/renderer/src/components/sidebar/worktree-list/listing || trueRepository: stablyai/orca
Length of output: 8176
🏁 Script executed:
#!/bin/bash
set -o pipefail
printf '%s\n' '--- ratchet scanner ---'
sed -n '1,260p' config/scripts/check-focus-read-ratchet.mjs
printf '%s\n' '--- baseline entry and diff ---'
nl -ba config/focus-setting-read-baseline.txt | sed -n '185,198p'
git diff --no-ext-diff --unified=8 1ad8755fa809bdae29c7dfef7c34f552edab9452 7c2bff99d98159a0c6c655280214864de7d03412 -- config/focus-setting-read-baseline.txt
printf '%s\n' '--- called helper definitions/imports ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'useSidebarSectionRows' -e 'useSidebarWorktreeSortOrder' -e 'useVisibleSidebarWorktrees' -e 'useSidebarHostVisibleScope' -e 'useSidebarExternalWorktreeCards' -e 'useOrderHeldWhileEngaged' src/renderer/src/components/sidebar/worktree-list
printf '%s\n' '--- setting references in renderer ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -- 'activeRuntimeEnvironmentId' src/renderer/src | head -200Repository: stablyai/orca
Length of output: 41390
🏁 Script executed:
#!/bin/bash
set -o pipefail
printf '%s\n' '--- ratchet discovery and counting ---'
sed -n '250,470p' config/scripts/check-focus-read-ratchet.mjs
printf '%s\n' '--- relevant helper files: imports and declarations ---'
for f in \
src/renderer/src/components/sidebar/worktree-list/listing/use-window-list-model.ts \
src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts \
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-list/listing/use-host-visible-scope.ts \
src/renderer/src/components/sidebar/worktree-list/listing/use-external-worktree-cards.ts \
src/renderer/src/components/sidebar/worktree-list/listing/use-order-hold.ts
do
printf '\n--- %s ---\n' "$f"
rg -n -F \
-e 'activeRuntimeEnvironmentId' \
-e 'defaultScopeHost' \
-e 'defaultScopeSource' \
-e 'defaultCreationHost' \
-e 'rowLessSourceTarget' \
-e 'getActiveRuntimeTarget' \
-e 'legacyRouteFromSettings' \
-e 'settingsForRuntimeOwner' \
-e 'export function' \
-e 'export const' \
"$f" || test "$?" -eq 1
doneRepository: stablyai/orca
Length of output: 8352
🏁 Script executed:
#!/bin/bash
set -o pipefail
printf '%s\n' '--- listing imports and relevant calls ---'
rg -n -E '^(import|export)|ORCA_SIDEBAR_INPUTS|useAppStore|use[A-Z][A-Za-z0-9_]*\(' \
src/renderer/src/components/sidebar/worktree-list/listing \
--glob '*.ts' --glob '*.tsx' || test "$?" -eq 1
printf '%s\n' '--- selected implementation files ---'
rg -n -C 3 -E 'useSidebarWorktreeSortOrder|useMainSidebarWorktreeSortOrder|useWindowSidebarWorktreeSortOrder|activeRuntimeEnvironmentId|defaultScopeHost|defaultScopeSource|defaultCreationHost|rowLessSourceTarget' \
src/renderer/src/components/sidebar/worktree-list \
--glob '*.ts' --glob '*.tsx' || test "$?" -eq 1Repository: stablyai/orca
Length of output: 630
🏁 Script executed:
#!/bin/bash
set -o pipefail
printf '%s\n' '--- listing imports and relevant calls ---'
rg -n -e '^(import|export)' -e 'ORCA_SIDEBAR_INPUTS' -e 'useAppStore' -e 'use[A-Z][A-Za-z0-9_]*\(' \
src/renderer/src/components/sidebar/worktree-list/listing \
--glob '*.ts' --glob '*.tsx' || test "$?" -eq 1
printf '%s\n' '--- selected implementation files ---'
rg -n -C 3 -e 'useSidebarWorktreeSortOrder' -e 'useMainSidebarWorktreeSortOrder' -e 'useWindowSidebarWorktreeSortOrder' -e 'activeRuntimeEnvironmentId' -e 'defaultScopeHost' -e 'defaultScopeSource' -e 'defaultCreationHost' -e 'rowLessSourceTarget' \
src/renderer/src/components/sidebar/worktree-list \
--glob '*.ts' --glob '*.tsx' || test "$?" -eq 1Repository: stablyai/orca
Length of output: 41397
🏁 Script executed:
#!/bin/bash
set -o pipefail
printf '%s\n' '--- sort-order module ---'
nl -ba src/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.ts | sed -n '1,135p'
printf '%s\n' '--- sort-order implementation bindings ---'
rg -n -C 8 -e 'useStampSidebarWorktreeSortOrder' -e 'useSettledSidebarWorktreeSortOrder' \
src/renderer/src/components/sidebar/worktree-list \
--glob '*.ts' --glob '*.tsx' || test "$?" -eq 1
printf '%s\n' '--- exact referenced declarations ---'
rg -n -C 12 -e 'export function useStampSidebarWorktreeSortOrder' \
-e 'export const useStampSidebarWorktreeSortOrder' \
-e 'export function useSettledSidebarWorktreeSortOrder' \
-e 'export const useSettledSidebarWorktreeSortOrder' \
src/renderer/src --glob '*.ts' --glob '*.tsx' || test "$?" -eq 1Repository: stablyai/orca
Length of output: 11238
🏁 Script executed:
#!/bin/bash
set -o pipefail
for spec in \
'src/renderer/src/components/sidebar/worktree-list/listing/use-visible-worktrees.ts:1,260' \
'src/renderer/src/components/sidebar/worktree-list/listing/use-host-visible-scope.ts:1,180' \
'src/renderer/src/components/sidebar/worktree-list/listing/use-external-worktree-cards.ts:1,180' \
'src/renderer/src/components/sidebar/worktree-list/listing/use-order-hold.ts:65,120' \
'src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts:60,310'
do
file=${spec%%:*}
range=${spec#*:}
printf '\n--- %s [%s] ---\n' "$file" "$range"
nl -ba "$file" | sed -n "${range}p"
doneRepository: stablyai/orca
Length of output: 30051
🏁 Script executed:
#!/bin/bash
for spec in \
'src/renderer/src/components/sidebar/worktree-list/listing/use-visible-worktrees.ts:1,260' \
'src/renderer/src/components/sidebar/worktree-list/listing/use-host-visible-scope.ts:1,180' \
'src/renderer/src/components/sidebar/worktree-list/listing/use-external-worktree-cards.ts:1,180' \
'src/renderer/src/components/sidebar/worktree-list/listing/use-order-hold.ts:65,120' \
'src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts:60,310'
do
file=${spec%%:*}
range=${spec#*:}
printf '\n--- %s [%s] ---\n' "$file" "$range"
nl -ba "$file" | sed -n "${range}p"
doneRepository: stablyai/orca
Length of output: 30051
🏁 Script executed:
nl -ba src/renderer/src/components/sidebar/worktree-list/listing/use-external-worktree-cards.ts | sed -n '175,245p'Repository: stablyai/orca
Length of output: 1357
Remove the stale allowance for use-window-list-model.ts.
useWindowSidebarListModel and its called hooks contain no direct activeRuntimeEnvironmentId read or discovered focus-reader call. Remove this baseline entry.
Suggested baseline update
--- "a/config/focus-setting-read-baseline.txt"
+++ "b/config/focus-setting-read-baseline.txt"
@@ -190,7 +190,6 @@
1 src/renderer/src/components/sidebar/worktree-filter-visibility.ts
1 src/renderer/src/components/sidebar/worktree-list/listing/use-filters.ts
1 src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts
-1 src/renderer/src/components/sidebar/worktree-list/listing/use-window-list-model.ts
1 src/renderer/src/components/sidebar/worktree-list/rows/ProjectGroupDialogs.tsx
1 src/renderer/src/components/sidebar/worktree-visibility-host-target.ts
1 src/renderer/src/components/skills/SkillsPage.tsx📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| 1 src/renderer/src/components/sidebar/worktree-list/listing/use-window-list-model.ts |
…p-reads-main # Conflicts: # config/focus-setting-read-baseline.txt
…d waits for a frame after collapse
Do not merge: owner approval pending.
ELI5
Today the desktop window works out its own sidebar list (which workspaces exist, their order, activity, review state) from its own copy of the data. The app's main process already works out the same list for the phone. With the sidebar-inputs build switch on, the desktop window now reads that list from main too, so the desktop and the phone show one list from one source. With the switch off (every shipped build), nothing changes.
What Changed
All of this is behind the existing
ORCA_SIDEBAR_INPUTSbuild switch. Switch-off builds keep the current code path, and the sidebar goldens are byte-identical.use-window-list-model.tsis the current pipeline moved without changes.use-main-list-model.tsbuilds the same rows from main's feed. The phone's row builder in shared code is split into index, rank, plan and render steps so the desktop can reuse it. Cards still render the window's own store records.lib/sidebar-pending-layer.ts). It shows the window's own writes until main's feed shows them. It covers two cases: row writes (drag order, pin, archive, unread, rename, status) and newly created workspaces. Each entry has an operation id. A newer write to the same field replaces an older one. For rows main owns, an entry clears once a read sent after main answered is installed. For a paired server's rows, it clears once main's row shows the value, after at most 10 seconds. Either way, main's value wins afterwards.Measured round trips (switch-on build, hidden window)
Without the pending layer, drag and create showed a gap of one or two frames: the old order flashed back, or the new workspace showed up late. Those two got the pending layer. Activation and collapse are already instant because the window writes them, so they stay window-local.
Render cost at about 423 rows (re-render after one row changes)
Collapse costs about 0.32 ms on every model. An agent status tick causes 0 re-renders. Parsing the feed takes 0.38 ms (median). The row counts match (451 and 421).
What the flip will delete
The window-side computation only runs with the switch off. It stays until the flip:
use-window-list-model.ts,use-sort-order.ts,use-visible-worktrees.ts, the window-only parts ofuse-section-rows.ts, and thelib/sidebar-shadowreadouts that the parity fixture still uses.Known gaps before the flip
paired-mobile-desktop-mirror-workspace-visibility). This needs a producer fix in main.agent-send-picker-revealandworktree-reveal-host-sectionscreate workspaces only in the window's store, so main never lists them. Those specs need to plant through main.Why
The goal is one list that both clients read from main, instead of two copies that can drift apart. Reusing the phone's feed, read method and change notice avoids building a second channel. We measured before adding any optimistic state, and added it only where frames were visibly wrong. Keeping it in one module, keyed by operation id and always settling to main's value, leaves the flip with one thing to review. We also considered skipping the pending layer and waiting for main's notice. Before the publish fix below, that cost 54 ms (median) and up to about 105 ms of the old order snapping back after every drag.
Linked Issue
N/A (internal sidebar inputs series)
Visual Proof
The screenshots come from hidden windows via CDP. Switch off is the current behaviour; switch on is this change. They should look the same.
Testing
I manually tested these changes locally (hidden windows, macOS, both builds)
Automated tests added/updated
The new e2e
sidebar-desktop-reads-main.spec.tsruns on both builds and passed 2/2 on each. It covers:Switch-on e2e sweep: 26 sidebar specs against a baseline at the base commit.
worktree-jump-palette-filter.pr-commentswas flaky and passed 2/2 on rerun.Unit tests:
The parity suite now has the main-model adapter. As a positive control, reversing the ranked order made 13 tests fail. That control is not committed.
The goldens are unchanged.
Gates:
pnpm tc, the full unit suite with agent env stripped,check:code-quality:changed, the focus-read ratchet (total unchanged, the allowance moved with the code), oxlint, anti-slop and format all pass.AI Disclosure
Review
An Opus review was applied:
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Switch on vs today (interleaved A/B, same machine)
Both builds were measured on the same machine against this branch merged with main. "Today" is the switch-off build and "switch on" is the switch-on build. Runs alternated on/off for 10 rounds, with 6 samples per event per run (3 for creates), so each cell is 60 samples (30 for creates). Every number is the time from an event to the change being in the window's sidebar DOM, measured with a mutation observer. Hidden windows, background launch.
worktree.setcall through main's runtime RPC, the same handler a phone or the CLI uses.orcaCLI run as a separate process.orca servehost while the desktop is paired to it.The one-minute load average was 12 to 30 (median about 20 to 23) on both sides.
First pass: the feed as it was (50 ms trailing coalesce)
The extra latency is the feed's 50 ms coalescing, and nothing else.
Fix: publish a change after a quiet spell at once
In
sidebar-inputs-feed.ts, the first change after at least 50 ms without a publish now publishes on the next timer turn. Later changes in the same burst still wait for one shared publish, at most once every 50 ms. The publish rate is still bounded the way it was, so a phone over the relay sees no more notices in a burst than before. An isolated change simply arrives sooner, for the phone as well.This is smaller than a separate push channel to the window: there is no new IPC, no new event type on the wire, and one path for every reader. It is behind the switch, because the feed only exists in a switch-on build. A unit test pins it: the first change publishes within 1 ms, and a burst right after it waits for the shared publish. Restoring the plain 50 ms delay fails that test.
Second pass: with the fix
With the fix, every event lands within a few milliseconds of today at the median.
Re-render cost per row change at about 423 rows (simulated DOM, interleaved 10 runs each)
How to read the table: