Skip to content

fix(app): keep the thread transcript still while the context card fills - #8532

Open
smsunarto wants to merge 3 commits into
get-bb:mainfrom
smsunarto:scott/bb-34-layout-shifts-bb-core-thread-context-card-thr_tpyskn9yux
Open

smsunarto wants to merge 3 commits into
get-bb:mainfrom
smsunarto:scott/bb-34-layout-shifts-bb-core-thread-context-card-thr_tpyskn9yux

Conversation

@smsunarto

@smsunarto smsunarto commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

On a slow connection the pinned thread context card held back the transcript's layout until a card row rendered DOM (#8531). The transcript reserves the card's 1384 px centring width only while isCardShown is true, and for a pinned card that waited on cardHasContent, a MutationObserver on the card body. usePaneState also stayed null until rows were revealed. So the first paint centred the column across the whole pane, and when the slowest row's data arrived (about 25 s at Slow 4G) the 760 px column and composer moved 132 px left. The thread outline sat my-auto under the card, so it also moved whenever the card's height changed.

What changed

  • PluginThreadContextCard.tsx: the card is shown from the synced pin, or from a per-thread choice for a card that has no content yet. Row content is no longer an input, so cardHasContent and its MutationObserver are removed. The transcript's centring width now depends only on that state. Clicking the header on a card with content flips the synced pin. Clicking it on an empty card toggles that thread only. The card is hidden rather than unmounted, and its height is capped inside its slot.
  • thread-context-card-pane.ts: the pane layout depends on registered rows and sections (hasItems), not revealed ones, so lazy parts no longer flip it from banner to card.
  • synced-preference-atom.ts and ui-preferences-sync.ts: synced preferences can keep a per-device last-known value (bb.threadContextCard.pinned in localStorage). The atom initialises from it lazily, and reconciling with the server also saves the value when it didn't change. With no saved value the card lays out for the shipped default (true). A pin the user sets before the server answers counts immediately.
  • ThreadScreen.tsx: the scroll overlay is a flex column with the card in a flex-1 basis-0 slot and a matching spacer under the outline, so the outline is centred whatever the card's height.
  • docs/configuration.md: the "Thread context card" section describes the pin, the per-thread toggle on an empty card, and the default layout.

No wire, CLI or protocol changes.

Accepted edge: on a device's very first load (no saved value), a server value of false that arrives late moves the column back once (x 368 → 500). After that the value is saved, and later loads don't shift.

Tradeoff: the card's height is now capped at its slot, about half the pane, so the outline stays centred.

How you verified

CLS (largest session window) from the layout-shift audit harness: source build, Chrome headless over CDP, Slow 4G, cache disabled, 4× CPU, 1440×900, two cold loads each. Base is main at e0c49e2e5d.

Page Before After
thread, long reply 0.0645 / 0.0645 0.0001 / 0.0002
thread, short reply 0.0538 / 0.0538 0.0001 / 0.0001
thread, GenUI reply 0.0544 / 0.0538 0.0041 / 0.0006
thread with outline 0.0563 / 0.0563 0.0013 / 0.0013
thread, localStorage cleared 0.0644 / 0.0645 0.0010 / 0.0010
thread, 14 KB reply 0.0675 / 0.0913 0.0913 / 0.0913
thread, PR repo 0.0082 / 0.0109 0.0082 / 0.0082
  • On the 14 KB reply, the card shift (0.0674) is gone. The remaining 0.0913 is timeline markdown, outside this change.
  • The PR-repo thread had no card shift before or after.
  • On a cold load, switching threads loses the same 0.0644 card shift.
  • Probes that hold the /preferences/ui response:
    • A late true with nothing saved keeps x = 368. Before: 500 → 368.
    • A late false after a reload keeps x = 500.
  • With a tall card, the outline stays at y 437. Before: 678 → 700.

Tests:

  • PluginThreadContextCard.test.tsx:
    • the default layout with no saved value, then a late true or false;
    • a pin set before the server answers;
    • per-thread empty-card toggles across two panes;
    • a header click on a card with content flips the synced pin;
    • reload from the saved value;
    • lazy parts;
    • a first render with a null row.
  • ui-preferences-sync.test.ts: reconciling an unchanged value saves it as last known.
  • ThreadScreen.test.tsx: the outline sits between equal flex spacers, independent of the card.

Checks:

  • pnpm exec turbo run typecheck test lint lint:type-aware --filter=@bb/app (10/10 tasks; 7584 passed, 19 skipped)
  • @bb/app build
  • oxfmt --check
  • git diff --check

Closes #8531

AGENT GENERATED

This branch has not been deployed

No deployments
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.

Thread context card moves the transcript 132 px when its first row's data arrives

1 participant