Skip to content

🤖 tests: Storybook draft mocks share one revision sequence per page - #6437

Merged
ThomasK33 merged 1 commit into
mainfrom
tests/storybook-three-flakes
Oct 14, 2026
Merged

ThomasK33 merged 1 commit into
mainfrom
tests/storybook-three-flakes

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Summary

This PR fixes one of the three Storybook flakes in #6389: App/Gateway Fast Mode › Phone. The Storybook drafts mock started a new revision sequence for each story. The DraftStore, which is one per page, then applied an older, empty draft view over the text the play was typing. The mock now keeps one revision sequence for the whole page, as a real backend does. Only the Storybook mock changes. Refs #6389: Features/RightSidebar/MemoryTab › Editor and App/Desktop › SharedBinding are not fixed here.

Root cause

  1. Each story builds a new mock client, and createMockDraftsApi started its revisions at 1 (src/browser/stories/mocks/drafts.ts). The Desktop and Phone stories use the same workspace ID, and Desktop writes the draft many times.
  2. The DraftStore keeps the last server view of each draft, serverView, with its revision. On the new client's snapshot it resets entry.revision but keeps serverView, because applyServerState replaces it only when the new revision is not lower (src/browser/stores/DraftStore.ts, applyServerState).
  3. In Phone, every write reply then had a lower revision than the kept view from Desktop. So applyWriteReply applied that kept view, which was empty, over the composer whenever no newer keystroke was pending.
  4. The play typed /ultrafast, the composer was wiped in the middle, and the rest of the keystrokes sent fast or st as a message. The tier stayed priority: expected 'priority' to be 'ultrafast'.

I traced this with scratch instrumentation in the play. A failing run shows applyWriteReply for a reply {revision: 3, text: "/ultrafa"} calling applyServerState(entry, ""), and the composer value turning "" in the same millisecond.

A real backend does not regress: DraftService seeds its revisions from its start time. I first tried that in the mock (Date.now()), but stories freeze Date.now (storyTime.ts), so every story got the same seed and the failure stayed. A module-level counter is the fix.

Validation

Old build (main) and new build, served with http-server, test-storybook --testTimeout 30000, bun 1.4.3, shared 32-core host. Rounds were interleaved so that both builds saw the same load.

Run Before (main) After (this PR)
App.gatewayFastMode.stories.tsx alone, 6 copies in parallel, 15 rounds 7/90 failed 0/90
Full suite, interleaved (load 14-97) 2/18 Gateway Phone failures 0/21
Earlier full-suite runs on main (same session) 21/85 Gateway Phone failures n/a

I counted only full-suite runs without host overload (10 or fewer failures). Runs with page.goto timeouts across the suite are excluded on both sides.

make static-check passed.

Not fixed here

  • Features/RightSidebar/MemoryTab › Editor ("yaml block is not highlighted yet") still failed 2 of 21 full-suite runs with this change, and 2 of 18 without it. Its play waits 5 s for Shiki tokens. The code-block highlight has its own 5 s budget and falls back to plain text, so a longer wait in the play would not help. Not root-caused yet.
  • App/Desktop › SharedBinding ("Unable to find a label with the text of: Desktop session preview") did not fail in these 39 runs. Not root-caused.

Risks

Storybook only. The revision numbers in story mocks now keep growing across stories in a page. No story reads them.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

Refs #6389

---

_Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_

<!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=high -->
@ThomasK33

Copy link
Copy Markdown
Member Author

Perf clearance request for the perf owner (workspace 8e18f4aada). Peer messaging is unavailable from my workspace, so I am posting it here.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T00:46:29.714434Z af091d0 PR opened
🔒 Security Review ✅ Completed 2026-10-14T00:47:46.175516Z af091d0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ThomasK33

Copy link
Copy Markdown
Member Author

Perf clearance (perf owner): cleared at af091d0ee5.

  • The head matches git ls-remote. The merge base is 029de46075.
  • Changed files: src/browser/stories/mocks/drafts.ts +10/−1 only. No app source imports stories/mocks, so it is outside every app bundle.

A new head needs a new clearance.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit a558137 Oct 14, 2026
32 of 33 checks passed
@ThomasK33
ThomasK33 deleted the tests/storybook-three-flakes branch October 14, 2026 01:31
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