| name | webview-bridge |
| description | Adds or changes messages between the Skill Manager React webview and the extension host. Use when extending WebviewMessage/ExtensionMessage, wiring postMessage handlers, or debugging SkillManagerSidebarProvider / SkillManagerPanel message flows. |
| disable-model-invocation | true |
Webview ↔ extension host bridge
Architecture
- Types:
webview-ui/types/messages.ts defines WebviewMessage (webview → host), ExtensionMessage (host → webview), and SkillManagerState.
- Webview:
webview-ui/hooks/useVsCodeApi.ts exposes acquireVsCodeApi(); call postMessage(payload) with a WebviewMessage object.
- Host: Two providers mirror the same
handleMessage switch:
Errors in handlers are caught, logged, and surfaced as { type: "error", message: string } to the webview.
Workflow: add a new webview → host message
-
Extend the union in webview-ui/types/messages.ts:
export type WebviewMessage =
| { type: "ready" }
| { type: "yourAction"; foo: string };
-
Handle it in both panels — add a case in handleMessage in SkillManagerSidebarProvider and SkillManagerPanel (keep them in sync). Pattern from the sidebar:
-
Send from React: useVsCodeApi().postMessage({ type: "yourAction", foo: "bar" }).
-
Host → webview: If the UI needs new push updates, extend ExtensionMessage and post from the host with webview.postMessage(...). Existing examples: setState, syncComplete, browseUpdate, catalogSearchResults, recommendationsResult, error.
Recommendations tab (reference)
- Webview → host:
{ type: "tabChanged", tab: "manage" | "browse" | "recommended" } (active tab), { type: "requestRecommendations" } (refresh ranked skills).
- Host → webview:
{ type: "recommendationsResult", recommendations: Recommendation[], catalogReady: boolean }.
- Handled in both panels;
skillManagerRecommendations.ts builds the payload via WorkspaceAnalyzer + SkillRecommender.
Testing
Additional resources