From 1124758b6b4918e5c7d66eebdf3519d10e1459c1 Mon Sep 17 00:00:00 2001 From: tommy0103 Date: Mon, 3 Aug 2026 02:10:23 +0800 Subject: [PATCH] refactor(renderer): give session images one unavailable state, off the DOM A source the Markdown renderer refuses now goes through the same element with no src rather than a separate light-DOM span, so a blocked source and a source that fails to load are one piece of UI instead of two. That drops the span's stylesheet rule and the only reason the renderer built elements just to serialise them. Decoding what marked escaped no longer runs untrusted markup through a detached element's innerHTML; the entities marked actually emits are decoded in one pass, and attributes are escaped on the way out. With the DOM dependency gone the renderer is directly unit-testable, so the escaping and the protocol allowlist now have coverage that does not need Electron. The element's shadow styles also stop hard-coding values that already exist as tokens -- custom properties cross the shadow boundary, so --muted and --hairline-strong are now the single source of truth -- and the height cap becomes --session-image-max-block, which compact Markdown surfaces (subagent panes, memory rows, tool results) lower from a viewport fraction to 240px. Co-Authored-By: Claude Opus 5 (1M context) --- .../src/components/SessionImage.ce.vue | 29 ++++++--- .../renderer/src/markdown-image-renderer.js | 61 +++++++++++++------ app/src/renderer/styles/detail.css | 19 ++---- tests/markdown-image-renderer.test.mjs | 58 +++++++++++++++++- 4 files changed, 125 insertions(+), 42 deletions(-) diff --git a/app/src/renderer/src/components/SessionImage.ce.vue b/app/src/renderer/src/components/SessionImage.ce.vue index 0fd9303..b219188 100644 --- a/app/src/renderer/src/components/SessionImage.ce.vue +++ b/app/src/renderer/src/components/SessionImage.ce.vue @@ -1,18 +1,25 @@