Skip to content

tests: ArtifactTheme Layout Phone story can stay on Storybook's preparing loader #3267

Closed

Description

@schlessera

Context

Observed on PR #3265, confirmation run 41383510262, job browser (3) (checkout 9bd1eb92047d28951de02491a42f92edefbb030f, base b4b9204e25d5f882deacafe7f166029806f71bf6). The PR changes only packages/ui-server journal code, packages/ui-sdk types and docs; it does not touch packages/ui-react.

Failing test: packages/ui-kit/stories/conversation/ArtifactTheme.stories.tsx (path corrected 2026-11-02; it was cited under ui-react) › "Layout Phone", in both the storybook (chromium) and storybook-light (chromium) projects. The play function's findByRole("heading", { name: "Couldn't open this file." }) (ArtifactTheme.stories.tsx:56) timed out. The DOM dump shows the Storybook preview still on its sb-preparing-story loader, and its sb-errordisplay panel is present but inert with an empty message, so the story never rendered. The other three stories in the same file passed in both projects, as did 2846 of the shard's 2848 tests.

Scope

Diagnosed 2026-11-02 (see the diagnosis comment). The sb-preparing-story loader in the DOM dump is Storybook's static, inert preview template, which is always in the document; the dump is truncated before the story's own markup. The story did render: opened() found the link and the scratch check before the failing wait. The real cause is that FilePanel loads FileViewer (and FileTree) through lazyChunk, and "Layout Phone" is the first story in the file to open the panel. Its findByRole therefore has to absorb a cold Vite transform of the viewer module graph within Testing Library's default 1000 ms budget, which a loaded CI shard can exceed (the failing test took 1804 ms in total). The later stories find the chunk warm.

Fix: after Enter starts the real lazy load, await the same viewer and tree modules before the 1000 ms waits begin. This follows the precedent in destination-press.pointer.tsx. Apply it to both plays that open the panel, so the first story in either project, or under any filter, is never cold.

Out of scope

Raising the timeout or retrying the story without a diagnosed cause.

Acceptance criteria

  • Both ArtifactTheme plays wait for the real lazy FileViewer/FileTree imports to finish after opening the panel, before any 1000 ms Testing Library wait.
  • No timeout is raised, and no retry or skip is added.
  • A failing-first receipt holds the viewer module request in a real browser: without the fix "Layout Phone" fails on the same findByRole heading wait, and with the fix it passes.
  • Both story projects (storybook and storybook-light) pass the file in the pinned browser image.

Contract impact

None expected.

Activity

  1. added
    type: test
    area: ui-react
    on Nov 2, 2026
  2. schlessera commented on Nov 2, 2026

    @schlessera
    OwnerAuthor

    2026-11-02: second occurrence. This is PR #3282, confirmation run 41446241074, job `browser (3)`, head `beecb74c81e240b45279702e9eaddf005da83b69`, base `b228b1f21c4758ee712e922d12ebbe77cf4b3512`. The PR changes only the `packages/ui-sdk` worker socket test fixture and its test, and touches nothing in `packages/ui-react`. The failure is the same: `ArtifactTheme.stories.tsx` › "Layout Phone" (`storybook-light (chromium)`) timed out in `findByRole("heading", { name: "Couldn't open this file." })` at `:56`, with the preview still on `sb-preparing-story`. 1 of 2906 tests failed in that shard. Every other selected job in the run passed.

    Under the 2026-10-25 strict-flake ruling (a repeated suspected flake on one test escalates to real, and a rerun never makes proof green), this now blocks a merge. #2745 (`priority: p0`) is blocked by it, so under the blocker-priority rule this issue is raised to `priority: p0`.

  3. added
    priority: p0
    on Nov 2, 2026
  4. self-assigned this
    on Nov 2, 2026
  5. schlessera commented on Nov 2, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation (claim token w3267-c7f2), branch test/3267-artifact-theme-cold-viewer. Collision check on the story file: proof-closure overlaps only (no path collisions).

  6. added
    agent-ready
    on Nov 2, 2026
  7. schlessera commented on Nov 2, 2026

    @schlessera
    OwnerAuthor

    2026-11-02: readiness review and diagnosis. The body is updated: the corrected path, the diagnosed scope and acceptance criteria.

    The preparing loader is a red herring. The sb-preparing-story, sb-preparing-docs, sb-nopreview and sb-errordisplay blocks in the dump are Storybook's static preview template. It is always in the document and stays inert, and the dump is cut off (...) before the story's own markup. The story had rendered: opened() had already found the link and the present scratch check before the failing wait. ArtifactTheme.stories.tsx:56:7 is a bad source-map frame. The failing call is the findByRole straight after Enter in LayoutPhone.

    Root cause. FilePanel loads FileViewer and FileTree through lazyChunk (packages/ui-react/src/components/files/file-panel.tsx:34-35). "Layout Phone" is the first story in the file, so it is the first to open the panel in each project's page. Its findByRole, with Testing Library's default 1000 ms, therefore also absorbs a cold Vite transform of the viewer's module graph. A loaded shard can exceed that: the failing case took 1804 ms in total. The later three stories find the module warm, and that matches the evidence, since only Layout Phone ever failed. destination-press.pointer.tsx already handles the same thing by awaiting the real lazy imports before its 1000 ms poll.

    Reproduction. I held the file-viewer.tsx module request for 2.5 s with a temporary Playwright route (receipt only, not committed) and ran the unchanged story file in the pinned Playwright image. "Layout Phone" failed in both storybook and storybook-light with Unable to find role="heading" and name "Couldn't open this file.", at the same :56:7 frame and with the same sb-preparing-story dump. The other three stories passed.

    Fix. After Enter, both plays now await the same viewer and tree modules before their 1000 ms waits. No timeout, retry or skip changes. It is implemented on branch test/3267-artifact-theme-cold-viewer.

    Same class elsewhere. packages/ui-react/tests/browser/file-loading.layout.tsx polls viewer and tree content on the default budget on a cold first render. It has no observed failure, so it is filed as a follow-up instead of widening this PR.

  8. added this to the 0.45.0 milestone on Nov 2, 2026
  9. schlessera commented on Nov 2, 2026

    @schlessera
    OwnerAuthor

    Merged in #3286 as efea2be3edb69c8eb2e95549fb19852afa07b089 on main (milestone 0.45.0). The squash parent 557b01bc1 and tree 5cb9ce51f match the confirmed candidate checkout d638b8052.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: ui-reactpriority: p0type: test

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions