Skip to content

Sidebar P2: main publishes without waiting on git, and every source announces its changes (inert) - #31513

Merged
Jinwoo-H merged 8 commits into
mainfrom
sidebar-p2-producer-prep
Oct 21, 2026
Merged

Jinwoo-H merged 8 commits into
mainfrom
sidebar-p2-producer-prep

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​808 $\color{#cf222e}{\Huge{\mathbf{−}}}$​15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​793
Prod 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1024 $\color{#cf222e}{\Huge{\mathbf{−}}}$​178 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​846

ELI5

The phone (and, later, the desktop window) reads the sidebar from a feed that the desktop's main process publishes. Today that feed has two weak spots. First, every publish waits for fresh git scans, so a pin or rename can sit behind a slow repo or a stalled SSH host. Second, some sources never say when they change, so the feed re-reads them whenever a phone asks. That means a PR merging on a quiet desktop does not reach the phone until something else happens.

This PR fixes both inside main and adds three new feed sections. Nothing reads the new sections yet. The sidebar's switch is off on main, so users see no change.

What Changed

Publishing never waits on git

  • The workspace list keeps its last git scan for each repo. A publish joins that cached scan with the metadata as it is at that moment, synchronously.
  • Scans refresh separately, one at a time, and only on catalog changes (worktrees or repos changed) or a repo no scan covers yet. A metadata write never rescans, since metadata joins at read.
  • A rescan is queued for any change that arrives mid-scan. Here the stale-result fence is a version check: an older scan result can never replace a newer one. The per-workspace lifecycle-revision fence from design §7 lands with the lifecycle queue in P3.
  • A feed read is now synchronous by type. A domain can return "nothing yet". A phone's first read waits only for the first workspace scan; it never waits on the detected-checkouts listing.
  • Urgent publish: metadata writes, pin, settings and repo saves, accepted creations and view-setting writes skip the 50 ms batching and publish in the same turn. Git results follow in a later revision.

Every store announces its own writes

  • Saving the GitHub PR cache now notifies listeners (new onGitHubCacheWritten). The review section listens for it, and also for workspace-row and paired-server changes.
  • WSL host status changes now notify listeners (onStatusesChanged, fired from handleConnectionChange, Add and Remove).
  • The "re-read on every phone read" escape hatch is deleted. The desktop section hears UI, settings, pin and full saves through the store's write signal, so its separate UI and settings listeners are gone.

Branch switches are decided in main

  • When main's scan sees a workspace change branch, two things happen:
    • An automatic title follows the new branch, and keeps its last name while the head is detached.
    • Links tied to the old branch (linked reviews and the push target) are cleared in the store.
  • This replaces the window's writer, which P5b-2 deletes. The window is unchanged for now.
  • Only scans that reached a verdict count. A stalled or offline scan's stored rows carry no branch, so they are ignored.
  • The links recorded for a branch update only when git actually ran again (a new scan-cache entry) or the branch changed. A rescan answered from the 30 s cache does not count. So a PR linked right after checkout -b survives the next real scan.
  • A row whose repo listed without it is forgotten. A row with no instance id is never matched to an earlier sighting.

New feed sections, no readers yet

  • detected: each repo's detected checkouts, from the same listing worktree.detectedList serves.
  • view: the sidebar view settings, the same fields ui.get returns.
  • liveContent: live terminal count and attached-terminal state per workspace.

What runs with the switch off: the PR cache save and WSL status change now loop over their listener sets. With the switch off, nothing registers a listener, so both loops are empty. The scan/join split adds new methods only. The listing everything else uses (computeResolvedWorktrees) is unchanged.

Why

  • Why a cached scan joined at read, rather than a faster scan: metadata lives in the store and is always current, so only git output needs caching. Joining at read also means a scan that started before a write can never undo that write.
  • Why announcements rather than polling: the feed then only does work when a store actually changes. A census test (below) pins every domain to the writers it depends on, so a new silent source fails CI instead of going stale. The census already caught one real gap: a settings save that skips its listeners. The desktop section now also hears it through the store's write signal.
  • Wire compatibility:
    • Older phones ignore domain names they don't know.
    • No existing field changed, and there is no new stream opcode and no semantics-version bump.
    • The one-shot sidebarInputs.workspaceRows reply now waits for queued scans, so it is never older than the fresh listing it replaced.

Linked Issue

Part of the sidebar one-owner design, P2 (producer preparation). Stacked on #31466.

Visual Proof

N/A: main-side only, behind the switch, and nothing reads the new sections yet.

Testing

  • pnpm tc: clean (node, cli, web).

  • New unit tests:

    • Cached scan: serial scans, rescan queue, stale fence, scans only when someone is reading.
    • Git identity decisions: link clear, kept link, recreated workspace, same id on two hosts, detached title.
    • Announcement census: every domain × every writer, through the real store.
    • Urgent and coalescing tests in the feed.
  • Quiet-desktop PR grouping: with no other activity, a PR cache save alone reaches the phone's review fact and its group ("done"). It fails if the cache announcement is removed.

  • Timing: with a scan held for 2 s, a metadata write published in 0.22 ms, in one microtask turn (the test asserts under 20 ms).

  • Cost at 1000 workspaces (real store, join, filters and feed diff; git stubbed as its cached scan), 60 metadata writes: median 9.9 ms, max 13.3 ms. That is inside the 100 ms bar; a 5-writes-per-second burst costs about 5% of one core.

  • The 1000-workspace cost test gates on the median: a max gate flaked when the machine's load average was 40–60. On a quiet machine: 9.9 ms median, 13.3 ms max.

  • Link-wipe sequence: first scan, then checkout -b, PR linked, cached rescan, then a real scan on the new branch. The PR is kept. The test fails if links are recorded on every scan.

  • vitest --project node over src/main/runtime, src/main/wsl, src/main/persistence/loading-store, the parity fixture and the hosted-review renderer tests: all pass except 2 cases in orca-runtime.test.ts (the existing-folder imports). Those 2 fail the same way on the base commit, because macOS resolves /var to /private/var.

  • Lane static gate (lint, formatting, anti-slop, code quality, ratchets, typecheck:ci, mobile typecheck): all pass.

  • The full switch-on e2e suite was not run for this PR.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Notes

  • SSH: remote repos use the same cached scans. An unreachable host's stored rows never trigger a link clear.
  • Folder workspaces: they join from the store with no scan.
  • Known limits, left for later PRs:
    • Live-content counts are a simpler count than worktree.ps and get reconciled when a reader adopts them (P8a).
    • The per-workspace lifecycle-revision fence on scans (design §7) belongs to the lifecycle queue (P3). Here the fence is a version check.
    • Main notices a branch switch at its next catalog-triggered scan, not on its own schedule. The window still applies titles and link clears in the meantime.

…lip)

The fixes found while the sidebar ran from main's feed, without turning
that on: ORCA_SIDEBAR_INPUTS_IS_MAIN stays false, and none of flip-a's
stop-gaps come along.

- Main stops counting a closed tab's terminal once it was asked to stop
  and no pane shows it; a failed or refused stop takes the request back,
  and a host out of contact stays unverifiable.
- Main fetches a paired server's rows with the transport's normal bound,
  so a server slower than 5 s still lists.
- A deferred unread raise flips the folder row it was decided for, and a
  read while the owner check is out cancels it.
- Phone: no worktree.ps flash before the feed; a host's last installed
  feed stands in while a fresh read is out; it highlights its own
  last-opened workspace and a fold never scrolls; projects file under
  their project group with the desktop's indent; the collapse spinner
  shows only after 500 ms; "Reopen to update" keeps the rows on screen.
- e2e helpers and journeys for the switch-on suite.
…d prune pending unread raises

- A stop-and-wait that throws takes its stop request back, like one that fails.
- A final stop the legacy relay still owes stays marked, since the relay retries it.
- Pending unread raises are tracked only while one waits, so the map no longer grows.
- The paired-server fallback poll test gives its third fetch a reply and asserts live.
…stores; detected, view and live-content domains (inert)
…n metadata writes, no phone wait on detected checkouts
@Jinwoo-H
Jinwoo-H changed the base branch from sidebar-p0 to main October 21, 2026 16:25
@coderabbitai

coderabbitai Bot commented Oct 21, 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: 410ac51b-a3c5-46b9-a383-dc86e6a5a30a
📥 Commits

Reviewing files that changed from the base of the PR and between 11ade66 and 6dd3547.

📒 Files selected for processing: 1
  • src/main/runtime/sidebar-inputs/workspace-git-identity.test.ts
🚧 Files skipped from review as they are similar to previous changes: 1
  • src/main/runtime/sidebar-inputs/workspace-git-identity.test.ts

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

📝 Walkthrough

The change adds cached, serialized worktree scanning and separates repository scans from row joining. Workspace rows now use cached snapshots and track Git identity changes. New producers expose detected checkouts and live workspace content. Sidebar feed domains now use synchronous nullable snapshots, readiness promises, and urgent notifications. Store, workspace, and WSL status changes can notify feed domains, including GitHub cache writes.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 6dd35

A reconnecting reader may see an outdated detected-checkout listing until another catalog change. The sidebar switch remains off, so this is a bounded risk to address before enabling it.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 48.28% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 33 files. 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 two main changes: publishing without waiting for Git scans and announcing source changes. The “inert” qualifier also reflects the switch-off state.
Description check Passed The description covers the required ELI5, change summary, rationale, linked issue, visual proof, testing, and notes sections. It provides detailed implementation and validation information. Some optio…
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: Description check

Explanation

The description covers the required ELI5, change summary, rationale, linked issue, visual proof, testing, and notes sections. It provides detailed implementation and validation information. Some optional template checklist sections are omitted, but the description is otherwise complete.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • 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: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 77522c93-3d1c-4ba2-951c-56816fbccbc1
📥 Commits

Reviewing files that changed from the base of the PR and between 92bbb38 and 11ade66.

📒 Files selected for processing: 33
  • src/main/persistence/loading-store/profile-preferences.ts
  • src/main/persistence/loading-store/store-runtime-state.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/repo-worktree-row-resolution.ts
  • src/main/runtime/rpc/methods/sidebar-inputs.ts
  • src/main/runtime/runtime-store-contract.ts
  • src/main/runtime/sidebar-inputs/cached-scan.test.ts
  • src/main/runtime/sidebar-inputs/cached-scan.ts
  • src/main/runtime/sidebar-inputs/detected-checkouts-producer.ts
  • src/main/runtime/sidebar-inputs/orca-runtime-detected-checkouts-live-content.ts
  • src/main/runtime/sidebar-inputs/orca-runtime-sidebar-temporal.ts
  • src/main/runtime/sidebar-inputs/producer-revision.ts
  • src/main/runtime/sidebar-inputs/sidebar-inputs-feed-announcements.test.ts
  • src/main/runtime/sidebar-inputs/sidebar-inputs-feed-domains.ts
  • src/main/runtime/sidebar-inputs/sidebar-inputs-feed.test-fixture.ts
  • src/main/runtime/sidebar-inputs/sidebar-inputs-feed.test.ts
  • src/main/runtime/sidebar-inputs/sidebar-inputs-feed.ts
  • src/main/runtime/sidebar-inputs/workspace-activity-facts-producer.ts
  • src/main/runtime/sidebar-inputs/workspace-git-identity.test.ts
  • src/main/runtime/sidebar-inputs/workspace-git-identity.ts
  • src/main/runtime/sidebar-inputs/workspace-live-content-producer.ts
  • src/main/runtime/sidebar-inputs/workspace-rows-producer.test.ts
  • src/main/runtime/sidebar-inputs/workspace-rows-producer.ts
  • src/main/runtime/sidebar-inputs/workspace-rows-publish-cost.test.ts
  • src/main/runtime/workspaces/resolved-worktree-scan-join.ts
  • src/main/runtime/workspaces/workspace-catalog.ts
  • src/main/wsl/wsl-host-service.ts
  • src/renderer/src/components/sidebar/sidebar-list-parity-project-catalog.test-fixture.ts
  • src/renderer/src/components/sidebar/sidebar-list-parity.test-fixture.ts
  • src/renderer/src/store/slices/worktrees/listing/worktree-slice-types.ts
  • src/renderer/src/store/slices/worktrees/metadata/hosted-review-link-mutation.ts
  • src/shared/sidebar-list/workspace-live-content.ts
  • src/shared/worktree/hosted-review-links.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 +49 to +55
watch(listener: () => void): () => void {
const detach = this.revision.onChange(listener)
if (!this.listings.current) {
this.listings.request()
}
return detach
}

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

Make watch refresh a stale listing as well as a missing one.

The producer has demand only while a listener exists. Without demand, a catalog event calls this.listings.request(), and CachedScan.request only sets stale = true.

On the next attach, watch rescans only when current is null. A reader that reconnects after a catalog change therefore gets the old listing. The listing stays old until another worktreesChanged/reposChanged event arrives.

CachedScan.ready() already forces a scan when the value is null or stale. Use it here; it never rejects.

🐛 Proposed fix
--- "a/src/main/runtime/sidebar-inputs/detected-checkouts-producer.ts"
+++ "b/src/main/runtime/sidebar-inputs/detected-checkouts-producer.ts"
@@ -46,13 +46,12 @@
   }
 
   /** Listens and starts the first listing; a reader shows nothing for this domain until it lands. */
   watch(listener: () => void): () => void {
     const detach = this.revision.onChange(listener)
-    if (!this.listings.current) {
-      this.listings.request()
-    }
+    // Scans when nothing has applied yet, or when a change landed while no one listened.
+    void this.listings.ready()
     return detach
   }
 
   /** Null before the first listing applies. */
   snapshot(): Record<string, DetectedWorktreeListResult> | null {
📝 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.

Suggested change
watch(listener: () => void): () => void {
const detach = this.revision.onChange(listener)
if (!this.listings.current) {
this.listings.request()
}
return detach
}
watch(listener: () => void): () => void {
const detach = this.revision.onChange(listener)
// Scans when nothing has applied yet, or when a change landed while no one listened.
void this.listings.ready()
return detach
}

@Jinwoo-H
Jinwoo-H merged commit 84a9f99 into main Oct 21, 2026
54 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