Repository navigation
feat(agents): polish visual kit defaults and add a gallery - #723
Merged
Merged
Conversation
nixuuu
marked this pull request as ready for review
November 14, 2026 14:29
This was referenced Nov 14, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
Adds `render_html` beside `render_visual`, storing HTML as an immutable, owner-scoped visual version. The existing item, GetVisual, expected_version, citation and export pipeline remains the source of truth. Old clients reject kit version 2; workers and gateways negotiate `thread_html_v1` additively. The shared compiler rebuilds untrusted HTML, attempts to remove embedded documents, navigation attributes, inline handlers and external/module scripts, and prefixes each classic script with lockdown before hashing it. Removal is best-effort: parser differences and reparsing can restore markup (mXSS); CSP is the execution/resource boundary. Foreign MathML/SVG style elements are additionally discarded. Script CSP is hash-only; there is no unsafe-eval or unsafe-hashes. The trusted shell also restricts child navigation. Web/mobile residual network risk is explicitly accepted: matching-SRI external scripts and DNS hints can still send data. Desktop adds a separate network-denied browser process in #718. Validation: install, generation, typecheck, lint and formatting passed. The focused compiler/inbox/migration/gateway/harness run passed 58 tests. Tests cover pre-parse/UTF-8 limits, CSP hashes, stripped permissive metas, script-only sandbox, cyclic/invalid/flooded messages, owner scoping, version conflicts and format preservation. Migration is now **0144_thread_html** (file, index and schema expectation), following dev's 0143 from #725. The CLIProxyAPI stack moves to 0145; this stack merges first. Protocol remains additive. Security review fixes: the CSP meta, style and bootstrap scripts are inserted as parse5 tree nodes. Regression tests cover `<html data-x="<head>">`, a leading `<!-- <head> -->`, and `</body>` text in attributes/comments: exactly one CSP meta is first in the real head and every executable script has an authorized hash. Gateway publishing applies the same depth100/script64 limits as clients; rejected documents leave no stored version. The shell relay forwards only `JSON.parse(text).message`; an 8 MiB ArrayBuffer regression proves the original clone is not forwarded. Shared iframe permissions explicitly deny PiP and clipboard features. The focused security/gateway/three-harness run passed 38/38; channel identity tests passed 3/3. Per-platform probe evidence is recorded on #718, including the DNS positive control and protected result. The independent security re-check recommended merge. Copy audit: no new UI copy in this layer; tool instructions state inline-only code, addEventListener, size/script/depth limits, theme variables and no secrets. Previous-head full check:tmp was green in [CI run 43605016001](https://github.com/itsoltech/canopy/actions/runs/43605016001), head `cc18c0b7d86ae78ddd7d1cdff1af221107910367`. Pre-merge update: rebased onto origin/dev including #723, #725 and #730, preserving the new visual kit/gallery compiler and provider migration. The shell's own hash-authorized script now starts with the shared network lockdown, including when copied into a fresh realm. Only the trusted mobile shell retains its own message bridge; opaque agent realms have none and also remove ReactNativeWebView. Regression tests exercise web/native relay, locked RTC/fetch properties, the shell hash prefix and MathML/SVG reparsing with script-src-attr none. Final-head checks: schema/compiler 51/51, visuals/three-harness integration 16/16, both with empty temp directories; gen:check, full typecheck, lint and format:check passed. Immediately before the final push, origin/dev was re-fetched at d2af937 and its highest migration confirmed as 0143. New-head full CI is pending. All four PRs are ready, as requested; no merge performed.
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
Offers `render_html` through the shared tool catalog on Claude Agent SDK, Codex app-server and Grok ACP. The worker announces `thread_html_v1`; an older gateway gets an actionable update response instead of an unknown-tool call. Validation: fake adapters for all three harnesses publish HTML through WorkerLink into PostgreSQL. Existing component-tool coverage is retained. The focused compiler/inbox/migration/gateway/harness run passed 58 tests; install, generation, typecheck, lint and formatting passed. Security/gateway/three-harness run passed 38/38, including fake adapters publishing through WorkerLink. Platform probes are recorded on #718. Gateway depth100/script64 errors reach the tool before storage. The independent security re-check recommended merge. Copy audit: model-facing description prefers components for standard charts/cards/tables, requires addEventListener rather than inline handlers/eval, inline libraries/assets, no network or secrets, bounded documents and Canopy theme variables. No UI copy changes in this layer. Previous-head full check:tmp was green in [CI run 43605016001](https://github.com/itsoltech/canopy/actions/runs/43605016001), head `cc18c0b7d86ae78ddd7d1cdff1af221107910367`. Pre-merge update: rebased onto origin/dev including #723, #725 and #730, with render_html migration 0144 after the provider migration 0143. The shared compiler/shell P3 fixes and regression evidence are described in #716 and #718. Final-head schema/compiler tests: 51/51; gateway/three-harness visuals integration: 16/16; both temp checks clean. Generation, typecheck, lint and formatting passed. New-head full CI is pending. All four PRs are ready; no merge performed.
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
HTML visuals run inside an opaque `sandbox="allow-scripts"` iframe, with hash-only scripts prefixed by lockdown. The card identifies agent content and warns against entering passwords or secrets. Web and mobile require an explicit **Run**; desktop requires opening a separate viewer. The main window CSP is unchanged. ### Independent security review fixes - CSP and bootstrap insertion now uses parse5 tree nodes. Regression tests cover `<head>` inside an HTML attribute and a leading comment, and misleading `</body>` text. Exactly one CSP meta is first in the actual head; every executable script is hashed. Downloads include CSP and lockdown. - The shell forwards only the JSON-checked copy, never the original structured-clone object. A regression test sends an 8 MiB ArrayBuffer and verifies it cannot reach the parent relay. - Gateway publishing rejects depth >100 and >64 scripts before storing a version. Both frames deny PiP, clipboard, capture and other permissions explicitly. - HTML does not auto-run on web/mobile. A watchdog failure persists across reactive updates; explicit Retry is required. Revisiting/remounting starts at Run again. Same-process engines can still freeze their host after Run; the watchdog cannot guarantee recovery there. - Desktop fixes the native title, compiles in a worker thread with bounded heap/time, and serves the compiled document at a private session protocol URL rather than a size-limited data URL. ### Desktop DNS boundary The DNS finding reproduced: runtime `dns-prefetch` escaped CSP, proxy and webRequest. A renderer additionalArguments Blink flag did not reliably reach the renderer and did not stop it. The viewer therefore runs in a **separate Electron browser process**, configured before ready with `host-resolver-rules=MAP * ~NOTFOUND`. The network boundary is the resolver rules plus the refusing proxy plus webRequest cancellation. The unsupported `disable-network-prediction` switch has been removed. This applies to every viewer frame without changing the main app's flags, session or CSP. The independent security re-check verified the resolver block and judged it sufficient. The child retains a dedicated ephemeral session with deny proxy, request cancellation, denied permissions/devices/downloads/navigation/popups and `disable_non_proxied_udp`. It receives only bounded source, title and theme through private process IPC and a curated OS/display environment. It has no app services, app profile or credentials. One viewer is allowed; parent exit closes it and its temporary profile is removed. ### Review-fix probes Electron 45.2.1, Linux, headless Ozone; actual viewer/compiler implementation: | Probe | Observed result | |---|---| | Runtime dns-prefetch and preconnect via rel/href properties, setAttribute, innerHTML and template insertion | Positive control recorded speculative HOST_RESOLVER_MANAGER_REQUEST/JOB events for a unique canary. Final protected run: `DNS_CANARY_EVENTS []`. | | Matching-hash/SRI external script, remote image, fetch, RTC | `HTTP_CANARY_REQUESTS []`; image CSP violation; fetch/RTC undefined and calls throw TypeError. | | canvas.captureStream → video.requestPictureInPicture with user activation | SecurityError: disallowed by Permissions Policy. | | Agent document.title mutation | Native title stays `Custom HTML from the agent — Canopy`. | | 524236-byte source expanding beyond 2 MB when compiled | Actual production sidecar renders 524188 text characters, first head child is CSP, RTC undefined, protocol URL length 63. Healthy frame survives 11 seconds without a false watchdog. | | while(true) in actual production sidecar | Watchdog terminates all owned frame renderer PIDs, including the hung OOPIF, destroys the old window and opens one safe warning window. CDP returns `This visual stopped responding.` | DNS evidence uses Chromium netlog with a positive control, **not packet capture**: tcpdump was unavailable and privileged capture was not available. It demonstrates no canary resolver events in the protected run; it is not a claim of observing port 53. The direct diagnostic harness used `--no-sandbox`; the actual production sidecar startup/large-document/loop probes ran without that flag in the child. ### Earlier compiler/shell probes retained Chromium 155.0.8059.84 against the actual compiler/shell: | Attempt | Observed result | |---|---| | fetch, XHR, WebSocket, EventSource, WebTransport, beacon, mediaDevices, listed RTC constructors | Removed/locked; fetch and RTC calls throw TypeError. | | cookie, top navigation, popup | SecurityError, SecurityError, null. | | Remote image, form submit, self navigation | No canary HTTP request; trusted parent's frame-src blocks self navigation. | | eval, Function, string timer, inline handler, blob import | EvalError / no execution / TypeError. | | Worker | CSP blocks execution. | | object/embed, data/blob frames | CSP blocks loading. | | Nested srcdoc and empty srcdoc/about:blank | Realms can exist; parent access throws SecurityError and arbitrary unapproved scripts do not execute. | | Exact authorized script copied into nested srcdoc | Lockdown runs in that realm; RTC is undefined. | | document.write into nested realm | SecurityError. | | Agent permissive CSP meta | Does not widen policy. | | parent.postMessage spam | No host action; inbox tests validate rate limits and invalid/cyclic messages. | | Matching hash + SRI external script on ordinary web | **Accepted residual risk reproduced:** GET containing user-input canary reaches the server. | Web/mobile also retain DNS-hint, pastejacking, file-export and same-process engine risks, documented in Polish in docs/agent-visuals.md §9. Source, cache and live-frame counts are bounded; no hard browser renderer memory quota is claimed. Exported HTML includes CSP/lockdown but executes JS outside the Canopy iframe sandbox when opened as a file. ### Validation Install, gen:check, full typecheck (Svelte: zero errors/warnings), lint, format:check, focused security/gateway/three-harness tests (38/38), channel identity tests (3/3), web build and iOS/Android exports passed. Fingerprints remain iOS `138e0c6b171c82b4933e86808cdfef56da73b8c6`, Android `906dc944f94eb8333fa384ed9f198834fdd30d13`. **Previous-head full check:tmp was green in [CI run 43605016001](https://github.com/itsoltech/canopy/actions/runs/43605016001)** on `cc18c0b7d86ae78ddd7d1cdff1af221107910367`: all four check:tmp shards passed, and the final job verified that every test file actually ran exactly once. Static checks and web/Linux build were green too. The redundant local full run was interrupted after this complete CI result; it is not claimed as a local full-suite success. Actual VisualFrame fixture reviewed in Chromium at 1280px/390px, light/dark: no iframe before Run; counter increments after Run; warning wraps within the card. A button-triggered infinite loop shows the stopped warning; resizing does not remount, and remounting the component shows Run with no iframe. Screenshots were inspected. The fixture is isolated from a gateway; this does not certify an authenticated timeline, long-title header, or version-picker flow. Native iOS/Android hostile-document probes remain unverified; mobile exports do not establish native runtime behavior. The independent security re-check recommended merge. Pre-merge update: rebased onto origin/dev including #723, #725 and #730, with render_html migration 0144 after the provider migration 0143. The shell's hash-authorized executable now begins with network lockdown, preventing its inherited hash from authorizing an unlocked fresh realm. Markup removal is best-effort: MathML/SVG and browser reparsing can recreate removed elements/attributes (mXSS), so CSP, not sanitization completeness, is the boundary. Foreign-content style nodes are additionally stripped. Regression tests check the retained restrictive policy, absence of reparsed handlers, shell prefix/hash, immutable RTC/fetch removal in a fresh VM realm and preserved trusted native relay. Final-head schema/compiler: 51/51; gateway/three-harness visuals integration: 16/16, both temp checks clean. Generation, full typecheck, lint and formatting passed. The pinned Electron binary contains the host-resolver-rules switch token, with no disable-network-prediction token found. New-head full CI is pending. All four PRs are ready; no merge performed. Copy audit (§8): **Run** is the explicit action that starts agent JS. “Custom HTML from the agent. Don't enter passwords or secrets.” identifies the source and gives one concrete instruction. “This visual stopped responding.” names the failure and retains an explicit Retry. Desktop's action describes opening a separate window. No jargon, humor or color-only meaning in these strings.
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
HTML visuals now start as an inert warning card with an explicit **Run** action. No HTML compilation or WebView mount occurs before Run. Watchdog failure requires explicit Retry; revisiting/remounting starts inert again. The existing WebView shell and per-mount token envelope use the same hash-only CSP, lockdown and explicit denied-feature permissions as web. Existing fullscreen, version picker, citations and save/share HTML use the shared visual pipeline. No native modules, native patches or WebView upgrade. Baseline/current fingerprints match exactly: iOS `138e0c6b171c82b4933e86808cdfef56da73b8c6`, Android `906dc944f94eb8333fa384ed9f198834fdd30d13`. Both platform exports passed. ### Platform evidence and accepted gaps | Platform | Evidence | |---|---| | Web | Chromium 155 hostile-document probes on the renderer PR: opaque isolation, hash/eval restrictions, denied known networking APIs, nested realm tests and responsive host under an infinite loop. Matching-SRI external-script request remains an accepted exfil path. | | Desktop | Electron 45.2.1 separate browser process with resolver denial: runtime dns-prefetch/preconnect produce no canary resolver events; image/fetch/RTC/matching-SRI attempts produce no canary HTTP requests; canvas PiP throws SecurityError. Production sidecar loop recovery and >2MB compiled-document probes passed. Measurement details and limitations are on #718. | | iOS / Android | **Device probes not run.** device_open failed with “Device list failed: Could not communicate with device support. Try refreshing devices.” One refresh returned the same error. JS exports and shared shell tests do not substitute for WKWebView/Android WebView runtime probes. | As explicitly agreed, mobile accepts the browser residual network risk. RN WebView 14.0.1 exposes neither Android subresource interception nor iOS WKContentRuleList. File/universal access off, incognito, blocked navigation, no shared cookies/storage/windows and the token envelope are retained. iOS mediaCapturePermissionGrantType denies capture. On Android the library can auto-grant camera/microphone permissions already granted by the OS; lockdown mediaDevices and the opaque iframe permissions boundary are the available defenses without a native change. A hard network block and complete native permission denial require a later native build. These gaps are documented in Polish in docs/agent-visuals.md. Focused security/gateway/three-harness checks passed 38/38. iOS/Android exports passed after review fixes; fingerprints above remain unchanged. Validation is recorded on #718. The independent security re-check recommended merge. Native hostile-document probes and native light/dark/phone-width acceptance remain unverified. No hard renderer memory quota is claimed. Same-process WebViews can freeze the app after Run, preventing the watchdog from firing; click-to-run prevents automatic re-entry on later visits. DNS hints, matching-SRI exfiltration, pastejacking and exported-file execution remain documented browser/mobile risks. Copy audit (§8): **Run** explicitly starts execution. “Custom HTML from the agent. Don't enter passwords or secrets.” gives source plus a direct instruction, plain English, no jargon or humor. “This visual stopped responding.” reuses the existing Retry action. Theme-aware text colors and app-owned framing preserve meaning without depending on color. Device layout/accessibility review remains blocked, not claimed as passed. Previous-head full check:tmp was green in [CI run 43605016001](https://github.com/itsoltech/canopy/actions/runs/43605016001), head `cc18c0b7d86ae78ddd7d1cdff1af221107910367`. Pre-merge update: rebased onto origin/dev including #723, #725 and #730, with render_html migration 0144 after the provider migration 0143. The shell executable now starts with shared network lockdown while retaining its trusted native message bridge; the native/web relay regression passes in both modes. Markup stripping is best-effort and CSP remains the boundary against mXSS; foreign MathML/SVG style nodes are discarded. No native change. Final-head schema/compiler tests: 51/51; gateway/three-harness visuals integration: 16/16, both temp checks clean. Generation, full typecheck, lint and formatting passed. New-head full CI is pending. All four PRs are ready; no merge performed.
This was referenced Nov 16, 2026
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.
Improve the default appearance of agent visuals with Canopy theme tokens, compact spacing, designed list rows, quiet device chrome and readable sequence steps.
Related: #682
The reported banking composition now has a thin rounded phone bezel, a status hint and balanced proportions. Transfer/BLIK previews no longer sit in dashed placeholder boxes. Transaction rows align signed values on the right. Login participant headers share the first grid row, columns fit their container, future messages remain readable, the current message is highlighted, and reset uses the same button treatment as navigation.
The development gallery uses the production compiler and sandbox to show every component in realistic compositions at 360px and 960px, in light and dark themes. It includes the reported banking/login composition, long labels, button states and all device artboards. Previously there was no complete kit gallery.
List row fields are additive within schema v1; stored string lists remain supported. Rendering still uses textContent and the CSP/security model is unchanged.
Sequence-only next/previous controls now derive their numeric range from the message count; previously a sequence starting at zero could remain at zero unless another control established its range. Explicit numeric values accepted by stored v1 specs remain valid.
Validation (all passed, with nice and temporary outputs under /var/tmp):
bun install,bun run gen:check,bun run typecheck,bun run lint,bun run format:check.bun test packages/domain/src/visuals tests/integration/visuals.test.ts tests/integration/visual-harnesses.test.ts: 27 tests passed, including additive row validation, unsafe/oversized fields, stored v1 compatibility, and bounded sequence navigation/reset.bun run --filter @canopy/web buildand Expo Android/iOS exports.138e0c6b171c82b4933e86808cdfef56da73b8c6, Android906dc944f94eb8333fa384ed9f198834fdd30d13; both unchanged.Browser review ran on the requested review machine in the isolated PR directory, using loopback port 5397 and a single fixture server. The fixture needs no gateway, database or containers. The server, tunnel, review checkout and temporary files were removed afterwards. No screenshots or run artifacts are committed.
Compared the dev kit with the updated kit using the gallery's stored-v1 banking fixture. At a 320px viewport, the previous sequence had 336px of content in a 296px column; the updated sequence measures 296px/296px, with aligned headers and legible future messages. Reviewed light/dark at phone and desktop widths, long merchant/branch names, signed amounts, wrapping segmented options, next/reset sequence controls, loading/danger button preview, before/after switching, device artboards and both chart types. The same compiled HTML used by mobile fits the phone viewport. Native WebView/device execution was not part of this browser review.
Copy audit (§8): “Reset” keeps its verb; its visual treatment changes from ghost to secondary. Gallery headings use sentence case and concise descriptions; Polish text is retained as screenshot/sample fixture data. Positive/negative values include explicit signs. Checked short/long content at phone and desktop widths. No new glossary terms or product error/empty states; meaning does not rely on colour alone.