Skip to content

Unify plugin icon registration and provider artwork rendering - #3513

Merged
ymichael merged 6 commits into
mainfrom
bb/clarify-plugin-icon-api-support-thr_pfhbgascgz
Sep 11, 2026
Merged

ymichael merged 6 commits into
mainfrom
bb/clarify-plugin-icon-api-support-thr_pfhbgascgz

Conversation

@ymichael

@ymichael ymichael commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Plugin app icons were effectively limited to BB's built-in names. Several callers discarded unfamiliar names before rendering, so adding artwork did not make it usable consistently across plugin UI and timeline content. Provider artwork had a separate inconsistency: BB supported frontend provider-icon overrides, but Provider Usage and Tasks implemented their own logo rendering and ignored those overrides.

What changed

Plugin SDK APIs

API Behavior
New: app.experimental_icons.register({ name, component }) Adds a shared app icon or overrides an existing name, including built-ins. Any plugin can reference it. Names are trimmed and must be nonempty; namespacing is recommended, not required. The component receives className and can inherit color with currentColor.
New: experimental_Icon from @get-bb/plugin-sdk/app Renders an icon by name, with optional fallback (default Zap), className, style, aria-label, and aria-hidden. Uses the same registry and renderer as BB.
New: experimental_ProviderIcon from @get-bb/plugin-sdk/app Renders an existing agent, machine, or environment record with <ProviderIcon providerKind="agent" provider={provider} />. Reads id, logoUrl, icon, and strings.iconTint directly. Optional props: fallback (default Code), className, aria-label, and aria-hidden; marks are decorative by default. Resolves kind-specific provider override → legacy unscoped override → declared logo → declared glyph → fallback. It does not fetch metadata: pass the existing provider record, or { id } when only frontend registrations and fallback are needed.
Existing: app.slots.experimental_providerIcon({ providerKind, providerId, icon }) Preserves the upstream signature, including required providerKind (agent, machine, or environment). The new shared component makes this registration effective in plugin consumers as well as BB. Artwork receives a sizing class and inherits color from its wrapper. It can render a named experimental_Icon or its own inline artwork.

The SDK version is bumped to 0.4.84; Provider Usage and Tasks require that version. The authoring skill API index and builder-field contract check are updated alongside the Plugin Guide.

New SDK types: ExperimentalAppIcons, ExperimentalIconRegistration, ExperimentalIconProps, and ExperimentalProviderIconProps. The testing harness captures icon registrations and provides stubs for both shared components. The Plugin Guide and experimental API audit document these contracts.

For example, inside a plugin's app setup:

import {
  definePluginApp,
  experimental_Icon as Icon,
  experimental_ProviderIcon as ProviderIcon,
} from "@get-bb/plugin-sdk/app";
import { AcmeMark } from "./acme-mark";

export default definePluginApp((app) => {
  app.experimental_icons.register({ name: "acme/mark", component: AcmeMark });
  app.slots.experimental_providerIcon({
    providerKind: "agent",
    providerId: "acme-agent",
    icon: ({ className }) => <Icon name="acme/mark" className={className} />,
  });
});

// Any plugin can render either reference:
<Icon name="acme/mark" fallback="Zap" />;
<ProviderIcon providerKind="agent" provider={{ id: "acme-agent" }} />;

// When you already have a provider record:
<ProviderIcon providerKind="agent" provider={provider} fallback="Bot" className="size-4" />;

Resolution and lifecycle

  • Registration returns void, matching app slots. BB commits registrations with plugin setup, replaces them on reload, and removes them on unload. Mounted icons update automatically; no manual disposer is needed.
  • Duplicate app-icon names within one plugin reject setup and preserve the previous generation. Across plugins, the first plugin ID in lexical order wins, with a warning. Removing the winner restores the next owner or built-in.
  • Registered app artwork takes precedence over built-ins. Missing names try the caller's fallback, then built-in Zap. Render errors are contained and recursive references terminate safely. Provider override errors fall back to declared artwork. Reload remounts artwork even when its component identity is unchanged.
  • Provider lookup, caching, and recursion detection use both kind and ID. Same-ID providers in different kinds remain independent; older plugins with unscoped registrations remain a fallback.
  • The internal provider helper now always supplies a subscribed renderer, so providers without initial artwork can pick up later registrations.

Consumers and contract boundaries

  • Provider Usage and Tasks comment avatars use the SDK provider component. BB's provider helper and machine/environment provider marks use that same implementation. Tasks also gains support for declared glyphs and tints.
  • Shared UI IconName now accepts strings, Icon accepts fallback, and BuiltinIconName / isBuiltinIconName identify the fixed built-in set. ICON_NAMES and built-in artwork remain unchanged. Host-only registry plumbing and the vendorable icon registry artifacts are updated.
  • Plugin branding glyphs and timeline presentation names reach the shared renderer instead of being rejected by built-in-only frontend checks. Existing SVG assets retain precedence where applicable; work rows retain their contextual fallbacks.
  • Tasks adds icon and strings.iconTint to its computed comment-provider RPC response. Provider Usage uses those same SDK field shapes instead of flattening them into iconGlyph / iconTint, so both plugins pass records directly to the component. No database migration, persisted icon definitions, server/daemon wire change, or protocol-version bump is needed.
  • The manifest API and server-side presentation validation are unchanged. Frontend registration does not declare a manifest SVG or authorize new namespaced server presentation values. Registration code runs per app client; web, desktop and mobile web use the same mechanism, with fallback when definitions are absent.

How you verified

  • After rebasing onto main's machine-provider changes, Turbo typechecks passed for the app, server, SDK, Provider Usage, Tasks, and plugin registry.
  • Turbo test suites passed for the SDK, Plugin Guide/API map, Provider Usage, Tasks, and plugin registry.
  • Focused app tests passed (24 tests), including provider-kind isolation, legacy override fallback, cross-kind recursion, declared artwork, app-icon lifecycle, and environment providers.
  • Server authoring API inventory and CLI scaffold-build tests passed. Registry artifacts were regenerated from the merged source.
  • Earlier branch verification exercised the built plugins in an isolated source app: registrations updated Tasks, Provider Usage, and BB icons; disable restored declared artwork and reload reapplied overrides. Native iOS was not tested.

AGENT GENERATED

@ymichael
ymichael force-pushed the bb/clarify-plugin-icon-api-support-thr_pfhbgascgz branch from f34bf29 to 6d7d458 Compare September 11, 2026 20:30
@ymichael
ymichael merged commit d4c3b45 into main Sep 11, 2026
16 checks passed
@ymichael
ymichael deleted the bb/clarify-plugin-icon-api-support-thr_pfhbgascgz branch September 11, 2026 20:45
ymichael added a commit that referenced this pull request Sep 17, 2026
)

## Human comments

## What was wrong

bb had two icon vocabularies that shared one spelling, so
`"<pluginId>/<name>"` meant different things in different fields and
nothing about the name said which.

- **Manifest-declared icons** (`bb.branding.experimental_icons`, added
2026-08-23 in #2325 for provider and tool rows) resolved at five
server-side declaration sites and silently rendered `Zap` everywhere
else.
- **App registrations** (`app.experimental_icons.register()`, added
2026-09-11 in #3513) resolved at app surfaces and nowhere else.

#3204 was filed 2026-09-07, between those two, and was accurate when
written: app icon fields really were limited to BB's built-in names, so
a plugin could not paint its own artwork on a sidebar thread row. #3513
fixed that general problem four days later — in its own words, "Plugin
app icons were effectively limited to BB's built-in names" — but never
referenced #3204, and documented the new registry only as something
`experimental_Icon` renders. So the issue stayed open, the docs still
read as if the stock set were the only option, and the half of the
complaint that was still true (declared icons don't work there) stayed
true.

## What changed

**Behavior.** `Icon` (`packages/shared-ui/src/components/ui/icon.tsx`)
now resolves a registration, then a built-in, then a manifest-declared
glyph. A declared icon works everywhere a BB icon name is accepted —
thread row statuses, sidebar footer items, composer `+` rows, message
actions, nav panels, panel tabs and actions, mention rows — as well as
in the declarations that already took one. One vocabulary, one
resolution order.

Strictly additive: registrations still shadow built-ins and both still
shadow a declared icon, so every name that resolved before resolves to
the same artwork. Only names that previously fell back to `Zap` change.

- `icon-registry.ts` gains a declared-icon store beside the app-icon
store. The two sources keep distinct lifecycles rather than being
merged, because they genuinely differ: declared icons come from the
server inventory and exist even when a plugin ships no frontend bundle
or is stopped; registrations are React components tied to a bundle
generation.
- `plugin-frontend.ts` pushes the declared map in the same pass that
already populates plugin logos. That pass runs before any bundle loads,
so a declared glyph never renders a frame of fallback first.
- The five declaration sites keep their stricter ownership check — a
glyph there must name the registering plugin and a declared icon,
because those references persist in timeline rows and are revalidated at
ingest. App surfaces resolve any declared glyph, matching the app icon
registry, which has always been global across plugins.

**Docs**, now describing one vocabulary rather than a split: a
module-local `BbIconName` alias carries the resolution order once,
replacing ten near-identical comments that each restated it (and were
the reason the contract drifted). It is deliberately unexported —
`app.ts` re-exports app-contract wholesale, so exporting it would make a
doc comment a public SDK member owing an `experimental_` prefix and an
`api_to_audit.md` entry. The guide references say when to register
versus declare, and the quickstart's site list is corrected from three
to five.

No wire change, so no `HOST_DAEMON_PROTOCOL_VERSION` bump. Plugin SDK
bumped to 0.4.100, since JSDoc ships in `bundled-types/*.d.ts`.

## How you verified

A probe plugin in a running dev app declaring one manifest icon and
registering two, driving three sidebar rows through
`experimental_setThreadRowStatus`:

| `icon` passed | Source | Before | After |
| --- | --- | --- | --- |
| `"probe-flat"` | `app.experimental_icons.register()` | plugin artwork
| plugin artwork |
| `"icon-probe/registered"` | `app.experimental_icons.register()` |
plugin artwork | plugin artwork |
| `"icon-probe/declared"` | `bb.branding.experimental_icons` | generic
`Zap` | **plugin's SVG** |

Tests: the declared-glyph tier resolves, a registration of the same name
shadows it, removing the registration restores it, and an undeclared
namespaced glyph still falls back. Plus a `ThreadRow` test that a
registered namespaced name draws the plugin's artwork — mutation-checked
by stubbing the status-icon pass-through, which fails it along with the
four existing plugin-status tests.

- `pnpm exec turbo run typecheck lint --filter='...[origin/main]'` — 101
tasks, clean. The filter earned its keep: editing `icon.tsx` staled the
checked-in `@bb/plugin-registry` mirror, regenerated with
`build-registry.mjs`.
- `@bb/app` 4811 passed, `@get-bb/plugin-sdk` 291 passed, `@bb/server`
2913 passed with one unrelated failure (`project-attachment-accounting`,
a timing bound) that passes in isolation.

Fixes #3204

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

> AGENT GENERATED

---------

Co-authored-by: Claude Opus 5 (1M context) <[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