Skip to content

refactor(hosts): stamp events and optimistic rows at ingest - #27223

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/d4-d4-f2b
Oct 10, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/d4-d4-f2b

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​55 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​55
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​105 $\color{#cf222e}{\Huge{\mathbf{−}}}$​31 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​74

ELI5

When a paired Orca server or this app tells the renderer "the worktrees of project X changed", or when you create a new workspace, Orca has to remember which machine that belongs to. The previous step put the labelling of fetched project rows in one function. This PR sends live worktree events and the just-created workspace through that same function, and adds a counter that notices when a row gets a remote owner by guesswork instead of a label. Nothing a user sees changes.

What Changed

  • Before: each event path decided its owner inline. A server's worktreesChanged and activateWorktree events computed runtime:<server> in three places; this app's own worktrees:changed event set forceLocalOwner: true by hand; a new workspace's owner was computed inline in createWorktree.
  • After: all of them call adoptFromEndpoint(target, …) in src/renderer/src/store/adopt-from-endpoint.ts, with two new kinds:
    • worktreeEvent: an event from a server is owned by that server; an event from this app is pinned to this app (it can name any repo in this app's catalog, local or direct SSH, so it is not pinned to a single host).
    • createdWorktree: the host the caller asked for wins; otherwise a server-created workspace belongs to that server and a locally created one to its repo's host.
  • New dev counter unstampedNonLocalRow (src/renderer/src/lib/unstamped-non-local-row-counter.ts). It counts each time worktreeMatchesHost gives a worktree row that has no host label to an SSH host or server (the old fallback for rows saved before labels existed). It should stay at 0. The planned owner-first sidebar step will report to the same counter.

For users: no change. The same owners are stamped on the same events and rows as before.

Why

This is the second foundation step for routing work by the owning host instead of the focused "Active Server". With every row and event getting its owner from one function, the later slices can stop falling back to focus. The counter is how a slice proves that nothing it reads still needs a guessed owner.

Adapted from the plan: agent-status rows are not stamped here. They carry no owner field; their owner comes from the pane's tab, which already has a host. Adding a field to that hot reducer with no reader yet would be speculative. The agent and terminal slices that need it will add it.

Alternatives considered: a separate helper per event type. Rejected because the point of this step is one entry point for all ingress, with the per-kind differences visible side by side.

Linked Issue

None (maintainer refactor, part of the host-ownership routing work).

Visual Proof

N/A — internal refactor with no visual or interaction change.

Testing

  • adopt-from-endpoint.test.ts: characterization rows for both new kinds (this app vs server, rename carried through, requested host wins).

  • worktree-host-ownership-unstamped.test.ts: the counter fires only when an unlabelled row is given to an SSH host or server, never for local or labelled rows, and the match result is unchanged.

  • Focused suites: src/renderer/src/hooks/ and src/renderer/src/store/slices/worktrees* (231 files, 1712 tests) plus the worktree create suites pass.

  • pnpm tc, oxlint and pnpm run check:code-quality:changed pass.

  • I manually tested these changes locally

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

AI Disclosure

Review

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

Security, cross-platform, SSH, mobile and backwards compatibility: no change. No wire or persisted format changes; the same owner values reach the same code paths. Performance: one integer increment on a legacy-only branch.

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)

Worktree change/activation events and the just-created worktree's owner now go
through adoptFromEndpoint, and a dev counter reports rows that reach a reader
unstamped but get attributed to a non-local host.
@coderabbitai

coderabbitai Bot commented Oct 10, 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: 24408c15-a252-4873-a769-80aec7d22aeb

📥 Commits

Reviewing files that changed from the base of the PR and between 7aa91f7 and d930107.


📒 Files selected for processing (8)
  • src/renderer/src/hooks/ipc-events/project-catalog-ipc-bridge.ts
  • src/renderer/src/hooks/ipc-events/runtime-client-ipc-bridge.ts
  • src/renderer/src/lib/unstamped-non-local-row-counter.ts
  • src/renderer/src/store/adopt-from-endpoint.test.ts
  • src/renderer/src/store/adopt-from-endpoint.ts
  • src/renderer/src/store/slices/worktrees/create/create-worktree.ts
  • src/renderer/src/store/slices/worktrees/listing/worktree-host-ownership-unstamped.test.ts
  • src/renderer/src/store/slices/worktrees/listing/worktree-host-ownership.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

Walkthrough

The changes extend adoptFromEndpoint to handle worktree events and created worktrees. Project catalog and runtime IPC bridges use it to assign ownership to events, and worktree creation uses it to select a host ID. Host matching now records unowned rows that match a non-local host. Tests cover adoption rules, match results, and counter values.


Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to d9301

No merge-blocking behavior change is established; the PR is mergeable after normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: assigning ownership to events and optimistic worktree rows during ingestion.
Description check Passed The description covers the required explanation, scope, rationale, testing, visual proof, compatibility notes, and checklist. The missing linked issue is justified as a maintainer refactor, and the ma…
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.

  • Fix all pre-merge checks with AI
✨ 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.

@OrcaWin
OrcaWin merged commit 26bca89 into main Oct 10, 2026
30 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