Rich inline cards for tool results via Chat Output Renderer API - #68
Rich inline cards for tool results via Chat Output Renderer API#68JehutyPT wants to merge 13 commits into
Conversation
|
I was looking for a way to bring our sidebar webview Q&A directly into the Copilot chat. The main blocker right now is that the API can't return a webview and simultaneously wait for user interaction before finalizing the tool call. |
|
Great job. Since it uses a proposed API, I'm not sure if I can merge this into the main branch, as it will prevent further fix and features from being published. Maybe creating another branch and link its build into de README.md... Any suggestion? |
|
Oh yeah, definitely do not merge this in, for the reason you mentioned. I'm fine just letting this sit for now and revisit in the future once the API stabilizes. Just wanted to get your eyes on this to get an initial impression. Want me to move this back into a draft? Or I could close the PR altogether and just reopen it once it stabilizes |
|
You may let it open. I'll build it for anyone interested in testing it. |
PR: Rich Inline Chat Output Rendering
Summary
Integrate VS Code's proposed Chat Output Renderer API to replace plain JSON tool results with rich, themed inline cards in the chat stream for
ask_userandplan_review/walkthrough_reviewtool results.Before: Tool results rendered as raw markdown:
**User Response:** {"responded":true,"response":"yes","attachments":[]}After: Styled inline cards with question, response, status badges, collapsible plan content, attachments, and timestamps — all themed to match VS Code's color scheme.
Resolves #62
Motivation
@seamlesschat participant was raw JSON — ugly, information-poor, and inconsistent with the rich Agent Console webviewWhat Changed
New Files (5)
src/proposed-api.d.tschatOutputRendererAPI (ExtendedLanguageModelToolResult2,ChatOutputWebview,ChatOutputRenderer,registerChatOutputRenderer). Remove when API stabilizes into@types/vscode.src/renderers/index.tssrc/renderers/types.tsAskUserRendererData,PlanReviewRendererDatainterfaces,encodeRendererData/decodeRendererDatahelpers,truncatePlanutility (50KB max)src/renderers/htmlUtils.tsescapeHtml, theme CSS using VS Code CSS variables, localizedformatTimestamp,wrapInDocumentsrc/renderers/askUserRenderer.tsask_usercard renderer — question section (with truncation/expand), response section, attachment list, dismissed state, all markdown-rendered viamarkdown-itsrc/renderers/planReviewRenderer.tsModified Files (8)
package.jsonenabledApiProposals: ["chatOutputRenderer"]and twochatOutputRendererscontribution entriessrc/extension.tsregisterChatOutputRenderers(context)inactivate(); participant handler skipsstream.markdown()whentoolResultDetails2is presentsrc/tools/index.tstoolResultDetails2with MIME-typed renderer data toask_user,plan_review, andwalkthrough_reviewtool resultssrc/tools/schemas.tsASK_USER_RESULT_MIMEandPLAN_REVIEW_RESULT_MIMEconstantssrc/localization.tsrendererUserResponse,rendererStatus,rendererViewPlan, etc.)package.nls.jsonpackage.nls.pt-br.jsonpackage.nls.pt.jsonTechnical Design
Architecture
Data Flow
LanguageModelToolResultwith both:LanguageModelTextPart(JSON for LLM consumption — unchanged)toolResultDetails2(MIME + Uint8Array for renderer)chatOutputRenderersinpackage.jsonChatOutputWebview+ binary data, setswebview.htmlMIME Types
ask_userapplication/vnd.seamless-agent.ask-user-resultplan_review/walkthrough_reviewapplication/vnd.seamless-agent.plan-review-resultKey Design Decisions
enableScripts: false<details>for interactivity — no JavaScript needed. Simpler CSP, better security.markdown-itin extension host^14.1.0.localResourceRootscomplexity.truncatePlan()caps renderer data size. Full plan remains accessible via Agent Console.approve_planregisterChatOutputRenderers()checkstypeof vscode.chat?.registerChatOutputRenderer !== 'function'at runtime. No-op on VS Code Stable.@seamlesshandler skipsstream.markdown()whentoolResultDetails2is present, preventing the rendered card from being replaced by markdown.Card Previews
ask_user— Responded:Plan Review — Changes Requested:
Graceful Degradation
chatOutputRendererAPItoolResultDetails2silently ignored by VS Code. Participant handler falls back tostream.markdown(**User Response:** ...)Known Limitations
chatOutputRendererrequiresenabledApiProposals— blocks VS Code Marketplace publication. Distribution via VSIX only.webview.asWebviewUri()pattern without base64 encoding.Dependencies
markdown-it^14.1.0No new dependencies added.
Testing Status
ask_userwith responseask_userdismissedask_userwith image attachmentsask_userwith many attachmentsLocalization
16 new string keys added to all 3 NLS files:
renderer.userResponserenderer.defaultAgentNamerenderer.userDismissedrenderer.statusrenderer.changesRequestedrenderer.viewPlanrenderer.revisionsRequiredBreaking Changes
None. The existing text-based output path is preserved as a fallback. LLM-facing
LanguageModelTextPartJSON is unchanged.File Structure