Skip to content

feat: render background-task HTML output and open its links externally - #615

Merged
Gagancreates merged 2 commits into
devfrom
feat/bg-task-html-output
Jun 10, 2026
Merged

feat: render background-task HTML output and open its links externally#615
Gagancreates merged 2 commits into
devfrom
feat/bg-task-html-output

Conversation

@Gagancreates

Copy link
Copy Markdown
Collaborator

What

  • Background-task output pane now renders an index.html artifact (when present and non-empty) instead of index.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.
  • The runner agent picks the format per run: index.md for prose/notes, a self-contained index.html for inherently visual output. The Copilot background-task skill steers visual asks toward HTML.
  • Links inside the rendered HTML now open in the system browser, matching the markdown viewer's behavior.

How

  • HTML renders full-bleed via the existing HtmlFileViewer (sandboxed iframe over the app://workspace protocol), so CSS/layout/scripts are faithful and relative assets resolve against the task folder. The viewer remounts on refreshKey so a re-run's updated HTML reloads.
  • Link routing: added allow-popups to the iframe sandbox so target="_blank" reaches setWindowOpenHandler, and handled will-frame-navigate in main for plain (subframe) links. Scoped to app://workspace frames so third-party note embeds (YouTube/Figma) keep their internal navigation.

Test plan

  • Drop an index.html with real CSS into a bg-tasks/<slug>/ folder → renders full-bleed with styling intact.
  • Task with only index.md → still renders as a markdown note (no regression); when both exist, HTML wins.
  • Source ⇄ Rendered toggle works for both formats.
  • Edit index.html / hit Run now → preview reloads (no stale content).
  • Click a plain link and a target="_blank" link in an HTML report → both open in the system browser; the report stays put.
  • Note embeds (YouTube/Figma) still navigate internally — not hijacked.

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.
@Gagancreates
Gagancreates merged commit 9453e0d into dev Jun 10, 2026
2 checks passed
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