Skip to content

Run composer draft observers and assemble decorations outside the editor - #6091

Merged
ymichael merged 1 commit into
mainfrom
bb/assemble-composer-decorations-on-the-host-thr_vtmuabsctc
Oct 21, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/assemble-composer-decorations-on-the-host-thr_vtmuabsctc

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The composer's Tiptap decoration extension mixed painting with work that doesn't need an editor: bb's built-in ultracode highlight and running plugins' richText.onDraftChange observers (debounce, error isolation, draft conversion). Ahead of moving the composer into a replaceable plugin, anything left in the editor would have to be re-implemented by every composer, including bb's own product rule and the legacy observer API.

What changed

  • New apps/app/src/components/promptbox/composer-decorations.ts:
    • composerDecorationSources() builds one ordered paint list: bb's ultracode highlight, then plugins' richText.effects, then setTextEffect effects.
    • createDraftObserverRunner() runs plugins' draft observers off the host's draft: 100 ms debounce, per-observer error isolation, and re-notification only when the text, mentions, observers or scope change. Pending calls are dropped on dispose.
  • PromptBoxInternal builds the decoration list and feeds the runner from its own value/mentionRanges and composer view. The runner lives for as long as the component and is disposed on unmount.
  • editor/prompt-decoration-extension.ts now only paints the sources it's given. The ultracode rule, observer scheduling and the getDraftObservers/draftObserverDebounceMs options are gone.
  • No Plugin SDK, wire or data model changes. Plugin-facing behavior of richText.effects, richText.onDraftChange and setTextEffect is unchanged.

How you verified

  • turbo run typecheck lint test --filter=@bb/app: typecheck and lint clean. The full suite passed before rebasing (648 files). After rebasing, the only failure was a timeout in the unrelated markdown-incremental-pieces streaming fixture under local load.
  • New composer-decorations.test.ts covers ultracode matching, paint order, the observer debounce and coalescing, re-notification rules, error isolation and dispose. The existing PromptBoxInternal tests drive onDraftChange through the real component.
  • Manual A/B against main in a running build, with a QA plugin that has a TODO richText.effects rule, a setTextEffect whole-draft effect and an onDraftChange recorder. Ultracode highlight (screenshots identical), plugin highlight, text effect on and off, and observer payloads and call counts were identical while typing and after pasting. Observer timing is about 3 ms later in production (paste→call 105–108 ms vs 102–105 ms on main) because the draft now arrives after React commits.

AGENT GENERATED

🤖 Generated with Claude Code

PromptBoxInternal now owns everything about rich-text effects that does not
need the editor: it runs plugins' richText.onDraftChange observers off its own
draft (100 ms debounce, per-observer error isolation, re-notified only when
the text, mentions, observers or scope change) and hands the Tiptap
decoration extension one ordered source list — bb's ultracode highlight,
plugins' richText.effects, then setTextEffect effects. The decoration
extension only paints ranges; the ultracode rule and the observer scheduling
move to composer-decorations.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 908656a into main Oct 21, 2026
28 checks passed
@ymichael
ymichael deleted the bb/assemble-composer-decorations-on-the-host-thr_vtmuabsctc branch October 21, 2026 23:34
samantha-clanker Bot pushed a commit to samanthar0se/bb that referenced this pull request Oct 30, 2026
Conflict resolutions:
- plugin-sdk app-contract: keep local JsonObject alias; take upstream's
  hoisted rpc-contract import and PluginMentionTrigger import.
- desktop main: keep main-instance env handoff; drop
  ensurePackagedUserShellPath, replaced upstream by hostToolchain (get-bb#6194).
- NewThreadComposer: keep plugin metadata on submit and in the composer
  handle; adopt upstream's ComposerSubmitExtras and sendsOnEnter.
- FollowUpPromptBox test: adopt upstream's ComposerBox mock, keep the
  MemoryRouter wrapper and selected-provider probe.
- composer prompt-decoration test: take upstream; draft observers moved
  out of the editor extension (get-bb#6091).

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