cmux NEXT: the agent pane ships every stylesheet it imports, listed from the imports (base red)

Closed
TE
8d ago
+274-158

Every fleet DEV build (cmux-ci build, pr-capture) and the webview CI shards stop in the agent pane's web step on feat-cmux-next:

error: the agent pane imports webviews/src/ui/wave.css but build-agent-pane-web.sh does not add it to the page's styles

build-agent-pane-web.sh wrote the page's one <style> from a list of sheets kept by hand, and refused any sheet the pane imports that the list missed. So each new CSS import (ContextSection.css, then ui/wave.css from desktop.ts since #23995) stopped the web step, and with it every native capture, until someone added a line (78c71ce7 did for wave.css; fe140262 added composer/dropOverlay.css the same way while this PR was open). This PR removes the hand-kept list, so the next import can't do it again. It also covers the ContextSection.css case that #23939 fixes for that one file, and the wave.css case of #24141.

What changes

  • webviews/scripts/agent-pane/bundle.mjs --css-inputs now lists the sheets in the order the page applies them: esbuild's CSS bundle order (import order, each sheet at its first import, a sheet's @import ahead of it) for the graph of --page-styles and then the entry, followed by any sheet only a lazily loaded chunk imports, by path. It used to be a sorted list that only fed the check.
  • New webviews/src/agent-session/acpmux/pageStyles.ts imports the page's own sheets (the desktop layer, the base layer, the transcript and composer rules), in the old list's order. A component's own import "./x.css" needs no entry: it ships after these, at its first import.
  • build-agent-pane-web.sh writes the <style> from that list. It drops a sheet's @import of a sibling (the list carries the sibling ahead of it, as git.css before changes.css), skips acpmux/tailwind.css (still compiled and put last), and keeps both guards: every listed sheet's rules are in the page, and no @import reaches it.
  • dev.tsx and the gallery (dev-server/galleryHost.ts, which used to regex the shell script) read pageStyles.ts, so the dev server, the gallery and the app share one order. The gallery's list puts each sheet after the siblings it @imports (git.css before changes.css), as the page does, so editing git.css reloads the gallery's pane sheet and marks pane entries touched.

Behaviour

None for the app: built on cmux16 at base 972843dd and at this head, the whole page output (index.html, pane.js, chunks/, locales/, the highlight worker) is byte-identical (diff -rq).

Takes back

Takes back #22710: its cat .../ui/importCards.css line in the hand-kept list goes with the list; pageStyles.ts imports ui/importCards.css at the same place, and the page still ships it there (output byte-identical).
Takes back #22815: its cat .../ui/glass/glass.css line goes the same way; pageStyles.ts imports ui/glass/glass.css right after desktop.css, as before.

Testing

webviews/test/agent-pane-styles.test.ts asks bundle.mjs for the list as the script does and checks that it holds wave.css, ContextSection.css, ghost.css, git.css and the page-level sheets, that it starts with desktop.css, that git.css comes right before changes.css, that it starts with the gallery's list, and that the built page carries every sheet in the list's order.

  • Red on base (the test commit alone): bun test test/agent-pane-styles.test.ts fails 2 tests (the list is sorted and has no page-level sheets).
  • Green on the head: the same command passes 4 of 4 after scripts/cmux-next/build-agent-pane-web.sh (5 of 5 with test/popup-surface-dev.test.ts, which now checks pageStyles.ts).

Observed / Not run

  • Observed on cmux16 (a blob-less checkout, bun 1.4.2): build-agent-pane-web.sh --check failed with the error above on fbcb3d3f (before 78c71ce7) and passes on the head. The head's page output is byte-identical to base 972843dd's.
  • Negative check: an indented @import "./ghost.css" screen; appended to ui/wave.css makes the script exit 1 with "an @import reached the agent pane's styles".
  • Fleet DEV builds of earlier heads passed the web step and produced the app: c436caaec321f545bb84096b (328523c2) and be6439987e581e9e309e48c5 (ea2d75d2).
  • vp fmt --check and vp lint on the changed files pass, as does scripts/cmux-next/prepush-gate.py. test/gallery-touched-rank.test.ts passes.
  • Not run: the full bun run check and the whole webviews suite (the sparse checkout lacks the Swift packages that some checks read) and the gallery dev server; the PR's CI covers those.

Changelog

none

Agent session: cosmic-gray

šŸ¤– Generated with Claude Code