Repository navigation
feat(native): HTML render frames in the transcript, first slice - #91
Merged
Merged
Conversation
A completed html_render tool result draws as a frame: the page is fetched as an inline attachment off the UI thread and shown in a WKWebView (wry) while its row is on screen, sized to the page's reported height, with a full-screen view and zoom. The web view wrapper (webview/) hosts native views beneath zui's scene overlay so deferred menus, dialogs and the palette stay above pages, and clips pages away from base-plane overlays that register an occluder.
rynfar
force-pushed
the
nw/87-html-render
branch
from
November 3, 2026 00:06
fc7ff0e to
460ad06
Compare
…views Pages can no longer navigate any frame to a remote site (WebKit keeps no sandbox across navigation and every main-frame document gets the IPC bridge), and script windows need a reader's click. Inline views are held only by the frames drawing them, so they go when a thread switches or a transcript closes. The thread details popover registers an occluder, and the full-screen controls scale with the interface size.
A navigation delegate decides by frame, which wry's URL-only handler cannot: the main frame loads only the page's own document (WebKit keeps no sandbox across a main-frame navigation, nor on inherited data:/blob:/about: documents), subframes load what a sandboxed frame could but never the page's scheme, and a new-window request from a clicked http(s) link opens in the browser. IPC messages from any frame but the page are ignored.
Any other t3-page: URL is the 404 document, so the main frame and IPC now accept only the exact page URL (any fragment), every custom-protocol response carries the sandbox, and the page policy forwards didFinishNavigation to wry's delegate too.
This was referenced Nov 3, 2026
Open
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.
Problem
When an agent called
html_render, the native client showed only a tool row inside the turn's work log. The web draws the page inline as a sandboxed frame that fits its height, with an "Open full screen" view (HtmlRenderFrame.tsx,HtmlRenderDialog.tsx,HtmlRenderDocumentinBrowserDocumentFrame.tsx). Issue #87, ledger row TR-HTML.Approach
Core (
crates/core/src/html_render.rs, tests beside it). PortsreadHtmlRenderReference,htmlRenderFrameHeight(measured widths, the column-width cap, live content height up to 20 000),htmlRenderFileNameandreadHtmlRenderContentHeightfrompackages/shared/src/htmlRender.ts. It also ports the envelope reader ofcompactDynamicToolOutput/htmlRenderFromToolItem(toolOutput.ts), including its byte and node budget.resolveT3McpToolIdis narrowed tohtml_render. The upstream envelope test is ported row for row.Timeline. A completed
dynamic_toolwhose result carries anhtmlRenderreference becomesEntryKind::HtmlRenderand thenRowKind::HtmlRender. It sits outside the turn fold and superseded-attempt folds, as on the web, with the web'spb-2spacing. Running, failed andisErrorresults stay tool rows. Extended the timeline tests.The web view (
crates/app/src/webview/), reusable for TR-MCPAPP.WKWebViewin a clippingNSViewcontainer under GPUI's view.t3-page:scheme, with the server'ssandboxCSP minus downloads. Each view gets a non-persistent WebKit store, so the page never sees the app's token, cookies or storage. No token goes in any URL.PagePolicy) decides by frame. The main frame loads only the page's ownt3-page:document. WebKit keeps no sandbox across a main-frame navigation, nor on inheriteddata:/blob:/about:documents, and every main-frame document gets the IPC bridge. Subframes load what a nested frame of the web's sandboxed iframe could (http(s),data:,blob:,about:) and inherit the page's sandbox, but never the page's scheme. IPC messages from any frame but the page are ignored. All of this is tested.target=_blank) opens in the default browser; windows are always refused. Script windows need a reader's click (javaScriptCanOpenWindowsAutomaticallyoff; macOS defaults it on).web_viewelement holds a lease in its element state, and the view is placed with zui'sWindow::on_present. The view therefore shows only while a frame draws it, follows cached paint reuse, and hides in the same frame its row scrolls away. Only the drawing frame holds it (the store keeps a weak handle), so it is destroyed a frame later: on scroll, a thread switch, or a transcript closing. At most 6 inline views exist; past that a frame shows its card.NSEventmonitor passes vertical wheel scrolls over inline pages to GPUI's view. The transcript keeps scrolling over a frame, as an iframe that fits its page does on the web. Horizontal scrolls stay with the page.Overlays (what I did about z-order).
enable_scene_overlay(). Deferred content (menus, context menus, popovers, dialogs, the command palette, toasts, tooltips) then draws on a plane above native views. That plane takes input while any of it is open, so nothing new was needed at those call sites.occluder, and pages are clipped away from it on the edge that keeps the most. The occluders are the find bar, the provider and error banners, the minimap preview, the thread details card (a popover in narrow windows), and the composer's@//menu, which floats above the composer over the transcript. The composer itself sits below the transcript, so it never overlaps.App (
crates/app/src/transcript/html_render.rs).assets.createUrl(inline attachment,text/html) andassets::fetch_mediaon the network runtime. Up to 32 are cached, and a failed fetch is retried after 30s.ui/notifications/size-changedmessage throughwindow.ipc.NSAppearancefollows the app's light or dark mode, so the bootstrap's default palette applies. The theme's canvas is set as--backgroundright after the bootstrap's theme sheet, as the web'sgetStandardThemeColorsoverrides it. The default theme therefore matches the web exactly, and pages sit seamlessly on the canvas.HtmlRenderDialog): the page is 92% wide and min(86vh, 100vh − 160) tall, on a 75% black backdrop. It has the close button above the top-right corner, the title, and zoom from 50% to 200% (page zoom), with theoverlay/media-closebuttons sized in rem. Escape or a backdrop click closes it.icon-xsbutton under the frame's right edge, always visible. On the web it is a hover-revealed button on the page.--html-fixture <page.html>(andT3_NATIVE_HTML_FIXTURE, both behind thesnapshotfeature) appends a completedhtml_renderto the open thread, served from the file. The smoke server can't publish one, becausehtml_renderneeds an agent's thread-scoped MCP call.thread_view.rsgained the store init and the cfg'd fixture, andtranscript/mod.rsthe module line plus the row and spacing arms.Evidence
The page in all captures is a real bootstrapped page, generated by running the shared
injectHtmlRenderBootstrapon a small dashboard./private/tmp/claude-501/-Volumes-DevSSD-t3code-native/3998c826-bb1a-4777-8d4c-a9ea46007740/scratchpad/87/real-2.png. The WKWebView shows the page inline, sized to its reported height, using the theme variables, seamless on the canvas, with the control under it.real-1.pngin the same folder is from before the canvas fix: the page sits on the bootstrap's#0a0a0a, a visible box on the app's#000.--snapshot … --html-fixture):snap-card.pngshows the fallback card and row spacing.snap-full.pngshows the full-screen layout: backdrop, box, close button, caption and zoom. The page area is empty because the offscreen renderer can't host a native view.cargo clippy --workspace --all-targets -- -D warnings,cargo clippy -p t3-native --all-targets --features snapshot -- -D warnings,cargo test --workspace,node scripts/gen-theme.ts --check,node --test parity/sync.test.ts,conformance/generate.ts --check.Not verified
Synthetic input to a real window is dropped, so none of these were exercised in a real window:
Gaps (TR-HTML stays
partial)htmlRenderTheme).t3/notifications/shortcuts/keydown) are not forwarded.t3/notifications/open-image).onFullscreenChange).Built with Claude Opus 5.5 in Claude Code.