Skip to content

test(chat): await settings, bootstrap, and send owners in view model tests - #165172

Merged
steipete merged 3 commits into
mainfrom
steipete/ock-waits-b4
Oct 5, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/ock-waits-b4

Conversation

@steipete

@steipete steipete commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: macos-swift (packages) intermittently fails with Timeout waiting for: … in ChatViewModelTests and ChatViewModelSessionManagementTests when 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 parallel swift test process, 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 remaining ChatViewModelTests waits, plus ChatViewModelSessionManagementTests: 57 tests, 121 waits. With this PR, ChatViewModelTests.swift has no waitUntil left.

Each wait now awaits its owner or an arrival signal, so a backlog can delay it but cannot expire it:

  • Settings lane. Model, thinking, verbosity, and fast-mode patch completions await waitForPendingSessionSettings, including the captured target for patches that outlive an agent switch.
  • Session switches and stale requests. These await bootstrapTask, including a captured stale bootstrap after its gate is released, and the send() Task.
  • Request starts. These use transport.waitForState, the counter wait(until:), and the existing hook gates' waitUntilBlocked().
  • Session-management refreshes. These have no handle, so they use waitForObservedState. The rename fixture's refreshed row gets a distinct updatedAt, so the wait can tell the post-rename refresh apart from the optimistic update.
  • Hook sleeps. Two Task.sleep calls 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.

  • Before, on the base (a44817c): 30 of the 57 tests fail, with 50 issues, e.g. stale subscribe is in flight, stale sessions refresh starts, other session loads, and old route is captured by queued thinking.
  • After, on this head: all 57 pass under the identical flood (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:

Checks. git diff --check is 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 in ChatCompletedWorkLayoutTest.browserDismissalSurvivesRefreshAndSessionSwitchUntilReopenedOrNewToolPresentation, via showToolResults at 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

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 4, 2026 22:46
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 4, 2026
@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 5:34 AM ET / 09:34 UTC (Revision 6).

ClawSweeper review

What this changes

The 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
Reviewed head: 1924453ee6f5d47924c0e958600c4f601cab94d0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused reliability patch with preserved assertions, documented stress validation, and no actionable correctness or security finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The verified trusted author's test-only change is exempt from contributor runtime proof. Its documented saturation run exercises the changed test synchronization against the native view model; repeated and sibling runs are supplemental validation. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The verified trusted author's test-only change is exempt from contributor runtime proof. Its documented saturation run exercises the changed test synchronization against the native view model; repeated and sibling runs are supplemental validation. No stored-data contract changes.
Evidence reviewed 7 items Verified introduced scope: The pinned merge-base-to-head diff changes only ChatViewModelTests.swift. The verified test-merge comparison likewise contains only that test file; Control UI endpoint differences belong to the base branch.
Still necessary on current main: Fetched main contains the original test blob e41de0a0aa74790552d188cbd7cca9bd449ddcef, including the model-patch, stale-subscription, and rename polling waits. The reviewed head contains the distinct replacement blob 24c9c041c2b821bcb51c34d9c24c7c1327468ead. No merged fixing PR for this remaining batch is established.
Completion-owner contracts: Bootstrap awaits its history, session-list, and model work before clearing loading state. Settings waiters resume after the target's in-flight patch count drains, and send returns the task running the send operation. The changed tests release their held gates before awaiting those completions and capture old targets or tasks where required.
Findings None None.
Security None None.

How this fits together

OpenClaw'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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Other -196. Total -196 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 304 500 -196
Total 1 304 500 -196

Review metrics

None.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This addresses a documented native-test reliability defect with bounded scope and no product behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The verified trusted author's test-only change is exempt from contributor runtime proof. Its documented saturation run exercises the changed test synchronization against the native view model; repeated and sibling runs are supplemental validation. No stored-data contract changes.

Evidence

What I checked:

  • Verified introduced scope: The pinned merge-base-to-head diff changes only ChatViewModelTests.swift. The verified test-merge comparison likewise contains only that test file; Control UI endpoint differences belong to the base branch. (apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatViewModelTests.swift:10013, 1924453ee6f5)
  • Still necessary on current main: Fetched main contains the original test blob e41de0a0aa74790552d188cbd7cca9bd449ddcef, including the model-patch, stale-subscription, and rename polling waits. The reviewed head contains the distinct replacement blob 24c9c041c2b821bcb51c34d9c24c7c1327468ead. No merged fixing PR for this remaining batch is established. (apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatViewModelTests.swift:10013, 13c1d87f6df4)
  • Completion-owner contracts: Bootstrap awaits its history, session-list, and model work before clearing loading state. Settings waiters resume after the target's in-flight patch count drains, and send returns the task running the send operation. The changed tests release their held gates before awaiting those completions and capture old targets or tasks where required. (apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel.swift:1501, 1924453ee6f5)
  • Rename assertions remain independent: The refreshed rename fixture has updatedAt 201, distinguishing server refresh from the optimistic label change. The failure wait accepts any non-nil error, then separately asserts rollback and the expected error text, avoiding an exact-error wait that could hang on a different failure. (apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatViewModelTests.swift:13945, 1924453ee6f5)
  • Captured validation and accepted shard coverage: The supplied PR body reports 30 of 57 tests failing before conversion under MainActor saturation and all 57 passing afterward, plus 20 clean standalone runs and 552 passing sibling tests. It explicitly assigns original Swift-package shard coverage to hourly main for this series after the CI-tier change. These are reported results; this read-only review did not execute tests. The separate Android timeout is recorded as unresolved reliability evidence, not a repaired failure. (1924453ee6f5)
  • Verified trusted-author routing: The live collaborator-permission endpoint identifies steipete as a repository admin, independently supporting the trusted-author proof exemption despite the pull endpoint reporting CONTRIBUTOR association.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-10-04T22:52:18.607Z sha dcc7b9f :: needs changes before merge. :: none
  • reviewed 2026-10-04T23:00:59.137Z sha 3c1e41c :: needs changes before merge. :: none
  • reviewed 2026-10-04T23:20:13.608Z sha 3c1e41c :: needs changes before merge. :: none
  • reviewed 2026-10-05T08:58:29.562Z sha 3c1e41c :: blocked before merge. :: none
  • reviewed 2026-10-05T09:08:22.816Z sha 1924453 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/ock-waits-b3 branch from 6df213a to e988b12 Compare October 5, 2026 08:28
Base automatically changed from steipete/ock-waits-b3 to main October 5, 2026 08:52
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.
@steipete
steipete force-pushed the steipete/ock-waits-b4 branch from 3c1e41c to 1924453 Compare October 5, 2026 09:01
@blacksmith-sh

blacksmith-sh Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
ai.openclaw.app.ui.chat.ChatCompletedWorkLayoutTest/
browserDismissalSurvivesRefreshAndSessionSwitchUntilReopenedOrNewToolPresentation
View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@steipete
steipete merged commit 1dd5192 into main Oct 5, 2026
132 of 137 checks passed
@steipete
steipete deleted the steipete/ock-waits-b4 branch October 5, 2026 09:39
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant