Repository navigation
test(chat): await settings, bootstrap, and send owners in view model tests - #165172
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, 5:34 AM ET / 09:34 UTC (Revision 6). ClawSweeper reviewWhat this changesThe PR replaces deadline-based polling in native chat tests with existing task completions, request-arrival signals, and observed state while preserving behavioral checks. Merge readiness✅ Ready for maintainer review The PR remains useful: current main retains the polling waits it replaces. No actionable introduced defect was found, and the related merged work covers different tests. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw's shared native chat view model loads conversations, applies session settings, and sends messages through a transport. These tests exercise that model with controlled transport responses and verify its resulting state. flowchart LR
A[Chat test scenarios] --> B[Native chat view model]
B --> C[Controlled transport responses]
C --> B
B --> D[Completion and arrival signals]
D --> E[Behavioral assertions]
E --> F[Native package validation]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceOther -196. Total -196 across 1 file. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep native chat tests synchronized with their existing completion owners and preserve independent assertions of transport and view-model behavior. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the 15-second polling deadlines over queued MainActor work, and the PR documents a before/after saturation reproduction. This review did not independently execute that reproduction. Is this the best way to solve the issue? Yes, awaiting existing owners removes scheduling-dependent deadlines without introducing new production seams, and the changed tests retain the relevant behavioral assertions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 13c1d87f6df4. LabelsLabel changes: No label 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)
|
6df213a to
e988b12
Compare
Await bootstrap, send, and settings owners, and use fake arrival signals for in-flight requests. Use observed state where no owner handle reaches, preserving the original assertions. Convert 121 waits across 57 tests without production or shared-helper changes.
3c1e41c to
1924453
Compare
|
Found 1 test failure on Blacksmith runners: Failure
|
|
Merged via squash.
|
…tests (openclaw#165172) * test(chat): replace B4 view model polls with completion signals Await bootstrap, send, and settings owners, and use fake arrival signals for in-flight requests. Use observed state where no owner handle reaches, preserving the original assertions. Convert 121 waits across 57 tests without production or shared-helper changes. * test(chat): drop assertions repeated by observed waits * test(chat): assert the rename failure after any error lands
What Problem This Solves
Fixes:
macos-swift (packages)intermittently fails withTimeout waiting for: …inChatViewModelTestsandChatViewModelSessionManagementTestswhen 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 settings-lane, session-switch, and session-management tests.Why This Change Was Made
Follows #165171 (rebased onto main after it landed; patch-identical to the proven head 3c1e41c). 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 last third of the remainingChatViewModelTestswaits, plusChatViewModelSessionManagementTests: 57 tests, 121 waits. With this PR,ChatViewModelTests.swifthas nowaitUntilleft.Each wait now awaits its owner or an arrival signal, so a backlog can delay it but cannot expire it:
waitForPendingSessionSettings, including the captured target for patches that outlive an agent switch.bootstrapTask, including a captured stale bootstrap after its gate is released, and thesend()Task.transport.waitForState, the counterwait(until:), and the existing hook gates'waitUntilBlocked().waitForObservedState. The rename fixture's refreshed row gets a distinctupdatedAt, so the wait can tell the post-rename refresh apart from the optimistic update.Task.sleepcalls that only gave a stale replay time to appear are replaced by awaiting the owner, which is a stronger proof.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. Test-only; no production changes.
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.stale subscribe is in flight,stale sessions refresh starts,other session loads, andold route is captured by queued thinking.Test run with 58 tests in 3 suites passed after 420.0 seconds).Flake-fix proof bar (writing tests, Flake triage step 4), on this head with a private HOME, CFFIXED_USER_HOME, OPENCLAW_STATE_DIR, and TMPDIR:
ChatViewModelTests.swift(ChatViewModelTests+ChatViewModelSessionManagementTests): 347 tests, 1.16–1.84 s of test time each (median 1.22 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.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.Landing CI observation. On rebased head
1924453ee6f5, the first CI attempt passed 3,700 of 3,701 Android third-party tests but hit a 1,000 ms Compose timeout inChatCompletedWorkLayoutTest.browserDismissalSurvivesRefreshAndSessionSwitchUntilReopenedOrNewToolPresentation, viashowToolResultsat line 674 (job log). This Swift-only diff changes no Android inputs. A single targeted replay of that shard was requested under the series landing authority; the timeout remains an unresolved Android test-reliability observation, and a passing replay would not establish a repair. The exact-head required CI gate remains mandatory before merge.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