Repository navigation
refactor(hosts): stamp events and optimistic rows at ingest - #27223
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No merge-blocking behavior change is established; the PR is mergeable after normal checks. Pre-merge checks |
|
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
worktreesChangedandactivateWorktreeevents computedruntime:<server>in three places; this app's ownworktrees:changedevent setforceLocalOwner: trueby hand; a new workspace's owner was computed inline increateWorktree.adoptFromEndpoint(target, …)insrc/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.unstampedNonLocalRow(src/renderer/src/lib/unstamped-non-local-row-counter.ts). It counts each timeworktreeMatchesHostgives 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/andsrc/renderer/src/store/slices/worktrees*(231 files, 1712 tests) plus the worktree create suites pass.pnpm tc, oxlint andpnpm run check:code-quality:changedpass.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)