Skip to content

test(harness): click the three Workbench suggestions in a real browser (SP4, step 2) - #765

Merged
blove merged 19 commits into
mainfrom
blove/sp4-step2-suggestion-journeys
Sep 21, 2026
Merged

blove merged 19 commits into
mainfrom
blove/sp4-step2-suggestion-journeys

Conversation

@blove

@blove blove commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Completes SP4: W8 clicks the scaffolded Workbench's three empty-state suggestions in the same headless Chromium session as W7, finishing the list the Workbench arc named — "click a suggestion, watch the plan fill, the subagent run, the permission gate fire, approve, see memory candidates."

Spec: docs/superpowers/specs/2026-09-20-workbench-suggestion-journeys-design.md · Plan: docs/superpowers/plans/2026-09-20-workbench-suggestion-journeys.md · Builds on #750.

The three journeys

Each starts a new conversation, so each is its own thread with its own exact aimock delta.

Journey Proves Delta
Research a topic the plan card fills (Plan · 1/4 complete), the researcher subagent card completes, its tools list opens, writeFile ran at the root, the cited report lands 10
Trigger a permission prompt the gate renders as a role="alert" carrying the real command, Allow once resolves it, the run finishes, the post-approval reply appears 2
Teach it a preference a remember candidate reaches the memory panel and survives approval 2

What the lane proved, and what only it could

Nothing local verifies any empirical claim here: changing + 14 to + 13 leaves typecheck, lint and all 77 harness tests green. The lane is not a confirmation step for this change, it is the only test.

  • Clean run exit 0, twice (activation test 137 s and 291 s — the body is dominated by npm install, which this file records swinging 92–137 s, so W8's cost is inside run-to-run variance).
  • A clean pass is itself the proof the journeys ran: toHaveLength(suggestionsJournalStart + 14) fails on any other delta, including 0.
  • Three mutations, one per journey, each exit 1 with the journey name, a 45 s Playwright timeout rather than the harness deadline, the locator in the call log, and exactly one screenshot named for the failing journey.

Findings that changed the design

  • A completed subagent card renders collapsed. <details open={content.status === "running"}> means the tools list is in the DOM but not visible once the subagent finishes — the journey clicks the <summary> to expand it, which is also a real user action worth gating.
  • The rail's create button is + New conversation; an untitled thread row is exactly New conversation. Measured in Chromium: the bare-string locator matched the row (1 on a fresh load, 0 once titled), so journey 1 passed by accident and journeys 2 and 3 would have timed out. This was the first-run blocker, in the one assertion nothing local can test. The identical latent copy in capture.mjs is filed separately rather than changed here.
  • Approve and Delete are indistinguishable by removal alone — both drop the row and both empty the candidates list, and describeApprove returns null for a plain activation so the outcome line is empty either way. The journey watches the approve POST and asserts record.status === "active"; the unit-test fake deliberately wires a reject POST first so the predicate must discriminate.
  • .last() masked the duplicate-card regression the AG-UI suppression ledger fixed. Replaced with a one-shot expectExactlyOne (Playwright's toHaveCount polls until the count becomes 1, so a duplicate that resolves would pass).
  • 120 s waits handed the likely failure to the harness abort, where the screenshot and call log are lost. Cut to 45 s so Playwright always wins the race — mutation 1 confirms it does.

Shape

The shared page scaffolding moved to test/harness/workbench-page.ts (launch, console-error collection with the 404 hydrate-probe allowlist, abort race, screenshot, cleanup, plus a success-path backstop so no caller can forget the error check), and now enforces its own contract: screenshotPath is string | (() => string) resolved late and guarded, so a throwing resolver cannot replace the real failure. The journeys live in their own workbench-suggestions.ts and import the seam; a golden ordered call list pins every locator, so a locator change shows up in the review diff rather than only in a four-minute lane.

43 unit tests across three harness files; typecheck, lint and check-docs clean.

Not covered

Allow always / Deny, subagent-approval gates, reloading these threads (W7 covers restore once), visual assertions, and the Reject decision.

🤖 Generated with Claude Code

blove and others added 19 commits September 20, 2026 09:15
W8 clicks the three empty-state suggestions in the same browser session as
W7: Research a topic (plan card 1/4, researcher subagent card, report),
Trigger a permission prompt (Allow once → completion), Teach it a preference
(remember → memory candidate → Approve). Exact journal deltas 10/2/2.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…r gate

No behaviour change: launch, error collection, abort race, screenshot, and
cleanup move into withWorkbenchPage so the suggestion journeys share them.

Co-Authored-By: Claude Opus 5 <[email protected]>
A completed subagent renders <details open={status === "running"}> closed, so
the Subagent tools list is in the DOM but not visible; journey 1 must click the
summary first. Also record that card summaries carry the marker glyph in
textContent, so header assertions cannot use exact matching.

Co-Authored-By: Claude Opus 5 <[email protected]>
The panel reloads on onRunFinishedEvent, so journey 3 needs no reload, and it
renders null when empty so its aria-label element only exists once a candidate
does. The gate command is inside the role=alert wrapper.

Co-Authored-By: Claude Opus 5 <[email protected]>
Keeps withWorkbenchPage the single outer wrapping site so a CI log does not
print one Playwright timeout three times, checks collected console errors per
journey so attribution and the screenshot name are right, and passes
screenshotPath as a function now that the seam resolves it late.

Co-Authored-By: Claude Opus 5 <[email protected]>
screenshotPath is now `string | (() => string)`, resolved inside the catch, so
the late read is a type the compiler checks rather than a comment: a caller
driving several journeys through one options object gets a per-journey file
name, and hoisting the read now fails a test.

withWorkbenchPage is the single wrapping site — it adds the collected console
errors and the cause once, and a journey that wants its own name applies that
prefix inside the body, so flattenCause does not print a Playwright timeout
two or three times.

It also backstops the success path: a body that returns while console errors
were collected still fails, for callers that forget their own check (W7's
check fires first, so its message is unchanged).

Deps are narrowed to Pick<WorkbenchBrowserDeps, "chromium"> because the seam
never reads deps.journey, and WorkbenchBrowserOptions now extends
WorkbenchPageOptions so the relationship is checked, not structural.

Co-Authored-By: Claude Opus 5 <[email protected]>
The page seam moves to test/harness/workbench-page.ts, so Task 2 adds the
suggestion journeys to a smaller workbench-browser.ts that imports it.

Co-Authored-By: Claude Opus 5 <[email protected]>
…lure

The screenshot resolver is caller code now that the seam is exported, and it
ran unguarded inside the failure handler whose mkdir and screenshot are both
best-effort. A throwing resolver escaped the catch and replaced the real
error: a Playwright timeout surfaced as a bare TypeError, losing the call log,
the collected console errors and the whole cause chain. It now resolves to
string | undefined, and undefined skips the mkdir and the screenshot while the
original error is still rethrown with its console-error append.

Also pins W7's own console-error wording in its existing expectation, so
deleting that check can no longer hide behind the seam's backstop; and stops
the backstop printing a second, wrong heading ('before the failure' when the
errors ARE the failure) plus a third near-identical line through flattenCause.

Co-Authored-By: Claude Opus 5 <[email protected]>
Pure move ahead of the suggestion journeys, which are about to add ~110 lines
to a file whose header already described only W7. workbench-page.ts now owns
the shared browser session — WorkbenchPageOptions, withWorkbenchPage,
raceAbort, collectPageErrors, isExpectedHydrateProbeError,
JOURNEY_ABORTED_MESSAGE and COLLECTED_ERRORS_BACKSTOP_MESSAGE — and
workbench-browser.ts keeps W7 alone and imports it. Both headers rewritten to
describe their own file. No behaviour, message text, or call-site change: the
same 25 tests pass, 21 in the gate's file and 4 in the seam's.

Co-Authored-By: Claude Opus 5 <[email protected]>
Appending them to workbench-browser.ts would undo the split that just gave the
seam its own home, and typing their chromium off WorkbenchBrowserDeps would
re-invert the dependency direction. They import the seam directly.

Co-Authored-By: Claude Opus 5 <[email protected]>
The abort refusals, the hydrate-probe allowlist, pageerror collection,
console-warning tolerance and the context-before-browser close order are
`withWorkbenchPage` behaviours, not W7 behaviours; they now live in
workbench-page.test.ts and drive the seam directly. workbench-browser.test.ts
keeps only what is about W7 itself: prompt shape, the thread-id lookup and its
diagnostics, restore, and W7's own console-error message.

Also de-duplicates the launch signature: WorkbenchBrowserDeps now extends
WorkbenchPageDeps instead of restating `chromium`.

Counts: workbench-browser.test.ts 21 -> 14, workbench-page.test.ts 4 -> 12
(25 -> 26 total).

Co-Authored-By: Claude Opus 5 <[email protected]>
W8 clicks each of the scaffolded Workbench's empty-state suggestions from a
fresh conversation and asserts what comes back:

- "Research a topic": the plan card's `Plan · 1/4 complete` summary, the
  collapsed `researcher · completed · 2 tools` subagent card expanded to show
  searchCorpus and readDoc, the writeFile card, and the report reply.
- "Trigger a permission prompt": the role="alert" gate holding the fetch
  command, resolved through `Allow once`, awaited hidden, then the gated reply.
- "Teach it a preference": the remembered candidate in the memory panel,
  approved by its full `Approve: <content>` name, then confirmed gone over
  /api/b4/memory/candidates.

All three share ONE browser and one openReadyWorkbench through the
`workbench-page.ts` seam, which stays the single outer wrapping site: each
journey applies its own name to a failure from inside the body, and the
collected-console-error check runs per journey, so a research-journey error is
never reported against the teach journey. The screenshot path is a resolver, so
each journey's failure writes workbench-browser-<key>.png rather than
overwriting one file.

Co-Authored-By: Claude Opus 5 <[email protected]>
A 120s wait hands the likely failure to the harness abort path, where the
screenshot and call log are lost; .last() masks the duplicate-card regression
the suppression ledger fixed; and Approve and Reject both remove the row, so
removal alone does not prove approval.

Co-Authored-By: Claude Opus 5 <[email protected]>
…Playwright

Review of 763c415 found the gate could drift without any test noticing, and
could fail in the one place that reports nothing useful.

Timeouts: every wait drops from 120s to 45s. `withWorkbenchPage`'s abort race
rejects from OUTSIDE the body, so a harness-deadline loss skips the per-journey
catch entirely — no journey name, no Playwright call log, and a screenshot that
no-ops against a closing browser. 45s guarantees Playwright wins the race,
which is the only path that names the drifted locator and writes the PNG.

Shape guard: `teachContent` is now rejected before launching, mirroring W7's
PROMPT_SHAPE_MESSAGE, with MEMORY_LABEL_LIMIT = 60 mirroring MemoryPanel.tsx's
LABEL_LIMIT. `shortLabel()` collapses whitespace and truncates, so an untrimmed,
multi-line or over-long content yields an accessible name the exact-name Approve
locator can never match.

Approve discriminator: every UI-visible consequence of Approve is shared with
Delete — both remove the row, both hard-delete the candidate, and the
role="status" outcome line is empty for both (describeApprove returns null for a
plain "activated"; reject never sets an outcome). The journey now arms
page.waitForResponse for POST …/candidates/:id/approve before the click and
asserts the returned record is our content with status "active". Only approve
POSTs that route, and only its body carries the stored record. The HTTP negative
stays: a UI-only check would pass on an optimistic removal with a failed POST.

Golden call list: the first test pins the full ordered locator trace. Dropping
`.last()`, deleting the writeFile assertion, deleting the plan-card assertion,
and changing it to 2/4 were all green before; all four now fail.

Also: `.last()` on the cards replaced by expectExactlyOne (a duplicate card is
the regression the AG-UI suppression ledger fixed); writeFile asserted at the
root and proven absent from every activity card; the expand click followed by a
details[open] wait so a disclosure bug does not read as a rendering bug; the
journey function hung on its JOURNEYS entry; the suggestion title escaped before
RegExp; SuggestionJourneyDeps extends WorkbenchPageDeps; and the test's
RESEARCH_REPLY constant restored to the fixture's verbatim reply with its
citation.

Co-Authored-By: Claude Opus 5 <[email protected]>
The journeys use a local expectExactlyOne, not toHaveCount(1), because the
web-first matcher cannot be driven by the structural fake and because it polls
until the count becomes 1. And W8's worst single wait is the 120s inside the
shared completion helper, not the 45s the journeys arm.

Co-Authored-By: Claude Opus 5 <[email protected]>
…masking duplicates

Two proven defects from the re-review of b31c040.

The approve wait was a floating promise. `waitForResponse` was armed, then the
Approve click was awaited on its own: a click that throws (name not found, still
disabled past the actionability timeout, page closed) rejects the journey with
nobody ever handling `approvePost`, which then rejects on its own timer. The
reviewer reproduced it standalone — the journey's real message, then UNHANDLED
REJECTION: waitForResponse timeout, exit 3 — which in the activation lane can
take the vitest worker down and destroy exactly the named, screenshotted failure
this gate exists to produce. Now Playwright's documented
`Promise.all([approvePost, approveButton.click()])`, with `approvePost` still
created first so the ordering the golden list pins is unchanged.

The two surviving `.last()` calls rested on a mechanism that does not exist.
The comment claimed nested markdown could make one message match several
elements; measured in real Chromium, Playwright's text engine excludes an
ancestor whose child also matches, so a message nested <div><p> counts 1 and
triple-nested counts 1 — only TWO MESSAGES count 2. `.last()` was therefore
masking the duplicate-emit regression, the same class `expectExactlyOne` was
introduced to stop masking. Both replaced with `expectExactlyOne` ("assistant
reply", "gated reply") and the false comments deleted; two new tests fail on a
doubled reply.

Comment corrections: the module header and `LOCATOR_TIMEOUT_MS` now say "every
wait this file arms" and name the imported `waitForWorkbenchRunCompletion`'s own
three 120s waits (so W8's true worst single wait is 120s, from capture.mjs);
`expectExactlyOne` says its count is a one-shot snapshot after the visibility
wait, not a settled invariant; and the approve predicate says `APPROVE_PATHNAME`
is the discriminator and the method check is belt-and-braces, so a future reader
loosens the pathname at their peril.

Co-Authored-By: Claude Opus 5 <[email protected]>
…owser

Research a topic proves the plan and subagent cards fill and the report lands;
Trigger a permission prompt proves Allow once resolves the gate and the run
finishes; Teach it a preference proves a remembered preference reaches the
memory panel and survives approval. Each journey is its own thread with its own
exact aimock delta (10 + 2 + 2).

Co-Authored-By: Claude Opus 5 <[email protected]>
`startSuggestion` matched `New conversation` exactly, which is the UNTITLED
THREAD ROW's label (`UNTITLED_THREAD_LABEL`, ThreadRail.tsx:24,53). The rail's
create button renders the literal `+ New conversation` (ThreadRail.tsx:42). So
the locator matched one element on a fresh load — the row — and ZERO once
journey 1 had titled that thread. Journey 1 passed by accident (clicking the
already-active untitled row is a no-op, and that thread is the clean slate the
journey wants); journey 2 would have retried to Playwright's implicit 30s
default and thrown on the first lane run. Now `+ New conversation`, with a
comment recording why the plus is load-bearing so the next reader does not tidy
it away. `handleCreate` no-ops on an already-untitled active thread, so journey
1's behaviour is unchanged.

Explicit deadlines: the two clicks in `startSuggestion`, the summary expand, the
`Allow once` click, the Approve click and the `page.request.get` all now pass
`{ timeout: LOCATOR_TIMEOUT_MS }`. They were falling back to Playwright's
implicit 30s, so the module header's claim that every wait this file arms sits
inside the harness's own deadline held only by the accident of 30 < 45, and a
`setDefaultTimeout` or a Playwright default change would have broken it
silently.

The fake can now express absence. `countFor` applies through `.first()`/
`.last()` narrowings, a click on a zero-count locator rejects with Playwright's
own timeout wording, and a `visible` wait on one does too (a `hidden` wait still
passes — a locator matching nothing IS hidden). Without this, "the button does
not exist" was unrepresentable and all 15 tests passed against the broken
locator above: the ordering test's create-button assertion was decorative. Two
new tests make it falsifiable — a missing create button and a missing suggestion
button each fail with the journey's name and Playwright's message. Restoring the
old bare-string locator now reds three tests.

Co-Authored-By: Claude Opus 5 <[email protected]>
Two clean runs plus one mutation per journey, each failing inside Playwright
with the journey name and its own screenshot. Also records the sed trap: a
pattern that does not match mutates nothing and the lane passes.

Co-Authored-By: Claude Opus 5 <[email protected]>
@vercel

vercel Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
b4-run Ready Ready Preview Sep 20, 2026 11:14pm UTC

Request Review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval: this PR received an intelligent (AI) code review. See the review comments on this PR.

@blove
blove merged commit 6b45ec8 into main Sep 21, 2026
31 of 32 checks passed
@blove
blove deleted the blove/sp4-step2-suggestion-journeys branch September 21, 2026 16:27

This branch was successfully deployed

1 active and 1 inactive deployments
vercel-preview — 51c02b42 Deployed Sep 20, 2026 by blove via vercel-native #2150
Preview — 51c02b42 Deployed Sep 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant