Skip to content

Keep the timeline pinned when content collapses for a single task - #6405

Merged
ymichael merged 2 commits into
mainfrom
bb/investigate-discord-message-content-thr_8dmzhx83rt
Oct 27, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/investigate-discord-message-content-thr_8dmzhx83rt

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

A thread scrolled to the bottom unpinned itself with no input: the view jumped up by about the composer's height and the ↓ button appeared (Discord report: "jumps up 225 pixels after a few idle seconds", iPad and iPhone). The timeline composer footer is a sticky element inside the scroll content. When the footer or a row collapses and regrows within one task while something forces a layout, the browser clamps scrollTop to the shrunken extent. The content regrows before the frame ends, so no ResizeObserver fires. The clamp scroll then arrives with no input and no size change, which the keeper reads as navigation, so it detaches. #6253 did not change this path: its attach rule only applies within 4 px of the end.

A second source of the same no-input scrolls: buildMarkdownComponents defined MarkdownLink, MarkdownCodeRenderer, image/video/source and the mention elements as closures. Whenever link routing or mentions changed identity, every link, inline code element and pill in every message remounted. On main this happens twice on every thread open (52 code elements each time in the fixture) and again on background events. iOS WebKit moves the scroller when links remount, as found while working on #6253.

What changed

  • Scroll extent floor (scroll-position-keeper.ts, bottom-anchored-scroll-body.tsx): the first child of the timeline's scroll content is an invisible spacer. Its height is the content's height at the last ResizeObserver delivery, cancelled by an equal negative margin-bottom. It takes no space, but the scroll extent can no longer drop for a one-task collapse, so the browser has nothing to clamp. A shrink that lasts reaches the ResizeObserver, which lowers the floor before reconciling. A scroll with no input now counts as layout when the extent changed or when the content height no longer matches the floor. This preserves the existing rule for native scroll adjustments that come with a size change. The keeper's detach rule is otherwise unchanged, so find in page and focus moves still navigate. Tool output boxes pass no floor.
  • Stable markdown components (markdown-preview.tsx, markdown-thread-mentions.tsx, markdown-prompt-mentions.tsx, QueuedMessagesList.tsx): the components are module-level and read per-message options (link routing, image policy and offset, theme, localhost rewriting, mentions) from context. Option changes re-render them instead of remounting them. The components map depends only on table layout and which mention and directive kinds are present. buildThreadMentionComponent and buildPromptMentionComponent are replaced by ThreadMentionElement and PromptMentionElement with their contexts.
  • Test layout (test/fake-flow-layout.ts): honors margin-bottom, counts overflowing boxes toward scrollHeight, and clamps scrollTop when the extent shrinks, as browsers do. takeClamp() reports a clamp so harnesses can fire its scroll event. Tests that stood in for a ResizeObserver delivery by calling reconcile() now flush the observers.
  • docs/timeline-pagination.md documents the floor.

Client only; no wire, CLI or plugin API change.

How you verified

  • iOS 26.5 Simulator Safari, iPad Pro 11 and iPhone 17 Pro, dev server. I used a fixture like the reporter's (long message with inline code, worktree environment with the git "Committed" bar) and a probe-injecting proxy. Collapsing [data-scroll-footer] for one task (hide it, read scrollHeight, restore it):
    • main: the view jumped 203 px on iPad and 113 px on iPhone, exactly the footer height, and the button appeared and stayed. Collapsing the last row jumped the full distance.
    • branch: scrollHeight and scrollTop were unchanged and the view stayed pinned, on both devices and for both footer and row.
  • Markdown remounts on load (probe counts <a> and <code> removed inside rows):
    • main: 52 code elements twice per open, or 91 links plus 91 code elements on a links fixture;
    • branch: 0.
  • Real touch on the branch (Maestro): a swipe up unpins and shows the button; a swipe back down re-pins and hides it.
  • Desktop and phone-width Chromium: scrollHeight equals the content height, and the footer sits flush at the viewport bottom, so the floor leaves no gap.
  • Tests that fail on main and pass here:
    • scroll-position-keeper.test.ts: stays attached when content shrinks and regrows within a frame and the clamp scroll arrives late (with and without iOS write deferral); follows content that stays shrunk to the new end;
    • scroll-position-keeper.model.test.ts: new random step that shrinks a row, forces layout, regrows it, then delivers the late clamp. On main's keeper it fails with "a content change detached the reader";
    • markdown-preview.test.tsx: links and inline code stay mounted when link routing and thread mentions change identity (with and without incremental blocks); a link routes through the latest handler.
  • ConversationMessageContent.streaming.test.tsx: when the settled prefix grows, the live tail is now parsed as two pieces instead of one whole-tail parse, because the piece cache is no longer reset by a component-map change. The rendered output is identical.
  • pnpm exec turbo run typecheck lint test --filter=@bb/app: 638 files, 6313 tests passed.

AGENT GENERATED

🤖 Generated with Claude Code

Michael Yong and others added 2 commits October 27, 2026 15:23
Two causes unpinned a thread scrolled to the bottom with no input:

- A footer or row that collapses and regrows within one task, while
  something forces a layout, lets the browser clamp scrollTop. The clamp
  scroll arrives after the content regrew, with no input and no size
  change, so the keeper reads it as navigation and detaches. The timeline
  now holds a floor under its scroll extent: a spacer, cancelled by a
  negative margin, sized to the content at the last ResizeObserver
  delivery. One-task collapses no longer lower the extent; lasting
  shrinks lower the floor before reconciling.
- Markdown links, inline code, images and mention pills were component
  closures rebuilt whenever link routing or mentions changed identity, so
  every message remounted them (twice per thread open, and on background
  events). iOS WebKit moves the scroller when links remount. They are now
  module-level components that read per-message options from context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The overflow-aware extent re-measured each subtree at every depth, read
inline styles on every row, and clamped on every scrollTop read. The
keeper model test took 9x longer and timed out on Windows CI. Flow height
and overflow now come from one walk, unstyled elements skip style reads,
and scrollTop reads clamp only during ResizeObserver delivery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ymichael
ymichael merged commit c6c23be into main Oct 27, 2026
93 of 95 checks passed
@ymichael
ymichael deleted the bb/investigate-discord-message-content-thr_8dmzhx83rt branch October 27, 2026 22:51
ymichael added a commit that referenced this pull request Oct 27, 2026
)

## Human comments

## What was wrong

After #6388 moved Commit into the Git plugin, nothing in core needed
"Show Git changes and Commit button" except one fold. Core still owned
the setting in general settings (`AppSettings.showGitChanges`). The Git
plugin read it through `sdk.system.config()`. `ThreadDetailView` nulled
the `environment` it hands every thread context segment when the setting
was off, so the GitHub PR Status plugin's pull request segment hid along
with changed files. The `docs/api_to_audit.md` thread context segments
entry called this out as a Known coupling.

## What changed

- **The Git plugin gets two settings**, declared with
`bb.settings.define` in `plugins/git/server.ts` and read with
`useSettings()` (`plugins/git/ui/queries.ts`):
- `showGitChanges`, "Show Git changes above the composer", default
`true`. It gates the changed-files segment and its merge-base picker
(`useChangedFilesSegmentVisible`).
- `showCommitButton`, "Show Commit button", default **`false` for
everyone**, existing users included. It gates the Commit thread action
in the header and overflow menu (`commit-action.ts`, which drops its own
`system.config` subscription). **This is the one intended user-visible
change:** Commit disappears until a user turns it on. The old switch
can't tell an explicit `true` apart from the untouched default, so the
migration doesn't copy it here.
- **GitHub PR Status plugin gets `showPullRequest`.** Default `true`,
labelled "Show pull request above the composer".
`usePullRequestSegmentVisible` reads it. When it's off, the plugin skips
the PR read, just as the null environment did before. It gates only the
composer's pull request segment, which is all the Git switch hid for
this plugin. The Info tab's Pull request row was never gated and still
isn't.
- **Core's fold is gone.** `ThreadDetailView` passes
`threadEnvironmentId` straight through. `ExperimentalThreadEnvironment`
is no longer null because of a setting. Its SDK doc comment is updated,
and the plugin SDK is bumped to 0.6.93.
- **Removed from core:** the key in `appSettingsSchema`, its defaults
and update schemas, the `PUT /settings/general` merge, the General
switch (`SettingsView` and stories) and its settings-search entry. Both
new switches stay searchable because settings search indexes plugin
settings by label and description.
- **Migration `0147_git_and_pr_status_plugin_show_settings`.** This is a
custom Drizzle migration generated on current main, using the same
pattern as `0105_provider_settings_to_plugins`. It copies the saved
`app_settings_values.showGitChanges` into both `bb--git/showGitChanges`
and `bb--github-pr-status/showPullRequest` (an existing plugin row
wins), then deletes the old row. Users with no saved value get both
plugin defaults (`true`), which matches the old default. Nothing is
written for `showCommitButton`, so it starts off.
- **What an old client sending `showGitChanges` gets.** This follows the
provider-settings move: the key is deleted from the `.strict()`
general-settings schema. A `PUT /api/v1/settings/general` that still
includes it gets **400 `{"code":"invalid_request","message":"Invalid
input"}`**, and nothing is saved. In practice only an old client
toggling the old switch, or an old CLI running `bb settings general
showGitChanges …`, sends it. Clients send `{ ...cachedSettings, ...patch
}`, and after the upgrade the server's config no longer returns the key.
- **Docs and CLI:**
- `docs/configuration.md`: the general-settings row is removed and
there's a new "Git and GitHub PR Status plugins" section.
- `bb guide customization` points to `bb plugin config bb--git set
showGitChanges false`, `bb plugin config bb--git set showCommitButton
true` and `bb plugin config bb--github-pr-status set showPullRequest
false`.
- Each plugin's skill and PLUGIN_OVERVIEW now describe its setting. This
also replaces the Git overview's stale "Commit button and dialog stay in
core".
- In the plugin-authoring reference and `docs/api_to_audit.md` (thread
context segments), the environment-null-when-setting-off clause and the
Known coupling bullet are gone.

No server/daemon wire change.

## How you verified

- `pnpm exec turbo run typecheck lint --filter='...[origin/main]'`
passes.
- `turbo run test` passes for `@bb/db` (634), `bb-plugin-bb--git` (248),
`bb-plugin-bb--github-pr-status` (160), `@get-bb/plugin-sdk` (403),
`@bb/domain`, `@bb/templates` and `bb-plugin-bb-guide`.
- `@bb/server`: 3688/3689. The one failure was `builtin-plugins.test.ts`
"hot-reloads a source-layout builtin server", a 40 s file-watcher timing
test that ran while a dev instance was building. Re-run alone, the file
passes 28/28.
- `@bb/app`: the settings, thread-detail, promptbox banner, plugin and
settings-mutation tests pass (1193 across 126 files).
- New and changed tests:
- `migrate.test.ts`: a saved `showGitChanges: false` lands in both
plugins and the core row is removed.
- `PullRequestContextSegment.test.tsx`: the segment hides while
`showPullRequest` is off or loading.
- `commit-action.test.tsx`: Commit hides while `showCommitButton` is
off. It now reads plugin settings instead of mocking `system.config`.
- Real app on an isolated `pnpm dev` with a fresh data dir. The fixture
was a project checkout on PR #6405's branch with two uncommitted files.
- Default: the composer shows "PR #6405" and "Uncommitted · 2 files",
and the header shows Commit.
- Git off: changed files and Commit disappear and PR #6405 stays. PR off
with Git on: the PR disappears, and changed files and Commit stay. Both
off: all three are hidden. Both back on: all three return. Each of these
updated in the open thread tab without a reload, both when flipped from
the CLI and when clicking each switch on its plugin page (Settings →
Git, Settings → GitHub PR Status).
  - General settings no longer lists the switch.
- Follow-up commit (Commit split out), on `pnpm start:worktree` with a
project on this PR's branch and two uncommitted files:
    - Defaults show PR #6410 and the changed files, with no Commit.
- With `showCommitButton` on, Commit appears. Turning off
`showGitChanges` then hides the changed files and leaves Commit and the
PR.
- Back to defaults restores the starting state. Clicking Show Commit
button on Settings → Git shows Commit and then hides it again in the
open thread.
- Upgrade: on a copy of that DB with the 0147 record removed and
`showGitChanges=false` seeded, the real `migrate()` wrote `false` to
both plugin settings.
- An old-client `PUT /api/v1/settings/general` with `showGitChanges`
returned 400 `invalid_request`. The same payload without it returned
200.

> 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 <noreply@anthropic.com>
ymichael added a commit that referenced this pull request Oct 28, 2026
…6434)

## Human comments

## What was wrong

#5951 changed what a scroll with no input means. Before, such a scroll
could never detach the timeline from the bottom (`if
(!hasRecentUserScrollIntent()) return;` in the old
`bottom-anchored-scroll-body.tsx`). Since #5951,
`ScrollPositionKeeper.handleScroll` treats any scroll with no input and
no size change as navigation. It handles it exactly like a reader
scroll:
- it detaches a view at the bottom when it moved up;
- it cancels a pending restore;
- it sets `userScrolled`, which skips the NEW-divider landing;
- it opens a 150 ms input window, so the next few scrolls also count as
the reader's.

iOS WebKit makes such scrolls on its own. The Discord reports ("jumps up
225 pixels after a few idle seconds", "coming back to a thread it lands
randomly up") came from two of them. #6405 removed both triggers: a
collapse and regrow within one frame, and markdown links being
recreated. The rule stayed, though, so any stray scroll we haven't found
still detaches the view.

## What changed

`apps/app/src/components/ui/scroll-position-keeper.ts`:
- A scroll with no input and no size change now counts as layout, and
the keeper puts the view back, when the view is attached to the bottom
or a restore is waiting for its row. It no longer detaches, cancels the
restore, or marks the reader as having scrolled.
- A detached view still follows such a scroll as navigation, so find in
page keeps working while reading history
(`bottom-anchored-scroll-body.test.tsx` already covers that case).
- While the desktop window find bar is open, an attached view also
follows these scrolls, so find works from the bottom. `WindowFindHost`
dispatches `bb:window-find-open` (`apps/app/src/lib/window-find.ts`)
when it opens the bar, and the keeper resets when the window regains
focus.
- Tab counts as input, so moving focus to an offscreen control still
navigates.
- The scroll-extent floor from #6405 stays. It still keeps a detached
reader within a collapse's height of the end in place. The model test
fails with "the reading row moved … without the reader" when the floor
is removed.

`docs/timeline-pagination.md` describes the rule, the find-bar signal
and Tab.

Trade-off: browser find on the web (no signal) and VoiceOver scrolling
are pulled back while the view sits at the very bottom, as before #5951.

Client only; no wire, CLI or plugin API change.

## How you verified

- **New tests.** 4 of them fail on main's keeper:
  - `scroll-position-keeper.test.ts`:
    - an attached view stays at the end on a no-input scroll;
    - a pending restore survives a no-input scroll;
- the find bar lets an attached view follow, and window focus ends that.
    - Tab: passes on main too, as a guard.
- `scroll-position-keeper.model.test.ts`: a new random step fires a
scroll with no input. On main it fails with "a content change detached
the reader".
- The model test passes 2,000 sequences (`KEEPER_MODEL_SEEDS=2000`).
- `pnpm exec turbo run typecheck lint test --filter=@bb/app`: passes
(643 files, 6,347 tests; lint has 0 errors).
- **iOS 26.5 Simulator Safari, main vs this branch**, alternating runs
against real long threads through a proxy that blocks mark-read and
sends:
  - open and sit idle: 10 runs each;
  - leave and come back: 10 runs each;
- re-insert or replace 25–96 links and code elements mid-run: 12 runs
each;
  - real Maestro swipes, then leave and come back: 2 runs each;
  - real typing in the composer: 2 runs each.
- Results were identical on both builds:
  - no detach without input, and no run ended away from the bottom;
  - a swipe up detaches;
  - a return restores the same row within 10 px;
  - typing stays attached.

Current main does not reproduce a stray scroll on iOS in these flows.
This change guards against new sources rather than fixing a visible bug
on main.
- **Not checked:** VoiceOver, and the desktop find bar in Electron
(covered by a unit test only).

> AGENT GENERATED

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

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
albrand pushed a commit to alb-hold/bb that referenced this pull request Oct 29, 2026
Reintroduce the no-input extent comparison dropped during the 0.48 sync merge, including the fork bottom-scroll path that defers to reconcile instead of handleScroll.

Co-authored-by: Cursor <cursoragent@cursor.com>
albrand added a commit to alb-hold/bb that referenced this pull request Oct 29, 2026
Restore get-bb#6405 extent-changed scroll pinning dropped in 0.48 sync
ymichael added a commit that referenced this pull request Nov 18, 2026
…y switches (#7731)

## Human comments

## What was wrong

AGENTS.md says a plugin API that performs a core action must be the path
core uses, proven by one contract test table run against every surface.
Only part of that was enforced. The view-level panel table
(`test/panel-controller-contract.tsx`) covered panel tabs, not
`openTerminal`, `openFilePreview` or `openUrl`. The terminal and file
tables were hook-level and mocked `reveal`. There was no table for
ThreadScreen consumers, Markdown surfaces or single-pane layout. So
per-surface switches that turn a feature off for plugin surfaces kept
shipping. Each was a small, reasonable-looking exception that no table
asserted against:

- **#7065.** Plugin thread actions got `experimental_panel` routed to
the focused surface, but their `navigate` came from the app-level
context in `ThreadActionsProvider`, outside every view's navigation
host. From a header thread action, `experimental_openTerminal`,
`experimental_openFilePreview` and `openUrl` returned `false` and did
nothing. The issue's suspected cause (`reveal: openCompactDrawer`) is
not it: that is the same function as `openDrawer`, and terminal
selection already writes `isOpen: true`. That is also why SlopCop's
in-view test did not reproduce it.
- **#2967.** `PluginThreadChat` passed `includePluginMessageActions:
false`, so slot-registered message actions never showed in an embedded
ThreadChat.
- **#7277.** `SplitThreadArea` kept a single pane mounted across the
compact breakpoint only for the `thread` and `new-thread` kinds. A
plugin page swapped between `StandalonePaneContent` and
`WorkspacePaneContent` and lost its DOM and React state.
- **#5340.** `PluginNewThreadComposer` started an unseeded composer on
`null` (the personal project) instead of the remembered New thread
project.

### Earlier issues and fixes from the same root cause

This is the 20th fix in the class. Each earlier one patched a single
surface:

- **Fix PRs:** #1469, #1518, #2026, #3147, #3752, #3867, #3968, #4331,
#4693, #4954, #5128, #6104, #6269, #6291, #6387, #6752, #6754, #6756,
#6763 and #7060.
- **Closed issues:** #1836, #2288, #3395, #4323, #4438, #4480, #4501,
#4951, #6071, #6268, #6289 and #7015.

The open issues the tables catch today are #7065, #2967, #7277 and
#5340. #6311 is covered by the Markdown table, which already passes
because #6405 removed the closure chain.

## What changed

**Guards (written first; each failed on main for the past case named):**

- **Panel table.** `test/panel-controller-contract.tsx` gains three
rows: open a terminal, open a file preview (reusing the tab for the same
file), and open a URL in the in-app browser. Each row must select the
tab and reveal a closed panel. The table runs on the thread view, thread
header row, **thread header action** (new row), New thread screen and
plugin page. On main the header-action row failed all three (#7065).
- **ThreadScreen table.** New `ThreadScreen.surface-contract.test.tsx`
runs against the thread page and plugin ThreadChat full, compact and
timeline. It uses real timeline rows. Every row must show
slot-registered message actions, and every composer must receive the
thread's context-window usage. On main the three ThreadChat rows failed
(#2967). Context usage already passed on every row, so that half of
#2967 was fixed by #6387.
- **Markdown table.** New `markdown-surface-contract.test.tsx` runs
against assistant messages, plugin `Markdown` and plugin document
`Markdown`. It checks thread-token mentions, web-link routing through
the surface's navigation host, and `<video>` identity when the
navigation host changes. It passes on main and guards #6311 and #6756.
- **Single-pane table** in `SplitThreadArea.test.tsx`. Thread, New
thread and plugin page panes must keep their DOM nodes and unsaved state
across four breakpoint crossings. On main the plugin page row failed
(#7277).
- **#5340 test** in `PluginNewThreadComposer.test.tsx`. An unseeded
composer must start on, and submit, the project the user picked in bb's
New thread view. It failed on main.

**One owner, copies deleted:**

- `lib/app-navigation-host.tsx` gains `AppNavigationSurfaceProvider`.
Each surface now registers its *resolved* navigation host while it has
focus: the thread view, New thread, plugin page and Plugins.
`getFocusedAppPanelController` is derived from that registry. The
panel-only `focusedControllers` registry and the `isFocused` argument to
`useAppPanelController` are deleted.
- `ThreadActionCollectors` wraps collectors in
`FocusedAppNavigationSurfaceProvider`. Thread actions' `navigate.open*`
now reaches the same focused surface as their `experimental_panel`. When
no surface has focus, it falls back to the app-level host.
- `includePluginMessageActions` is deleted end to end:
`ThreadScreenTimelineHost`, `ThreadTimelineSurface`,
`ThreadTimelineRows`, `PluginThreadChat` and `ThreadDetailView`.
- `keepsSinglePane` is deleted from `SplitThreadArea`: any single pane
stays in `WorkspacePaneContent`.
- The duplicate `PLUGIN_MARKDOWN_THREAD_MENTIONS` and
`ASSISTANT_THREAD_MENTIONS` constants are merged into one
`AUTHORED_MARKDOWN_THREAD_MENTIONS` exported from
`markdown-preview.tsx`.

**Follow-up from the independent review: missing host fields and
untested panel contexts.**

- **Required host fields.** Every `ThreadScreenTimelineHost` and
`ThreadScreenComposerHost` field is now required (`ThreadScreen.tsx`),
so each surface must state each handler or an explicit `null`. A host
field a surface leaves out now fails typecheck.
- **Shared title actions and environment rules.** New
`thread-screen-hosts.ts` owns the timeline title-action resolver and the
thread environment rules (context environment, reusable environment).
ThreadDetailView and plugin ThreadChat both use it.
- **What plugin ThreadChat newly gets, matching the thread page:**
- Clicking a tool title opens the diff or file, a local file, or a side
chat. On main, `onTitleAction` was missing, so these clicks did nothing.
- The context row above the composer still receives no environment
(`contextEnvironmentId: null`), as on main, so a side chat does not
repeat its parent thread's changed-files row. An opt-in prop for it was
dropped because no plugin used it.
  - "New thread in this environment" is available.
- The unread divider is shown. It now uses the same
`useThreadUnreadDividerState` as the page, and read tracking waits for
the divider, as on the page.
- **ThreadScreen table.** The page row now mounts the real
`ThreadDetailView`, not a hand-built `ThreadScreen`. Two rows were
added: opening a changed file from its timeline title, and the composer
receiving the new-thread action and each surface's expected context
environment (the thread's on the page, none in embedded chats). On
main's `PluginThreadChat`, these fail 5 of 11 rows.
- **Panel table.** New rows for **thread message actions**, **command
palette commands** and **thread new-tab plugin actions**, alongside the
existing surface rows. `CommandPalette` now builds plugin commands
through one `buildFocusedSurfacePaletteActions`, which the table also
uses. The table gains `actionTabs` and `navigation` support flags,
because those three contexts receive only a panel. The **Plugins view**
gets a test that its panel declines every plugin tab without changing
its tabs.
- **Panel tab renderers.** `ThreadTerminalPanel`'s `onOpenLink` and
`onSelectionAddToChat` are required, so each of the three panel tab
renderers must state them. The plugin page's terminal had no
`onOpenLink`; its links now route through that page's in-app browser, as
on the thread and New thread surfaces. I did not merge the three
renderers into one. Their file-preview cases depend on different surface
scopes, and the shared parts are now enforced by types.

**SDK (backward compatible):**

- The JSDoc for `PluginMessageActionRegistration` and
`ThreadChatMessageAction` no longer says embedded ThreadChat hides slot
actions.
- `ComposerCustomization.actions` documents where actions render: the
expanded composer, not the collapsed single-line one.
- `defaultProjectId` documents the remembered-project default.
- New optional `PluginMessageActionRegistration.experimental_surfaces`
(type `ExperimentalMessageActionSurface`): `"thread-view"` is bb's
thread view and `"embedded-chat"` an embedded `ThreadChat`, matching the
SDK docs' wording (`"thread"` alone already means any thread composer in
the composer host's `surface`). Omitted, an action shows on both. The
collector fills that default and rejects an empty or unknown list. It
has an entry in `docs/api_to_audit.md`, on the Plugin Guide's message
actions card (whose stale "main timeline only" bullet is replaced) and
in the bb-plugin-authoring skill, which no longer says embedded
ThreadChat hides slot actions.
- `@get-bb/plugin-sdk` is set to 0.6.161, above main's 0.6.160.
- No wire changes and no CLI changes.

**Message action surfaces (review follow-up):**

- With decision 2, Side chat's own "Reply in side chat" also showed
inside a side chat and in other plugins' embedded chats. Its side chat
tab only exists in the thread view's panel, so on a plugin page it would
create a side chat thread and then fail to open it.
- Each `ThreadScreen` host now states `messageActionSurface`
(`ThreadDetailView` `"thread-view"`, `PluginThreadChat`
`"embedded-chat"`). The timeline reads slots through one hook,
`useSurfaceMessageActionSlots` (`lib/message-action-surface.tsx`), so
every surface filters the same way. This is a filter the registration
owns, not a per-surface switch.
- Side chat registers `experimental_surfaces: ["thread-view"]`. Every
other message action keeps showing in embedded ThreadChat.
- The ThreadScreen table gains a row: an action limited to one surface
shows only there, on all four surfaces. An SDK collector test covers the
default and the validation.

**Not deleted:** `PluginNewThreadComposer`'s
`selectionScope="component-local"`. That switch decides whether SDK
seeds (`defaultProviderId`, `defaultModel`, `defaultEnvironment`, …)
beat core's remembered picks. Switching to the `"new-thread"` scope
would override third-party plugins' seeds and write plugin picks into
core's New thread preferences, and an existing test pins that
separation. This PR fixes only the #5340 project fallback. The
seeded-but-unknown project id case resolves to personal exactly as a
stale remembered id does in core's New thread view, so it is parity and
left unchanged.

## Decisions for review

1. **Thread actions route open\* to the focused pane.** This applies to
header actions and to thread actions run from menus for other threads (a
sidebar row's menu, the New thread screen's recents on a phone, or a
plugin's `experimental_ThreadActionsMenu`). It matches how
`experimental_panel` was already routed. Run from thread A's menu while
thread B has focus:
- `experimental_openTerminal` with A's terminal returns `false`, because
B's panel accepts only B's terminals (`acceptsThreadTerminal`).
- `experimental_openFilePreview` and `openUrl` open in B's panel. A file
preview is addressed by environment and path, not by thread.
- On main, all three returned `false` from every thread action, the
header included. Opening A first and then the tab in A's panel would
need a new "open a thread with a panel tab" path (see decision 7).
2. **Embedded ThreadChat shows every slot-registered message action**,
including compact side chats. Actions that need a thread-context tab
receive the embedding page's panel. That returns `false` where the tab
does not exist, as #2967 asks.
3. **The collapsed single-line composer still leaves plugin actions
out**, as on main. It leaves out bb's own `+` menu and model picker too;
all of them show once the composer expands. An earlier version of this
PR showed plugin actions in the collapsed composer for #3358, but even
with a scrolling strip it crowded the one-line composer on phones, so
that change was reverted and #3358 stays open.
4. **An unseeded plugin NewThreadComposer starts on the remembered New
thread project.** It reads that project but never writes it.
5. **A single plugin page or Plugins pane is no longer remounted at the
compact breakpoint.** On compact it renders through the workspace pane,
with the same close button as before.
6. **"Reply in side chat" stays out of embedded ThreadChat, including
side chats.** Side chat limits its action to bb's thread view with
`experimental_surfaces: ["thread-view"]`. Embedded ThreadChat cannot
open its side chat tab, and a side chat inside a side chat is not
wanted. Other plugins' message actions still show in embedded
ThreadChat.
7. **A side-chat title on a surface whose panel can't host the side chat
opens the side chat thread itself.** Opening the source thread with the
side chat tab would need a new "open a thread with a panel tab" path;
this uses the existing thread navigation instead.
8. **Plugin ThreadChat's thread-info button is left off
(`onOpenThreadInfo: null`).** Thread info is a fixed tab in the thread
page's side panel. From a plugin page, the button would open nothing, so
it is left off.
9. **The standalone plugin model picker keeps
`commandShortcutsEnabled={false}`.** ⇧⌘M toggles the focused composer's
picker, and every composer, plugin composers included, gets it through
`ExecutionControls`. A form-control picker that also grabbed ⇧⌘M would
make the shortcut ambiguous.
10. **The plugin page's new tab keeps `showFileSearch={false}` and a
no-op `onSelect`.** A plugin page has no project, environment or thread,
so there is nothing to search and no recents to select; `onSelect`
cannot fire.
11. **The Plugins view's panel accepts no plugin tabs.** It has no
plugin tab destinations, so a plugin command run there gets a panel that
declines every tab. The new test pins this.
12. **Embedded ThreadChat now shows the unread divider and marks the
thread read once the divider is ready**, the same order as the thread
page. Before, it marked read immediately and showed no divider.

## How you verified

### Live verification (isolated source dev instance, verify-bb)

These ran on the source dev web app at this branch, before the rebase,
with a fresh data directory and the connected local host. A probe plugin
registered three header thread actions (open a terminal, a file and a
URL), a slot message action, three composer actions, and a page holding
ThreadChat full and compact plus an unseeded
`experimental_NewThreadComposer`. A Claude Code Haiku thread produced
the assistant messages. Screenshots and measurements are kept locally.

1. **Header thread actions.** Pass in the web client; the in-app browser
case was not run.
- 1400×900 with the right panel closed: "Probe open terminal" returned
`true`, the panel opened, and a zsh terminal tab was selected.
- With the panel closed again, "Probe open file" returned `true`, the
panel opened, and the README.md preview was selected.
- "Probe open URL" returned `true` and opened
`https://example.com/probe` externally. The web client has no in-app
browser, so the Electron in-app browser path was not run live; the
contract table covers it.
2. **Plugin message actions in embedded ThreadChat.** Pass.
- On the probe page, both ThreadChat full and compact show "Probe
message action" on the user and assistant messages.
- In a real side chat (compact ThreadChat, opened with "Reply in side
chat"), after one reply the assistant message shows "Probe message
action" next to "Send to main thread". After the surfaces follow-up, a
rerun on the rebased branch shows 0 "Reply in side chat" inside the side
chat; the thread page still shows it on both messages. See decision 6.
3. **Plugin actions on a phone (375×812, touch).** The collapsed
composer shows no plugin actions, as on main. After tapping it, the
expanded composer shows all three probe actions before the mic.
4. **Remembered project in an unseeded plugin composer.** Pass.
- After picking Fixture in bb's New thread view, the plugin composer
showed "Project: Fixture", and it still did after a reload.
- After picking No project in New thread, the plugin composer showed
"Project: No project".
5. **Single plugin page across the compact breakpoint.** Pass.
- I typed into the page's input and selected characters 2–6, then
resized 1024 → 767 → 768 → 700 → 1024.
- Throughout, the same input and page nodes stayed, with the same mount
id, the value "unsaved plugin form", focus, and the selection `[2,6]`.
The compact page shows the close button.

### Live verification of the review follow-up (second run, isolated dev
instance and desktop app)

The second run used a fresh dev instance from this branch (`ae6db4b0d34`
plus the side-chat fix below). The URL check also used the source
desktop app (Electron) attached to the same instance and driven over
CDP. Each check compares plugin ThreadChat on the probe plugin's page
with the thread page. The fixtures were Claude Code Haiku threads:
- an "Edits" thread that changed a workspace file (`README.md`) and a
file outside the workspace (`/tmp/.../outside-note.txt`);
- a side chat whose reply was sent back to the main thread;
- two threads that were marked read and then got an unread reply.

1. **Tool title opening a changed workspace file.** Match.
- On the thread page, clicking `README.md` opened a README.md preview
tab in the thread's panel.
- In plugin ThreadChat, it opened the same preview in the plugin page's
panel.
- On both, the git Diff tab declines this file target, so both fall back
to the file preview.
2. **Tool title opening a file outside the workspace.** Match.
`outside-note.txt` opened a host-file preview in each surface's own
panel.
3. **Side-chat title ("Message from side chat").** Mismatch found and
fixed.
- On the thread page, clicking it opened the side chat in the thread's
panel.
- In plugin ThreadChat, it did nothing: the plugin page's panel has no
thread side-chat tab.
- Fix: the shared resolver now opens the side chat thread itself when
the surface's panel declines the tab. After the fix, plugin ThreadChat
navigates to the side chat thread; the thread page is unchanged and
still opens it in its panel. Covered by `thread-screen-hosts.test.tsx`.
- Related finding, already on `main` and not caused by this PR: both
surfaces label the row "Message from Agent", with no link, until the
hidden side-chat thread is in the query cache. Sender metadata is read
only from cached threads. After a reload with the side chat tab closed,
the thread page shows the same unlinked label. Not changed here.
4. **"New thread in this environment".** Match.
- The thread page opened New thread with project Fixture and "Reuse"
selected.
   - Plugin ThreadChat, about 920 px wide, did the same.
- In a probe column about 250 px wide, the composer's environment row is
clipped. This comes from the narrow container; the side chat tab at
about 520 px shows the row.
5. **Unread divider.**
- Thread page (thread C): the "NEW" divider sits above the unread second
reply.
- Plugin ThreadChat full and compact (thread B): the divider sits in the
same place.
- On both, the thread stayed unread until there was user activity (mouse
and keyboard input), then `lastReadAt` advanced and the divider stayed
on screen. Read timing matches.
6. **Plugin-page terminal link (desktop app).** Match.
- On the plugin page, ⌘-clicking `https://example.com/terminal-link` in
a panel terminal opened an in-app browser tab ("Example Domain") in the
plugin page's panel. On main this link had no handler on the plugin
page.
- On the thread page, the same click opened the same in-app browser tab
in the thread's panel.

### Tests and checks

- After rebasing onto main (`28cdd915db4`) and dropping
`experimental_environmentContext`: `typecheck lint` pass for `@bb/app`,
`@get-bb/plugin-sdk`, side chat and plugin-api-docs; the 15 changed app
test files pass (533 tests, 16 skipped); plugin SDK (439), side chat
(27) and plugin-api-docs (75) tests pass; the plugin SDK version check
passes. A live rerun on the rebased build showed "Probe message action"
in both the thread page and embedded ThreadChat, with "Reply in side
chat" only on the thread page.


- Each guard was run against main's version of the changed component and
failed as described above. All guards pass with the fix.
- A targeted run of the 35 affected test files passed after the review
follow-up: 1,112 tests, with 16 skipped.

- `pnpm exec turbo run typecheck lint --filter=@bb/app`: pass. The
composer plugin lint shows 4 warnings, all of which were already there.
- `node apps/app/scripts/check-bundle-budget.mjs` after the rebase: the
boot payload is 418.6 KB brotli against a 419.1 KB budget.
- The first CI run's other failures were 15 s timeouts in `@bb/logger`
(Windows) and `@bb/db` resolved-item pruning. This PR touches neither
package.
- Not run on a native iOS or Android device, and not in the Electron
in-app browser.
- After rebasing on main and adding message action surfaces: the 15
affected app test files pass (651 tests, 16 skipped);
`@get-bb/plugin-sdk` typecheck, lint and tests pass (39 files);
side-chat and plugin-api-docs tests pass; `typecheck lint` pass for
`@bb/app` and both plugins; the boot bundle budget passes.

Fixes #7065
Part of #2967. Gaps 1 and 2 are covered; gap 3, the per-chat identity
seam for content scripts, is not in this PR.
Fixes #7277
Part of #5340. The unseeded-project half is fixed; the unknown-seed half
is kept as parity, as explained above.

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

> AGENT GENERATED

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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