Repository navigation
fix(orcad): mobile home stats on orca serve hosts, and a parity test that sees every way a host wires a service - #31197
Conversation
…parity test see positional and host-port wiring
Mobile home on an orca serve host showed 0 agents and 0 agent time since
1.4.229: orcad built the runtime with no stats collector, so stats.summary
answered {}. orcad now loads the profile's orca-stats.json and counts hook
sessions through the same feed the desktop uses.
The runtime composition parity test only compared constructor options and
runtime/rpc setters in four files, so a positional constructor argument
(stats) and process-wide host ports installed at preflight (speech) were
invisible to it. It now records both, and checks every declared
construction option is accounted for.
Reported-by: Fergus Molloy (@fergusmolloy)
…eardown resets and finds unlisted host-port files
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to
|
ELI5
When you run Orca headless with
orca serve, the server that answers your phone has been a separate Node program (orcad) since 1.4.229. That program never got the piece that counts agent sessions, so the phone's home screen showed 0 agents and 0 agent time. This PR gives orcad that counter. It reads the sameorca-stats.jsonfile, so your old totals come back. It also fixes the test that should have caught this.What Changed
Before: on an
orca servehost from 1.4.229 on, Orca Mobile's home screen shows 0 agents spawned and 0 agent time, andorca-stats.jsonstops changing.After: the home screen shows the host's totals again, including everything counted before the upgrade, and new agent sessions keep being counted.
How it works:
src/main/stats/collector.tsno longer imports Electron. It finds the profile directory through the app environment port, which both the desktop and orcad install, so plain Node can load it.src/main/stats/agent-session-stats-feed.tsis one function that counts sessions from agent-hook status, the same signal the sidebar uses. The desktop now calls it instead of wiring the recorder inline.src/main/orcad/orcad-stats.tscreates the collector before the hook server starts and passes it toOrcaRuntimeService. On shutdown it stops the feed, then writes the file, all before the profile lock is released.The test fix (the bug class):
runtime-composition-parity.test.tsexists to fail when the desktop and orcad build the runtime differently. It missed this for two reasons:undefinedthere.orca servehost after 1.4.205 → 1.4.232 (speech_unavailable) #31174).It now records separate constructor arguments, records every service setter called in those startup files, and fails when such a setter is called from a startup file it doesn't read. It ignores teardown resets like
set…(null), and it checks that every constructor option is wired by at least one host. Services orcad deliberately leaves out stay listed with a reason. Speech is listed as a known gap for now; a follow-up PR wires it.Why
A collector belongs on the host that runs the agents, because that host's hook server is what sees them. That holds for a local desktop,
orca serve, and SSH or WSL hosts alike. I reused the existing collector and session recorder instead of writing a headless version, so the desktop and orcad count sessions the same way.For the test, I extended the existing parity check rather than adding a second one. That way there is one place that lists what orcad deliberately leaves out, and each entry needs a reason.
Alternatives I rejected:
Linked Issue
Fixes #31112
Thanks to @fergusmolloy for the report and the precise pointer to
orcad-entry.ts.Related: #31174 (speech, same gap in the parity test; separate PR). #30160 was already fixed by #29209; see the comments there.
Visual Proof
N/A. This is a data fix with no UI change. The mobile home screen just shows real numbers again. The live check below shows the RPC answer the screen renders.
Testing
Verified live (macOS arm64): I built the real orcad slot (
pnpm build:orcad) and started it with its own HOME andORCA_USER_DATAunder/tmp, seeded with anorca-stats.jsonholding 42 agents, 3 PRs and 2 hours of agent time.stats.summaryover the local runtime transport returned{"totalAgentsSpawned":42,"totalPRsCreated":3,"totalAgentTimeMs":7200000,…}. Before this change it returned{}.speech.models.liststill answeredspeech_unavailable, which confirms Mobile voice dictation broken on headlessorca servehost after 1.4.205 → 1.4.232 (speech_unavailable) #31174 is a separate, real gap.Tests only:
agent-session-stats-feed.test.tsrecords a session on a Node app environment with no Electron, and the totals survive a reload.orcad lacks ctor-arg:statsand passes here.I also ran the full static job locally: lint, format, anti-slop, the focused and type-aware code-quality checks, changed-code quality,
pnpm tc, every ratchet including focus-read, and the generated-catalog checks.Review
gpt-6.1-sol, high): no findings.Agent skill upstream boundary
Notes
stats.summarykeeps its shape and simply stops answering{}.path.join, and no new processes are started.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)