Repository navigation
test(ui): assert positive New Session draft behavior - #124253
Conversation
Replace the New Session draft E2E's only assertion, a zero-count check against a CSS selector that appears nowhere in production code, with positive coverage: the draft text stays on the composer, the route and sidebar stay put, no sessions.create request fires before submit, and submitting creates exactly one session with canonical navigation. Fixes #124237
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 5:30 PM ET / 21:30 UTC. ClawSweeper reviewWhat this changesThe PR replaces a New Session E2E check for a retired CSS class with assertions that a draft stays in the composer until one session is created and the app navigates to it. Merge readinessKeep open for normal maintainer handling. Current main still contains the vacuous obsolete-selector assertion, while this focused test-only PR replaces it with behavior-level coverage; no blocking correctness or security finding was identified. Priority: P3 Review scores
Verification
How this fits togetherThe Control UI New Session page holds an unsent draft locally, renders canonical sessions from the Gateway, and creates a session only after submit. Its E2E suite drives that browser flow with a mocked Gateway and records requests. flowchart LR
A[New Session route] --> B[Draft composer]
B --> C[Draft submission flow]
C --> D[Mock Gateway request recorder]
D --> E[Canonical session route]
D --> F[Sidebar session list]
Decision needed
Why: The protected Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +32. Total +32 across 1 file. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Land one browser-level regression test that protects the existing composer-owned draft and canonical create-and-navigate flow without restoring sidebar-markup coupling. Do we have a high-confidence way to reproduce the issue? Yes for the coverage defect: current main's test checks only a retired selector and never types or submits a draft; the supplied Testbox Chromium run further exercises the proposed positive assertions. Is this the best way to solve the issue? Yes. The patch tests the existing route, composer, Gateway request, sidebar, and navigation boundary without adding production hooks or preserving retired markup. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 73c45824e1e2. LabelsLabel 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)
|
Reorders the exactly-once sessions.create assertion to run after the canonical navigation-settle poll (the same signal the neighboring submission test waits on), instead of right after waitForRequest resolves. The old order could pass prematurely if a late duplicate create landed after the count check but before navigation completed.
|
Merged via squash.
|
* test(ui): assert positive New Session draft behavior Replace the New Session draft E2E's only assertion, a zero-count check against a CSS selector that appears nowhere in production code, with positive coverage: the draft text stays on the composer, the route and sidebar stay put, no sessions.create request fires before submit, and submitting creates exactly one session with canonical navigation. Fixes openclaw#124237 * test(ui): settle before asserting exactly-once sessions.create Reorders the exactly-once sessions.create assertion to run after the canonical navigation-settle poll (the same signal the neighboring submission test waits on), instead of right after waitForRequest resolves. The old order could pass prematurely if a late duplicate create landed after the count check but before navigation completed.
Fixes #124237
What Problem This Solves
The first case in
ui/src/e2e/new-session-page.places.e2e.test.tsboots the full mocked New Session page but its only assertion isexpect.poll(() => page.locator(".sidebar-recent-session--draft").count()).toBe(0). That selector does not appear anywhere in production code, so the check is vacuous: it passes regardless of whether the pre-creation draft actually stays on the composer, the sidebar reflects real session data, or the composer avoids creating a session before submit.Why This Change Was Made
Replaced the vacuous selector check with positive assertions inside the same mocked-Gateway suite, reusing the existing submission pattern from the neighboring test case: after typing a draft on
/new?agent=main, the test now confirms the route and agent query param stay put, the composer textarea holds the typed value, the sidebar shows exactly the one canonical sessionsessions.listreturned (no phantom draft row), and zerosessions.createrequests have fired. It then submits and confirms exactly onesessions.createrequest with the expected params plus navigation to the canonical session route. The change is test-only; no production code was touched.Review follow-up: the exactly-once
sessions.createassertion originally ran immediately aftergateway.waitForRequest("sessions.create")resolved, before waiting for the navigation-settle signal the neighboring submission test uses. That ordering could pass prematurely if a late duplicate create landed after the count check but before navigation finished. Reordered so the test polls for navigation to the canonical session route first, then asserts the request count, matching the neighboring test's wait pattern.User Impact
No user-facing behavior changes. This closes a coverage gap so a real regression in the New Session draft-preservation flow (draft-navigation-handoff.ts / new-session-page.ts) would now fail this test instead of passing silently.
Evidence
tbx_01m03mdvkmyakbab0e4w4xsncz), temporarily changedexpect(await page.locator(".sidebar-recent-session").count()).toBe(1)to.toBe(2)and ran the test with real Chromium/Playwright. It failed for the right reason:AssertionError: expected 1 to be 2at the sidebar-count assertion line. Restored the correct value and reran: passed. This proves the new positive assertion is wired to real DOM state, not vacuous like the selector it replaced.node scripts/run-vitest.mjs ui/src/e2e/new-session-page.places.e2e.test.tson the same Testbox lease — all 10 tests in the file pass, including the reordered exactly-once assertion.checks-uiandchecks-ui-e2e (4/12)on the exact-head rollup): both failures are pre-existing, unrelated flakes, not caused by this test-only change:checks-ui-e2e (4/12)failed inui/src/e2e/agent-file-lifecycle.e2e.test.ts:294(AssertionError: expected '# Real main instructions\n# Saved thr…' to be '# Saved through real Gateway\n') — a different file entirely. The identical assertion failed on unrelated, concurrently open PRs at different shard indices:brzezowski/sharing-identity-kindshard 10/12 (run 31908362789) and another run at shard 6/12 (run 31904182917). Two more unrelated PRs failedchecks-ui-e2eat yet other shards on different tests (config-safe-write.e2e.test.tstimeout at shard 6/12 in run 31908362789,lobster-pet-dismiss-menu-overflow.e2e.test.tsassertion at shard 8/12 in run 31904527461) — consistent with generalchecks-ui-e2elane flakiness rather than anything in this PR's diff.checks-uifailed insrc/pages/chat/chat-responsive.browser.test.ts(Error: page.evaluate: Resulting promise was garbage collected) — an unrelated browser-mode test for the chat responsive layout, in a file this PR never touches. The error is a Playwright/GC timing artifact, not a content assertion tied to this change.node scripts/check-changed.mjs -- ui/src/e2e/new-session-page.places.e2e.test.ts— delegated through Testbox, exit 0. Conflict markers, max-lines ratchet, changelog attributions, doctor deprecation registry, extension/plugin-sdk wildcard re-export guards, duplicate scan coverage, coercion helper guard, dependency pin guard, formatting (oxfmt --check), package patch guard, dead-export scan, Control UI i18n catalog, and core-test typecheck all passed..agents/skills/autoreview/scripts/autoreview --mode uncommitted— clean: "no accepted/actionable findings reported", overall correctness 0.99.oxfmtrun on the changed file: "All matched files use the correct format."