Repository navigation
Reserve the inline-vis preview height while loading - #2165
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
InlineVisDirectiveinplugins/inline-vis/app.tsxstarts inloadingand stays there until theprepareHtmlPreviewRPC 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'sheightattribute (default 224px, min 120px). The card therefore grew by hundreds of pixels in one React commit (measured 37px -> 515px forheight="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 smallPreviewCardso the loading and ready states cannot drift. The loading branch now renders that card with asize-5spacer where the open-in-sidebar button goes, and arole="status"/aria-busy/aria-label="Loading visualization <file>"container withstyle.height = previewHeightholding a plain<Skeleton className="size-full" />from@bb/shared-ui/skeleton. The ready branch is unchanged except for usingPreviewCard.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.Relation to #1555: that PR also reserves the height, but it duplicates the header markup, uses
.animate-shine-iconinside anaria-hiddengrid, whichtheme.csspauses 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 thePrepareHtmlPreviewRpcResulttype it touches. This PR is the ~20-line version the report recommends: shared header, fixed-heightSkeletonwith its built-in pulse (verified running in the app), and a behaviour-only test.How you verified
origin/mainapp.tsx(git checkout origin/main -- plugins/inline-vis/app.tsx, thenpnpm exec vitest run app.test.tsxinplugins/inline-vis):git status --porcelainempty):pnpm exec turbo run typecheck test --filter=bb-plugin-inline-vis --force->Tasks: 6 successful, 6 total,Tests 17 passed (17).scripts/bb-dev-app current, claude-code turn that replied with::inline-vis{file="demo.html" height="480"}), holding theprepareHtmlPreviewrequest in headless Chrome and measuring the card before and after release:app.tsx: loadingboxHeight: 37-> readyboxHeight: 515,deltaHeight: 478; the user message above moved fromtop: 75totop: 17.boxHeight: 515-> readyboxHeight: 515,deltaHeight: 0; user message stays attop: 17; skeletonanimationName: pulse,playState: running.Fixes #1837
Independent verification
Checked out
140e23e7f(git fetch origin bb/fix-1837-inline-vis-layout-jump && git checkout -b verify-1837-r1 FETCH_HEAD);origin/mainis an ancestor, GitHub reportsMERGEABLE. Diff:plugins/inline-vis/app.tsx+plugins/inline-vis/app.test.tsxonly, +117/-17.Fail-before:
git checkout origin/main -- plugins/inline-vis/app.tsx, thenpnpm exec vitest run app.test.tsxinplugins/inline-vis:(The second failure is the existing sandbox test, which now looks the loader up by
role="status"name.)Pass-after: restored
app.tsxfrom the PR head (git status --porcelainempty),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 withdemo.html, real claude-code turn replying::inline-vis{file="demo.html" height="480"}. Headless Chrome via doobie held theprepareHtmlPreviewRPC, measured the card, released it, measured again: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.