Skip to content

feat: add extension points API for companion extension button registration#833

Merged
rajbos merged 1 commit into
mainfrom
rajbos/special-chainsaw
May 10, 2026
Merged

feat: add extension points API for companion extension button registration#833
rajbos merged 1 commit into
mainfrom
rajbos/special-chainsaw

Conversation

@rajbos
Copy link
Copy Markdown
Owner

@rajbos rajbos commented May 10, 2026

Summary

Introduces a generic extension points API that allows companion VS Code extensions to contribute buttons directly into the navigation toolbar of all webview panels — without needing a separate VS Code status bar item.

Changes

New files

  • \src/extensionPoints.ts\ — Public API types (\ExtensionPointButton, \AiFluencyExtensionApi) exported from the extension's \�ctivate()\
  • \src/webview/shared/extensionPoints.ts\ — Browser-side \wireExtensionPointButtons()\ helper that appends registered buttons to the .button-row\ and wires click events back to the host

Modified

  • \src/extension.ts\
    • _extensionPointButtons\ registry +
      egisterExtensionPointButton()\ method
    • \�xtensionPointButtonsScript()\ injects \window.EXTENSION_POINT_BUTTONS\ into all 9 webview HTML generators
    • \handleExtensionPointAction()\ routes button clicks to registered handlers
    • \dispatchSharedCommand()\ now accepts the full message object and handles \�xtensionPointAction\ alongside existing commands
    • \�ctivate()\ returns \AiFluencyExtensionApi\
  • All 8 webview panel \main.ts\ files (dashboard, details, chart, environmental, usage, maturity, fluency-level-viewer, diagnostics): import + call \wireExtensionPointButtons(vscode)\ after the button row is rendered

How it works

  1. A companion extension calls \�pi.registerButton({ id, label }, handler)\ using the main extension's exported API
  2. The button is injected into the HTML of every webview panel via \window.EXTENSION_POINT_BUTTONS\
  3. The webview renders the button in the toolbar and posts \�xtensionPointAction\ on click
  4. The main extension routes the click back to the registered handler

…ation

- Add AiFluencyExtensionApi interface and ExtensionPointButton type to new
  src/extensionPoints.ts for the public API surface
- Expose registerButton() on CopilotTokenTracker and return it from activate()
- Change dispatchSharedCommand signature to accept full message object, enabling
  extensionPointAction routing without breaking existing navigation commands
- Inject window.__EXTENSION_POINT_BUTTONS__ into all webview HTML generators
- Add src/webview/shared/extensionPoints.ts with wireExtensionPointButtons() that
  appends registered buttons to .button-row after each render
- Wire wireExtensionPointButtons(vscode) in all eight webview panels

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rajbos rajbos force-pushed the rajbos/special-chainsaw branch from 663117d to 63e737b Compare May 10, 2026 10:00
@rajbos rajbos enabled auto-merge (squash) May 10, 2026 10:01
@rajbos rajbos merged commit 8c1c757 into main May 10, 2026
21 checks passed
@rajbos rajbos deleted the rajbos/special-chainsaw branch May 10, 2026 10:02
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