* feat(session-query): import DeepSeek chat exports as Sessions Add @deepseek-ai/dsh-deepseek-chat-import: the browser uploads a deepseek_data-*.zip export, the Host buffers it in memory (bounded by maxUploadBytes, default 512 MiB), linearizes each conversation tree to its newest leaf, keeps the most recent maxSessions conversations, and stores one Session per conversation in the chosen Workspace with original titles and times. Reasoning, answers, web search/open fragments, and exported images map to native events and attachments; withdrawn, failed, and templated replies end their turn with an error and stay out of model context. Also add the sidebar.session.action slot beside New session, publish the New-session Workspace menu as the reusable workspace.picker Factory (with a directory-flow hole both directory pickers fill), and add an upload icon. * refactor(experimental): ship DeepSeek chat import as an optional bundle Move @deepseek-ai/dsh-deepseek-chat-import from packages/session-query to packages/experimental under its unprefixed name (recorded in EXPERIMENTAL_PACKAGE_NAME_EXCEPTIONS). The Web composition no longer mounts it: the package now declares dsh.bundle.patch with its own deepseek-chat-import row, an icon, and localized display metadata, and joins OPTIONAL_BUNDLES, MORE_BUNDLES, and EXPERIMENTAL_BUNDLES, so the Plugins page offers it switched off under More with the Experimental badge. The dsh installation carries it as an optional-bundle dependency. Also fix the test typings that failed the aggregate build:check (branded SessionId keys, the generic renderFactorySlot stub, an ArrayBuffer-backed Request body), the lines oxlint rejected, and regenerate the config catalog, module graph, and dsh-doc package list. * docs(experimental): document DeepSeek chat import as an optional bundle Rewrite the DeepSeek chat export import Agent Note for the current design, add its English counterpart and pairing record: browser upload to an owner-only exact route, in-memory unzip bounded by maxUploadBytes, one import at a time, a Workspace chosen through workspace.picker, the closed failure reasons, and delivery as an experimental optional bundle. Record the rejected host-path input, Workspace file listing, and disk staging alternatives. Add the package README pair in the package-bundle layout (enabling from the Plugins page, Config fields, results, failures, implementation, Model Experience, limitations), list the package in the experimental group tables, and re-record the ui-sidebar README pair whose sidebar.session.action paragraph changed on both sides without a new record. * fix(experimental): import DeepSeek chat exports one conversation at a time Address the review of the DeepSeek chat import route and importer: - Decompress with fflate's asynchronous unzip, one entry per request, and refuse any entry whose declared uncompressed size exceeds the new maxEntryBytes (default 256 MiB) before inflating it. A first pass keeps only each conversation's entry, id, title, and last-message time; a second pass imports the selected conversations oldest first, one at a time, yielding to the event loop between them. - Fill the Session limit with the next older conversation when a selected one fails; omittedByLimit counts only conversations never attempted. - Check that the Workspace still exists before each write; a Session stored but not attached is reported in skipped with its id. - Stream the route answer as NDJSON progress lines and one outcome line; the dialog shows a progress bar and "Importing n/K". - The service owns the single import slot and an AbortController per request; unloading cancels the running import and waits for it to stop. - Buffer the upload once, sized from content-length; drop the unreachable 405 branch. - limits() refuses non-owner callers. - Normalize titles with normalizeSessionTitle (new maxTitleBytes, default 80); fixed error codes for unfinished replies with DEEPSEEK_EXPORT_UNFINISHED_REPLY for unknown statuses; an empty user message becomes "[empty message]"; a question whose reply was withdrawn by content filtering is left out together with the reply. - The plugin entry exports only the Service class, error classes, and types. - The dialog shows thrown errors, refreshes the Session list after every attempt without turning a success into a failure, and chooses singular or plural summary lines. * docs(experimental): document and test the per-conversation chat import Move the DeepSeek chat export import Agent Note to implemented/feature with the Decision/Consequences skeleton and describe the shipped design: two passes over the in-memory archive, the maxEntryBytes and maxTitleBytes limits, NDJSON progress, the service-owned import slot and unload cancellation, owner-only limits(), filling the limit, the per-conversation validation guarantee, attach failures without a persistence delete, the [empty message] placeholder, dropped content-filtered rounds, fixed error codes, and branch selection that ignores current_message_id. Update the package README pair to match, rewrite the unit tests for the new importer, route, archive, and client behavior (including a declared-size zip bomb, a misdeclared entry, buffer sizing, owner-only limits, and unloading during a paused import through the real Loader composition) at 100% per-file coverage, classify normalizeSessionTitle as a peer-required Host export, record the Session exports the importer already uses in the dependency policy spec, fix the lines oxlint rejected, and regenerate the config catalog and module graph. * fix(experimental): give imported Sessions a protected empty system head An imported seed had no system/message, so a resumed Agent appended its system prompt after the imported history. The released Session format accepts a system/message only as surface node 0 or after such a head, and the JSONL reader checks this on every read, so a continued imported Session failed to open again with SessionPersistenceCorruptionError. The first imported turn now writes an empty system/message as surface node 0. It derives no model message and renders no prompt card; on resume the Agent replaces it with the real prompt. The resume test asserts the single replacement, one system message in the model request, and a successful read of the stored log after the turn. * test(web): record a DeepSeek chat import snapshot Add the keyless Web snapshot case snapshots/web/deepseek-chat-import with its driver apps/web/tests/deepseek-chat-import.e2e.ts. The driver enables the optional bundle in the scaffold profile, uploads a synthetic export through the owner route (two conversations: a branch, reasoning, a web_search/web_fetch pair, a content-filtered round, and an incomplete reply), opens the imported Session in the browser, and continues it with one recorded model turn. The persisted log shows the empty system head replaced by the real prompt and replays without a key. Register the driver in the Host program and out of the Web Client program, and point the package README pair and the Agent Note at the case. * fix(experimental): classify the chat import service in the doc gates The chat import service surfaces in the Cordis catalog, the capability-seam graph, and the plugin manager inventory, but none of the three gates knew about it: doc graphs threw on the missing role classification, the catalog gate rejected the unclassified `DeepseekChatImportLimits` and the service without a subsystems page, and the Web inventory expectation predated the bundle. Map `ctx.deepseekChatImport` to persistence.md and classify the limits type and service role, then regenerate the catalog and graph docs. The two Web replay fixtures were recorded before the bundle was listed, so regenerate them against the current catalog and plugin inventory. * fix(experimental): upload chat imports through the page transport carrier A page whose Host runs in another execution context has no HTTP server: the preview answers the archive POST with 405. Send the export through the pre-boot `__DSH_TRANSPORT__.fetch` carrier when a shell installed one, and keep XMLHttpRequest on served pages so the browser still reports upload progress. * test(experimental): cover the chat import upload carrier path Cover the page-transport branch of the export upload, which the previous commit left untested: the carrier request, a streamed NDJSON answer, an answer without a body, non-200/JSON/result failures, and cancellation before and during the request. Both upload paths now share one answer collector, so the XHR path keeps its behavior with fewer branches. Resolve the generated `./remote` contribution through a stand-in when this package has no built `lib/`, as the LiveShare suite does: on a clean checkout Vite transforms the client entry before `vi.mock` can answer that import, which failed the jsdom assembly suite in CI. Record the Chinese capability-seams row and the pair after the generated English row, so the bilingual pairing gate passes. * feat(experimental): import the 2026-11-12 DeepSeek chat export structure The 2026-11-12 exporter keeps `export_format_version: 3` while adding `current_message_id`, `stage_id`, tool statuses, plaintext `READ_LINK` fields, and exported `TOOL_FIND.pattern`. Read the added fields as optional so a structurally older archive still imports. - Select the branch ending at `current_message_id`, falling back to the greatest message id when the field is absent, null, or unknown. - Split steps at a `stage_id` change; fragments without one keep the reasoning-or-text-after-a-tool-call rule. - Replay a `FAILED` search as an error result, skip `WIP`, and treat a missing `status` as `FINISHED`. - Write placeholder lines for opened pages without an address, links, image searches, partial file reads, tips, and page finds instead of dropping them; keep `CONTENT_RISK` dropped. - Cover the new fields with a synthetic archive test, update the Web snapshot driver to the new structure, and refresh its fixture. * docs(experimental): record the 2026-11-12 chat import structure Update the package README pair and the Agent Note pair for the branch rule (`current_message_id` with the greatest-id fallback), the new fragment mappings, the `TOOL_FIND` pattern, the `stage_id` step rule, and the limitation that only the 2026-11-12 structure is supported. Re-record both translation-pairing records. * fix(experimental): reject duplicate and misdeclared archive entries A ZIP may list several entries under one name, and read() selects by name, so duplicates decompressed every match at once and bypassed maxEntryBytes. Reject a directory with duplicate names while opening the archive. A ZIP_STORED entry is copied by its compressed size, not by originalSize, so a stored entry could declare 16 bytes and deliver a megabyte. Require the declared and stored sizes to agree and bound both by maxEntryBytes before anything is copied. * fix(experimental): validate the chat import answer lines parseLine cast decoded JSON to the line union, so a null or any other valid JSON threw when the reader read line.type. In the XHR path that throw happened inside onload/onprogress, leaving the upload promise unsettled and the dialog on "importing". Validate the decoded value against the union with typed guards: an object of a known type with that type's fields. An invalid line now fails the answer as "the server answered with invalid JSON". Covered on both the XHR and carrier paths. * fix(experimental): keep call-less chat import steps open and bracket tips A stage_id change split a step even when it held only placeholder text, so a placeholder-only step became an assistant message without a call and the resumed history carried two adjacent assistant messages, which the live agent loop never produces. Split only when the open step already holds a tool call; otherwise update its stage. A TIP is a website notice attributed to the assistant, so write it as the bracketed placeholder [tip: ...] like the other non-model records. * fix(experimental): report the import limit the Host applied The pre-check limit (maxUploadBytes) was attached to every Host failure, and failureText printed only that limit, so a manifest over maxEntryBytes was reported as "the file is too large: the limit is 512MB". Attach the pre-check limit only to the browser's own too-large outcome and show the Host's message when it reports too-large, which names the real limit. * fix(client): fade the imported sidebar action in with the rail The rail-in fade targeted .newSessionRow > *, whose slot entry is the renderer's display: contents anchor: it has no box, so the imported button appeared without fading next to New session. Hit the anchor's child too and assert the selector keeps the rail-in animation. * docs(experimental): describe the chat import upload carrier A page whose Host runs in another execution context, such as the static Cloudflare Pages preview, supplies __DSH_TRANSPORT__.fetch and carries the archive over it with no byte progress, straight to the reading and importing phases; a served page uses XMLHttpRequest. Record that in the README and the Agent Note, and list the missing upload percentage under Known Limitations. Also record the bracketed [tip: ...] placeholder, the stage-split rule that keeps call-less steps merged, the within-step block order, and why dsh-client-file-upload is not reused. Re-record both i18n pairs. * fix(client): fade only the slot entry with the rail The rail-in rule reached every child below the row's slot anchor, which also matched the label mask and shortcut inside the New session button: the button ran the animation twice, so its icon was clipped and then slid in from the edge. Target the renderer's `data-slot` anchor child, which is the registered session action alone, and assert that no rule under the row reaches into the button. * feat(experimental): stream the chat import from the export index `chat_session_index.json` now selects the conversations: the newest `maxSessions` by its `updated_at` (ties by `inserted_at`, then id) are imported, and a missing or unreadable index fails with the new `missing-index` reason instead of falling back to a scan. The selected conversations are handled in one streaming pass over the archive. Each conversation is parsed, converted, and written as it arrives; one that waits for its images is held until they stream past or the archive ends, and images that never arrive stay placeholders. No conversation the index does not select is inflated, and a failure pulls the next older indexed conversation by name. The pass reports a stored entry whose declared size differs from the bytes it holds as damage, not as an oversized entry, and reports actual bytes above `maxEntryBytes` as oversized. * refactor(client): wrap the New-session row with the session-action slot Make `sidebar.session.action` an HOC layer instead of a list: the shell passes the New-session Tooltip and button as `children` and an occupant returns them together with its own controls. No wrapper element is added, the per-entry anchors are gone, and an occupant that adds nothing (or may not act) returns `children` unchanged. The rail-in fade now targets the outlet anchor's children, because the renderer's `display: contents` anchor has no box of its own; the style spec asserts the rule matches both buttons and nothing inside them. * fix(experimental): read chat-import images by name Resolve each selected conversation's images by name through the archive's targeted read instead of holding the conversation until its image entries stream past. Archive entry order no longer decides whether an image is attached, and an image rejected for size or corruption reports its own reason. A replacement conversation now runs image planning and reads inside its per-conversation failure handling, so an invalid candidate is skipped instead of aborting the import. * docs(experimental): record chat-import residual risks Document the synchronous inflation that outlives the entry size bound, duplicate local file headers, partial writes after a mid-pass archive failure, by-name read truncation, and attachments stored for withdrawn rounds. Explain the session-action HOC layering and the children obligation in the Agent Note, and align both language pairs. * docs(experimental): give the chat import a plugin detail page The Plugins page renders `meta.detail` rather than the README, so the package now ships `docs/DETAIL.md` and `docs/DETAIL.zh.md` beside Chinese and English preview images of the import dialog. Every locale names its detail document, and `docs` joins the published files. * fix(experimental): store chat-import images in one archive pass Pass 1 stores every image entry of a conversation the index chooses, before any conversation is parsed, and records the reference or the reason it stayed a placeholder. Pass 2 converts and writes each chosen conversation from those references, so the main path no longer re-parses the central directory once per image. A replacement conversation is still read by name once, and its images come from one further image pass. Correct the convertWithStoredImages JSDoc and the Known Limitations entry: the images-first order makes validate-before-store impossible, so images of a withdrawn round, a dropped branch, or a conversation that fails conversion or Session.create seed validation stay stored without a referencing event. Neither SessionPersistence nor the attachment store offers a removal. Settle the browser answer on the first invalid NDJSON line in both the XHR and page-carrier paths, cancel the rest of the stream, and prevent a later outcome from replacing the failure. * fix(experimental): drop image searches and address-less opens from the chat import The website shows neither of these in a reply, so the import no longer writes a line for them: - `TOOL_IMAGE_SEARCH` replays as nothing. The searched image is not in the export and the reply's reasoning already states what the model took from the results, so the `[image search: n results]` line carried no information a reader could act on. - A `TOOL_OPEN` without an address is the all-null record the exporter writes beside the real page opens of a stage, carrying only `stage_id` and `group_id`; it names no page and replaces the line `[opened page: the export recorded no address]` with nothing. A constructed archive with a pictured question, an image search, two opened pages, and the all-null record now imports to the image, the two fetch cards, the reasoning, and the answer. * feat(experimental): show imported files as cards instead of placeholder text The website shows none of these records as reply text, so the import now matches it: - A non-image file, and an image the archive cannot store, become a synthetic file card: the standard card renders its icon, name, and exported size, and no bytes exist behind the reference. - A `READ_LINK` record becomes one Markdown link line per linked page. - A `TOOL_FIND`, `PARTIAL_FILE_READ`, `TIP`, or `TOOL_IMAGE_SEARCH` record leaves no trace in the reply. - A user message without any content keeps one empty text block instead of `[empty message]`. `file_size` is optional in the export schema so an archive without it still imports. * fix(session-query): keep the session-log export when an attachment is gone A reference whose stored object was deleted failed the whole ZIP download. Each attachment is now read inside the entry that needs it: a missing object is recorded in `attachments-missing.txt` with its archive path and reason, while every other read failure still fails the export. A file's first chunk is pulled before its entry is yielded, so an absent object no longer breaks the download halfway through. * fix(experimental): take attachment brands and error codes from their owners The import package now builds the synthetic file reference with `brandString<AttachmentId>` from dsh-brand instead of importing the attachment package's runtime helper, so dsh-attachment stays type-only and dsh-brand becomes its one runtime dependency. The log export matches the missing-object code on the error instead of importing the class, which keeps that class its owner's peer. The recorded web snapshot follows the new link line. * fix(session-query): release an abandoned attachment stream and accept invalid references A consumer that stops early left the open file iterator to the garbage collector: the entry's stream is now closed by the entry owner too, so a cancelled download releases it. A reference the backend rejects as invalid joins a missing object as a reported skip rather than failing the download. The chat import documents that an empty question's text block is dropped by DeepSeek request serialization, so that Turn's question stays out of the model context. * docs(experimental): drop a duplicated clause from the import note * fix(session-query): close abandoned attachment streams without masking failures Closing one stream must not keep the others open or replace the failure in flight: the streams live in a set that removes each entry as it closes, and the drain settles every close. The chat import converts a pictured conversation once, resolving its references first, and states both possible model handles for a synthetic card.
17 KiB
description, kind
| description | kind |
|---|---|
| Web Session-log ZIP export and Markdown copy: Host streaming, authenticated routes, Session Header actions, and the /export command. | package-reference |
@deepseek-ai/dsh-session-log-export
English | 中文
Summary
dsh-session-log-export lets the Web interface export a session's complete history. The Session Header's more-actions menu offers Copy Session as Markdown and Download session log; an /export slash command also starts the ZIP download. The ZIP contains the session, its sub-sessions, and attachments. The package owns both authenticated Host routes, the Markdown transcript formatter, and the browser controls and feedback. The browser chooses the download destination and owns the clipboard. Setup and usage come first; implementation details follow.
Table of Contents
- Use this package
- Understand the implementation
- Further Exploration
- Model Experience
- Known Limitations and Deferred Work
- Dev Note
Use this package
Use this package when the Web bundle should let users export a session log. It requires Connection, the command registry, Session query and persistence, and attachments. Mount the plugin, then choose Copy Session as Markdown or Download session log from the Session Header's more-actions menu, or type /export; the browser copies the transcript or downloads dsh-session-<id>.zip.
Copy Session as Markdown
Copy Session as Markdown copies the complete selected Session, including history that the client has not loaded, as portable Markdown. The transcript starts with the latest log-backed title. Human user messages are blockquotes in chronological order, final assistant replies remain ordinary Markdown, and earlier assistant commentary and tool activity in each turn are folded into a collapsible <details> section before that turn's final reply. A turn whose last committed assistant message carries tool calls has no final reply, so all of its activity stays folded. An incomplete turn renders the committed messages it has. Only append message events are exported. An unfinished assistant code fence is closed at the message boundary, and four-space or tab-indented code keeps its indentation.
The formatter reads the committed raw log, so a compaction surface replacement never removes earlier messages, and fork-inherited history appears once. The title and body come from one readSession snapshot. When persistence metadata reports a selected materialized artifact, the transcript adds a Session file: fenced text block with that exact path; without one, the block is absent. Only the selected Session and its inherited prefix are copied; descendant logs remain ZIP-only. Reasoning blocks, system and developer messages, injected user-role context whose source kind is not user, request headers and context, and runtime records are omitted. Images and files become readable labels; attachment bytes and authentication links never enter the transcript. Structural labels such as Assistant, Tool, and attachment placeholders are intentionally English; original message text stays unchanged. The text ends with exactly one newline.
The clipboard is one browser-wide destination, so this plugin instance runs one copy at a time. On hosts with ClipboardItem and navigator.clipboard.write, the write starts synchronously from the click with a promised text/plain Blob while the transcript is read; other hosts fall back to the shared clipboard helper after preparation. A request made while a copy is pending joins that operation and keeps the first click's Session. Every Session Header menu disables its copy row until the operation settles; unrelated actions remain available. Success, preparation-failure, or clipboard-failure feedback uses the root overlay toast. Disposal aborts the read and prevents later text from reaching the Blob; an operating-system clipboard write already accepted cannot be rolled back.
When ui-message-feedback is mounted, the same menu also offers Feedback, which opens its existing Session feedback dialog. Opening or dismissing that form does not export the Session or submit feedback. The feedback row follows the feedback plugin’s availability; both export actions remain independently available. ui-open-in-app contributes its application submenu in a separated group after download and before feedback.
When to choose it
Choose it for a Web deployment that needs user-facing session export: a readable Markdown transcript for copying and a ZIP archive for downloading, or for a backend caller that already holds a complete committed logical event snapshot and needs the same Markdown conversion. Avoid it when a Host path write is needed: the browser operations keep their result in the browser, and the conversion utility performs no IO. The logs are serialized from persistence read handles, so any mounted backend is supported.
Backend conversion
The package entry also exports formatSessionMarkdown(events, sourcePath?): a pure backend utility for callers that already hold a complete committed logical event snapshot in seq order, including any inherited prefix. It reads the latest session/title event, returns Markdown ending in one newline, performs no IO, starts no plugin or Session, and does not mutate the events. An optional backend-resolved sourcePath is emitted verbatim in a dynamic fenced Session file: block after the title; omitted or empty paths add no block. Missing or blank titles produce Untitled Session. Only the supplied events are converted; descendant Session logs are not read.
import type { SessionEvent } from '@deepseek-ai/dsh-session'
import { formatSessionMarkdown } from '@deepseek-ai/dsh-session-log-export'
export function convertTranscript(events: readonly SessionEvent[], sourcePath?: string): string {
return formatSessionMarkdown(events, sourcePath)
}
Composition
- id: session-log-download
name: '@deepseek-ai/dsh-session-log-export'
The Web bundle mounts the package with Connection, dsh-commands, dsh-client-ui-commands, dsh-client-ui-conversation, dsh-client-ui-context-menu, and dsh-client-ui-layout. The conversation package owns the Header trigger, the context-menu service renders its shared popup, and layout declares shell.overlay for the download dialog and copy-feedback toast. Locale and command services supply translated copy and command acknowledgements.
Configuration
| Field | Default | Meaning |
|---|---|---|
compressionLevel |
6 |
DEFLATE level from 0 through 9 for each ZIP entry. |
Command contract
| Input | Result |
|---|---|
/export |
Records a human-command lifecycle; the submitting browser downloads the document-relative api/session.export?sessionId=<id>&includeDescendants=true (Host route /api/session.export) |
/export <path> |
An error; browser downloads choose their destination through the browser's ordinary download behavior |
What to expect
The root dialog identifies the exported Session by ID and reports preparing, download started, or failed. Switching conversations keeps it visible. Different Sessions download concurrently, while their dialogs appear one at a time in initiation order; closing one reveals the next open dialog. Closing does not cancel the download or reopen its dialog on settlement. Repeated requests for the same in-flight Session share its operation and keep its original position; a new request after settlement takes a new position. The export includes the live session's newest events: the host endpoint flushes a live root session before reading, so a slash-triggered ZIP includes the command/run and command/done pair that started the download; cold persisted sessions need no flush. Each logical log uses the current generation's canonical filename inside the archive (session.jsonl for v0, otherwise session.vN.jsonl), including beneath each sub-session directory. Images use media/<attachmentId>.<ext>, and generic files use files/<digest-prefix>/<digest>/<name>. Generic-file bytes are read and compressed as bounded chunks, so exporting a large upload does not buffer it in full. A reference the backend cannot read — its object was deleted, a Session names a file card whose bytes never existed, or the backend rejects the reference as invalid — is left out and listed in attachments-missing.txt with its archive path and the reason; the rest of the archive still downloads.
Attachment collection reads declared content fields of built-in Session events and completed assistant stream blocks, including flat V4 tool-role messages. Unknown event payloads and unrelated fields remain unchanged in the exported log but do not cause attachment reads.
Failures
The dialog shows a preparation error when the preflight fails before ZIP streaming starts — for example an unreachable or misconfigured host endpoint. A descendant read failure, or an attachment read failure other than a missing object, is reported by the browser download manager after the browser accepts the GET, not by the dialog. A Markdown preparation failure reports a toast asking the user to retry the Session read; a clipboard write failure reports a separate toast asking the user to check clipboard permission. Neither reports success for a partial or missing transcript, and no pending toast is shown.
Understand the implementation
Implementation internals — click to expand
This section explains how the package wires the export control and points at the code that realizes it; the observable behavior is fully covered in Use this package.
Design split
The package has two halves. The Host half (src/index.ts) registers the /export command and contributes the exact GET/HEAD /api/session.export and /api/session.markdown Fetch routes to Connection; src/archive.ts builds the bounded ZIP stream, and src/markdown.ts renders the Markdown transcript. The browser half (src/client/index.ts) provides the shared download and Markdown copy controllers and UI, and observes command/executed so only the submitting browser starts a download.
The shared context-menu package declares the captured sessionHeader target, independent of Session-row and title context actions; the conversation package owns its Header trigger. This package contributes export and optional feedback rows that observe controller, availability, and locale sources. Its download dialog and copy toast mount in the root overlay independently of the Header lifetime.
Download flow
Both entry paths issue a HEAD preflight to the document-relative api/session.export?..., then hand the GET route to the browser download manager without buffering the ZIP in JavaScript. One controller owns one in-flight download per session, collapses concurrent gestures into that operation, and cancels the preflight on plugin disposal. The root component selects the earliest open entry from the controller’s Session-keyed snapshot using each operation’s initiation order; no separate dialog queue is maintained. Disposal waits for all preflights to settle and prevents a late response from starting a browser save; a download already handed to the browser remains browser-owned.
The Host route is a feature-owned exact Fetch contribution. Connection applies its Host/Origin and browser-session checks and bridges the streaming Response; this package owns query validation, live-session flushes, handle-based log reads and attachment reads, ZIP generation, and HTTP status semantics.
Markdown copy flow
The Header asks the Markdown copy controller for the clicked Session. During the click, the controller requests the deferred ClipboardItem write while it loads the document-relative api/session.markdown?sessionId=<id> route; other hosts fall back to the shared clipboard helper after preparation. The Host route reads the complete live-preferred logical log through ctx.sessionQuery.readSession and passes those events to the pure formatter. It separately asks ctx.get('sessionPersistence')?.stat for the selected materialized artifact path and passes that optional path to the formatter; a metadata-read failure is a sanitized preparation failure. The read is a detached export observation: it creates no Agent, retains no Session, and writes no Session data. It answers 404 for an absent Session and a sanitized 500 for every other read failure.
The controller holds one pending operation and one shell.overlay toast entry. A second Header request joins the pending operation, so the clipboard and its notice always describe the first click's Session. Both the preparation promise and the admitted clipboard write are observed; every rejection is contained. Disposal aborts the read, prevents later text from reaching the promised Blob, suppresses notices, and awaits admitted clipboard work.
Further Exploration
Read these pages when the package-level contract is not enough. They move from the Web control to the host endpoint and the surrounding command and session surfaces.
- dsh-client-connection — the authenticated Fetch-route carrier used by the Host endpoint.
- Commands subsystem reference — the human-command registry the
/exportcommand registers on. - dsh-client-ui-commands — the browser command surface that renders and acknowledges
/export. - Session Query package map — the retrieval family this package belongs to.
Model Experience
Human export and copy controls
What the model sees
Nothing. /export stays on the human-command plane, and the ZIP download does not enter model history. The Markdown copy action is also human-only: it reads the committed log, writes the browser clipboard, and appends no Session event.
Token effect
Zero. The command creates no model turn, and neither export control changes a request.
KV Cache effect
None. The log-only command lifecycle, browser download, and clipboard write do not change the derived request prefix.
Known Limitations and Deferred Work
These limits define when this package is a poor fit or needs special operational care. They are current package constraints, not a task backlog.
- Browser download, not a Host-path writer — the browser chooses the local destination; no Host path or native folder action is returned.
- Preflight reports only pre-stream failures — a descendant or attachment failure after the browser accepts the GET is reported by the browser download manager, not by the dialog.
- Markdown contains committed history only — an unsettled live token chunk has no committed text, so it is absent from the copied transcript. Compaction and fork inheritance follow the raw log rather than the current model context.
- Markdown copy is the selected Session only — descendant Session logs are exported by the ZIP download, not by the Markdown copy.
- Transcript text is buffered in memory — the complete Markdown string and its Blob are held before the clipboard accepts them. Browser clipboard limits can reject a large export; this package does not add a byte cap or truncate the requested complete transcript.
- Accepted clipboard writes cannot be rolled back — disposal stops pending preparation and feedback, but an operating-system write that already succeeded remains on the clipboard.
- The source path is observed metadata, not an atomic log claim —
statidentifies the selected materialized artifact at export time. Live committed events can be ahead of that file, and an unmaterialized Session has no source-path block.
Dev Note
Working context for maintainers — click to expand
This Dev Note is working context for maintainers: open design questions and directions that are not decided. It is explicitly non-authoritative — shipped behavior, limits, and accepted rationale live in the sections above, the package code, and the linked pages.
Future: export destinations beyond the browser
The download is deliberately browser-scoped; a Host-path or native folder export would need a new endpoint contract and a decision on where the ZIP lands.