Skip to content

Convert large text pastes into ordinary attachments - #5098

Merged
ymichael merged 17 commits into
get-bb:mainfrom
aotd1:pasted-text-attachments-upstream
Oct 9, 2026
Merged

ymichael merged 17 commits into
get-bb:mainfrom
aotd1:pasted-text-attachments-upstream

Conversation

@aotd1

@aotd1 aotd1 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

Large clipboard text stayed inline in the composer, so users had to save it to a file and attach it by hand to keep their request and history readable (#4910 proposes converting it automatically, as Codex Desktop does). Working on this also exposed related attachment problems:

  • Every turn staged attachments into one flat Attachments/ directory, so a later file with the same name overwrote an earlier turn's file. An agent going back to an earlier message read the wrong contents.
  • Attachments were not part of editor undo history.
  • Uploading non-image files jumped between pill rows.
  • File attachments opened as raw browser tabs.

What changed

The first version of this PR built a dedicated pasted-text pipeline: an upload manager, IndexedDB recovery, a retry/insert card, draft pastedText state, and provider prompt changes. It has been replaced by a much smaller design on top of the existing attachment path (about 2,200 lines removed).

  • Large paste becomes an attachment. Plain text of 5,000+ characters becomes a Pasted text.txt file handed to the existing attachFiles path. A clipboard that also carries files keeps main's behavior, so large text beside an image is no longer dropped.
  • Unique names within a draft. Every attachment gets a name unique within its draft (notes 2.txt, Pasted text 2.txt).
  • Original names in history. localFileDetails (path, name, nullable size) is now a required timeline field, so history and the just-sent optimistic row show the original name instead of the stored path.
  • Staging no longer overwrites earlier turns (apps/host-daemon/src/command-handlers/prompt-attachments.ts).
    • Files are created exclusively. Identical bytes reuse the existing file; different bytes get the next -N suffix.
    • Cleanup after a failure only removes files that attempt created.
  • Undo/redo. Paste, drop, the + button, and removing a pill record an editor history step. Redo does not upload again, and a removed pill returns to its original position. Undoing a large paste first turns the pill back into the inline text, then removes the paste.
  • Upload pills stay put. Uploading non-image files render in the file row with the finished pill's size, so the composer no longer jumps when an upload finishes.
  • Attachment viewer. Clicking a file pill in the composer or in history opens a new attachment-file-preview panel tab (or the drawer on compact layouts). The tab persists through local tab state and the thread-tabs contract. HTML attachments render as source. Surfaces without a panel keep the new-tab link.
  • @-mention attachments. A bare @ lists the draft's non-image attachments. Picking one inserts an attachment mention pill that opens the file from the attachment's own project.
    • Codex and Pi now name attached files, as Claude Code and ACP already do, so agents can match a mention to its file.
    • A mention whose attachment was removed before sending is sent as plain text.
    • The plugin SDK's runtime draft schema accepts the new mention kind, so composer.replace (for example Prompt Library restoring a saved prompt) no longer throws.
  • Wire and SDK changes.
    • HOST_DAEMON_PROTOCOL_VERSION 232 → 233, because the daemon validates the new attachment prompt mention kind.
    • @get-bb/plugin-sdk 0.6.34 → 0.6.35 for the ComposerMention attachment variant, recorded in docs/api_to_audit.md.
  • Merged origin/main at d933fc2757.

How you verified

On the merged tree:

  • pnpm exec turbo run typecheck lint --filter='...[origin/main]': 133/133 tasks pass. Two plugin typechecks needed pnpm install for dependencies added on main.
  • pnpm exec turbo run test for every changed package (@bb/app, @bb/client-core, @bb/demo-server, @bb/domain, @bb/host-daemon, @bb/host-daemon-contract, @bb/server, @bb/server-contract, @bb/thread-view, @get-bb/plugin-sdk, prompt-library, provider-codex, provider-pi): 25/25 tasks pass, including 5,617 @bb/app tests.
    • One local PluginIcon failure came from untracked build output of the removed navigation plugin left in the worktree. It passes once that is moved aside.
  • node .github/workflows/check-plugin-sdk-version.mjs passes.
  • Tests that fail before the fix and pass after:
    • plugin-composer-handle.test.ts exercises attachment mentions through restore and quote for both core and plugin callers. Without the schema fix, 4 tests fail with "Invalid composer draft".
    • PromptBoxInternal.test.tsx opens a mention of an attachment from another project from that project. It fails against the old resolver.
  • apps/host-daemon/test/command/thread-dispatch.test.ts covers same-name staging across turns, reuse of identical bytes, and failure cleanup.
  • Manual check on a worktree build: in a seeded thread, two turns each attached a different notes.txt, and the agent re-read the first turn's file correctly. On the same machine, uploads already have unique stored paths, so the daemon collision path is covered by the unit test rather than this run.
  • Not verified: a full turn on a remote enrolled host, native mobile clipboard events, and live non-Codex providers.

Feature approval: Sawyer approved opening this upstream PR in the Discord #contributors thread on 2026-10-07. aotd1 is in the approved contributor list. The original prototype and review history are in aotd1/bb#3.

Fixes #4910

AGENT GENERATED

🤖 Generated with Claude Code

qa and others added 10 commits October 7, 2026 21:19
Replace the dedicated pasted-text pipeline (upload manager, IndexedDB
recovery store, custom undo step, retry/insert card, draft pastedText state,
provider prompt changes, and docs) with one branch in the composer's paste
handler: plain text of 5,000+ characters becomes a "Pasted text.txt" File
handed to the existing attachFiles path. Clipboards that also carry files
keep main's behavior, so large text beside an image is no longer dropped.

History keeps the original attachment name and size: localFileDetails is now
a required timeline field (sizeBytes nullable) filled by thread-view and by
the optimistic user row, so a just-sent message no longer flashes the
uploaded path name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Name each large paste after the attachments already in the draft and the
uploads still in flight, so a second paste becomes "Pasted text 2.txt".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Attachments for every turn stage into one flat Attachments/ directory, so a
later turn's file with the same name replaced the earlier one and the agent
read the wrong contents when it went back to an earlier message. Staging now
creates files exclusively: an existing file with identical bytes is reused,
and a differing one gets the next -N suffix. Failure cleanup only removes
files the failed attempt created, so it can no longer delete a file an
earlier turn still references.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Paste, drop, the + button, and removing a pill now record a history step, so
Cmd+Z removes or restores the attachment and Cmd+Shift+Z replays it without
uploading again. A removed attachment returns to its original position, and
one undone while still uploading stays out of the draft until redo.

A large text paste records two steps: undo first turns the attachment back
into the pasted text, then removes the paste. The text step is applied to
editor state without rendering, so the paste only appears inline on undo.

Attach handlers now return the attachments they added, and composers pass an
onUpdate attachment updater instead of onRemove. History steps only act in
the draft that recorded them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pending uploads all rendered in the image row, so a non-image file appeared
as a chip in a new row and then jumped to the file row once uploaded,
resizing the composer twice. Uploading files now render as a pill in the
file row with the same box as the finished pill, spinner in the remove
slot, so finishing an upload no longer moves the composer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Clicking an uploaded file pill in the composer or in sent-message history now
opens it in a right-panel tab (or the drawer on compact layouts) instead of a
raw browser tab. A new attachment-file-preview tab kind carries the project,
stored path, and display name; it persists through local tab state and the
thread-tabs contract, loads through loadFilePreview against the attachment
content endpoint, and renders HTML attachments as source rather than in the
preview iframe. Surfaces without a panel keep the new-tab link.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Typing @ in a composer now lists the draft's non-image attachments in an
Attachments group, including on a bare @, and picking one inserts an
attachment mention pill (`@<name>`). Codex and Pi now name attached files
the way Claude Code and ACP already do, so agents match the mention to the
file by name. Images are not offered because most providers deliver them
without a name.

Every attachment added through the composer gets a name unique within the
draft ("notes 2.txt"), replacing the paste-only numbering, so mentions are
unambiguous. Mentions of attachments removed before sending are sent as
plain text. Attachment mention pills in history and in the editor open the
file in the attachment viewer.

The new mention kind is part of the prompt input contract the host daemon
validates, so HOST_DAEMON_PROTOCOL_VERSION moves to 231 (origin/main is
already at 230). ComposerMention gains the attachment variant; the plugin
SDK version bump is left for the rebase onto main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The plugin SDK's runtime draft schema did not list the attachment mention
kind, so composer.replace threw "Invalid composer draft" whenever the draft
held an attachment mention. That broke plugins writing back a draft they had
read, including Prompt Library restoring a saved prompt into an empty
composer.

Clicking an attachment mention in the composer opened the file from the
current project, while the attachment pill uses the attachment's source
project. A draft attachment recalled from another project therefore failed
to preview. The prompt box now resolves attachment mentions against the
draft's own attachments, through the same opener and project rule as the
pill. Sent-message history keeps resolving through the thread view, and the
root compose view's now-unreachable attachment branch is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	apps/app/src/views/RootComposeView.tsx
#	packages/host-daemon-contract/src/protocol.ts
#	packages/host-daemon-contract/test/contract.test.ts
ComposerMention gained the attachment variant, so plugins that read or write
attachment mentions need a host at 0.6.35 or later.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 81f98d6 into get-bb:main Oct 9, 2026
46 checks passed
SawyerHood added a commit that referenced this pull request Oct 9, 2026
## Human comments

## What was wrong

When a provider install failed in the first-run setup guide, the agent
row said "Install failed. Check the log, then retry." but the row had no
way to open that log. The only route to it was the "View log" action on
the failure toast, which disappears.

## What changed

- `apps/app/src/components/onboarding/OnboardingViews.tsx`: a failed
install row now shows a **View log** button next to **Retry**. It also
shows when the machine reports no install action, so the log stays
reachable without a retry.
- `apps/app/src/components/onboarding/OnboardingFlow.tsx`: the button
opens the failure's stored log in the existing provider CLI install log
dialog, the same one the Updates settings page and the failure toast
use. The row text is shortened to "Install failed", since the buttons
now carry the rest and the longer text was truncated.
- `apps/app/src/components/onboarding/Onboarding.stories.tsx`: the
failed-install story passes the new handler and the shorter text.

-
`apps/app/src/components/secondary-panel/lazySecondaryPanelComponents.tsx`:
unrelated fix for a type error on `main` that failed this PR's lint and
typecheck job. The attachment preview tab (#5098) passed the shared
loading component directly, but that component requires a copy path
(#5264) the tab never supplies. The loading state now shows the
attachment name with no copy path, matching the loaded preview.

No wire, CLI, or configuration changes.

## How you verified

- Added `apps/app/src/components/onboarding/OnboardingViews.test.tsx`:
the log button appears only on the agent whose install failed and
reports that agent, and it stays available when no retry is offered.
- `pnpm exec turbo run test --filter=@bb/app --
src/components/onboarding src/components/secondary-panel` (565 tests
pass).
- `pnpm exec turbo run typecheck lint --filter=@bb/app` (0 errors; it
fails on `main` without the loading-state fix).
- Not checked in the running app.

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

> AGENT GENERATED

---------

Co-authored-by: Claude Code <[email protected]>
ymichael added a commit that referenced this pull request Oct 9, 2026
…5246)

## Human comments

## What was wrong

Push notifications had only server-wide channel toggles. Users could not
mute one thread, quiet the workers under a coordinator, or keep
approvals while skipping finished-turn pushes (#1446, Discord
2026-09-29). This is step 2 of the thread action registry plan,
following #5243 (merged): the first plugin registration in
`experimental_threadAction`. A per-thread setting also exposed a gap in
step 1's API. A registration had no way to know which threads are on
screen, and core had no way to read one plugin's metadata for many
threads in one request. Without those, a plugin either loads every
thread or fetches per row.

## What changed

Ten commits; the first four change core or the thread list and can be
reviewed on their own, and the last four are review follow-ups (items
7–10).

1. **Batched metadata read (core).** `POST /threads/plugin-metadata`
takes `{ pluginId, threadIds }` (1–200 ids). It runs one `WHERE
plugin_id = ? AND thread_id IN (…)` query on the table's primary key, so
no new index or migration. Archived and deleted threads are included,
and corrupt namespaces are omitted and logged. The core SDK exposes it
as `threads.experimental_listPluginMetadata({ pluginId, threadIds })`.
The plugin-bound SDKs (backend `bb.sdk`, app `useSdk()`, fake host)
default `pluginId` to the caller and accept another plugin's id, like
`getPluginMetadata` and `updatePluginMetadata`. The route trusts
`pluginId`, like the existing single-thread metadata routes, because app
requests carry no plugin identity. That is listed as an audit item for
all three routes.
2. **`useData({ threadIds })` (core).** The registry reference-counts
the thread ids named by `experimental_useThreadActions` callers: sidebar
rows on screen, the open thread's header, and open menus. It publishes
them sorted and deduplicated, once the set has been quiet for 32 ms (at
most 100 ms after the first change), so rows that mount a frame apart
during a scroll step arrive in one change. A surface counts only while
visible: `AppSidebar` wraps the thread list in
`ThreadActionSurfaceVisibility`, visible when the app body is shown and
the sidebar (or compact drawer) is open. A hidden sidebar on a settings
route therefore contributes no ids, even if a plugin list mounts rows.
The ids live in their own store that only the collectors read, so
scrolling re-renders one collector per registration, not the rows. bb's
own `useData` hooks take no arguments and are unaffected. The
registration docs make this the recommended pattern for per-thread data
until an attributes layer lands.
3. **Hidden thread list mounts no rows (thread-list plugin).**
`SidebarWindowedItems` treated a zero-height scroll container as
"realize every row", and pinned threads render outside the windowing. So
a direct load of a settings route mounted every row behind the hidden
sidebar. A zero-height container now realizes nothing, and the
IntersectionObserver realizes visible rows once a resize gives it
height. Environments without IntersectionObserver keep promote-all. The
pinned tree waits for `useSidebarListShown`, which follows the
container's height with a ResizeObserver.
4. **Select option labels (core).** `PluginSettingDescriptor` select
settings can declare `experimental_optionLabels` (value → label). The
settings form shows the label in the picker and as the current value,
while stored values, defaults, `settings.get()` and `bb plugin config
set` keep the option values. A label for a value that is not an option
is refused at define time. The level selects use it: All activity, Needs
input only, Muted, Same as default.
5. **Notification levels (push-notifications plugin).** A level is
`all`, `input-only` or `muted`. Defaults fill gaps and ancestors cap. A
thread uses its own level, else `childLevel` if it has a parent (default
`input-only`, which matches today's rule that child threads never push a
finished turn), else `defaultLevel` (default `all`). Every ancestor's
own level caps the result: muting a coordinator mutes its whole subtree,
a worker set to `all` beats the child default, and a parent set to `all`
never makes an unset worker louder. Thread plugin metadata stores only a
thread's own level, `{ own }`, and only when one is set; the limit from
ancestors is worked out on every read from the current tree (item 10).
The CLI says "limited by parent" when that ancestor is the direct parent
and "limited by an ancestor" otherwise. One pure resolver serves the
sender, the CLI and the app, so changing a default rewrites nothing. The
registration sits in `THREAD_ACTION_GROUPS.settings`; its `useData`
keeps an id-keyed cache and fetches only uncached `threadIds` through
`threadNotifications.list` (200-id batches). It applies the
`threadNotifications` realtime channel per id. After a reconnect it
refetches the threads on screen and drops cached levels for the rest, so
they load fresh when shown again. `item` resolves the level (shown as
described in item 9), and `run` calls `threadNotifications.set`. Nothing
is fetched per row. CLI: `bb push-notifications thread <thread> [--level
inherit|all|input-only|muted] [--json]`, and `status` shows both
defaults.
6. **SDK 0.6.36**, with push-notifications' `engines.bbPluginSdk` floor
raised to match.
7. **Consistent plugin id on metadata reads (core).** The bound batched
read takes an optional `pluginId`, like the single-thread reads, instead
of always forcing the caller's namespace.
8. **Reconnect staleness fix (push-notifications).** A reconnect used to
keep cached levels for off-screen threads, and the fetch when they came
back skipped ids already cached, so a level changed during the
disconnect stayed stale until reload.
9. **Current level on the menu entry (core + push-notifications).** The
submenu repeated its trigger as a heading, and its hint ("Default (All
activity)") was the same size as the choices and sat right above
"Default", so it read as an extra option. The entry itself never showed
the level. Thread actions gain `detail`, a muted second line under the
label; a quick-action button's tooltip shows "Label: detail". Desktop
submenus no longer draw `choices.heading`, because the trigger names
them; the phone drawer step and the quick-action popover still use it as
their title. `choices.hint` is now a footnote below the choices, after a
separator. Notifications sets `detail` to the effective level and
switches its icon per level: two SVGs declared in the plugin manifest,
`push-notifications/ringing` and `push-notifications/off`, plus the
built-in `BellDot` for Needs input only. The Default choice names its
fallback ("Default (Needs input only)"), and the footnote appears only
when a parent or ancestor limits the level ("Limited by a parent thread"
/ "Limited by an ancestor thread").
10. **Limits resolved from the current tree (core +
push-notifications).** Each thread used to store a copy of its quietest
ancestor's level, updated only when a level was set or a child was
created. Nesting a thread under a new parent, or archiving a parent
(which releases its unarchived children), left that copy stale. Core
gains `threads.experimental_listAncestors` (`POST /threads/ancestors`,
1–200 ids): each thread's ancestor ids from the parent up, in one
recursive query on the primary key. Push-notifications reads the
ancestors and then everyone's own level in one batched metadata call,
for the menu, the CLI and the sender. The cap push-down, the
`thread.created` copy and stored `inherit` rows are gone. Open menus are
not refreshed when an ancestor's level changes; only the written thread
is published.

No server/daemon wire changes. Docs: `docs/api_to_audit.md` (new read
entry; slot entry updated with `threadIds` and the Notifications
registration), `docs/configuration.md`, `docs/multiple-devices.md`, the
`bb guide` customization template, the plugin-authoring references, the
plugin overview, and the Plugin Guide surfaces.

Changes from the source commits (b237c68fb8, 2f9fc5d886, 2b482e6462,
8dffcd7402):
- The per-row metadata fetch and `threadNotifications.get` are gone.
- Inheritance follows Michael's rule ("defaults fill gaps, ancestors
cap") instead of "a parent's level applies to its tree".

## How you verified

- One server test table over a grandparent → parent → worker tree covers
six cases:
  - an unset worker gets the child default;
  - a worker's own `all` beats an `input-only` child default;
  - a parent set to `all` leaves an unset worker at `input-only`;
  - a muted parent mutes an unset worker;
  - a muted grandparent caps a parent set to `all` and its worker;
  - a muted grandparent caps a worker set to `all`.
- Further server tests cover:
- storage of only each thread's own level, with limits resolved from the
current tree;
- a worker moved between a muted and a loud coordinator, then detached,
follows each move, and a question notifies after the move to the loud
one;
- list by id with archived threads included, and publication of the
written thread;
- `POST /threads/ancestors` against a real database: ancestor order, one
entry per id, unknown ids dropped, 400 for 0 or 201 ids, and both move
paths (`PATCH /threads/:id` nesting and the child release when a parent
is archived);
  - CLI output;
- send-time filtering, including workers no louder than `childLevel`
under a muted default.
- App tests:
- one list call for the shown ids; only uncached ids fetched, once each,
and nothing for an empty list;
  - 250 ids split into 200 + 50;
  - an unarchived thread shows its stored level without a reload;
  - own writes, realtime updates, and a refetch after reconnect;
- threads off screen during a reconnect refetched when shown again,
picking up a changed or cleared level.
- Host tests check that:
  - `useData` gets the union of subscribed ids and drops released ones;
  - rows mounting 20 ms apart produce one change;
  - a hidden surface with 250 rows contributes no ids until shown.
- The sidebar harness mounts the real thread-list and push-notifications
plugins hidden with 250 threads. It asserts no rows, no subscribed ids,
and no `threadNotifications.list` call. Thread-list windowing tests
cover zero height realizing nothing, then realizing on resize plus
intersection.
- Route tests: a requested-ids-only response with archived and deleted
threads included, corrupt rows logged, and 400 for a bad plugin id, an
empty id list, or 201 ids. A bound-SDK test checks that the batched read
defaults to the caller's namespace and reads another plugin's with an
explicit `pluginId`.
- `pnpm exec turbo run typecheck lint test --filter=@bb/app
--filter=@get-bb/plugin-sdk --filter=./plugins/thread-list
--filter=./plugins/plugin-api-docs --filter=@bb/server
--filter=./plugins/push-notifications --filter=@bb/db --filter=@bb/sdk
--filter=@bb/server-contract` passes: app 5580, server 3399, lint 0
errors.
- `turbo run typecheck --filter='...[ea9cd40]'` (89 packages) and
every plugin's tests (46 tasks) pass. The SDK version guard passes.
- Item 9: the push-notifications app test checks `detail`, the icon, the
Default label and the footnote for a muted thread, a child limited by
its parent, a grandchild limited by an ancestor, a child on the child
default, and a top-level thread on the global default.
Push-notifications tests (41), thread-list row tests (107), and app
`ThreadActionsMenu` tests (42) pass; app/plugin lint has 0 errors; the
SDK version guard passes. On a `start:worktree` instance I took
screenshots of the desktop row menu (on Default, child on Default, set
to All activity under a muted parent, muted, Needs input only) and the
390 px phone drawer. A level set from the CLI updated the open menu
live. `@bb/app` typecheck fails only in
`lazySecondaryPanelComponents.tsx`, which comes from main (#5098) and
which this branch doesn't touch.
- Live verification of the earlier head ran in @thread:thr_kaqaxztx6m
and passed every journey. Its findings (hidden-sidebar fetch,
scroll-step stragglers, grandparent wording) are fixed here.

Request counts on a `start:worktree` instance with 240 threads (headless
Chrome 1400×900, counting `threadNotifications.list` requests and their
id counts):

| scenario | before (previous head 4fd4886) | after |
|---|---|---|
| direct load of `/settings` | 2 requests (200 + 40 ids) | 0 |
| load of `/` (34 rows) | 2 (32 + 2) | 1 (34) |
| five 400 px sidebar scroll steps | 1 request each, plus a 1-id
straggler in 3 of 5 | 1 request each (13–14 ids) |

Sidebar benchmark (`BB_SIDEBAR_BENCH=1`, 3,000 threads, 81 rendered
rows, median of 8 alternating runs in the same tree). The baseline
column is this branch with the push-notifications registration
unmounted. Core collectors and thread-list's Move are mounted in both.
The machine was noisy, so individual runs spread widely.

| metric | without Notifications | with Notifications |
|---|---|---|
| mountMs | 536.5 | 543.5 |
| statusPatchMs | 164 | 153 |
| membershipRefetchMs | 125.5 | 110.5 |
| pinMs | 164 | 150.5 |
| React Query observers | 821 | 822 |
| observers per rendered row | 10.14 | 10.15 |
| `threadNotifications.list` calls / ids requested | — | 4 / 84 (each id
once) |

The benchmark ran before the resolver and label changes; neither changes
what renders or how often. The single extra observer is the plugin's
settings query. The first cut cost about 30 ms per status patch: every
fetched batch replaced the cache, even when no requested thread had a
level, which re-evaluated every row. The cache now changes only when a
batch returns a stored level.

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

> AGENT GENERATED

---------

Co-authored-by: qa <qa@x>
Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Oct 9, 2026
…5275)

## Human comments

## What was wrong

When the sidebar row layer moved into the thread-list plugin (#4036),
about seventeen components were copied instead of moved. The app and the
plugin each kept a copy, and the copies drifted: different touch delays,
a release-click fix only in the app, extra rename features only in the
plugin, and a fourth confirm dialog in the tasks plugin. Separately,
bb's core `sidebar.collapsed*` UI preferences were left behind when the
plugin migrated its own preferences. The app kept writing all six, only
`sidebar.collapsedThreads` still had a reader (mobile recents), and that
made recents' collapse state sync across devices by accident.

## What changed

Three commits. Each component now has one home, placed by the rule now
written down in `docs/forkable-plugins.md` ("What belongs in
shared-ui"):

1. **Shared presentation primitives go to `packages/shared-ui` and the
plugin registry.** These are `use-dialog-state`,
`use-drag-click-suppression`, `use-reorder-dnd`,
`use-sidebar-reorder-dnd`, `sortable-motion`, `compact-long-press-menu`,
`action-menu-items`, `confirm-delete-dialog`, `rename-dialog`,
`inline-rename`, `inline-rename-editor`, `sidebar-visibility-customize`,
`sidebar-customize-panel`, `sidebar-row-classes`,
`sidebar-hover-actions`, `context-selection` and
`thread-list-empty-state`. Where the app and the plugin need different
behaviour, the difference is a prop:
- Each side passes its own touch sensor: the app's drawer-aware one, and
the plugin's 500 ms long-press one from #4329.
   - The app renders the inline rename editor through its lazy split.
   - `MachineRenameDialog` uses the shared `RenameDialog` shell.
- The tasks plugin's `ConfirmDialog` is replaced by
`ConfirmDeleteDialog`, which gains `className`, `size` and
`confirmDisabled` props.
2. **The thread status glyph is host-rendered through the SDK.** The app
still draws the glyph in the palette, related threads and mobile
recents, so the host now exposes it as `experimental_ThreadStatusGlyph`
(`indicator`, `archived`, `rowStatus`, `hideIdleDraftLabel`, `size`),
and the plugin deletes its copy. The plugin still resolves the indicator
itself, which lets it fold in collapsed children and drafts.
- The SDK test fake exposes the requested indicator as data attributes.
- Glyph rendering tests moved to the app's `ThreadStatusGlyph.test.tsx`.
   - SDK bumped to 0.6.36; the thread-list SDK floor is now 0.6.36.
- Added an `api_to_audit.md` entry and the Plugin Guide surface symbols.
3. **Mobile recents keeps its collapse state on the device.** It is
stored in local storage under `bb.mobileRecents.collapsedThreads`.
`useMobileRecentsThreadReveal` replaces the app's sidebar reveal hook
and keeps the one behaviour recents used: navigating to a thread, or a
thread becoming unread, opens its collapsed ancestors. The six
`sidebar.collapsed*` keys leave the UI preference registry, the demo
server and `docs/configuration.md`. The server already ignores stored
rows for unknown keys. The thread-list migration no longer reads them.

No server/daemon wire changes. Net −1,769 non-test lines (+399 generated
registry JSON).

**User-visible differences:**
- The plugin's long-press menus now swallow the click that follows a
long press (#4813), as the app's already did.
- `MachineRenameDialog` now returns focus to the opener after closing.
- Tasks confirm dialogs clear their content while closing.
- Mobile recents collapse no longer syncs across devices, and starts
expanded once per device.
- An install that has not started bb since 2026-09-21 loses its old
sidebar collapse state.

## How you verified

Ran with `pnpm exec turbo run typecheck lint test` on the touched
packages:

| Package | Tests |
|---|---|
| app | 5,640 |
| thread-list | 451 |
| tasks | 412 |
| db | 615 |
| client-core | 279 |
| domain | 220 |
| plugin-sdk | 368 |
| plugin-build | 165 |
| plugin-api-docs | 73 |
| demo-server | 15 |
| plugin-registry | 1 |

All pass. The server UI preferences test file also passes (18 tests).

- **Lint:** 0 errors.
- **Typecheck:** clean, except one error that already fails on main from
#5098 (`lazySecondaryPanelComponents.tsx:287`), in a file this PR does
not touch.
- **Fork check:** `pnpm check:plugin-forks plugins/thread-list
plugins/tasks` passes.
- **SDK version guard:** `check-plugin-sdk-version.mjs` passes.

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

> AGENT GENERATED

---------

Co-authored-by: qa <qa@x>
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.

Automatically convert large pasted text into an attachment, following Codex Desktop

2 participants