Repository navigation
feat: show HTML visuals in the Thread timeline - #2285
Merged
Merged
Conversation
A system message can carry a self-contained HTML page with a title and a requested height. The page is capped at 512 KiB of UTF-8 so one visual always fits a conversation history page.
Store the visual as JSON on a system message, return it on conversation pages and the tail, and add MessageStore.createVisual for the upcoming html_render tool. Its text names the visual for readers without the frame.
The frame allows scripts only, so the page runs in an opaque origin with no access to the app document, storage, or cookies, and cannot navigate the window. Mcode's design tokens are injected before the page and posted again when light or dark mode changes, so colours follow the app without a reload. The frame grows with the page up to its requested height.
The sandbox isolates a visual from the app, but its page could still fetch or beacon to any host. A meta Content-Security-Policy in the frame head keeps the page self-contained.
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.
Closes #2211
What
A Thread can now show an HTML visual above the agent's reply. The visual is a self-contained page in a sandboxed frame, as wide as the reply column, with no box around it. Its height follows the content up to the cap the visual requests. Before this change Mcode had no way to show a visual.
Nothing produces visuals yet. The agent tool arrives in #2216, and
html_previewin #2221. For this PR I injected a visual by seeding a fixture-repo Thread with a prompt, a visual and a reply.The page is untrusted:
allow-same-origin, so the page gets an opaque origin and cannot reach app storage, cookies or the parent document.allow-top-navigationorallow-popups, it cannot navigate the app or open windows.Verification:
localStorage,document.cookie,parent.documentandfetchblocked.window.originis"null". On a light/dark switch the in-frame--inkchanges fromoklch(19% …)tooklch(95.5% …)while a marker set inside the page survives, so the page did not reload. Chromium logged the fetch refusal as a CSP violation.Why
Agents can show results as a chart, table or diagram instead of prose (epic #2207). This PR builds the timeline item that the later tool writes to.
UI Changes
Electron live-testing captures follow. Before (main) is the same seeded Thread, which shows only the fallback note. After shows light and dark, plus the Thread after an app reload.
Config Changes
None.
Review Notes
0099adds a nullablevisualTEXT column tomessages. It is additive.providerSwitch,systemNotice).useAppearanceneeds to cover them.Need help on this PR? Tag
@codesmith-botwith what you need.