feat: render background-task HTML output and open its links externally - #615
Merged
Conversation
The task output pane now prefers bg-tasks/<slug>/index.html when present and non-empty, rendering it full-bleed via HtmlFileViewer (app://workspace protocol) so CSS, layout, and scripts render faithfully. Falls back to the markdown index.md note when there is no HTML artifact. The viewer remounts on refreshKey so a re-run's updated HTML reloads. The Source/Rendered toggle works for both formats. The runner agent is instructed to choose index.md (default, notes) vs a self-contained index.html (visual/styled output) per run, written via the existing file-writeText tool. The Copilot background-task skill notes the HTML option so visual asks are steered toward it.
Links inside the sandboxed iframe that renders a background-task/workspace index.html did nothing on click, unlike the markdown viewer which opens links in the browser. Two causes: target="_blank" links were blocked by the sandbox before reaching the window-open handler, and plain links fire will-frame-navigate (subframe), which the app did not handle (will-navigate only covers the main frame). - Add allow-popups to the HtmlFileViewer iframe sandbox so target="_blank" reaches setWindowOpenHandler, which routes to shell.openExternal. - Handle will-frame-navigate in main, routing external subframe navigations to the system browser. Scoped to app://workspace frames so third-party note embeds (YouTube/Figma/Twitter) keep their internal navigation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
index.htmlartifact (when present and non-empty) instead ofindex.md, so tasks can produce styled, visual reports — dashboards, charts, metrics tables — that a markdown note would flatten. Falls back to the markdown note when there's no HTML.index.mdfor prose/notes, a self-containedindex.htmlfor inherently visual output. The Copilot background-task skill steers visual asks toward HTML.How
HtmlFileViewer(sandboxed iframe over theapp://workspaceprotocol), so CSS/layout/scripts are faithful and relative assets resolve against the task folder. The viewer remounts onrefreshKeyso a re-run's updated HTML reloads.allow-popupsto the iframe sandbox sotarget="_blank"reachessetWindowOpenHandler, and handledwill-frame-navigatein main for plain (subframe) links. Scoped toapp://workspaceframes so third-party note embeds (YouTube/Figma) keep their internal navigation.Test plan
index.htmlwith real CSS into abg-tasks/<slug>/folder → renders full-bleed with styling intact.index.md→ still renders as a markdown note (no regression); when both exist, HTML wins.index.html/ hit Run now → preview reloads (no stale content).target="_blank"link in an HTML report → both open in the system browser; the report stays put.