Repository navigation
Description
Failure
The Mecatl Studio (apps/) CI job intermittently fails in:
src/features/chat/session-sidebar.pinning.test.tsx > chat list row pins > files a row into a folder, out of it, and into a new folder
Failing job on PR #2600, run 40810310063, attempt 1, head 2db90ff580b7876827ffcfdede4ab7480e353b16.
TestingLibraryElementError: Unable to find role="menuitem" and name "Move to folder"
rowAction src/features/chat/session-sidebar.pinning.test.tsx:118:29
src/features/chat/session-sidebar.pinning.test.tsx:169:5
Test Files 1 failed | 200 passed (201)
Tests 1 failed | 1762 passed (1763)
The failure occurs on the first move-to-folder action, before any folder callback runs. The companion Mecatl Studio (gate) job fails only because this upstream unit-test job failed; it is not an independent failure. Both mobile and desktop browser-journey jobs passed, as did the Go race/lint/API gates.
Flake evidence
- PR fix(learning): fit manual synchronous reflection to request budgets #2600 changes only
internal/app/reflection_observer.goand its Go regression test. This sidebar test renders local fixtures with mocked callbacks; it does not invoke the modified reflection path. - Passing main job, SHA
22a8ce6e218782d463cd911d5be57221737e529d, ran the same sidebar file successfully: 6 tests passed. - Git blob identities were compared between that passing main tree and the failing PR tree. The test, sidebar component, mobile hook, shared setup, viewport-mutating tests listed below, Vitest config, and
apps/pnpm-lock.yamlare byte-identical. This is stronger than relying only on the PR's unrelated file scope. - A later main CI run also has a passing Studio job: run 40881476164.
Classification: intermittent/order-dependent test-environment failure. The exact preceding worker-file sequence has not been replayed, so the root-cause explanation below remains a well-supported hypothesis, not a confirmed reproduction. No same-SHA CI rerun was requested. Local reproduction was not run: this checkout has no installed apps Vitest dependencies, and its ambient Node/pnpm versions differ from the pinned CI toolchain.
Suspected mechanism: shared viewport state changes the expected accessible role
rowActionclicks the row options button, thenfindByRole("menuitem", {name: "Move to folder"})(session-sidebar.pinning.test.tsx:108-120). It already waits for menu appearance; adding a generic delay is not a root-cause fix.SessionRowrenders a desktop submenu trigger with that role atsession-sidebar.tsx:402-407. In mobile mode it instead renders an inline group/label named "Move to folder", not a menuitem (:392-400). The existing test helper assumes the desktop submenu and sends ArrowRight.useIsMobilereads sharedwindow.matchMedia/innerWidth(apps/web/src/lib/use-mobile.ts:9-12).- Vitest uses
isolate: false, sharing a happy-dom window across files in a worker (apps/web/vite.config.ts:41-49). Shared setup restores stubbed globals but does not restore direct property assignments. chat-composer.configuration.test.tsx:153-157directly setsinnerWidth=320andinnerHeight=480without restoring them.option-field.test.tsx:45-65directly assigns viewport width,window.matchMedia, and DOM prototype methods without restoring them. Its media implementation reports mobile from the currentinnerWidth.- Both of those files completed before the failing sidebar test in the CI log. That does not prove they ran in the same worker, but the ordering and role mismatch are consistent with shared mobile viewport state.
apps/web/src/test-setup.ts:10-55explicitly documents the shared-window rules and central restoration requirement; direct window patches bypassunstubGlobals.
Suggested verification and fix scope
- Run the sidebar test alone as a desktop baseline with the pinned apps toolchain.
- Reproduce serially in one no-isolate worker after the viewport-mutating tests, with controlled order (do not assume CLI file order is honored). Record the width/media result at sidebar render without retaining unrelated user data.
- Confirm a mobile viewport explains the exact missing-role signature, and add a deterministic negative control.
- Restore viewport/media test-global state according to the existing central setup rules, or pin the intended desktop environment with correctly restored test stubs. Keep separate mobile coverage of the inline folder surface; do not change production accessible roles merely to satisfy this desktop test.
- Re-run the ordered reproducer and full no-isolate suite repeatedly. Avoid simply increasing the 1-second lookup timeout.
Prior-issue search
Searched open and closed issues for session-sidebar.pinning, Move to folder, matchMedia, sidebar flake, and Studio flake terms, and read the matching tracker entries. No matching existing issue found.
Related but distinct:
- CI: track flaky tests on main and PRs #2327 — general CI flaky-test tracker; no sidebar folder-menu entry.
- flake(studio): account quarantine test intermittently misses Bob thread IDs #2376 — Studio account quarantine/thread-ID flake; different failing test and symptom.
No code changes or reruns are included in this report.
Activity
test(studio): restore shared viewport state between tests