Repository navigation
test(infra): cover heartbeat typing keepalive refresh and interval config - #160229
Conversation
The runner typing test used real timers while runHeartbeatOnce starts the heartbeat typing keepalive (6 s default interval). Any run slower than one interval correctly refreshed typing a second time and failed toHaveBeenCalledOnce on loaded CI runners; the failed-run case shared the same wall-clock assumption. Fake only setInterval/clearInterval for the file so keepalive ticks follow the test clock, configure typingIntervalSeconds, and assert the contract explicitly: typing starts before the reply, refreshes once per interval while the reply is in flight, clears once, and stops after the run.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 6:45 AM ET / 10:45 UTC (Revision 2). ClawSweeper reviewWhat this changesExtends the heartbeat runner test to check that a configured two-second interval refreshes typing during a reply and that typing clears when the run finishes. Merge readiness✅ Ready for maintainer review Keep open. The merged timing-flake fix stabilizes the existing test, but current main still lacks this runner-level check for configured typing refresh. The prior review’s timer-lifecycle concern is resolved in the current head. Priority: P2 Review scores
Verification
How this fits togetherThe heartbeat runner starts an automated agent turn and asks the destination chat plugin to show typing while it runs. Agent settings determine the refresh cadence; runner cleanup stops the indicator. flowchart LR
A[Heartbeat starts] --> B[Runner starts agent turn]
C[Typing interval setting] --> B
B --> D{Chat supports typing?}
D -->|Yes| E[Start and refresh typing]
E --> F[Clear typing at finish]
D -->|No| G[No typing signal]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +18. Total +18 across 1 file. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep one runner-level check for configured refresh and cleanup alongside the existing callback test for the default cadence. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR adds coverage rather than reporting a current product defect. Comparing current main with the patch identifies the missing runner assertion. Is this the best way to solve the issue? Yes. Exercising the production heartbeat runner with a controlled interval checks setting propagation and cleanup at the relevant boundary; the existing callback test covers the default cadence. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 14f65626bd25. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Main's #159980 already wraps the heartbeat run in fake setInterval and restores real timers in its finally block. Merging it with this branch's file-level fake timers left a post-run clock advance running after real timers were restored, which failed CI. Keep the merged helper as the only timer lifecycle, drop the file-level fakes and the post-run advance, and keep the added coverage: the configured typingIntervalSeconds refreshes typing once while the reply is in flight, and the run clears typing exactly once.
…nfig (openclaw#160229) * test(infra): drive heartbeat typing keepalive from the test clock The runner typing test used real timers while runHeartbeatOnce starts the heartbeat typing keepalive (6 s default interval). Any run slower than one interval correctly refreshed typing a second time and failed toHaveBeenCalledOnce on loaded CI runners; the failed-run case shared the same wall-clock assumption. Fake only setInterval/clearInterval for the file so keepalive ticks follow the test clock, configure typingIntervalSeconds, and assert the contract explicitly: typing starts before the reply, refreshes once per interval while the reply is in flight, clears once, and stops after the run. * test(infra): share one fake-interval lifecycle for heartbeat typing Main's openclaw#159980 already wraps the heartbeat run in fake setInterval and restores real timers in its finally block. Merging it with this branch's file-level fake timers left a post-run clock advance running after real timers were restored, which failed CI. Keep the merged helper as the only timer lifecycle, drop the file-level fakes and the post-run advance, and keep the added coverage: the configured typingIntervalSeconds refreshes typing once while the reply is in flight, and the run clears typing exactly once.
Related: #159980
What Problem This Solves
Heartbeat typing has no runner-level test that the typing indicator refreshes while a heartbeat reply is still running, or that
agents.defaults.typingIntervalSecondsreaches the heartbeat typing keepalive. If either broke, the typing indicator would lapse during long heartbeat replies or ignore the configured interval, and no test would fail.User Impact
No user-visible change. Test coverage only.
Why This Change Was Made
This PR started as a fix for the timing flake in
runHeartbeatOnce heartbeat typing › starts and clears typing around a heartbeat run(run 36377844500). #159980 landed a fix for that flake first: it wraps only the heartbeat run in fakesetInterval/clearInterval. The first revision here faked intervals for the whole file, and GitHub merged it with #159980 without a conflict. The combined test restored real timers before its post-run clock advance, so CI failed. After mergingmain, this PR uses #159980's helper as the only fake-timer lifecycle and keeps only the coverage it adds.The main typing case now configures
typingIntervalSeconds: 2and advances the fake clock by one interval while the reply is in flight. It then records typing counts at three points: when the reply starts (one start, no clear), after one configured interval (one keepalive refresh, no clear), and after the run (no further refresh, exactly one clear). The failed-run and no-typing cases are unchanged frommain. The default 6 s cadence stays covered bysrc/infra/heartbeat-typing.test.ts.Evidence
Merged-head proof (local, after merging
mainand removing the second timer lifecycle):src/infra/heartbeat-typing.test.ts: passes.typingIntervalSecondswiring: fails as intended with the in-flight snapshot{ sent: 1 }instead of{ sent: 2 }. On the first revision, droppingtyping.onCleanup()also failed (cleared: 0);main's exactly-once clear assertion already catches that.maincommit: no remaining P0–P2 findings in the working tree. Its one finding was index-only, the pre-fix merge state this commit replaces.check-changed: format and all ratchets pass. The core tsgo graph boundary failed onui-other: 721 test roots exceeds the advisory 720 limit, which comes frommain(the merge brought inui/src/lib/sessions/session-describe.test.ts), not from this infra-only test change. Local oxlint timed out preparing plugin-sdk boundary artifacts at load average about 70, so lint and typecheck are rerun on Testbox below.First-revision Testbox proof (
tbx_01m3kdxkk1mv8p2ackvk74qby7, 4 vCPU): 20/20 standalone runs of the file (24–27 s wall warm), 3/3 replays of thecore-runtime-infra-heartbeat-runnershard, and owner tests passed. On the same host the original file passed 3/3, consistent with the flake needing a run slower than 6 s.Final-head Testbox proof (infra typecheck, changed-file oxlint, 20 standalone runs, owner test, one shard replay) is running; results will be added here.
Test cost: the unchanged file's five tests took 29.9 s of test time in the original failing CI job; final-head wall time and CI seconds will be added here.