Repository navigation
Add a per-call background lane for event-driven project refresh - #6160
Closed
audichuang wants to merge 1 commit into
Closed
audichuang wants to merge 1 commit into
audichuang wants to merge 1 commit into
Conversation
audichuang
force-pushed
the
feat/runtime-rpc-background-lane
branch
2 times, most recently
from
June 23, 2026 09:16
6a91e38 to
16d4d84
Compare
audichuang
marked this pull request as ready for review
June 23, 2026 09:31
Contributor
📝 WalkthroughWalkthroughA new 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
audichuang
force-pushed
the
feat/runtime-rpc-background-lane
branch
from
June 23, 2026 23:02
16d4d84 to
baaca7e
Compare
Runtime RPC calls are sorted onto a background lane by method name (isBackgroundRuntimeMethod), but the event-driven project refresh — a reposChanged event fanning out to repos, worktrees and lineage — fires methods that are not on that list, so the refresh storm competes with user-initiated calls on the foreground lane. Add a per-call `background` override that flows through the RPC call queue, main call routing, the renderer/preload/web call paths and the renderer fetch helpers, then route the event-driven runtime project refresh through it so the refresh storm yields transport capacity to foreground interaction.
audichuang
force-pushed
the
feat/runtime-rpc-background-lane
branch
from
June 25, 2026 11:44
baaca7e to
8330442
Compare
5 tasks done
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Runtime RPC calls are sorted onto a foreground/background lane by method name
(
isBackgroundRuntimeMethod). The event-driven project refresh fired byserver-pushed client events —
reposChangedfanning out to repos, worktrees,and lineage, and
worktreesChangedrefreshing worktrees, lineage, and (for anunknown repo) discovery — fires methods (
repo.list,project.list,worktree.detectedList,worktree.lineageList) that are not on that list,so the refresh storm lands on the foreground lane and competes with
user-initiated calls for transport capacity. With several remote servers
connected this is a visible jank source on every remote event.
This adds a per-call
backgroundoverride that flows end-to-end through the RPCcall queue → main call routing → renderer/preload/web call paths → renderer
fetch helpers. The queue keeps the existing method-name classification as the
default and lets a call site opt in:
Both server-pushed refresh paths are then routed through it:
runtimeProjectRefreshSchedulerrefresh forreposChanged(repos +worktrees + best-effort lineage), and
worktreesChangedrefresh (worktrees + lineage, plus itsensureRuntimeEventRepoKnownrepo discovery) — the sameruntime.clientEventsstream, treated symmetrically.
No change to what is refreshed — only which lane, so the all-host
project model still refreshes every connected environment exactly as before.
Screenshots
No visual change.
Testing
Rebased onto latest
origin/main(v1.4.98-rc.1); the rebase is clean (no conflicts).pnpm lint— clean (oxlint type-aware + localization catalog/parity all pass)pnpm typecheck— green (3 tsgo projects)pnpm test— full suite on the rebased base: 20735 passed, 23 failed,75 skipped. All 23 failures are pre-existing and live in files this PR does
not touch (verified zero overlap with the changed file set — git-handler,
omp-shell-wrapper, automation-schedules, pr-comment
localStorage,Linear/SidebarToolbar, hook-service). The 7 changed/affected test files pass
329/329 in a focused run.
pnpm build— green on the rebased base (desktop web bundle built in ~35s;native build is a no-op on Linux). Only a pre-existing chunk-size advisory, no errors.
runtime-rpc-call-queue.test.ts)fetchWorktrees(..., { background: true })carriesbackground: trueonboth
worktree.detectedListand the best-effortworktree.lineageListreposChangedscheduler refresh issues repos + worktrees + lineage allwith
{ background: true }(useIpcEvents.test.ts)worktreesChangedrefresh + its repo discovery ride the background lane,while the
activateWorktreereveal path stays on the foreground lane(
useIpcEvents.test.ts)AI Review Report
Reviewed with multiple independent AI passes. Risks checked: flag continuity
across every layer (queue → main → preload → web → renderer); the three lane
cases (explicit
truedemotes, explicitfalseforces foreground,undefinedfalls back to method classification); and that no active-only / single-env gate
was introduced that would break the all-host project model. Two real issues were
caught and fixed during review:
fetchWorktrees's best-effort lineage follow-up(
refreshRemoteWorktreeLineageBestEffort) was not forwardingbackground, sothe event-driven refresh still issued a foreground
worktree.lineageList; itnow threads the flag and a regression test guards both lineage call sites.
worktreesChangedrefresh was still entirely on the foreground lane whilethe sibling
reposChangedrefresh was demoted — an asymmetry in the sameclient-event handler. The
worktreesChangedworktrees/lineage refresh and itsrepo discovery now ride the background lane too, with the
activateWorktreereveal path kept on the foreground lane (it carries user-facing intent) via an
explicit option on the shared
ensureRuntimeEventRepoKnownhelper. Symmetrictests lock both lanes.
Cross-platform: no platform-specific paths are touched — the change is shared RPC
plumbing plus renderer store logic, with no OS-specific shortcuts, labels, path
handling, or shell behavior. The
backgroundflag rides the existing callenvelope used identically on macOS, Linux, and Windows.
Security Audit
The only new data crossing the IPC boundary is an optional boolean
backgroundflag on the runtime call envelope. It is not user input; it carries no path,
command, secret, or auth material; and it only selects which in-process queue
lane a call uses — it cannot change the selector, method, or params. No new input
handling, command execution, or dependency surface. No follow-up needed.
Notes
reposChangedscheduler refresh and the
worktreesChangedrefresh (list + lineage + repodiscovery) — are demoted to the background lane, treated symmetrically since
they share the same
runtime.clientEventsstream. User-initiated calls, theactivateWorktreereveal path (a CLI-created worktree the user wants shownimmediately), and the
status.getcontrol-plane compatibility probe stay onthe foreground lane on purpose — the probe gates connection/compatibility UI
and should not yield.
resolves the target host from focused settings rather than the event's
environmentId, and repo discovery matches on the barerepo.id, so twoservers sharing a repo id can cross-refresh. This is existing behavior — not
introduced here — and is being addressed by the upstream host-qualified
identity stack (Preserve same-id repos across hosts #6030 / Preserve shared project host setups on refresh #6031 / Use host-qualified worktree identities #6096); moving these refreshes onto the
background lane does not change it.
request-id staleness guard to the same
fetchWorktrees. Routing these callersonto the (slower) background lane widens the stale-overwrite window fix: Prevent stale worktree refreshes hiding new worktrees #5266
addresses, and the two conflict textually in
worktrees.ts. Whichever landssecond should reconcile so the background path is also covered by the
staleness guard.
ELI5
Event-driven project refresh RPC was treated as foreground work and could stall the UI during storms of change events. Those refreshes use a dedicated background lane.