Keep the contributor independent-page implementation, but make it opt-in: the default is still one shared page with the session last/newest reattach, and Settings -> Side card -> Side chat can switch to one native page per thread. The descriptor gains a dynamic multiple predicate, native sync re-registers on a flip, and occurrence bindings are read/written only for sidebar://sidechat/<uuid> contentIds so the shared page can never be captured by an old binding.
Markdown syntax now passes data:image/* through the image vocabulary (the host allowlist already accepts it); every other data payload stays inert. The desktop shell's sandboxed HTML preview is self-contained: the trusted top frame fetches the document and its same-origin assets, inlines them, and frames a sandboxed blob instead of a dsh-app route the shell rejects from an opaque subframe. The sandbox never gains allow-same-origin; browser and explicitly-unsandboxed paths are unchanged.
Follow-up to the iframe isolation: after that fix a 31-diagram document
still felt janky while scrolling. The remaining cost was work competing
with the scroll gesture:
- background diagram renders kept running during scroll (each one injects
an SVG, runs DOM passes and lays out);
- hidden native tabs kept warming diagrams (tab bodies are keepMounted);
- the inline-HTML and heading-anchor MutationObservers ran a full-document
scan per mutation (measured 8-15 ms per pass, dozens of passes when a
document swaps its diagrams in);
- initial near-viewport detection read one rect per diagram between DOM
writes, forcing a layout per diagram;
- off-screen rendered SVGs still participated in layout and paint.
The queue now pauses background work for 350 ms after the last captured
scroll event, and only schedules renders whose preview is visible
(IntersectionObserver gate per preview; hidden tabs keep placeholders and
wake the queue when shown again, and unmounting a preview drops its queued
tasks). The two mutation passes coalesce bursts into one 80 ms pass.
Initial priorities come from one batched rect read before the swap writes.
.mermaidWrap gains content-visibility:auto + contain-intrinsic-size +
contain:layout paint style, so off-screen diagrams leave layout and paint.
Visible diagrams still render on demand, every diagram is still eventually
rendered, and nothing falls back to a code block.
Mermaid measures every label with SVGElement.getBBox() against a node
appended to document.body, so each measurement flushes the whole host
document's layout. Measured in the live DSH window (15,418 DOM nodes):
59-75 ms per measurement, versus 1 ms in an empty iframe document. One
diagram therefore took 1.5-7.3 s, and a 31-diagram markdown document kept
the renderer main thread blocked for >20 s - long enough for the desktop
shell's surface watchdog to kill the renderer, with tab restoration
turning it into a crash loop. CSS containment on the app root does not
help (59-62 ms); only an independent layout tree does.
Render diagrams inside a hidden sandboxed iframe instead: a self-contained
blob: document (mermaid UMD bundle + a small postMessage protocol, both
inlined by scripts/build-mermaid-frame-asset.mjs) renders each diagram;
the parent only sends/receives and sanitizes the SVG. Diagrams now take
30-104 ms each and 31 diagrams complete in ~5 s in the background, while
the client mermaid chunk shrinks from 7.04 MB to 3.69 MB (minified UMD
replaces the unminified inline bundle).
Also add a shared render queue: visible/near-viewport diagrams first, the
rest filled in on requestIdleCallback with 16 ms main-thread yields between
renders, so every diagram is still rendered (none degrades to a code
block). Fence-line-sized placeholder skeletons reserve height while a
diagram waits. No host-half route changes are needed.
cwdOf() resolves the cwd for every file/Git route, and a cold (detached)
session paid one host observation per call: sessionQuery.observeSession({
projectionMode: 'all' }) decodes the whole zstd artifact and hydrates every
projection to answer with one workingDirectory string. The 0.28.1
single-flight only covered /sidebar/api, while the real startup fan-out
never goes through it: the fs-watch socket sends one frame PER WATCHED
DIRECTORY (server resolves cwd before it even reads the op), /sidebar/file
and /sidebar/html resolve per resource, upload/write per call. A 39 MB
session was therefore decoded dozens of times in parallel — the 44-read
OOM on 0.28.0 and the 36 reads reported against 0.28.1 are the same path,
not a broken dedupe.
A detached session now resolves through sessionPersistence.stat(), which
reads the first zstd frame only (header-only, never the log), memoized per
session id (headers are immutable) and shared in-flight across concurrent
asks. activeWorktreeRootOf() answers a detached session with that address
and no longer folds the stored log. Once the host attaches the session the
committed working_directory and linked-worktree following resume as before.
Trade-off (documented): until attach, the sidebar roots at the original
project rather than the agent's last directory/worktree.
tests/smoke.spec.ts rewrites the cwd group (header ahead of a stale hint,
one header read per session, 12 concurrent asks share one, stat absent or
failing falls back to the hint, live committed directory wins, relative
header cwd still refused) and tests/active-worktree.spec.ts pins that a
detached session performs no persistence read and no git probe.
Background pans, the floating-window title drag and the anchored-popover drag committed on every pointermove, so a high-report-rate mouse re-rendered the tasks canvas at event cadence. Compose the latest position in a ref and commit it through the existing frame batcher; release and cancel flush synchronously. Click suppression still updates per event.
Regression: same-frame 100-move burst commits drop 98 -> 1; full suite 2720 passed.
Replace a failed present card with the generic failed tool row; keep one event-authoritative card whichever of the call and its delivered event lands first.
Use the host's real border token for the delivery card; include the visible description in the file button's accessible name and resolve its title path.
Handle CommonMark angle-delimited image destinations and preserve titles; add transcript, prose-rewrite, and DOM regression tests.
Update the change spec with review-driven acceptance commands, status, and evidence.
The desktop shell serves the GUI from the dsh-app://app/ origin while the
Host listens on another site (__DSH_TRANSPORT__.streamBaseUrl). Markdown
preview images were rewritten to an absolute /sidebar/file URL on that
TRANSPORT origin, so from the shell page the request was cross-site: the
Connection fence rejected it (403, Sec-Fetch-Site + a SameSite=Strict
session cookie the shell never forwards for plain http subresources) and
MarkdownText fell back to the image's alt text. Disabling the plugin
worked because the built-in document preview resolves images against the
page base.
Resolve local markdown images through the renderer's pathImages vocabulary
on the PAGE base instead of pre-rewriting destinations: in a browser the
plugin media route stays byte-for-byte what it was, and in the desktop
shell the vocabulary maps to the Host's authenticated api/file route
(dsh-app://app/api/file?...), the only local-file shape the renderer
accepts from that page and the same shape the built-in document preview
uses. Images stay plain <img> elements, so the preview keeps the size the
browser/built-in previews have (no chat thumbnail cap or lightbox chrome).
The host file route requires an ABSOLUTE path (a relative one answers
400 "absolute path required"), while an editor tab opened from a chat
address can carry a workspace-relative path (the plugin's own media route
resolved that via its cwd parameter). The desktop branch therefore joins
the session workspace root before building the URL, and falls back to alt
text when no root is known instead of requesting a guaranteed 400.
Raw HTML <img src> leaves keep the direct rewrite, now also page-based.
Image references stay as authored, so the link pass leaves an
image-referenced definition alone (a link-only definition is still pinned
inert).
Regression coverage renders the real MarkdownText in jsdom with the
desktop page origin (markdown images must render as
dsh-app://app/api/file?..., raw-HTML images as dsh-app://app/sidebar/file...,
not alt text) and pins the relative-tab-path → absolute-target rule.
The http-page assertions are unchanged.
Design notes: docs/plans/2026-10-23-desktop-markdown-media-base.md
Cache markdown label objects by value so MarkdownText's memo survives parent re-renders; pass streaming for unsettled assistant rows.
Rewrite local image destinations in Side Chat prose against the session cwd through the existing /sidebar/file media route.
Map present tool calls and deliverables/presented events to a compact delivery card with thumbnails and the plugin's file-open path.
Add the change spec, exploration notes, and regression tests.
Reset per-gesture travel before node guards so a preceding background pan cannot suppress the next card click. Index and iteratively lay out graph topology, memoize agent card contents, and project complete settled branches under independent existing-settings preferences.
Keep unknown real workflow catalogs and explicitly opened descendant paths visible. Add regression coverage and real rc.1 browser/baseline validation evidence.
Restore selection declarations removed with logRow during graph integration. Dangling selectors had inherited absolute positioning and borders from indent guides. Add parsed CSS and mounted browser regression coverage for staged, unstaged and conflict rows.