Skip to content

Keep plugin utilities from outranking app variant utilities - #3635

Merged
ymichael merged 1 commit into
mainfrom
bb/look-up-side-chat-bug-thr_d3eiae23e4
Sep 14, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/look-up-side-chat-bug-thr_d3eiae23e4

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Plugin bundles compile their own Tailwind and declared it in a layer literally named utilities (buildTailwindCss() in build-plugin-app.ts). Cascade layer names are global to the document, so plugin utilities did not land in a sandbox — they were appended to the end of the app's own utilities layer. Any base utility a plugin happened to emit then sat after every app variant utility, inverting the ordering Tailwind depends on: .hidden and .md:flex have identical specificity, so within one sheet Tailwind guarantees the variant wins by emitting it later, but inside a plugin root the plugin's .hidden came last and won at every width.

The side chat is the first surface to embed enough host UI to hit it. Its queued-message rows carry hidden md:flex, so the send/steer/edit/delete cluster computed display: none and was unreachable — hovering flipped opacity to 1 and pointer-events to auto but never display. The plugin never uses a bare hidden class; Tailwind's scanner extracted the candidate from overflow-hidden in plugins/side-chat/app.tsx. Any plugin whose source contains that substring anywhere would break hidden md:* on host components rendered inside it.

Reported on Discord (bugs forum, thread 1548212957438156891, 0.42.1): "on the sidechat when i sent a message it gets queued but i don't have options on it".

What changed

  • packages/plugin-build/src/scope-plugin-utilities.ts — new exported PLUGIN_UTILITIES_LAYER constant, used by both the emitter and the leak assertion so the two cannot drift.
  • packages/plugin-build/src/build-plugin-app.ts — plugin utilities compile into @layer bb-plugin-utilities instead of @layer utilities.
  • apps/app/src/components/ui/theme.css — declares @layer theme, base, components, bb-plugin-utilities, utilities; as the first line. It has to precede @import "tailwindcss": layer order is fixed at first appearance, and Tailwind's import declares its own four names, after which a later statement could only append the plugin layer above utilities.
  • packages/plugin-sdk/package.json, packages/domain/src/plugin-sdk-version.ts — patch bump. Plugin artifacts are invalidated by their own source mtimes against dist/app.js (plugin-runtime.ts), so a plugin-build change alone leaves cached third-party bundles on the old layer name. isPrebuiltServerSdkCompatible gates prebuilt artifacts on the SDK version while the major is 0, so the bump is what forces them to rebuild.

The :where() scoping is unchanged. It contains plugin utilities; the layer now ranks them. No wire or protocol changes.

Plugin-only classes still apply, since nothing else in the document defines them. Classes both sheets emit are the same declaration either way. The only behavior that changes is the broken case — two different classes fighting over one property on one element — where the app's Tailwind ordering is now restored.

How you verified

Tests (fail before, pass after):

  • packages/plugin-build/src/build-plugin-app.test.ts — builds a fixture whose only Tailwind token is overflow-hidden (the exact accident behind this bug) and asserts the emitted CSS uses the plugin layer and contains no bare @layer utilities.
  • apps/app/src/components/ui/theme.test.ts — pins the layer order and that the statement precedes the Tailwind import.
  • packages/plugin-build/src/scope-plugin-utilities.test.ts — updated to the shared constant.

Commands: pnpm exec turbo run typecheck lint test --filter=@bb/plugin-build --filter=@bb/app --filter=@bb/domain — all pass (528 app test files, 0 lint errors). A pre-PR --filter='...[origin/main]' run surfaced failures in @bb/host-watcher (nested-ignore watch test) and @bb/host-workspace (GIT_SSH, flaky — passed on re-run); both are pre-existing and this branch touches 0 lines in either package.

Manual, in a source dev app driven through real browser input:

  • Before: side-chat queued row display: none, width 0; hover gave opacity: 1, pointer-events: auto with display: none unchanged. Main-thread row in the same page: display: flex with all three buttons.
  • After: side-chat row display: flex, width 88, three buttons; hover reveals them; clicking Delete removed the queued message, confirmed by bb thread queue list going from one entry to none.
  • Regression sweep: Plugins page and the Automations plugin panel render correctly, and a DOM scan of every plugin root found zero elements collapsed to display: none while carrying a layout class.

Note for reviewers reproducing locally: rm -rf plugins/*/dist before restarting, or the server serves stale plugin bundles and the change appears to do nothing.

AGENT GENERATED

Plugin bundles compile their own Tailwind and declared it in a layer
literally named `utilities`. Cascade layer names are global to the
document, so plugin utilities joined the app's own utilities layer at
the end. Any base utility a plugin happened to emit then sat after every
app variant utility, inverting the ordering Tailwind relies on: inside a
plugin root `.hidden` beat `.md:flex`, and host components rendered
there collapsed to display:none at every width.

The side chat hit this first. Its queued-message rows carry
`hidden md:flex`, so the send/edit/delete cluster was display:none and
unreachable -- hover flipped opacity and pointer-events but never
display. The plugin never uses a bare `hidden` class; Tailwind's scanner
extracted the candidate from `overflow-hidden` in its own source.

Plugin utilities now compile into `bb-plugin-utilities`, which theme.css
declares ahead of the app's `utilities` layer. Layer order outranks both
specificity and document order, so app utilities win inside plugin roots
while plugin-only classes still apply. The `:where()` scoping is
unchanged: it contains plugin utilities, the layer now ranks them.

The plugin SDK patch bump forces prebuilt plugin artifacts to rebuild.
Artifacts are otherwise invalidated by their own source mtimes, so a
plugin-build change alone leaves cached bundles on the old layer name.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@ymichael
ymichael merged commit e8ce153 into main Sep 14, 2026
25 of 26 checks passed
@ymichael
ymichael deleted the bb/look-up-side-chat-bug-thr_d3eiae23e4 branch September 14, 2026 17:00
ymichael added a commit that referenced this pull request Oct 28, 2026
)

## Human comments

## What was wrong

On phone-sized coarse-pointer screens, the Info panel's Branch, Merge
base and Git status rows drew 12px icons, while Parent, Project,
Environment and Directory drew 16px. Their labels started 4px further
left. This began with #6157, which moved those rows into the Git plugin
via the SDK `experimental_DetailRow`.

The SDK component is core's own `DetailRow`, so the class list stayed
the same: `size-3 … max-md:pointer-coarse:size-4`. What changed is that
the row now renders inside the Git plugin's root. Plugin sheets compile
into the shared `utilities` cascade layer and load after the app sheet.
The Git plugin uses `size-3` itself, so its sheet emits
`:where([data-bb-plugin="bb--git"], …) .size-3`. That rule has the same
specificity as core's `max-md:pointer-coarse:size-4` and comes later, so
it wins.

Nothing drops the variant. In the live page, the matched rules on the
Branch icon are core `.size-3`, core `@media (width < 48rem) and
(pointer: coarse) .max-md\:pointer-coarse\:size-4`, and the Git plugin's
scoped `.size-3`, last and winning. This is the same ordering problem as
#3691, which made `hidden md:flex` disjoint after the layer change in
#3635 was reverted.

## What changed

- `apps/app/src/components/ui/detail-card.tsx`: `DETAIL_ROW_ICON_CLASS`
is now a single size utility, `size-(--bb-detail-row-icon-size)`, with
no base/variant pair. A plugin sheet re-emitting `size-3` or `size-4` no
longer matches the icon. `cn`/tailwind-merge still drops `Icon`'s
default `size-6` for custom and asset icons.
- `apps/app/src/components/ui/theme.css`: defines
`--bb-detail-row-icon-size` as `calc(var(--spacing) * 3)` on `:root`.
The existing `(max-width: 767px) and (pointer: coarse)` `:root` block
raises it to `* 4`, the same token-override pattern the file already
uses for `--text-*` so responsive values don't fight in the cascade.
- Rebased onto #6367, which added `min-h-0 min-w-0` to
`DETAIL_ROW_ICON_CLASS`. Those are kept, so the class is now
`size-(--bb-detail-row-icon-size) min-h-0 min-w-0 shrink-0
text-subtle-foreground`.
- Every SDK DetailRow from any plugin, and core's own rows using
`DETAIL_ROW_ICON_CLASS`, now resolve the icon size from the token.

No wire, SDK surface, CLI or doc changes. Plugin artifacts do not need
rebuilding.

## How you verified

New test in `apps/app/src/lib/plugin-sdk-app-impl.test.tsx`. It renders
`pluginSdkAppImplementation.experimental_DetailRow` and fails if any
rendered element pairs an unconditional utility with a variant utility
that overrides it (checked with tailwind-merge). Any such pair breaks
once a plugin sheet re-emits the base utility. With main's
`detail-card.tsx` it fails, reporting `size-3 +
max-md:pointer-coarse:size-4`. With this change it passes.

`pnpm exec turbo run typecheck lint --filter=@bb/app` passes. `pnpm exec
turbo run test --filter=@bb/app -- src/lib/plugin-sdk-app-impl.test.tsx
src/components/ui/theme.test.ts src/components/secondary-panel` passes:
54 files, 571 tests.

I checked the live layout on a source dev app (`pnpm dev`), using a
project on a local git repo and a worktree thread with the Info panel
open.

Chromium, 390×844, touch plus `pointer: coarse` emulation (icon box,
label left in CSS px):

| Row | main | this branch |
| --- | --- | --- |
| Parent / Project / Directory (core) | 16×16, 38 | 16×16, 38 |
| Branch (git plugin) | **12×12, 34** | 16×16, 38 |
| Merge base (git plugin) | **12×12, 34** | 16×16, 38 |
| Git status (git plugin) | **12×12, 34** | 16×16, 38 |

iOS 18.4 Simulator Safari (iPhone 16 Pro, 402px wide), measured from
simulator screenshots. On main, Branch, Merge base and Git status labels
start at x≈35.3 with ~9–10px glyphs, while core rows start at 39.3. On
this branch all six of those rows start at 39.3 with matching ~13–14px
glyphs.

On desktop (Chromium 1280×800, fine pointer), every row stays 12×12 with
labels at x=835, and the Info panel region is pixel-identical between
main and this branch.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Michael Yong <review@local>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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