Skip to content

Tools: a declared Tool may set render: webview - #1924

Closed
nedtwigg wants to merge 3 commits into
mainfrom
tool-render-webview
Closed

nedtwigg wants to merge 3 commits into
mainfrom
tool-render-webview

Conversation

@nedtwigg

@nedtwigg nedtwigg commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

A Tool declared in a project or user dormouse.yml may now set render: webview. Its page shows in a pane webview at its real origin, with no proxy in between. This follows the save protocol (#1910, #1915, #1923), which made save and unsaved state independent of the renderer.

Nothing here has been seen running in the standalone app. Only Tauri has pane webviews; see "Not verified".

Behavior

  • Opt-in. iframe stays the default. The display chooser also offers a declared Tool the webview where the host has pane webviews.
  • Fallback, not refusal. In VS Code, the dev harness, Pocket, or on an unsupported OS, a render: webview Tool shows in the proxied iframe with its mode kept stored, as webview browser Surfaces already do. One dormouse.yml works everywhere.
  • Built-ins stay on the iframe, and the chooser never offers them the webview. Their theme and the Markdown reading position reach the page through the iframe shim, and a pane webview gives a page no channel into Dormouse (S304).
  • Pane-sized, like an iframe Tool: only viewport: pane-sync.
  • Follows its Tool. A run that announces another port or path re-points the view. The view's own navigations do not trigger that.

Security

S158 changes. It said a pane webview opens "only at a URL the user chose"; it now adds "or a Tool they launched serves on loopback". A Tool's URL comes from the port scan or OSC 367 announcement of a Tool the user launched or approved.

One property to weigh: a webview Tool is a real page at 127.0.0.1:<port> in the one pane-webview profile. Cookies are shared across Tools, and a service worker one Tool leaves can control a later Tool on the same port, as in any browser. The iframe proxy prevents both today (S143, the 403 on service-worker requests). Built-ins are unaffected while they stay on the iframe. No audited rule other than S158 is edited, and scripts/outbound-lint.mjs is untouched.

Limits, stated in the specs

  • A webview Tool's page gets no Dormouse theme.
  • Its own reload or Back asks nothing about unsaved changes, as in every webview pane.
  • Break still reopens it as an iframe (already a Future item in webview-pane.md).
  • During a preview-slot switch a Tool in a pane webview holds a blank ghost; where it falls back to the iframe it holds its document, as an iframe Tool does.
  • A build without this change that reads a saved render: webview discards the session, since one unreadable pane fails the whole file.

Verified

  • Tests, on 9b11a2f5d: pnpm test:checks, pnpm test:packages and pnpm test:lib (7,486 passed, 24 skipped), run one after another, plus tsc -b in lib. After that commit: pnpm test:checks on the S158 wording, and tsc -b plus the preview-slot suites on the ghost fix.
  • Every new test was mutation-checked: each fails with its guarded line removed, including each half of the swap guard, the built-in exclusion at each of its three call sites, and following a re-announcement keyed on url instead of the announcement.

Not verified

  • Anything in a real pane webview. Placement, show and hide as the Tool's browser face comes and goes, the Terminal Context hiding it, keyboard handoff between the Tool's terminal and its view, real page events driving the ready signal and the re-point, a cross-window move. The tests use a fake host.
  • Windows.

🤖 Generated with Claude Code

nedtwigg and others added 2 commits November 29, 2026 23:19
A project or user dormouse.yml entry may declare `render: webview`: once it
serves, the Tool's page shows in a pane webview at its real origin, sized by
its pane like an iframe Tool. On a host without pane webviews it shows in the
proxied iframe as an iframe Tool, its stored mode kept. Built-ins stay iframe,
and neither the Display modal nor the Wall's swap gives a built-in, or any
Tool on a host without pane webviews, the webview.

WebviewPanel learns the two things a Tool needs from it: it reports ready
on a page load, so a preview switch no longer waits out its fallback, and it
navigates when the run announces another port or path, keyed on the
announcement rather than `url`, which the view writes on every navigation.

Specs: the render value and the built-in rule in dor-tool.md, a Tool as a
webview entry point and the follow rule in webview-pane.md, no theme for
pane webviews in theme.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…webview

A Tool declared render: webview opens its view at the port its own run
serves, which the user did not type.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8bc0457
Status: ✅  Deploy successful!
Preview URL: https://ef13fa56.mouseterm.pages.dev
Branch Preview URL: https://tool-render-webview.mouseterm.pages.dev

View logs

@dormouse-bot dormouse-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a host without pane webviews, a render: webview Tool loses its preview-slot ghost, even though it otherwise behaves as an iframe Tool there. In lib/src/components/wall/preview-transition.ts, capturePreviewGhost keeps the framed document as a layer ghost only when resolveRenderMode(params) === 'iframe'. A webview Tool falling back in VS Code still has renderMode: 'webview' stored, so it falls through to the screencast branch. That branch finds no automation controller and returns { kind: 'image', frame: null }. Every dor open --preview retarget of such a Tool in VS Code then flashes an empty ghost instead of holding the old page, which is the hold that dor-tool.md -> "Switching the slot" requires. The PR body lists the blank ghost only as a limit of the real pane webview.

Testing rendersInIframe(params) (already in browser-surface.ts, and what BrowserPanel and retainsLivePage use) fixes the fallback and leaves standalone on the image path. That matters because a layer ghost there would mount a second WebviewPanel for the same Surface id. The line is outside this diff, so I can push it as a commit if you'd like.

On a host without pane webviews a render: webview Tool is framed, but its
stored mode sent the switch down the screencast branch and its ghost was
blank.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@nedtwigg

Copy link
Copy Markdown
Member Author

Fixed in 8bc0457: capturePreviewGhost now tests rendersInIframe(params), so a webview Tool that falls back to the iframe holds its document, and one in a pane webview stays on the image path. Two tests in preview-transition.test.ts pin both sides; each fails with its side reverted. The PR body's limit now says the blank ghost is the pane webview's only.

@dormouse-bot

Copy link
Copy Markdown
Collaborator

Confirmed: the switch to rendersInIframe(params) in 8bc0457 resolves the blank fallback ghost, and standalone stays on the image path. Nothing further from my review.

@dormouse-bot dormouse-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm leaving this as a comment rather than an approval because two things in the PR body still need your call, and neither is a code finding. First, a webview Tool's page loses the isolation the iframe proxy gives it today (S143 and the service-worker 403): Tools share cookies, and a service worker one Tool leaves behind can control a later Tool on the same port. Second, nothing has run yet in the one host that has pane webviews. If both are acceptable as stated, I have nothing else to raise.

@argos-ci
argos-ci Bot temporarily deployed to dormouse/preview November 30, 2026 07:34 Inactive
@nedtwigg

Copy link
Copy Markdown
Member Author

Holding this until a Tool needs it; #1938 says why and what would restart it. The branch tool-render-webview stays.

This branch was previously deployed

1 inactive deployment
dormouse/preview — 8bc04578 Deployed Nov 30, 2026 by argos-ci[bot]
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.

2 participants