Skip to content

Expose structured composer input to plugins - #1977

Open
brsbl wants to merge 4 commits into
mainfrom
bb/composer-input-snapshot-thr_bwikffmsvp
Open

Expose structured composer input to plugins#1977
brsbl wants to merge 4 commits into
mainfrom
bb/composer-input-snapshot-thr_bwikffmsvp

Conversation

@brsbl

@brsbl brsbl commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

What was wrong

Composer customizations could read only the draft text and attachment count. The host retained the actual screenshot/file attachment paths and structured mention ranges inside its private draft state, so a plugin could not forward the complete composer input to another BB thread without dropping non-text context.

What changed

Adds the additive experimental PluginComposerApi.experimental_getInput method. It snapshots the same PromptInput array the active composer would submit at call time, including trimmed text, structured mentions, and local image/file attachments. The result is detached from live draft state and does not mutate, clear, focus, or submit the composer.

The official frontend test harness accepts structured composer input and mirrors the host's mention preservation, rebasing, removal, and insertion behavior. SDK documentation and the built-in plugin-authoring skill describe the same-project attachment boundary and the existing attachment-copy API for cross-project forwarding.

This is standalone from the Browser PR stack. It keeps the existing unpublished SDK 0.4.9 version on main; there is no compatibility version or protocol change.

How you verified

The new host and harness regressions failed before implementation because experimental_getInput did not exist, then passed after implementation.

  • Focused app test: 1 file, 41 tests passed
  • Focused SDK harness/declaration tests: 2 files, 38 tests passed
  • Full plugin SDK tests: 12 files, 106 tests passed
  • Plugin-authoring skill test: 1 file, 14 tests passed
  • Template tests: 6 files, 43 tests passed
  • Turbo typecheck: @bb/app, @get-bb/plugin-sdk, and @bb/templates passed
  • Turbo lint: 0 errors; 145 existing app warnings
  • Prettier and git diff --check passed

Fixes #1978

BB-Thread-ID: thr_bwikffmsvp

AGENT GENERATED: by GPT-5.6-Sol

@bb-slop-cop

bb-slop-cop Bot commented Aug 19, 2026

Copy link
Copy Markdown

🚨 SLOP COP 🚨 · review

I am SlopCop. I am reviewing this pull request for security, code quality, performance, architecture, and end-to-end behavior.

@SawyerHood SawyerHood left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  1. High — The new public type bypasses the experimental API policy.

packages/plugin-sdk/src/app-contract.ts:8 exports PromptInput with a stable name. app.ts:3 and index.ts:10 expose it from both public paths. The audit entry at docs/api_to_audit.md:362 covers only PluginComposerApi.experimental_getInput. The project policy requires an experimental_ name and an audit entry for each new app export. Rename this export and audit it, or avoid the new public export.

  1. Medium — The portable app harness loses structured mentions after composer edits.

packages/plugin-sdk/src/testing/app.tsx:1007 rebuilds changed text with mentions: []. At lines 1083-1084, insertMention changes plain text and records only the call. Production adds the structured range at apps/app/src/lib/plugin-sdk-hooks.ts:728. Thus, experimental_getInput() differs between tests and production after mention insertion or an edit around an existing mention. Preserve and reconcile mention ranges in the harness. Add a regression test for both paths.

  1. Medium — The forwarding guide omits the project boundary and the authoring skill omits the API.

packages/plugin-sdk/README.md:19 says a plugin can pass the snapshot unchanged to another thread. Relative attachment paths belong to one project. The server validates them against the destination project at apps/server/src/services/projects/attachments.ts:125. A spawn in another project can fail with an attachment error. State the same-project limit or describe the attachment-copy step. Also update the hook reference at apps/server/src/services/skills/builtin-skills/bb-plugin-authoring/SKILL.md:1882.

Review summary

Security: I found no new security defect. Plugin frontend code already has full page trust.

Performance: The getter clones data only when a caller invokes it. useComposer already updates with draft text, so this change adds no material render cost.

Architecture: Production uses promptDraftToInput, which is the canonical converter. The small clone helper duplication across the app and portable harness is acceptable.

Validation: HEAD matches 8d538317e32f8a270582911ba944c4db79eff000. git diff --check passed. The app suite passed 41 tests. The selected SDK suite passed 35 tests. The SDK Turbo task stopped twice in its generated-type prerequisite, so I ran the selected Vitest file directly. The worktree remains clean.

- Keep structured mentions aligned in the plugin app harness
Comment thread packages/plugin-sdk/src/app-contract.ts Outdated
Comment thread packages/plugin-sdk/README.md

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 SLOP COP 🚨 · review

Plain English summary: This PR lets plugin buttons read the current composer as structured data. It keeps text, mentions, screenshots, and files.

I found two current contract issues.

  1. High — The new public PromptInput export has a stable name. Project policy requires an experimental_ prefix and an audit entry.
  2. Medium — The README says plugins can send the snapshot unchanged to another thread. Relative attachment paths only work in the same project. The plugin author skill also omits this API.

The author pushed 5e3dc82 during this review. That commit fixes the earlier test-harness mention defect.

Security: I found no new defect. Installed plugins already have full computer access.

Performance: I found no material new cost. The host creates the detached snapshot only when a plugin calls the method.

Architecture: Production uses the shared draft converter. The small clone helper is acceptable. The updated harness now keeps mention behavior consistent with production.

Validation:

  • The targeted app suite passed 41 tests.
  • The selected SDK suite passed 35 tests.
  • The browser composer accepted text and a file.
  • git diff --check passed.
  • Latest CI has unrelated failures in unchanged server and automation tests.

This review uses comment status only.

@brsbl

brsbl commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed all three review findings on the current head.

  • Removed the accidental stable PromptInput re-export; the experimental method keeps using the existing internal type without adding a new stable app export. Added bundled-declaration coverage preventing that export from returning.
  • Fixed the official app harness so edits preserve/rebase unaffected structured mentions, remove overlapped mentions, and insertMention produces the same structured metadata as the real host (5e3dc82bb).
  • Documented that relative attachment paths are project-scoped, including the projects.attachments.copy path for cross-project spawning, in the SDK README, audit ledger, and built-in plugin-authoring skill (bd21d59d7).

Validation: focused SDK declaration/harness tests 38/38, full SDK tests 106/106, SDK typecheck passed, and the plugin-authoring skill test passed 14/14. No second review was run.

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.

Expose complete composer input to plugin customizations

2 participants