Repository navigation
test(claude): wait for a pane's subagent list instead of asking once - #969
Conversation
The subagent contract asked /api/pane/omo-tasks once and expected the running agent. The server's non-awaited background lookup can already have resolved the pane to no transcript (herdr busy or late under the 4-shard self-hosted runner); ClaudeSubagentStatus.ensure then skips a new lookup for refreshMs (5 s), so the first ask answers [] by design. Poll the list with the file's bounded helper and look for the count frame from the start of the socket's frames. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
Problem
CI on main at eace9f0 (run 38429338201, job 115409436687, self-hosted runner,
HERDR_TEST_SHARDS=4) failedserver/claude-session.contract.test.ts:200"lists a Claude pane's subagents, counts the running ones and pushes the count without a status": expected[{ id: "a1", status: "running" }], received[], in 120 ms. The test after it in the file and every later test passed.Root cause: a race in the test, not a regression
claudeAgents.refresh()without waiting for it. IfclaudePaneSessionanswers null once for the pane (herdr'sagent.get/pane.process_infobusy or late),ClaudeSubagentStatus.ensurerecordspath: null. It then skips a new lookup untilrefreshMs(5 s) has passed, and that includes the lookup/api/pane/omo-tasksmakes when asked. So an ask inside that window answers[]fast, on purpose. The client retries.beforeAllwaits forstatusReady, and another test runs before this one.claudePaneSessioncalls answer null. The result matched CI exactly: the same assertion,[], 107 ms, and the other 9 tests green. With this change the same injection passes.HERDR_TEST_SHARDS=4integration runs were all green before the fix.Change (test only)
untilpoll (100 × 100 ms, allowed by the fixed-sleeps ratchet) to file scope. The plan test and this test both use it.a1reads running, then keep the existingtoMatchObjectassertions.background_tasks === 1frame starting from the socket's first frame, after the poll. Its 10 s window now starts once discovery is done, and a count pushed while the list was polled still counts.Not changed: an explicit ask after a failed background lookup still waits out the 5 s cache. That is the intended product behaviour. If an explicit ask should look again at once, that is a separate follow-up.
Checks
bun run check fast: okbun test server/claude-session.contract.test.tson an isolated herdr session: 10 pass, with and without the injected lookup failure🤖 Generated with Claude Code