Skip to content

Draw plugin badges on navigation rail icons - #5524

Closed
ymichael wants to merge 1 commit into
mainfrom
t3/fix-issue-5327
Closed

ymichael wants to merge 1 commit into
mainfrom
t3/fix-issue-5327

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Since 0.46.0 the sidebar's labelled navigation list is an icon-only rail (#5229), and no surface mounted a nav panel's experimental_sidebarAccessory. Plugins that used it to show a live count beside their entry (Tasks' open-task count, dashboards like the reporter's) had nowhere to show it. Re-mounting the component on the icon was tried and reverted (#4964 → #4989): it is free-form plugin markup sized for a labelled row, so it overlapped the icon and was clipped, and the host could not read it to label the button for assistive technology.

What changed

New plugin API: PluginNavPanelRegistration.experimental_useBadge (packages/plugin-sdk/src/app-contract.ts, SDK 0.6.48). A React hook returning ExperimentalBadge ({ count?: number; label: string }) or null. The plugin supplies a value; bb owns the drawing and accessibility.

  • Host (apps/app/src/components/sidebar/RailBadges.tsx, AppNavRail.tsx): the rail mounts one hidden source per nav panel inside that plugin's PluginSlotMount (plugin context + crash boundary), so the hook can use useRpc/useRealtime. The value is validated at that boundary (positive integer count, non-empty label, no extra keys); an invalid value or a throw crashes only that slot and shows no badge.
  • Drawing: a 12px count on the icon's corner, capped at 9+, or a dot when count is omitted. label joins the tooltip and accessible name ("Tasks, 3 open tasks"); the mark is aria-hidden. A badged destination hidden under More puts a dot on More (its accessible name lists the hidden badges) and the badge on its menu item.
  • Compatibility: a plugin built against an older SDK that still passes experimental_sidebarAccessory keeps loading. The collector drops the field and warns ([plugin:<id>] slots.navPanel: "experimental_sidebarAccessory" is ignored: it was replaced by "experimental_useBadge" …) instead of failing the plugin's whole frontend. The collector's warning callback now carries any registration warning; composer rejections log exactly as before. Renamed keys (experimental_fixedTabs) and unknown experimental_ keys still fail as before. New builds get a type error for the old field.
  • Tasks moves its open-task count to the hook (plugins/tasks/shell/badge.ts) and requires SDK >=0.6.48.
  • Docs: docs/api_to_audit.md entry (with stabilization items), plugin-authoring frontend-core-slots.md / frontend-registration.md / API indexes, and the Plugin Guide nav-panel surface.

No server/daemon wire change, no database change.

Deviation from the issue: it offered "a count or dot on the rail icon" or "a labelled rail"; this does the first, with the value-based API suggested in the issue comments instead of mounting the old component.

How you verified

  • New tests: AppNavRail.test.tsx (count, 9/9+, dot, clearing, More dot + menu item badge, invalid value shows nothing and the destination still works), plugin-app-definition.test.ts (old field is dropped with the warning; non-function hook rejected), plugin-frontend-reload.test.ts (a whole plugin passing the old field activates with no setup failure and logs the warning), SDK harness capture, Tasks hook tests.
  • pnpm exec turbo run typecheck lint test --filter='...[origin/main]' --continue: 230/232 tasks pass. The two failures are @bb/app typecheck/test in src/lib/fixed-panel-tabs-sync.test.ts, which this PR does not touch: on origin/main it calls createNewTabFixedPanelTab without importing it (Keep new tabs open through concurrent save conflicts #5452 / Replace New tab when opening Browser or plugin actions #4593 race).
  • check-plugin-sdk-version.mjs and check-npm-version-guard.mjs pass at 0.6.48.
  • Manual: pnpm start:worktree with Tasks installed from this branch and three open tasks: the rail shows "3" on Tasks, tooltip "Tasks, 3 open tasks", hiding Tasks puts a dot on More and the count on its menu item. Ladle screenshots in light and dark checked badge size and placement.

Fixes #5327

🤖 Generated with Claude Code

AGENT GENERATED

Since 0.46.0 the navigation rail is icon-only and nothing mounted a nav
panel's experimental_sidebarAccessory, so plugins could no longer show a
live count. Mounting the free-form component on the icon was tried and
reverted (#4964, #4989) because it overlapped the icon and the host could
not read it to label the button.

Replace it with experimental_useBadge, a hook returning
{ count?, label } | null. The rail runs each panel's hook in that plugin's
slot scope and crash boundary, validates the value, and draws a count
(9+ cap) or a dot on the icon. The label joins the tooltip and accessible
name. Badged destinations hidden under More put a dot on More and a badge
on their menu item. A plugin built against an older SDK that still passes
experimental_sidebarAccessory keeps loading: the field is dropped with a
warning naming its replacement. Tasks moves its open-task count to the
hook. SDK 0.6.47.

Fixes #5327

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Oct 15, 2026
…ents

bb draws the sidebar navigation through app.slots.experimental_sidebarNavigation
again, restored under its pre-0.46 names so released navigation plugins load
unmodified. Registrations declare a placement: rail (a fixed column that stays
when the sidebar collapses, with the framed macOS title bar) or list (rows above
the thread list, Settings in the footer, Back to app rows, and the header slot).
bb ships two providers through the same contract, Rail and Top list, picked
with sidebar.navigationProvider in Settings -> Appearance -> Navigation;
Automatic prefers an installed plugin provider and falls back to Rail.

The navigation model now carries Home, Customize, reorder, and each panel's
experimental_useBadge value (folded in from #5524), so every provider draws the
same badges. experimental_sidebarHeader returns for list placements. Plugin
SDK 0.6.52.

Fixes #5360
Fixes #5327

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Oct 16, 2026
…ents

bb draws the sidebar navigation through app.slots.experimental_sidebarNavigation
again, restored under its pre-0.46 names so released navigation plugins load
unmodified. Registrations declare a placement: rail (a fixed column that stays
when the sidebar collapses, with the framed macOS title bar) or list (rows above
the thread list, Settings in the footer, Back to app rows, and the header slot).
bb ships two providers through the same contract, Rail and Top list, picked
with sidebar.navigationProvider in Settings -> Appearance -> Navigation;
Automatic prefers an installed plugin provider and falls back to Rail.

The navigation model now carries Home, Customize, reorder, and each panel's
experimental_useBadge value (folded in from #5524), so every provider draws the
same badges. experimental_sidebarHeader returns for list placements. Plugin
SDK 0.6.52.

Fixes #5360
Fixes #5327

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Oct 16, 2026
…ents

bb draws the sidebar navigation through app.slots.experimental_sidebarNavigation
again, restored under its pre-0.46 names so released navigation plugins load
unmodified. Registrations declare a placement: rail (a fixed column that stays
when the sidebar collapses, with the framed macOS title bar) or list (rows above
the thread list, Settings in the footer, Back to app rows, and the header slot).
bb ships two providers through the same contract, Rail and Top list, picked
with sidebar.navigationProvider in Settings -> Appearance -> Navigation;
Automatic prefers an installed plugin provider and falls back to Rail.

The navigation model now carries Home, Customize, reorder, and each panel's
experimental_useBadge value (folded in from #5524), so every provider draws the
same badges. experimental_sidebarHeader returns for list placements. Plugin
SDK 0.6.52.

Fixes #5360
Fixes #5327

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Oct 16, 2026
…ents (#5584)

## Human comments

## What was wrong

#5229 (0.46.0) made the icon rail the only sidebar navigation and
removed the plugin API that let a plugin draw it
(`experimental_sidebarNavigation`, `experimental_sidebarHeader`, and
their hooks).
- Users who preferred labeled rows had no way back (#5360).
- Navigation plugins on the marketplace stopped loading: Nav Rail,
Compact Nav, Collapsible Navigation, Slim Nav, Sidebar Subtitles, and
Herdr commands (#5376).
- Panel counts had nowhere to show, because the rail is icon-only and no
longer mounted `experimental_sidebarAccessory` (#5327). 30 bb-community
plugins draw one.

The old slot only covered rows above the thread list, so the rail and
the slot could not coexist.

## What changed

**One navigation slot with a declared placement.**
- `app.slots.experimental_sidebarNavigation` is restored under its
pre-0.46 names. Registrations declare `placement: "rail" | "list"`;
`list` is the default, so older plugins keep working.
- bb lays out the sidebar from the placement before the provider
renders:
- **rail:** a fixed column that stays when the sidebar collapses, New
thread in the header and Settings at the bottom of the column.
- **list:** rows above the thread list, the footer in the same column
after the thread list with a Settings action, Back to app rows on the
Settings, Plugins, and Skills lists, a collapse that hides the whole
sidebar, and the header slot.
- Both placements use the same macOS window frame on wide viewports.
Switching navigation keeps the title-bar controls in place and Settings
Search at the same height; sidebar headers do not reserve an empty
window-control gutter below the title bar. Providers without header
controls use only an 8-pixel top inset instead of reserving an empty
48-pixel header row. Compact windows retain the floating toggle.
- bb's Top list keeps the 0.45 row affordances: a hover "…" options
button (always shown on touch devices) with the same menu as
right-click, the split pane map beside a row's label when its page is
open in a split, and More only when a destination is hidden.
- bb's Top list pins New thread and More and scrolls the destinations
between them, capped near 70% of the window with fades at the scroll
edges, so many plugin panels or a short window can't push the thread
list out of view (the pre-0.46 rows could). The shared region stays
uncapped so plugin providers manage their own height.
- bb's own **Rail** (`navigation/rail`, the default) and **Top list**
(`navigation/top-list`) are the bundled Navigation plugin (see below),
so they use exactly the contract a third-party provider gets.
- The region is a `<nav>` element again, as before #5229, and list
placements keep the footer after the thread list in the same column, as
0.45 did. Plugins that find their column with `closest("nav")` and inset
what follows, such as Nav Rail, therefore dock with the footer beside
the rail.
- Picking a provider (`sidebar/sidebarNavigationProvider.ts`):
- `sidebar.navigationProvider` (Settings → Appearance → Navigation)
selects Automatic or a provider by plugin key.
- Automatic uses the first provider from a plugin the user installed,
else the first built-in one (Rail). A pinned provider that is missing
once plugins settle falls back the same way; with no provider at all the
sidebar uses the list placement and says no navigation plugin is
enabled.
  - Legacy `__builtin__` and `navigation/navigation` read as Automatic.
- Before plugin frontends settle, a plugin provider's last placement is
reserved, so a reload does not flash the rail.
- A crashing provider or header is replaced by the built-in provider for
its placement, with one toast.
- `experimental_Original` renders the built-in provider for the same
placement, or nothing when the Navigation plugin is disabled.

**Rail and Top list are a bundled, forkable plugin**
(`plugins/navigation`).
- The plugin registers both providers, plus Rail's New thread button as
its `headerComponent`, using only `experimental_useSidebarNavigation`,
`experimental_useSidebarNavigationSplit`,
`experimental_SidebarNavigationIcon`, and registry components. It is
default-enabled, on `scripts/forkable-plugins.json`, and served by the
demo server.
- The host keeps only what surrounds a provider: the placement layout
(including the rail's top inset), Settings, the customize editor, the
navigation model, and badge collection. The macOS window frame is
independent of navigation placement, and navigation headers sit below
the title bar on wide macOS windows.
- The shortcut pill, overflow fade, and split-pane mini-map move into
shared-ui and the component registry, so the app, Navigation, and Thread
list share one copy each (Thread list drops its private copies).

**Built-in providers come from the install source.**
- The app records which plugins were installed as built-ins from the
plugin list. Every replacement setting (thread list, navigation, source
code, diffs) labels their providers "(built-in)" and lists them after
installed plugins, and Automatic prefers a provider from an installed
plugin, then slot order. No per-slot constants remain.
- Monaco is a built-in plugin, so it now shows as "(built-in)" in the
Source code and Diffs settings, and Automatic prefers a third-party
renderer over it.
- The bundled Thread list option drops its "BB default." description;
the Automatic row already names what it chooses.
- The Navigation setting hides when no navigation plugin is installed,
like the thread list setting, and settings search uses the matching
condition.

**Shared model** (`SidebarNavigationModel.tsx`,
`lib/plugin-sidebar-navigation.ts`):
- `experimental_useSidebarNavigation()` returns `isHomeActive`, and its
actions include `goHome()`, `setOrder()`, and `openCustomize()`.
`openCustomize()` opens bb's editor in a popover beside any provider,
after open menus close, and returns focus to the control that opened it.
bb's menus and the editor call it "Customize navigation" on every
provider.
- Each panel's `experimental_useBadge` value is in the model as
`item.badge`. The badge sources mount once in the model instead of in
the rail.

**Badges (supersedes #5524).**
- This PR includes #5524's value-based `experimental_useBadge` and its
compatibility handling for `experimental_sidebarAccessory` (the field is
dropped with a warning), plus Tasks' migration to the hook.
- `ExperimentalBadge` is `{ count?, text?, tone?, label }`:
- `text` is a short visible value of at most 8 characters, such as
"NEW", "73%", or "2 down", and cannot be combined with `count`;
- `tone` is `neutral` (the default), `warning`, or `critical`, and bb
owns the colors.
- The fields follow the 30 bb-community plugins that drew
`experimental_sidebarAccessory`: 12 drew one count, 8 several numbers or
a fraction, 5 a short status, 3 a percentage, and 18 used red, amber, or
an accent color for state.
- Drawing:
- Fills are solid theme colors: muted gray for neutral, attention amber
with a new `--attention-foreground` for warning, and destructive red for
critical.
- The rail draws counts (capped at `9+`) and a tone-colored dot for
text, each cut out of the icon by a ring in the rail's own background.
- The Top list and More menu draw the count (capped at `99+`), the text,
or a dot.
- More's dot takes the strongest hidden tone, and the label is in every
accessible name.
- Plugins written before 0.46 that drew counts from the item's old
`experimental_Accessory` field show none until they read `item.badge`.

**Header.** A navigation's optional `headerComponent` renders in the
sidebar header row while it is active, replacing the separate
`experimental_sidebarHeader` slot and its `sidebar.headerProvider`
setting; that slot remains as an untyped runtime alias so a pre-0.46
plugin's header joins its navigation. The thread list setting is now
**Sidebar thread list**.

**Plugin SDK 0.6.53.**
- Restored types and runtime exports.
- `ExperimentalBadgeTone` and the new badge fields.
- Collector validation for `placement`.
- Test-harness support (the `sidebarNavigation` option and
`sidebarNavigationCalls`).
- Tasks now requires `>=0.6.53`. No server/daemon wire change.

**Docs.**
- `docs/configuration.md`, the customization guide, and the
plugin-authoring references (new `frontend-sidebar-navigation.md`, plus
`frontend-core-slots.md` and the API indexes).
- `docs/api_to_audit.md` entries with stabilization items and the core
callers on the same path.
- A Plugin Guide "Sidebar navigation" surface on the rail fixture, and
verify-bb rows for Top list and navigation/header plugins, including
disabling the Navigation plugin.
- The navigation docs, SDK doc comments, and renderer slot docs describe
the bundled Navigation plugin, the `navigation/*` keys, and the
built-in-aware Automatic rule.

## How you verified

- Empty header correction (`8cee6a05da`): the new regression test fails
before the fix; all 24 affected sidebar, header, and Settings tests pass
after it, along with app lint and typecheck. The rendered macOS
simulation confirms an 8-pixel inset above Top list and the retained
48-pixel Settings Search row.
- Desktop spacing fix (`fb133df5d9`): both regression tests fail before
the fix and pass after it. The 62 focused app layout, sidebar
chrome/header, and Settings tests pass; app lint and typecheck pass. An
isolated browser with simulated macOS chrome confirms Rail and Top list
use identical title-bar/toggle coordinates and Settings Search height,
with no extra window-control gutter. Compact windows retain their
floating toggle. This renderer check does not verify native Electron
window behavior.
- Windows CI timeout fix (`ae0adb0fa6`): the two ACP restart tests use
the same 30-second allowance as similar process-restart tests. All 499
ACP tests pass locally (4 skipped), along with lint and typecheck;
Windows confirmation remains with CI.

- Full typecheck, lint, and test run is left to CI on this branch
(rebased onto `399d63d277`). The rail and its Settings cell keep the
spacing from #5529 (compact macOS frame) and #5609 (row-rhythm
alignment), and the app typecheck passes after the rebase. Locally, the
affected app, SDK, Plugin Guide, Tasks, guide, mobile, and server suites
passed before the last rebase; the mobile theme and `global.css` were
regenerated for the new `--attention-foreground` token.
- `check-plugin-sdk-version.mjs` and `check-npm-version-guard.mjs` pass
at 0.6.53.
- Navigation plugin commit (`5a0cc8d599`):
- `scripts/check-plugin-forks.mjs plugins/navigation
plugins/thread-list`: both copies install, typecheck, test, and `bb
plugin build` outside the monorepo with published packages only (Thread
list passed on a re-run after one vitest worker start timeout under
load).
- Turbo typecheck and lint pass for the app, both sidebar plugins,
shared-ui, plugin registry, server, demo server, domain, SDK, Plugin
Guide, and templates. Tests pass for Navigation (14), Thread list,
Plugin Guide, plugin registry, demo server (which now serves both
sidebar plugins), the server's builtin-registry and UI-preference
suites, and 229 app test files across settings, lib, sidebar, code,
layout, and plugin. One app file (`PluginSettings.test.tsx`) failed
under the parallel run and passed alone.
- The app's Rail and Top list integration tests now load the real plugin
through `test/fixtures/navigation-plugin.ts`; the plugin's own drawing
(count caps, text badges, More's tone, menus, the header button) is
tested portably in `plugins/navigation/app.test.tsx`.
- After rebasing onto `399d63d277`: turbo typecheck and lint pass for
every package affected relative to main (155 tasks); Navigation, Thread
list, plugin registry, and 231 app test files pass.
- Ran `pnpm start:worktree` with the bundled plugin and the installed
Nav Rail, Compact Nav, and Collapsible Navigation plugins. I confirmed
the server and plugins come up, but did not repeat the visual pass below
after this commit.
- New and updated tests:
  - provider resolution (`sidebarNavigationProvider.test.ts`);
- plugin providers on the real SDK path: list placement, badges,
`openCustomize`, pinned built-ins, crash fallback, and Original
(`SidebarNavigationHost.test.tsx`);
- Top list rows, text and tone badges, the More dot, and Customize focus
(`SidebarNavigationList.test.tsx`);
- list placements keep the footer after the navigation in one column
(`AppSidebar.test.tsx`);
- the rail on the provider host, including invalid badge values (zero
count, count plus text, text over 8 characters, unknown tone), text
drawn as a toned dot, and More's strongest tone
(`SidebarNavigationRail.test.tsx`);
- the header slot, Back to app routing, and the last-known preference
store;
- SDK harness and placement validation, and the server reading stored
pre-0.46 provider rows.
- Manual checks with `pnpm start:worktree` in headless Chromium at
1440×900 (light and dark) and 390×844, plus the packaged macOS desktop
app (`pnpm desktop:worktree`), with Rail and Top list on the framed and
unframed windows:
- Installed from bb-community, unmodified: **Nav Rail**, **Compact
Nav**, and **Collapsible Navigation**. Each loads and draws its
navigation; Nav Rail docks as a vertical rail with the footer beside it
and moves New thread into the header; Compact Nav and Collapsible
Navigation also work as header providers.
- Installed the deleted `examples/plugins/sidebar-navigation` plugin:
Customize, Original, the crash fallback, pinning Rail over it, a reload
without a rail flash, and removal falling back to Rail.
- A local plugin with four badged panels (critical text, warning count,
warning text, neutral text) renders as intended on the rail and in the
Top list in both themes.
- Not verified: iOS Safari and the native mobile shell; the header
alignment on macOS after the header moved into the plugin. A pinned
plugin key that is not installed shows an empty rail-width column on the
first load until frontends settle, then falls back.

**Follow-up commits on this branch.**
- `fb133df5d9` keeps the macOS window chrome stable when switching
between rail and list placements (`AppLayout.tsx`, `SidebarChrome.tsx`,
with tests and docs).
- `8cee6a05da` removes the empty header row above Top list navigation
(`AppSidebar.tsx`, with a test).
- `ae0adb0fa6` gives the ACP restart tests enough time on Windows
(`provider-bridge-acp-next` test timeouts only).
- CI is green on `8cee6a05da`: 48 checks passed or skipped.

Supersedes #5524.

Fixes #5360
Fixes #5327

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

> AGENT GENERATED

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@ymichael ymichael closed this Oct 16, 2026
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.

Navigation rail (0.46.0) has nowhere to show plugin counts: experimental_sidebarAccessory is no longer shown

1 participant