Repository navigation
test(chat): await progress, foreground, and capability owners in view model tests - #165170
Conversation
|
🦞👀 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 October 5, 2026, 3:53 AM ET / 07:53 UTC (Revision 6). ClawSweeper reviewWhat this changesNative chat view-model tests await existing task completion and arrival signals instead of deadline-based polling, with small production changes that return existing task handles. Merge readiness✅ Ready for maintainer review This PR remains useful: current main retains the targeted polling waits. No actionable introduced defect was found, and the latest commit preserves the previously reviewed behavior. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw's shared native chat view model turns Gateway events and foreground activation into transcript, progress-card, and capability updates. These tests verify those updates after their owning work settles. flowchart TD
A[Gateway events] --> C[Native chat view model]
B[Foreground activation] --> C
C --> D[Existing refresh tasks]
D --> E[Chat and progress state]
D --> F[Completion and arrival signals]
F --> G[Test assertions]
E --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceOther -102. Total -102 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep native chat assertions synchronized with existing operation owners while preserving production scheduling and session guards. Do we have a high-confidence way to reproduce the issue? Yes: the supplied saturation scenario targets the actual Swift test process, and current main still has deadline-based waits over queued MainActor work. This read-only review did not execute that scenario. Is this the best way to solve the issue? Yes: awaiting existing operation completion and fixture arrival signals removes the scheduling deadline while retaining the behavioral assertions and established production owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4c097a150cab. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
Await bootstrap, send, foreground, event, and retry tasks or deadline-free fake arrivals and observed state; isolate periodic recovery in foreground fixtures. Return existing foreground, chat, progress-card, and Swarm settling tasks without changing behavior or increasing production line count.
5b45958 to
2bdf553
Compare
|
Merged via squash.
|
… model tests (openclaw#165170) * test(chat): replace polling waits with owned completion signals Await bootstrap, send, foreground, event, and retry tasks or deadline-free fake arrivals and observed state; isolate periodic recovery in foreground fixtures. Return existing foreground, chat, progress-card, and Swarm settling tasks without changing behavior or increasing production line count. * test(chat): drop assertions repeated by observed waits * style(chat): drop the redundant return in resumeFromForeground
What Problem This Solves
Fixes:
macos-swift (packages)intermittently fails withTimeout waiting for: …inChatViewModelTestswhen the full OpenClawKit package runs its tests in parallel on a loaded runner.User Impact
No user-visible change. PRs stop picking up a red
macos-swift (packages)job from the chat view model progress-card, foreground, and run-recovery tests.Why This Change Was Made
Follows #165157 (rebased onto main after it landed; patch-identical to the proven head 5b45958). These tests detected product progress with
waitUntil, a 15 s wall-clock poll. In CI the whole package runs in one parallelswift testprocess, and the MainActor carries a large backlog there. Work that needs several MainActor hops outlives the deadline while it is still queued. #163719, #163792, and #165157 fixed the same class. This PR converts the first third of the remainingChatViewModelTestswaits: 68 tests, 122 waits.Each wait now awaits its owner or an arrival signal, so a backlog can delay it but cannot expire it:
handleTransportEventand await the Task it returns.handleProgressCardChangednow returns the progress-card fetch Task it already scheduled. The metadata event now returns its swarm-capability refresh, which a follow-up PR extends to the model refresh as well.resumeFromForeground()now returns the Task it already spawned (@discardableResult; production callers ignore it), and the foreground tests await it.bootstrapTask, thesend()Task, andquestionRefreshRetryTask.waitUntilBlocked(), and the counter and recorderwait(until:)from test(chat): await send and run-event owners instead of wall-clock polls #165157 cover the rest.waitForObservedState.After awaiting an owner, each test asserts the condition the old poll checked, so a regression fails as an expectation instead of timing out. No timeouts were lengthened and no retries were added. Production code is net 0 lines: the return-plumbing is funded by turning
if !matchesCurrentSession, !isOurRun { return nil }into an equivalentguard.Evidence
Deterministic saturation probe, the same method as #163792 and #165157. A temporary suite, not committed, floods the MainActor with 16,000 yielding tasks that each spin 1 ms. That puts one MainActor hop past 15 s. The flood is held 420 s, and the suite is named so it starts first. It runs in the same
swift test --package-path apps/shared/OpenClawKit --skip-build --disable-sandbox --filter '<this batch's tests>|AAMainActorSaturationProbe/'process, with a private HOME, CFFIXED_USER_HOME, OPENCLAW_STATE_DIR, and TMPDIR.remote run is adopted,foreground history applies,new session progress card applies, andfailed progress refresh applies its denial outcome.Test run with 69 tests in 2 suites passed after 420.0 seconds).Flake-fix proof bar (writing tests, Flake triage step 4), on the patch-identical proven head with a private HOME, CFFIXED_USER_HOME, OPENCLAW_STATE_DIR, and TMPDIR:
ChatViewModelTests.swift(ChatViewModelTests+ChatViewModelSessionManagementTests): 347 tests, 1.14–1.23 s of test time each (median 1.19 s).ChatViewModel*andNativeConversation*suite. 552 tests in 15 suites, passed.macos-swift; the full-packagemacos-swift (packages)shard runs in hourly main CI, which covers this change after merge (maintainer decision for this series). test(chat): await send and run-event owners instead of wall-clock polls #165157 and test(chat): await outbox owners instead of wall-clock polls in outbox tests #165187, the same conversion class, each passed three clean shard runs on their heads before landing.2bdf5534502b317cae343340cb3b953ccd786e3a: build passed; filtered batch 68/68 (1.091 s), standalone 347/347 (1.269 s), and siblings 552/552 (2.049 s) passed in the same private-state runner. Both replayed commits are=pairs in the range-diff.Checks.
git diff --checkis clean. I did not run the full OpenClawKit suite locally, because its keychain fixtures reach the login keychain on this Mac.Not committed as a regression test. The repro needs a sustained multi-minute MainActor flood, which is far over the test cost budget. The structural guard is that none of the converted tests has a deadline left.
Related: #163719, #163792, #165068, #165157