Skip to content

Give plugins and core one way to open, link and reveal threads, messages and settings - #7954

Merged
ymichael merged 10 commits into
mainfrom
bb/implement-plugin-navigation-api-gaps-thr_7vtctebgv3
Nov 23, 2026
Merged

ymichael merged 10 commits into
mainfrom
bb/implement-plugin-navigation-api-gaps-thr_7vtctebgv3

Conversation

@ymichael

@ymichael ymichael commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Plugins could not reach three places core reaches every day, and core itself reached each of them through several separate implementations:

  • A message in a thread. useBbNavigate().toThread could not carry a message, so community plugins rebuilt the reveal from the DOM (paging, estimating offsets, fake wheel events) or forged history.pushState({ usr: { searchMessageSeq } }) plus popstate. Core had two reveal engines: message links and palette results went through useScrollToSearchedMessage, while the thread outline had its own loop (look up by row id, up to 1,000 older-page loads, one scroll with no settle, silent when the message was missing).
  • Settings. The only plugin API was the footer action's openSettings(); thirteen plugins forged history state to open a settings page. Core built settings paths with five different builders.
  • Thread locations and opening. Plugins hand-built /threads/<id>, #msg= and /settings/... paths. Core built thread paths with two builders plus hand-written strings in mobile, and opened threads through openThreadInSplit, a separate layout path for bb thread open, a plugin-only copy in the sidebar thread actions, and plain navigate calls.

What changed

Plugin API (on BbNavigate, so useBbNavigate() and every callback's context.navigate share it):

toThread(threadId, options?: { split?: boolean; messageSeq?: number }): void
experimental_toSettings(target?: { section: ExperimentalSettingsSection }): void
experimental_threadHref(threadId: string, options?: { messageSeq?: number }): string
experimental_settingsHref(target?: { section: ExperimentalSettingsSection }): string
  • toThread's messageSeq is stable and unprefixed so it matches the href option; it opens …/threads/<id>#msg=<seq> through the same placement as split, and a repeated call reveals again.
  • experimental_toSettings() opens the calling plugin's settings page; with a section it opens that bb section. Settings is whole-window; Back restores the panes.
  • The href builders return the location the matching call opens. Plain clicks on them inside plugin slots route in place (Cmd/Ctrl-click splits, middle-click opens a tab).
  • A seq that is not a non-negative integer, or an unknown section, throws RangeError. The SDK test harness (renderSlot) rejects the same input.
  • Message metadata components receive message.messageSeq. Message actions keep the already-shipped ThreadChatMessageReference.experimental_messageSeq.
  • ExperimentalSettingsSection must equal the app's settings section ids; a type test fails if they drift.

One implementation per concept in core:

  • Thread paths: getThreadLocationPath (@bb/client-core) is the only builder. getThreadRoutePath is folded into it, and every web and mobile caller uses it, including notification and bb thread open targets in the mobile app.
  • Opening threads: openThread (split-layout/openThread.ts) is the only way to open a thread for the user, with or without a split. It replaces openThreadInSplit and the CLI's own layout code. Callers: toThread, experimental_useSidebarThreadActions().open, the search palette, sidebar Open in split and keyboard navigation, bb thread open, mention links, the archived-thread toast, and newly created threads. Pane bookkeeping (closing, replacing or reconciling panes) only builds paths.
  • Settings paths: getSettingsTargetPath is the only builder, covering sections and plugin, machine and project pages. getSettingsRoutePath, getPluginConfigurationRoutePath, getSettingsMachineRoutePath, getSettingsProjectRoutePath and getSettingsSectionRoutePath are gone. The sidebar footer's openSettings / openPluginDetails call navigate.experimental_toSettings().
  • Revealing a message: useScrollToSearchedMessage is the only reveal. Its provider now accepts in-place reveal requests besides URL and palette targets; the most recent wins. It loads older pages, keeps the target rendered, waits for layout to settle, highlights, and toasts when the message is missing. The thread outline sends an in-place request with the message's seq, so it still adds no history entry. Its paging loop, pending pulse and the separate timelineNavigationTargetRowId plumbing are gone.

Server/client contract: ThreadConversationOutlineItem gains messageSeq. CONVERSATION_OUTLINE_PROJECTION_VERSION is bumped to 3 so stored outlines rebuild. No host daemon wire change.

Not changed: the generic Settings button, nav rail button and "Open settings" command reopen the last settings page visited (a stored location, not a target). The "Open server settings" command still navigates to /settings/servers, which the web app does not have; that predates this PR.

Docs: docs/api_to_audit.md entry, Plugin Guide symbols (Message actions, Thread list, Custom settings section cards), bb-plugin-authoring (references/frontend-navigation.md, routed from SKILL.md), SDK testing harness members, SDK 0.6.179.

Community callers that can migrate (not edited): nfour minimap/pinned-turns/lexicon/chat-dock, frankieshakes threadline, yusuf8834 chat-search, ahkohd sticky-prompt, mturilin quick-reply, rebryk bookmarks, brsbl timeline-comments; gpambrozio herald/model-pricing/dream/learning-exercises/launchd-jobs/firstmate-crew, vburojevic pets, jem-computer live, swairshah handsfree, brzvsk model-visibility, qwent71 waiting-on-you, wy3z cursor-suite, oddship dummie; joozio work-map, koenvg tasks-plus, anirudhranganath thread-tabs, VKirill voice-input, kalindudc session-log, charpeni agent-traces, cristoslc focus-board.

How you verified

Live on pnpm start:worktree with a local test plugin and a real three-turn thread, in headless Chrome:

  • On main, toThread(id, { messageSeq: 1 }) ignored the message (no #msg=, first prompt 2,228px above the viewport) and experimental_toSettings did not exist. On this branch the same call opens #msg=1 with the message at the top and highlighted; a repeated call after scrolling away reveals it again; a seq that is not a message toasts "Message not found".
  • toThread(id, { split: true, messageSeq: 1 }) opens or focuses the pane at the message without a new history entry when the thread is already open.
  • bb thread open <id> --split right adds a pane; opening an already-open thread focuses it without a new history entry.
  • experimental_toSettings() → /settings/plugins/navtest; { section: "appearance" } → /settings/appearance; "billing" and -1 throw RangeError. Settings → Machines → machine page, Projects → project page, General → /settings all route through the new builder.
  • A plain click on a plugin <a href={experimental_threadHref(...)}> routes in place without a reload.
  • Clicking the first prompt in the thread outline lands it at the same position a message link does (75px) and highlights it; clicking again after scrolling 6,000px away reveals it again; no history entries. Not exercised live: an outline jump several pages back (the test thread fits one page); that case now runs through the same paging code as message links.

Tests: plugin-navigation-hooks.test.tsx (6 of 7 fail on main), openThread.test.ts, the outline click test, a timeline test that an in-place reveal request after an older URL target keeps the message realized and reveals it, the SDK harness validation test, and MessageMetadata.test.tsx. pnpm exec turbo run typecheck lint test for @bb/app (7342, after rebasing onto main), @bb/server (4423), @bb/server-contract (89), @get-bb/plugin-sdk (447), @bb/mobile (356), @bb/client-core (243), bb-plugin-plugin-api-docs (76), bb-plugin-bb-guide (8); typecheck for every @bb/client-core dependent.

AGENT GENERATED

🤖 Generated with Claude Code

@ymichael ymichael changed the title Let plugins open and link threads at a message and open settings through bb's own navigation Give plugins and core one way to open, link and reveal threads, messages and settings Nov 21, 2026
@ymichael
ymichael force-pushed the bb/implement-plugin-navigation-api-gaps-thr_7vtctebgv3 branch from b251b44 to 0c4dbde Compare November 21, 2026 05:02
ymichael and others added 10 commits November 23, 2026 09:53
…ugh bb's own navigation

BbNavigate gains toThread's experimental_messageSeq, experimental_toSettings,
experimental_threadHref and experimental_settingsHref, on useBbNavigate() and
every callback's context.navigate. Core's Copy link, Copy message link,
mention links, search palette, targeted settings entry points and the
sidebar footer's openSettings now build and open these locations through the
same functions (getThreadLocationPath, openThread, getSettingsTargetPath).
Message metadata components receive experimental_messageSeq.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… its own skill reference

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ss reject what bb rejects

toThread, experimental_threadHref and message metadata now share one name,
messageSeq. toThread's option ships stable so it matches the href option;
members under an experimental_ method or an Experimental* type do not
repeat the prefix.

renderSlot's navigate throws the same RangeError as bb for a seq that is
not a non-negative integer or an unknown settings section, so plugin tests
catch input bb would refuse.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nction each

getThreadLocationPath is now the only thread path builder: getThreadRoutePath
is folded into it, and every app and mobile caller, including notification
and thread-open targets, uses it.

openThread is now the only way to open a thread for the user. It absorbs
openThreadInSplit and the CLI's own layout code, so toThread, the sidebar
thread actions' open, the search palette, sidebar Open in split and keyboard
navigation, bb thread open, mention links, the archived-thread toast and new
threads after creation all share one placement path. Pane bookkeeping keeps
using only the path builder.

getSettingsTargetPath is now the only settings path builder, covering
sections and plugin, machine and project pages; the separate builders in
client-core and settings-sections are gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The thread outline had its own reveal: it looked rows up by id, looped up to
1,000 older-page loads waiting six frames each, scrolled once without waiting
for layout to settle, and did nothing when the message was missing.

Outline items now carry the message's seq (the server's outline projection
adds messageSeq; its cache version is bumped so stored outlines rebuild), and
a click sends an in-place reveal request to the provider that already handles
message links and palette results. That one path loads older pages, keeps the
target rendered, waits for it to settle, highlights it, and toasts when it is
missing; whichever target arrived last wins. The outline still adds no
history entry. Its paging loop, pending pulse and the separate
navigation-target plumbing are gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
React Router's navigate returns a promise; callers passed it straight to
openThread, which type-aware lint rejects as a promise where void was
expected. openThread now accepts either return and discards the promise
itself, so callers pass navigate unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
experimental_makeActionContext's navigate proxy returned false for every
method, so experimental_threadHref and experimental_settingsHref broke their
string contract. They now share the test harness's href builders.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…reveals to their thread

openThread on a compact viewport pushed a new history entry even when the
thread was already open, so Back stayed on the same thread; it now replaces
the entry as it did before. Outline reveal requests carry the thread id so a
pane that switches threads does not reveal the old request's seq. Drops the
empty route-paths imports left by the settings path consolidation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/implement-plugin-navigation-api-gaps-thr_7vtctebgv3 branch from ed3bc3b to ebe72aa Compare November 23, 2026 17:55
@ymichael
ymichael merged commit 5ff27dd into main Nov 23, 2026
95 of 97 checks passed
@ymichael
ymichael deleted the bb/implement-plugin-navigation-api-gaps-thr_7vtctebgv3 branch November 23, 2026 18:10
ymichael added a commit that referenced this pull request Nov 23, 2026
## Human comments

## What was wrong

Core opened the New thread screen in about a dozen places, each building
`navigate("/", { state })` by hand. None of them could place the screen
in a split. `SplitThreadArea` then reconciled the layout so the composer
replaced whatever pane was focused. Plugins had the same limitation:
`toCompose` had no `split` (#8011). The thread-list plugin's project,
section and Threads `+` buttons go through `toCompose`, so they also
replaced the pane the user was reading (#2795).

## What changed

**One opener.** `openNewThread`
(`apps/app/src/lib/split-layout/openNewThread.ts`, with
`useOpenNewThread` for components) is now the only way core opens the
New thread screen, as `openThread` is for threads since #7954. It takes
the compose options (`projectId`,
`initialPrompt`/`replaceInitialPrompt`, `focusPrompt`, `placement`,
`environmentId`, `hostId`), plus `split` and `replace`. It selects the
project, builds the route state once, and with `split` places the pane
by the same rules as `openPaneContentInSplit`:
- a right split by default
- focus (and replace history) when a composer pane is already open, then
apply the options there
- replace the focused pane at the pane cap
- plain navigation on compact viewports or when there is no layout

The placement logic is extracted as `placePaneContentInSplit`, so both
callers share it.

**Callers moved onto it:**
- `toCompose`
- the superseded sidebar `openNewThread`, which takes no `split`
- the sidebar New thread button and its Open in split
- the `thread.new` command
- New thread in environment
- Create plugin, Create skill and Fork skill
- Edit skill/plugin via chat
- Create custom palette
- the screen after quick-creating a project

Redirects after deletion, route repair and
`LegacyProjectComposeRedirect` still only build the path. Every caller
keeps its current behavior; the thread-list `+` buttons gain
Cmd/Ctrl-click.

**SDK.** `BbNavigate.toCompose` gains `split?: boolean`. It is stable
and unprefixed, like `toThread`'s `split`. Plugin SDK is bumped to
0.6.187, and thread-list now requires `>=0.6.187`.

**#2795.** The thread-list plugin's `+` buttons (project, section,
machine, Pinned, Threads, and environment groups) now behave like the
sidebar New thread button. A plain click still replaces the focused
pane, and Cmd/Ctrl-click opens the New thread screen beside it. The
issue left this choice open; the modifier keeps all the New thread
buttons consistent. The click's modifier reaches `toCompose`'s `split`
through each handler. The issue's second point, raising `MAX_PANES`, is
not part of this PR.

**Small cleanups:**
- Dropped the never-read `createDraftKind` state from the skill entry
points.
- Dropped the sidebar `openNewThread`'s `sectionId` state key, which
`placement` (always sent alongside it) already overrides.
- `buildCreateThreadInEnvironmentState` and its test are replaced by the
`openNewThread` state test.

**Docs:**
- `docs/api_to_audit.md`: a new paragraph under Thread creation
placement lists the core callers.
- bb-plugin-authoring: `frontend-navigation.md` gets a New thread screen
section; `frontend-hooks-and-ui.md`, `frontend-thread-list.md` and the
SKILL.md routing line are updated.

No host daemon wire change.

## How you verified

- New tests:
- `openNewThread.test.ts`: focuses and replaces history for an existing
composer pane, replaces at the pane cap, does not touch panes on compact
or without split, and hands RootComposeView the environment, placement
and focus state.
- `plugin-navigation-hooks.test.tsx`: `toCompose({ split: true, ... })`
from a plugin panel adds a new-thread pane to the right with the state
and project selected; without split the layout is untouched. On main the
split case fails because `split` is ignored.
- Updated tests:
- `plugin-sidebar-hooks.test.tsx` now runs against the real project
selection.
  - The thread-list tests expect `split: true`.
- `pnpm exec turbo run typecheck lint --filter=@bb/app
--filter=bb-plugin-thread-list --filter=@get-bb/plugin-sdk`
- Targeted app tests: split-layout, plugin navigation and sidebar hooks,
sidebar, AppLayoutSidebar, RootComposeView, ThreadMetadataContent,
ThreadActionsMenu, app-route-history, PluginAppOverlays.
- `turbo run test` for `bb-plugin-thread-list` (458),
`bb-plugin-bb-guide`, `bb-plugin-plugin-api-docs`.
- Live on `pnpm start:worktree` in headless Chrome (1440×900), with a
thread open in a single pane:
- A plain click on the QAVault project `+` replaces the pane with the
composer, as before.
- Cmd-click on the same button keeps the thread in pane-1 and opens the
composer in pane-2.
- An earlier build that always split confirmed that an already-open
composer pane is focused and switched to the clicked project, with no
third pane.
  - The global New thread button still replaces the focused pane.
- `ProjectList.sectionCreate.test.tsx` covers a plain click, Cmd-click
and Ctrl-click on a section `+`.

Fixes #8011
Fixes #2795

> AGENT GENERATED

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

---------

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.

1 participant