Assistant file preview cards render inside the latest terminal assistant row,
above message actions and before the per-turn change summary. Assistant body text
keeps the existing Streamdown behavior: plain file-name mentions are not
automatically rewritten into clickable links. A complete
::zcode-file-citation{...} directive is a separate, explicit projection and is
rendered with the same file-link UI and opening behavior as a Markdown
[label](path) link.
::zcode-file-citation{...} remains the canonical syntax emitted by prompts and
Skills. The renderer also accepts the model compatibility form
:zcode-file-citation{...} with one missing leading colon. This tolerance is
limited to file citations: both forms share the same parameter parsing, path
validation, body-link projection, and preview-card eligibility, while other
directives such as ::code-comment{...} remain strict.
"...", '...') and
Chinese smart quotes (“...”, ‘...’) around citation parameters, Markdown
destinations, and plain path mentions. Mismatched or unclosed quotes are kept
as raw text and do not become file links, so malformed model output cannot
silently change the target path.~/ or ~\\ are resolved against the
homedir reported by the current workspace Host. This applies consistently to
preview cards, Assistant body links, citations, code comments, and local
Markdown images. The renderer never expands ~ with its own process home;
when the Host Home is unavailable, the path fails closed instead of being
treated as a workspace-relative path./ and \\
separators before they become cards. . segments are removed,
.. segments may only cancel a preceding segment, and any traversal that
would move above the workspace root is rejected before Host file I/O. Safe
forms such as ./a/../report.pdf resolve to the normalized workspace path;
unsafe forms such as foo/../../private.pdf do not generate a card.zcode-file-citation accepts path, purpose, and artifact_kind as its
current common parameters. path is required; purpose is parsed but does not
change presentation or opening behavior. Other syntactically valid parameters
are tolerated and ignored by this projection.artifact_kind mapping is document -> docx, presentation -> pptx,
workbook -> xlsx, video -> video, and audio -> audio; when artifact_kind is absent, the type is inferred from
the path extension. An unknown or extension-incompatible artifact_kind
suppresses only the citation card, not an otherwise valid body link.} cannot swallow the rest of the answer. Code-fenced
and inline-code examples are never projected.fileChanges. Office, PDF, and video/audio cards do not use this gate.fileChanges requests are deduplicated above virtualized rows in
SessionPane. Running-turn requests include the current projection revision
in their key and share only the in-flight promise; the settled result is
removed because that turn can still grow. Terminal-turn requests use
sessionId + logEpoch + turnHeader rowId + entityId + fileChanges state, share
both in-flight and successful results, and remain in the renderer-local LRU of
at most 20 entries. A projection transition from active to reverted
therefore cannot reuse the pre-rewind result. Failed requests are always
removed.fileChanges gate and final card builder
consume the same extracted references; rebuilding an equivalent assistant-row
array does not repeat Unicode/path parsing.Preview cards remain a UI-only projection from already delivered V4 rows. They do not add protocol rows, snapshot fields, replayable events, relay state, or agent-side metadata.
assistantText rows (desktop continuous / mobile replayable hydration)
|
+-- complete zcode-file-citation
| +-- body: render leaf-name link through existing MessageFileLink
| `-- cards: admit only compatible docx/xlsx/pptx/pdf references
|
+-- streaming / failed / non-tail row ----------------------> no cards
|
`-- latest complete|interrupted row
|
+-- join assistant text in body order once
+-- extract file references once; reuse them for gate + card build
+-- extract localhost candidates
+-- fetch this turn's fileChanges with the turnHeader target when md/html is present
| +-- running: revision key + in-flight only
| +-- terminal: target + active|reverted key + settled success, shared LRU <= 20 entries
| `-- active md/html paths only
+-- reverse occurrence order + dedupe
+-- take first 15 candidates
`-- workspace-scoped fileService.checkFilesExist()
|
+-- Host cache: workspace host instance + path, TTL 60 s
+-- concurrent checks: at most 15
`-- keep valid candidates, take first 10 -> render cards
The Host file service instance already belongs to one local or remote workspace
host. Cache entries are therefore isolated by the host instance; renderer code
must resolve the service with useWorkspaceServices(workspacePath,
remoteSessionId, workspaceIdentity) so remote paths are checked by their remote
workspace host.
The same workspace-scoped Host provides systemService.info().homedir for Home-
relative Assistant paths. Desktop local uses the local Host Home; SSH/WSL/Docker
and Web /remote use the attached remote Host Home. The Home result is cached per
workspaceIdentity?.trim() || workspacePath plus remoteSessionId and refreshed
when the Host service instance changes.
Workspace-scoped service selection identifies which Host performs file I/O; it
does not by itself prove that an input path is under the workspace directory.
That directory boundary is enforced earlier for relative Assistant card
references by the shared lexical resolver. Rejected card candidates must never
reach checkFilesExist, Preview Pane, Browser, or external-editor actions.
Citation body links deliberately remain outside this eager validation pipeline.
They reuse the existing Markdown file-link click path, including its workspace
scope, traversal rejection, Windows/UNC normalization, and click-time file stat.
The one-minute checkFilesExist cache is used only when a citation becomes a
preview-card candidate.
Markdown and HTML are source-like formats that appear frequently in discussion.
Their preview cards are shown only when the terminal row's turn reports an
active fileChanges result containing the resolved path. A missing target,
unavailable fetch function, reverted result, or failed request yields no Markdown
or HTML cards. This failure does not suppress DOCX/XLSX/PPTX/PDF/video/audio cards.
The turn header's fileChanges.state is the authoritative rewind state. When it
changes to reverted, the card projection immediately clears previously loaded
Markdown/HTML paths and does not wait for a detail query to rediscover the state.
The same primitive state is part of the shared terminal query key so the file
summary panel cannot reuse an active Promise/result after rewind.
The query target must be the same turn's turnHeader row. The terminal
assistantText row remains the body/card render anchor, but it is not a valid V4
fileChanges action target. If the turn header or its entity id is unavailable,
the UI fails closed for Markdown/HTML cards instead of querying with an assistant
row.
The gate compares normalized workspace paths. For a bare name, it may resolve to a fileChanges path only when that name identifies a matching file in the current turn; otherwise normal workspace-relative card resolution is used.
The shared cache lives above ConversationTimeline virtualization, so scrolling
a completed turn out of view and back does not repeat the full-detail query. A
running turn may expose a partial file summary; consumers therefore request it
with an in-flight-only policy and refetch after the header enters a terminal
state. This prevents an earlier projection revision from suppressing final
Markdown/HTML cards or leaving a remounted file-change panel incomplete. It is
recreated when the session, logEpoch, or fileChanges transport changes;
failures are never retained. This cache is separate from the Host's one-minute
file-existence cache because it stores turn diff results, including patch lines,
instead of path existence booleans.
workspacePath, optional workspaceIdentity, and optional
workspaceRemoteSessionId.complete, the renderer automatically
opens the PPTX cards that survived the existing candidate limit and file
existence validation. interrupted, streaming, failed, historical, and
cold-resumed turns do not trigger automatic opening.file:// Browser navigation to
the file Preview Pane because the browser cannot safely resolve the host
workspace path./remote does not project localhost/127.0.0.1 URL cards or HTML
output cards. Without port forwarding or a URL proxy those URLs cannot reach
the Desktop host, and Preview Pane would only show HTML source rather than the
rendered page. Markdown, DOCX, XLSX, PPTX, PDF, and video/audio cards remain available./remote keeps the cards
visible, but does not auto-open when the current surface has no usable right-
side Preview Pane.desktop-continuous message path.web-remote-replayable; card projection runs only after
row hydration and does not enter gap/snapshot recovery. Unsupported local URL
and HTML candidates are filtered in renderer projection before the 15-card
existence-check window, without adding protocol or Host state.fileChanges cache is renderer-local query state. It does not add relay,
Host, snapshot, or replayable state and does not alter delivery semantics.workspacePath as workspace identity. Remote
routing continues to carry workspaceIdentity and remoteSessionId through
the existing workspace service accessor.