feat: add multi-class artifact viewer#49
Conversation
|
Codex review: stale review; fresh review needed. Summary Next step Review history (10 earlier review cycles; latest 8 shown)
|
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Co-authored-by: Jacqueline Henriksen <[email protected]>
631960e to
5c1daff
Compare
|
Rebased and substantially hardened this proposal on current Key review fixes include inert-template HTML sanitization before live-DOM insertion, complete attribute stripping, authoritative DOCX/download-only routing, streamed byte and structured-output limits, interruptible highlighting, bounded PDF load/render/canvas/text/page-cache behavior, mobile modal focus/inertness, accessible PDF text, and preservation of thread reply/scroll/DOM state. Exact-head proof:
Risk: medium. This is a security-sensitive ingest/render/download boundary, but hostile inputs now fail closed to escaped source or authenticated download, resource budgets are explicit, and the full browser/repository gates are green locally. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77bbaa4c50
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| class="artifact-viewer__body" | ||
| class:is-pdf={kind === "pdf"} | ||
| role="region" | ||
| tabindex="0" |
There was a problem hiding this comment.
Block type-to-focus while artifact content is focused
With this focusable preview region, desktop artifacts are not treated as modals by ChatApp's redirectTypingToComposer guard (isModalOpen() still excludes selectedArtifact). When a PDF/source preview has focus, pressing Space to scroll—or any character after selecting text in the artifact—is captured by the global type-to-focus handler and moves focus into the chat/reply composer (Space is even inserted) instead of staying in the artifact. Add selectedArtifact to that guard or stop printable key propagation from the viewer while it is open.
Useful? React with 👍 / 👎.
Summary
application/octet-streamViewer behavior
markedand DOMPurify pipelinepdfjs-distintegrationiframe.srcdoc, and constrained by a CSP that permits only inline styles and localdata:/blob:assetsSafety contract
Verification
pnpm checkpnpm coverage— 86.5% total Go coveragepnpm exec playwright test tests/e2e/artifact-viewer.spec.ts— 6 passed, covering classification, worker highlighting, near-limit escaped fallback and cancellation, Markdown source/preview, normal PDF page/zoom, PDF canvas dimension and pixel budgets, oversized-page download fallback, bounded DOCX conversion, hostile-HTML isolation, oversized/malformed fallbacks, mobile sizing, andmessage.updatedCAPTURE_ARTIFACT_PROOF=1 pnpm exec playwright test tests/e2e/artifact-viewer.spec.ts -g "opens safe code"— 1 passed and produced live HTML-isolation diagnosticsCAPTURE_PDF_LIMIT_PROOF=1 pnpm exec playwright test tests/e2e/artifact-viewer.spec.ts -g "shows local fallbacks"— 1 passed and produced live oversized-PDF allocation diagnosticsReal behavior proof
These captures come from the local OpenClaw → ClickClack delivery path and the running viewer.
Oversized PDF canvas allocation
The crafted fixture is a small valid PDF with a 20,000 × 20,000-point page. Browser-observed diagnostics show the configured 8,192-pixel dimension ceiling and 16-megapixel budget, zero viewer canvases allocated, and the authenticated download fallback visibly available.
Uploaded HTML isolation
The hostile fixture attempts script execution, form submission, nested framing, external navigation, image loading, stylesheet import, and CSS URL loading. Browser-observed diagnostics show an empty sandbox token list, an absent script marker, zero requests to the sentinel host, no scripts/forms/frames in the preview DOM, and stripped external URL references.
Reproduction details:
docs/artifact-viewer-security-proof.mdBehavior while testing PR
Current behavior before merging PR
Out of scope
sendMediadelivery remains a separate companion PRFollow-up review fixes
pdfScalebefore the asynchronous PDF page load so zoom changes restart rendering immediately.Validation after these fixes:
pnpm typecheck,pnpm lint, andpnpm fmt:ts:checkall pass.