Skip to content

Reserve the inline-vis preview height while loading - #2165

Merged
SawyerHood merged 1 commit into
mainfrom
bb/fix-1837-inline-vis-layout-jump
Aug 21, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb/fix-1837-inline-vis-layout-jump

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

What was wrong

InlineVisDirective in plugins/inline-vis/app.tsx starts in loading and stays there until the prepareHtmlPreview RPC resolves. The loading branch rendered a bare one-line "Loading visualization…" box with no height (37px in the app). The ready branch renders a header plus an iframe whose inline height comes from the directive's height attribute (default 224px, min 120px). The card therefore grew by hundreds of pixels in one React commit (measured 37px -> 515px for height="480"). The thread timeline is bottom-anchored, so that growth scrolled every earlier message upward on every mount of the directive, not only on cold loads. The preview height is known synchronously from the attributes, so the final geometry was knowable in the loading state; it just was not used.

Issue: #1837. Report: https://get-bb.github.io/reports/issues/1837.html

What changed

  • plugins/inline-vis/app.tsx: extracted the card chrome (outer card + header row) into a small PreviewCard so the loading and ready states cannot drift. The loading branch now renders that card with a size-5 spacer where the open-in-sidebar button goes, and a role="status" / aria-busy / aria-label="Loading visualization <file>" container with style.height = previewHeight holding a plain <Skeleton className="size-full" /> from @bb/shared-ui/skeleton. The ready branch is unchanged except for using PreviewCard.
  • plugins/inline-vis/app.test.tsx: new test pins the behaviour (loader height equals the iframe height, same card/header classes, status role and label); the existing sandbox test now finds the loader by role instead of the removed text.
  • Error, missing-file, and invalid-height branches still render compact alerts; loading -> error shrinks the card, which is acceptable for an error path and out of scope here.
  • No server, wire, CLI, or doc changes. App-side plugin UI only.

Relation to #1555: that PR also reserves the height, but it duplicates the header markup, uses .animate-shine-icon inside an aria-hidden grid, which theme.css pauses since #1880 (so its advertised shimmer is frozen in the app), and its ~100-line test pins data attributes and class names rather than behaviour. It also predates #2140, which removed the PrepareHtmlPreviewRpcResult type it touches. This PR is the ~20-line version the report recommends: shared header, fixed-height Skeleton with its built-in pulse (verified running in the app), and a behaviour-only test.

How you verified

  • New test fails on origin/main app.tsx (git checkout origin/main -- plugins/inline-vis/app.tsx, then pnpm exec vitest run app.test.tsx in plugins/inline-vis):
    × reserves the preview height while loading so the timeline does not jump
    AssertionError: expected '' to be '480px' // Object.is equality
    
  • On this branch, from the committed tree (git status --porcelain empty): pnpm exec turbo run typecheck test --filter=bb-plugin-inline-vis --force -> Tasks: 6 successful, 6 total, Tests 17 passed (17).
  • Manual repro in a dev instance (scripts/bb-dev-app current, claude-code turn that replied with ::inline-vis{file="demo.html" height="480"}), holding the prepareHtmlPreview request in headless Chrome and measuring the card before and after release:
    • main app.tsx: loading boxHeight: 37 -> ready boxHeight: 515, deltaHeight: 478; the user message above moved from top: 75 to top: 17.
    • this branch: loading boxHeight: 515 -> ready boxHeight: 515, deltaHeight: 0; user message stays at top: 17; skeleton animationName: pulse, playState: running.

Fixes #1837

AGENT GENERATED: by Claude Opus 5

Independent verification

Checked out 140e23e7f (git fetch origin bb/fix-1837-inline-vis-layout-jump && git checkout -b verify-1837-r1 FETCH_HEAD); origin/main is an ancestor, GitHub reports MERGEABLE. Diff: plugins/inline-vis/app.tsx + plugins/inline-vis/app.test.tsx only, +117/-17.

Fail-before: git checkout origin/main -- plugins/inline-vis/app.tsx, then pnpm exec vitest run app.test.tsx in plugins/inline-vis:

FAIL app.test.tsx > InlineVisDirective > reserves the preview height while loading so the timeline does not jump
AssertionError: expected '' to be '480px' // Object.is equality
Tests  2 failed | 5 passed (7)

(The second failure is the existing sandbox test, which now looks the loader up by role="status" name.)

Pass-after: restored app.tsx from the PR head (git status --porcelain empty), pnpm exec vitest run app.test.tsx -> Tests 7 passed (7). pnpm exec turbo run typecheck test --filter=bb-plugin-inline-vis --force -> Tasks: 6 successful, 6 total, Tests 17 passed (17).

Repro on the fixed branch: own dev instance (scripts/bb-dev-app current, app :13647 / server :21647), scratch project with demo.html, real claude-code turn replying ::inline-vis{file="demo.html" height="480"}. Headless Chrome via doobie held the prepareHtmlPreview RPC, measured the card, released it, measured again:

before: state=loading cardHeight=515 innerHeight=480 userMsgTop=17 role=status label="Loading visualization demo.html" skeleton animation=pulse playState=running
after:  state=ready   cardHeight=515 innerHeight=480 userMsgTop=17
deltaHeight: 0, userMsgShift: 0

The report measured 37px -> 515px (delta 478) for the same scenario on main. The issue no longer reproduces.

CI: all required checks green on 140e23e7f (Checks, Tests app-1/2/3, integration, server, packages, Package Smoke ubuntu/macos, version check).

Residual risks: error / missing-file / invalid-height branches still render compact alerts, so loading -> error shrinks the card (error path, out of scope). The loader no longer shows visible "Loading visualization" text; it is conveyed through role="status" + aria-label. No wire, CLI, or plugin-API surface changed, so no protocol bump or doc update is required.

AGENT GENERATED: by Claude Opus 5

The inline-vis directive rendered a one-line "Loading visualization…"
box while it awaited the prepareHtmlPreview RPC, then swapped in a
header plus a fixed-height iframe. The thread timeline is bottom
anchored, so the card growing by hundreds of pixels in one commit
scrolled everything above it out of view on every mount.

The preview height is known synchronously from the directive
attributes, so the loading state now renders the same card chrome as
the ready state (shared PreviewCard, with a size-5 spacer where the
open-in-sidebar button goes) and a fixed-height Skeleton placeholder.
The card measures the same before and after the RPC resolves.

Fixes #1837

Co-Authored-By: Claude <[email protected]>
@SawyerHood
SawyerHood marked this pull request as ready for review August 21, 2026 06:52
@SawyerHood
SawyerHood merged commit 34a3ebb into main Aug 21, 2026
13 checks passed
@SawyerHood
SawyerHood deleted the bb/fix-1837-inline-vis-layout-jump branch August 21, 2026 14:40
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.

Inline visualization loading causes a timeline layout jump

1 participant