fix(host-service): coordinate base-ref fetches across workers
What
- restore process-wide TTL/in-flight coordination for background base-ref fetches across worker-backed status snapshots
- keep the actual network fetch in the host worker pool
- add a reusable CDP terminal-flood profiler and record two post-#5747 measurements
- update the worker-pool plan with the measured decision not to add a pinned ModeTracker worker
Why
Moving status computation into worker threads made the base-ref freshness maps worker-local. Worktrees sharing one Git common directory could therefore launch redundant fetches. The coordinator now lives on the host-service main thread while the network operation remains off-loop.
The earlier terminal measurement was blocked by the shared daemon socket disconnect. After #5747, two full reruns moved 279–288 MB per flood phase while both terminal sockets survived. Host health p99 stayed at 1.4–1.5 ms and probe echo p95 stayed at 12.5–18.3 ms, so a pinned terminal worker is not justified by current evidence.
Validation
bun run lint- 37 focused host-service tests, including worker parity, graph purity, limiter/watcher coverage, and cross-worktree fetch dedupe
bun run --cwd packages/host-service typecheckbun run --cwd apps/desktop typecheckbun run --cwd packages/host-service build:host- two 60-sample CDP terminal flood profiles at 150 ms intervals
Summary by cubic
Restores process-wide coordination of background base-ref fetches across worker-backed status snapshots, and adds an authenticated CDP terminal flood profiler with isolated echo latency sampling. Network I/O stays in the worker pool; the coordinator runs on the host-service main thread and dedupes by Git common dir.
-
Bug Fixes
- Reintroduce common-dir TTL/in-flight coordination for base-ref fetches across worktrees.
gitStatusSnapshotTasknow returns{ snapshot, baseRefFetchTarget };git.getStatusschedules fetch viascheduleBaseRefFetchand runs it in a worker withgitFetchBaseRefTask(coalesced by a dedupe key).- Ensure cross-worktree dedupe by keying on Git common directory; add test coverage.
- Update callers/tests to use
result.snapshot.
-
New Features
- Add
apps/desktop/scripts/cdp-terminal-flood-profile.tsandprofile:terminal-floodscript; requires an authenticated renderer session (cookie or bearer viaauthClient), isolates echo RTT sampling, and writes JSON summaries; updateapps/desktop/AGENTS.md. - Update the plan with post-#5747 measurements: transport survives floods, but second-terminal coupling persists; promote ModeTracker attribution and a pinned-worker experiment.
- Add
Summary by CodeRabbit
-
Improvements
- Git status now schedules a coordinated background refresh of outdated base-branch info after the initial snapshot, improving result freshness without delaying the first response.
- Refresh work is de-duplicated across worktrees that share the same underlying Git common directory.
-
Documentation
- Updated desktop CDP authentication troubleshooting for local vs non-local workspaces, including safer session verification and recovery guidance.
-
Tools
- Added a terminal performance profiling harness (with a new npm script) to measure echo latency and flood behavior under sustained output.
-
Tests
- Updated git worker-pool and snapshot-shape assertions to match the new computation result format.