From ee35e40bc83e45faeab86b62c74c5e207c72737a Mon Sep 17 00:00:00 2001 From: fz Date: Mon, 7 Sep 2026 23:25:09 +0800 Subject: [PATCH 01/32] feat(ui): preview Mermaid diagrams in Chat code blocks --- .../2026-09-07-web-mermaid-preview.i18n.yaml | 6 + .../feature/2026-09-07-web-mermaid-preview.md | 31 +++++ .../2026-09-07-web-mermaid-preview.zh.md | 31 +++++ THIRD_PARTY_NOTICES.md | 2 +- .../expected/markdown-mermaid/ui.expected.md | 53 ++++++++ .../expected/markdown-mermaid/zh.expected.md | 53 ++++++++ apps/web/tests/markdown-mermaid.e2e.ts | 127 ++++++++++++++++++ apps/web/tsconfig.json | 1 + packages/client/locale/src/locales/en.ts | 5 + packages/client/locale/src/locales/zh.ts | 5 + packages/client/ui-chat/README.i18n.yaml | 4 +- packages/client/ui-chat/README.md | 8 ++ packages/client/ui-chat/README.zh.md | 8 ++ .../ui-chat/src/client/markdown-labels.ts | 7 + .../client/ui-primitives/README.i18n.yaml | 4 +- packages/client/ui-primitives/README.md | 4 + packages/client/ui-primitives/README.zh.md | 4 + packages/client/ui-primitives/package.json | 3 +- packages/client/ui-primitives/src/index.ts | 2 + .../src/markdown/CodeBlock.module.css | 1 + .../ui-primitives/src/markdown/CodeBlock.tsx | 19 ++- .../src/markdown/MermaidPreview.module.css | 26 ++++ .../src/markdown/MermaidPreview.tsx | 42 ++++++ .../ui-primitives/src/markdown/mermaid.ts | 59 ++++++++ .../ui-primitives/src/markdown/render.tsx | 9 ++ .../tests/code-block.client.spec.tsx | 2 +- .../tests/mermaid-preview.client.spec.tsx | 107 +++++++++++++++ .../tests/mermaid-runtime.client.spec.ts | 83 ++++++++++++ pnpm-lock.yaml | 3 + tsconfig.host.json | 1 + 30 files changed, 697 insertions(+), 13 deletions(-) create mode 100644 .agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml create mode 100644 .agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md create mode 100644 .agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md create mode 100644 apps/web/tests/expected/markdown-mermaid/ui.expected.md create mode 100644 apps/web/tests/expected/markdown-mermaid/zh.expected.md create mode 100644 apps/web/tests/markdown-mermaid.e2e.ts create mode 100644 packages/client/ui-primitives/src/markdown/MermaidPreview.module.css create mode 100644 packages/client/ui-primitives/src/markdown/MermaidPreview.tsx create mode 100644 packages/client/ui-primitives/src/markdown/mermaid.ts create mode 100644 packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx create mode 100644 packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml new file mode 100644 index 0000000000..f40e8c5054 --- /dev/null +++ b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml @@ -0,0 +1,6 @@ +# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each +# side as of the last confirmed-consistent state. Both languages carry equal authority; +# after editing either side, bring the other along and re-record with: +# pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md +2026-09-07-web-mermaid-preview.md: c891b4133e48a555de945c250679555f91f44c2f +2026-09-07-web-mermaid-preview.zh.md: a4c79c430a07b2655c85354a4406da3914bbd4c4 diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md new file mode 100644 index 0000000000..c891b4133e --- /dev/null +++ b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md @@ -0,0 +1,31 @@ +# Agent Note: Mermaid previews in Chat code fences + +Status: implemented + +English | [中文](2026-09-07-web-mermaid-preview.zh.md) + +## Problem + +Assistant replies can describe diagrams in Mermaid code fences, but readers must interpret the source or copy it to another renderer. Rendering must handle incomplete streaming input and untrusted diagram content while remaining reusable outside Chat. + +## Decision + +Chat enables settled fence previews through `MarkdownLabels.mermaid`. The shared Markdown renderer uses the parsed fence language; streaming fences and consumers without those labels retain code display. The static [UI primitives package](../../../../packages/client/ui-primitives/README.md) owns `MermaidPreview`, which accepts source and localized labels without Session, file, or Cordis dependencies. `CodeBlock.preview` reuses the banner and copy action; copying always reads the source prop. + +Mermaid loads on demand. Its public render API serializes diagram work, and each call removes its temporary measurement DOM in `finally`. Strict security, disabled HTML labels, the neutral theme, and error-rendering policy cannot be overridden by diagram configuration. Generated SVG is displayed as an image without installing diagram links or scripts. Intrinsic dimensions come from the SVG viewBox; large diagrams shrink to fit, and the canvas stays light in both application themes. + +Source replacement and unmounting cancel result publication. Cancellation before runtime loading completes prevents rendering; an active Mermaid render finishes and releases its DOM but cannot publish to a cancelled component. Failures show a localized error and the original source. Replacing invalid source with a valid diagram recovers the preview. + +## Alternatives considered + +**Render each streamed chunk.** Incomplete diagrams are frequently invalid, and repeated layout work competes with text streaming. The existing message-settlement boundary provides a complete source value. + +**Put rendering inside Chat or add a general preview registry.** A shared primitive with plain props satisfies reuse without another registry or feature-plugin dependency. This follows the [shared-control rule](../architecture/2026-09-05-shared-client-control-primitives.md). + +**Insert interactive SVG into the message.** The requested preview needs diagram display and source access. Displaying the result as an image keeps diagram links and event handlers inactive. + +## Consequences + +The feature changes presentation without changing persisted messages, provider requests, tools, or Host APIs. Mermaid adds lazily loaded browser assets. Rendering still runs on the browser thread, and work already handed to the library cannot be interrupted. The initial feature has no editing, export, zoom controls, or interactive diagram links. + +Component tests cover delayed completion, stale success and failure, unmounting, source fallback, and copying. The keyless [browser scenario](../../../../apps/web/tests/markdown-mermaid.e2e.ts) exercises the assembled Chat with Chinese flowcharts, sequence diagrams, malformed source, configuration overrides, and English/Chinese UI snapshots. diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md new file mode 100644 index 0000000000..a4c79c430a --- /dev/null +++ b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md @@ -0,0 +1,31 @@ +# Agent Note: Chat 代码 fence 中的 Mermaid 预览 + +Status: implemented + +[English](2026-09-07-web-mermaid-preview.md) | 中文 + +## 问题 + +Assistant 回复可以在 Mermaid 代码 fence 中描述图表,但读者必须理解源码或把它复制到其他渲染器。渲染需要处理不完整的流式输入与不可信图表内容,同时保持在 Chat 之外的可复用性。 + +## 决策 + +Chat 通过 `MarkdownLabels.mermaid` 启用已定稿 fence 预览。共享 Markdown 渲染器使用解析后的 fence 语言;流式 fence 和未传入这些 label 的调用方保留代码显示。静态 [UI primitives 包](../../../../packages/client/ui-primitives/README.zh.md)拥有 `MermaidPreview`,它接收源码与本地化 label,不依赖 Session、文件或 Cordis。`CodeBlock.preview` 复用标题栏和复制操作;复制始终读取源码 prop。 + +Mermaid 按需加载。它的公开 render API 串行执行图表工作,每次调用在 `finally` 中移除临时测量 DOM。图表配置无法覆盖严格安全模式、禁用 HTML label、中性主题和错误渲染策略。生成的 SVG 以图片显示,不安装图内链接或脚本。固有尺寸取自 SVG viewBox;大图缩小以适应宽度,画布在两种应用主题下均保持浅色。 + +替换源码与卸载组件会取消结果发布。在运行时加载完成前取消可阻止渲染;已经开始的 Mermaid 渲染会完成并释放 DOM,但无法向已取消的组件发布结果。失败时显示本地化错误和原始源码。用有效图表替换非法源码可恢复预览。 + +## 考虑过的替代方案 + +**渲染每个流式分片。** 不完整的图表经常无效,反复布局也会与文本流式输出竞争。已有的消息定稿边界提供完整源码值。 + +**把渲染放在 Chat 内或增加通用预览注册表。** 接收普通 prop 的共享原语无需另一套注册表或功能插件依赖即可满足复用。这遵循[共享控件规则](../architecture/2026-09-05-shared-client-control-primitives.zh.md)。 + +**把可交互 SVG 插入消息。** 此次预览需求只需要图表显示与源码访问。将结果显示为图片后,图内链接和事件处理器不会生效。 + +## 后果 + +功能只改变展示,不改变持久化消息、提供者请求、工具或 Host API。Mermaid 增加按需加载的浏览器资源。渲染仍在浏览器线程上执行,已交给库的工作无法中断。首版不包含编辑、导出、缩放控件或可交互图内链接。 + +组件测试覆盖延迟完成、过期成功与失败、卸载、源码回退和复制。无密钥[浏览器场景](../../../../apps/web/tests/markdown-mermaid.e2e.ts)通过完整 Chat 组合验证中文流程图、时序图、非法源码、配置覆盖以及英文/中文 UI 快照。 diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 31eebdab8d..c2705ac530 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -79,6 +79,7 @@ External packages installed for runtime use or distributed inside the prebuilt b | [`mdast-util-from-markdown`](https://github.com/syntax-tree/mdast-util-from-markdown) | MIT | | [`mdast-util-gfm`](https://github.com/syntax-tree/mdast-util-gfm) | MIT | | [`mdast-util-math`](https://github.com/syntax-tree/mdast-util-math) | MIT | +| [`mermaid`](https://github.com/mermaid-js/mermaid) | MIT | | [`micromark-core-commonmark`](https://github.com/micromark/micromark/tree/main/packages/micromark-core-commonmark) | MIT | | [`micromark-extension-gfm`](https://github.com/micromark/micromark-extension-gfm) | MIT | | [`micromark-extension-math`](https://github.com/micromark/micromark-extension-math) | MIT | @@ -189,7 +190,6 @@ External packages **directly declared** for development, tests, types, or toolin | [`jsdom`](https://github.com/jsdom/jsdom) | MIT | | [`lefthook`](https://github.com/evilmartians/lefthook) | MIT | | [`lightningcss`](https://github.com/parcel-bundler/lightningcss) | MPL-2.0 | -| [`mermaid`](https://github.com/mermaid-js/mermaid) | MIT | | [`micromark-util-types`](https://github.com/micromark/micromark/tree/main/packages/micromark-util-types) | MIT | | [`msgpackr`](http://github.com/kriszyp/msgpackr) | MIT | | [`oxlint`](https://github.com/oxc-project/oxc) | MIT | diff --git a/apps/web/tests/expected/markdown-mermaid/ui.expected.md b/apps/web/tests/expected/markdown-mermaid/ui.expected.md new file mode 100644 index 0000000000..2b9d095829 --- /dev/null +++ b/apps/web/tests/expected/markdown-mermaid/ui.expected.md @@ -0,0 +1,53 @@ +- banner: + - navigation "Session hierarchy": + - button "Mermaid previews" [disabled] + - button "Session log": + - text: Session log + - img + - tablist: + - tab "Chat" [selected] + - tab "Trajectory" +- text: Preview these Mermaid diagrams. {{clock}} +- button "Copy": + - img +- heading "Mermaid previews" [level=1] +- text: mermaid +- button "Source" +- button "Copy" +- img "Mermaid diagram" +- text: mermaid +- button "Source" +- button "Copy" +- img "Mermaid diagram" +- text: mermaid +- button "Source" +- button "Copy" +- status: Unable to render this diagram. The source is shown below. +- code: flowchart LR A[unfinished +- text: mermaid +- button "Source" +- button "Copy" +- img "Mermaid diagram" +- button "Copy": + - img +- button "Good response": + - img +- button "Bad response": + - img +- button "Branch into a new conversation": + - img +- button "Ran for {{duration}}": + - img + - text: Ran for {{duration}} +- text: {{clock}} +- textbox "Message or run a task... / commands, @ files or sessions" +- button "Commands": + - img +- button "Add attachment": + - img +- 'button "Access mode, current: Workspace Write"': Workspace Write +- button "Select model, current DeepSeek-V4-Flash": + - text: DeepSeek-V4-Flash + - img +- button "Send message" [disabled] +- text: 1 turns · 1 steps LLM {{duration}} diff --git a/apps/web/tests/expected/markdown-mermaid/zh.expected.md b/apps/web/tests/expected/markdown-mermaid/zh.expected.md new file mode 100644 index 0000000000..07cb8ac9d6 --- /dev/null +++ b/apps/web/tests/expected/markdown-mermaid/zh.expected.md @@ -0,0 +1,53 @@ +- banner: + - navigation "会话层级": + - button "Mermaid previews" [disabled] + - button "Session 日志": + - text: Session 日志 + - img + - tablist: + - tab "对话" [selected] + - tab "轨迹" +- text: Preview these Mermaid diagrams. {{clock}} +- button "复制": + - img +- heading "Mermaid previews" [level=1] +- text: mermaid +- button "源码" +- button "复制" +- img "Mermaid 图表" +- text: mermaid +- button "源码" +- button "复制" +- img "Mermaid 图表" +- text: mermaid +- button "源码" +- button "复制" +- status: 无法渲染此图表,源码如下。 +- code: flowchart LR A[unfinished +- text: mermaid +- button "源码" +- button "复制" +- img "Mermaid 图表" +- button "复制": + - img +- button "好的回答": + - img +- button "有问题的回答": + - img +- button "在新对话中分支": + - img +- button "用时 {{duration}}": + - img + - text: 用时 {{duration}} +- text: {{clock}} +- textbox "发消息或做任务… / 调用指令 @ 文件或对话" +- button "指令": + - img +- button "添加附件": + - img +- button "访问模式,当前:工作区内修改": 工作区内修改 +- button "选择模型,当前 DeepSeek-V4-Flash": + - text: DeepSeek-V4-Flash + - img +- button "发送消息" [disabled] +- text: 1 轮 · 1 步 LLM {{duration}} diff --git a/apps/web/tests/markdown-mermaid.e2e.ts b/apps/web/tests/markdown-mermaid.e2e.ts new file mode 100644 index 0000000000..d23ca2f8ad --- /dev/null +++ b/apps/web/tests/markdown-mermaid.e2e.ts @@ -0,0 +1,127 @@ +import { fileURLToPath } from 'node:url' +import { join } from 'node:path' +import type { Browser, Page } from 'playwright' +import { chromium } from 'playwright' +import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest' +import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm' +import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session' +import type {} from '@deepseek-ai/dsh-session-title' +import { + assertFixtureInventory, captureStableAria, compareOrRefreshGolden, launchWebScaffold, + seedSession, watchConsole, webSnapshotMode, type WebScaffold, +} from './scaffold.ts' +import { newEnglishPage, saveFailureShot } from './support.ts' + +const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/markdown-mermaid', import.meta.url)) +const MODE = webSnapshotMode() +const SEED_ID = 'markdown-mermaid-web-e2e' +const FLOW = 'flowchart LR\n A[输入] --> B[共享渲染器] --> C[图形预览]' +const SEQUENCE = 'sequenceDiagram\n participant U as User\n participant R as Renderer\n U->>R: Mermaid source\n R-->>U: Diagram' +const INVALID = 'flowchart LR\n A[unfinished' +const UNTRUSTED = [ + '%%{init: {"securityLevel":"loose","htmlLabels":true,"themeCSS":"body {display:none!important}"}}%%', + 'flowchart LR', + ' A[""] --> B[Safe]', + ' click B "javascript:alert(1)"', +].join('\n') + +function fixture(): string { + const session = Session.create(SessionId('markdown-mermaid-source')) + session.append('turn/start', { turn: 1 }) + const user = session.append('user/message', createUserMessage({ + content: [{ type: 'text', text: 'Preview these Mermaid diagrams.' }], source: { kind: 'user' }, + }), { surfaceOp: 'append' }) + session.append('session/title', { title: 'Mermaid previews', messageSeqs: [user.seq], source: { kind: 'fallback' } }) + session.append('step/start', { turn: 1, step: 1 }) + session.append('assistant/message', { + stream: [], turn: 1, step: 1, + message: createMessage({ + role: 'assistant', + content: [{ type: 'text', text: [ + '# Mermaid previews', + ...[FLOW, SEQUENCE, INVALID, UNTRUSTED].map(code => `\`\`\`mermaid\n${code}\n\`\`\``), + ].join('\n\n') }], + source: { kind: 'model', provider: 'fixture', model: 'fixture' }, + }), + }, { surfaceOp: 'append' }) + session.append('step/end', { turn: 1, step: 1 }) + session.append('turn/end', { turn: 1, reason: { kind: 'completed' } }) + const noon = new Date().setHours(12, 0, 0, 0) + return [ + JSON.stringify({ + type: 'session', version: SESSION_FORMAT_VERSION, id: '{{sessionId}}', createdAt: 0, + cwd: '{{cwd}}', isSeeded: false, delegationDepth: 0, + }), + ...session.snapshotEvents().map(event => JSON.stringify({ ...event, time: noon + event.seq * 1000 })), + '', + ].join('\n') +} + +async function openConversation(page: Page, scaffold: WebScaffold): Promise { + await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' }) + await page.getByRole('treeitem').first().click({ timeout: 30_000 }) + await page.getByRole('treeitem').nth(1).click() + await page.getByRole('heading', { name: 'Mermaid previews' }).waitFor() +} + +describe('web e2e: Mermaid chat previews', () => { + let scaffold: WebScaffold + let browser: Browser + beforeAll(async () => { + scaffold = await launchWebScaffold({}) + await seedSession(scaffold, fixture(), SEED_ID) + browser = await chromium.launch() + }, 120_000) + afterAll(async () => { + await browser?.close() + await scaffold?.close() + }) + + it.skipIf(MODE === 'record')('renders diagrams, switches to source, copies source, and contains malformed content', async () => { + const page = await newEnglishPage(browser) + onTestFailed(() => saveFailureShot(page, 'web-e2e-markdown-mermaid')) + const tripwire = watchConsole(page) + const dialogs: string[] = [] + page.on('dialog', (dialog) => { dialogs.push(dialog.message()); void dialog.dismiss() }) + await page.context().grantPermissions(['clipboard-read', 'clipboard-write']) + await openConversation(page, scaffold) + const images = page.getByRole('img', { name: 'Mermaid diagram' }) + await expect.poll(() => images.count(), { timeout: 20_000 }).toBe(3) + await expect.poll(() => images.evaluateAll(nodes => nodes.every(node => (node as HTMLImageElement).naturalWidth > 0))).toBe(true) + expect(await images.evaluateAll(nodes => nodes.every(node => + node.getBoundingClientRect().width <= (node as HTMLImageElement).naturalWidth))).toBe(true) + expect(await page.getByText('Unable to render this diagram. The source is shown below.', { exact: true }).count()).toBe(1) + expect(await page.locator('pre code').allTextContents()).toContain(INVALID) + expect(await images.first().evaluate(node => decodeURIComponent((node as HTMLImageElement).src))).toContain('共享渲染器') + const first = page.locator('.md-code-block').first() + await first.getByRole('button', { name: 'Copy', exact: true }).click() + expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(FLOW) + await first.getByRole('button', { name: 'Source', exact: true }).click() + expect(await first.locator('pre code').textContent()).toBe(FLOW) + await first.getByRole('button', { name: 'Preview', exact: true }).click() + await first.getByRole('img').waitFor() + await first.getByRole('button', { name: 'Copy', exact: true }).waitFor() + expect(await page.locator('body').evaluate(node => getComputedStyle(node).display)).not.toBe('none') + expect(await page.locator('[id^="dsh-mermaid-"]').count()).toBe(0) + expect(dialogs).toEqual([]) + expect(tripwire.pageErrors).toEqual([]) + expect(tripwire.warnings).toEqual([]) + const snapshot = (await captureStableAria(page, '[class*="centerCol"]', scaffold.workspaceCwd)) + .split(SEED_ID).join('{{seededId}}') + await compareOrRefreshGolden(join(SNAPSHOT_DIR, 'ui.expected.md'), snapshot, MODE) + await page.close() + }, 60_000) + + it.skipIf(MODE === 'record')('localizes the preview and failure states in Chinese', async () => { + const page = await browser.newPage({ viewport: { width: 1680, height: 1000 }, locale: 'zh-CN', timezoneId: 'Asia/Shanghai' }) + await openConversation(page, scaffold) + await expect.poll(() => page.getByRole('img', { name: 'Mermaid 图表' }).count(), { timeout: 20_000 }).toBe(3) + expect(await page.getByRole('button', { name: '源码', exact: true }).count()).toBe(4) + expect(await page.getByText('无法渲染此图表,源码如下。', { exact: true }).count()).toBe(1) + const snapshot = (await captureStableAria(page, '[class*="centerCol"]', scaffold.workspaceCwd)) + .split(SEED_ID).join('{{seededId}}') + await compareOrRefreshGolden(join(SNAPSHOT_DIR, 'zh.expected.md'), snapshot, MODE) + await assertFixtureInventory(SNAPSHOT_DIR, ['ui.expected.md', 'zh.expected.md']) + await page.close() + }, 60_000) +}) diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index 3b01e3990c..a6e3b24bfd 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -79,6 +79,7 @@ "tests/math-rendering.e2e.ts", "tests/markdown-cjk-strong.e2e.ts", "tests/markdown-inline-code-links.e2e.ts", + "tests/markdown-mermaid.e2e.ts", "tests/clickable-links-gallery.e2e.ts", "tests/queue-actions.e2e.ts", "tests/queue-image.e2e.ts", diff --git a/packages/client/locale/src/locales/en.ts b/packages/client/locale/src/locales/en.ts index 70ce31598c..6261002e3a 100644 --- a/packages/client/locale/src/locales/en.ts +++ b/packages/client/locale/src/locales/en.ts @@ -38,6 +38,11 @@ export const en = { 'json.expandNode': 'Expand JSON node', 'json.label': 'JSON', 'markdown.footnotes': 'Footnotes', + 'markdown.mermaid.diagram': 'Mermaid diagram', + 'markdown.mermaid.preview': 'Preview', + 'markdown.mermaid.source': 'Source', + 'markdown.mermaid.loading': 'Rendering diagram…', + 'markdown.mermaid.error': 'Unable to render this diagram. The source is shown below.', 'markdown.truncatedCharacters': '… truncated at {total} characters', 'number.thousand': '{value}K', 'number.million': '{value}M', diff --git a/packages/client/locale/src/locales/zh.ts b/packages/client/locale/src/locales/zh.ts index 30cee308d5..9a03ac9b7f 100644 --- a/packages/client/locale/src/locales/zh.ts +++ b/packages/client/locale/src/locales/zh.ts @@ -36,6 +36,11 @@ export const zh = { 'json.expandNode': '展开 JSON 节点', 'json.label': 'JSON', 'markdown.footnotes': '脚注', + 'markdown.mermaid.diagram': 'Mermaid 图表', + 'markdown.mermaid.preview': '预览', + 'markdown.mermaid.source': '源码', + 'markdown.mermaid.loading': '正在渲染图表…', + 'markdown.mermaid.error': '无法渲染此图表,源码如下。', 'markdown.truncatedCharacters': '… 已截断,共 {total} 字符', 'number.thousand': '{value}K', 'number.million': '{value}M', diff --git a/packages/client/ui-chat/README.i18n.yaml b/packages/client/ui-chat/README.i18n.yaml index 4db27677d0..39b3cefe79 100644 --- a/packages/client/ui-chat/README.i18n.yaml +++ b/packages/client/ui-chat/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-chat/README.md -README.md: 860dcb9eeb9c92a14d9128d9d8c95c29796726f8 -README.zh.md: 4dd06a16b19b14cacc0ded603cc1cf8869dd1a43 +README.md: 6115e18f303cfa6ecc63379eabf8a7ad6f56b121 +README.zh.md: 3cb069cdf6cedb6d0c5c045f95e106c2c26959b6 diff --git a/packages/client/ui-chat/README.md b/packages/client/ui-chat/README.md index 860dcb9eeb..6115e18f30 100644 --- a/packages/client/ui-chat/README.md +++ b/packages/client/ui-chat/README.md @@ -15,6 +15,7 @@ File-mention providers receive the viewed Session ID with the closing-turn owner ## Table of Contents - [System prompt row](#system-prompt-row) +- [Mermaid previews](#mermaid-previews) - [Turn token usage](#turn-token-usage) - [Turn Process Folding](#turn-process-folding) - [Scroll ownership](#scroll-ownership) @@ -29,6 +30,13 @@ File-mention providers receive the viewed Session ID with the closing-turn owner Each nonempty appended `system/message` owns a collapsed prompt row, including a complete prompt at the start of a headerless window; the same-step header does not duplicate it. Chat also shows a collapsed `System prompt` row for a non-empty initial request, explicit message-series start, or `system/message` surface node replacement whose text differs, reading the last nonempty surviving system node in surface order at the `request/header`; a non-initial request whose preceding header is outside the loaded history window also shows one. A resume repeats the row even when its system text is unchanged, including after pagination supplies the preceding header and system node; same-series config-only or tool-only changes, tool steps, and retries create no repetition, and a `system/message` event is never rendered as a transcript message. The row appears before that request's user messages, matching the provider envelope, and expands to the exact model-visible text with its original line breaks. A request whose system node is empty or outside the loaded window creates no row until the page holding the node arrives. + +## Mermaid previews + +Settled Assistant Markdown shows `mermaid` code fences as diagrams. Each fence offers Source/Preview switching and copies the original Mermaid source in either view. Streaming fences remain code until the message settles; invalid diagrams show an error and their source without disrupting other blocks. Chat enables the shared [Mermaid preview primitive](../ui-primitives/README.md) through localized labels. This is a presentation change and adds no model prompt, tool, or Session event. + +----- + ## Turn token usage diff --git a/packages/client/ui-chat/README.zh.md b/packages/client/ui-chat/README.zh.md index 4dd06a16b1..3cb069cdf6 100644 --- a/packages/client/ui-chat/README.zh.md +++ b/packages/client/ui-chat/README.zh.md @@ -15,6 +15,7 @@ kind: "package-reference" ## 目录 - [系统提示词行](#system-prompt-row) +- [Mermaid 预览](#mermaid-previews) - [轮次 token 用量](#turn-token-usage) - [轮次过程折叠](#turn-process-folding) - [滚动归属](#scroll-ownership) @@ -31,6 +32,13 @@ kind: "package-reference" ----- + +## Mermaid 预览 + +已定稿的 Assistant Markdown 把 `mermaid` 代码 fence 显示为图表。每个 fence 支持源码/预览切换,在任一视图中复制的都是原始 Mermaid 源码。流式 fence 在消息定稿前保持代码显示;非法图表显示错误与源码,不影响其他块。Chat 通过本地化 label 启用共享的 [Mermaid 预览原语](../ui-primitives/README.zh.md)。这项展示变更不增加模型提示词、工具或 Session 事件。 + +----- + ## 轮次 token 用量 diff --git a/packages/client/ui-chat/src/client/markdown-labels.ts b/packages/client/ui-chat/src/client/markdown-labels.ts index 6c30b99396..d42e6e5f83 100644 --- a/packages/client/ui-chat/src/client/markdown-labels.ts +++ b/packages/client/ui-chat/src/client/markdown-labels.ts @@ -12,5 +12,12 @@ export function markdownLabels(t: ChatViewSlotProps['t']): MarkdownLabels { return { code: { copyLabel: t('copy'), copiedLabel: t('copied') }, footnotes: t('markdown.footnotes'), + mermaid: { + diagram: t('markdown.mermaid.diagram'), + preview: t('markdown.mermaid.preview'), + source: t('markdown.mermaid.source'), + loading: t('markdown.mermaid.loading'), + error: t('markdown.mermaid.error'), + }, } } diff --git a/packages/client/ui-primitives/README.i18n.yaml b/packages/client/ui-primitives/README.i18n.yaml index 138d94440f..7b19fb03f8 100644 --- a/packages/client/ui-primitives/README.i18n.yaml +++ b/packages/client/ui-primitives/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-primitives/README.md -README.md: 8fd59c5ecc98a609f1383e428701cf590da95e73 -README.zh.md: 2478330825681f65aa83415c698cf0edc54fdad6 +README.md: 1e9ee01f6c2243c8b980e45cf512dda1af330af0 +README.zh.md: 02c0417c359070c2f4a4ca11a22709c401847cec diff --git a/packages/client/ui-primitives/README.md b/packages/client/ui-primitives/README.md index 8fd59c5ecc..1e9ee01f6c 100644 --- a/packages/client/ui-primitives/README.md +++ b/packages/client/ui-primitives/README.md @@ -53,6 +53,7 @@ Check this table before writing a control in a feature package. A plugin cannot | `Toast` | Transient top-center banner held for the owner's `holdMs`. | | `JsonTree`, `JsonBlock` | Read-only JSON inspection. | | `MarkdownText`, `CodeBlock` | Untrusted GFM with TeX math, and highlighted code. `CodeBlock` accepts opt-in `lineNumbers`; copied source excludes the gutter. | +| `MermaidPreview` | Read-only Mermaid diagram image with loading and source fallback states. | | `TerminalBlock`, `ReadBlock`, `DiffBlock`, `SearchBlock`, `WebBlock` | The agent-output card matching each tool-result intent. | | `icons/*`, `FishLogo`, `BrandWordmark`, `ReferenceIcon`, `LinkIcon`, `DocumentFileIcon` | Glyphs and brand marks, all riding `currentColor`. | | `FileTypeIcon` | The coloured file-type sheet (code, html, image, markdown, pdf, sheet, slides, document, other); `classifyFileType` picks the kind from a path's extension. | @@ -73,6 +74,9 @@ The catalog above lists what each export is for; this section covers the behavio `MarkdownText` renders untrusted GFM and TeX math, blocks unsafe links and images, and can turn resolved file mentions into explicit controls. When the owner passes a `pathImages` vocabulary, image destinations that are local media paths rewrite to displayable URLs on settled renders only (the same streaming gate as file mentions); without a vocabulary, local destinations remain inert alt text. A load or decode failure replaces the image with its authored alt text, or the original destination when alt is empty. Changing the image source permits a fresh load. While a reply streams, it freezes completed blocks, advances a top-level open fence by completed lines, and highlights that fence from saved Shiki grammar state. Completed token lines enter fixed-size React groups, so later chunks reconcile only the growing group; an unchanged fence retains that DOM when the final full parse resolves cross-document syntax. `TerminalBlock`, `ReadBlock`, `DiffBlock`, `SearchBlock`, and `WebBlock` render the matching tool-result intent with copy controls, overflow handling, and ANSI processing where applicable. `JsonTree` and `JsonBlock` inspect JSON values read-only, while `projectUserText` projects sent user text into inline plain runs and reference chips for the message bubble and queue rows. +`MermaidPreview` renders complete Mermaid source on a light canvas. Rendering loads Mermaid on demand, uses strict security, and exposes the generated SVG as an image with no diagram link handlers. A render failure shows the original source with the supplied error label; replacing the source discards late results from the previous render. The diagram keeps its intrinsic size and shrinks to fit the available width. + +Supply `MarkdownLabels.mermaid` to enable `mermaid` fence previews in a Markdown consumer; without it, fences remain code. Previews start after the message settles. `CodeBlock.preview` supplies an optional alternate body and localized Source/Preview switch labels while the existing Copy button always copies the source. [The Mermaid decision](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md) records the rendering and reuse choices. ### Localizing copy diff --git a/packages/client/ui-primitives/README.zh.md b/packages/client/ui-primitives/README.zh.md index 2478330825..02c0417c35 100644 --- a/packages/client/ui-primitives/README.zh.md +++ b/packages/client/ui-primitives/README.zh.md @@ -53,6 +53,7 @@ kind: "package-library" | `Toast` | 顶部居中的瞬时横幅,保持时长由所有者的 `holdMs` 决定。 | | `JsonTree`、`JsonBlock` | 只读 JSON 查看。 | | `MarkdownText`、`CodeBlock` | 不可信 GFM 与 TeX 数学,以及高亮代码。`CodeBlock` 可通过 `lineNumbers` 开启行号;复制的源码不含行号栏。 | +| `MermaidPreview` | 只读 Mermaid 图表图片,包含加载状态与源码回退状态。 | | `TerminalBlock`、`ReadBlock`、`DiffBlock`、`SearchBlock`、`WebBlock` | 与各类工具结果意图对应的 agent 输出卡片。 | | `icons/*`、`FishLogo`、`BrandWordmark`、`ReferenceIcon`、`LinkIcon`、`DocumentFileIcon` | 字形与品牌标识,全部随 `currentColor`。 | | `FileTypeIcon` | 彩色文件类型纸片(code、html、image、markdown、pdf、sheet、slides、document、other);`classifyFileType` 按路径扩展名选出类型。 | @@ -73,6 +74,9 @@ kind: "package-library" `MarkdownText` 渲染不可信的 GFM 与 TeX 公式、阻止不安全的链接与图片,并可把已解析的文件提及转换为显式控件。当 owner 传入 `pathImages` 词表时,本地媒体路径的图片目标只在落定渲染阶段重写为可展示 URL(与 file mentions 相同的流式门);不传词表时本地目标保持惰性 alt 文本。加载或解码失败后,图片替换为作者的 alt 文本;alt 为空时显示原始目标路径。图片源变化后可重新加载。回复流式输出时,它冻结已完成的块、按已完成行推进顶层未闭合 fence,并从保存的 Shiki grammar state 为该 fence 增量高亮。已完成的 token 行进入固定大小的 React 分组,后续分片只 reconcile 正在增长的分组;最终全量解析解决跨文档语法时,未变化的 fence 会保留该 DOM。`TerminalBlock`、`ReadBlock`、`DiffBlock`、`SearchBlock` 与 `WebBlock` 把对应的工具结果意图渲染为带复制控件、溢出处理及适用时 ANSI 处理的卡片。`JsonTree` 与 `JsonBlock` 以只读方式检查 JSON 值;`projectUserText` 把已发送的用户文本投影为行内普通文本段与引用 chip,供消息气泡和排队行使用。 +`MermaidPreview` 在浅色画布上渲染完整的 Mermaid 源码。渲染按需加载 Mermaid、使用严格安全模式,并把生成的 SVG 显示为图片,不绑定图内链接处理器。渲染失败时显示原始源码与传入的错误文案;替换源码后会丢弃前一次渲染的延迟结果。图表保留固有尺寸,并在可用宽度不足时缩小。 + +为 Markdown 调用方传入 `MarkdownLabels.mermaid` 即可启用 `mermaid` fence 预览;未传入时,fence 保持代码显示。预览在消息定稿后开始。`CodeBlock.preview` 提供可选的替代正文和本地化的「源码/预览」切换文案,现有「复制」按钮始终复制源码。[Mermaid 决策](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md)记录了渲染与复用选择。 ### 本地化文案 diff --git a/packages/client/ui-primitives/package.json b/packages/client/ui-primitives/package.json index 2613c3aa98..6502b6564d 100644 --- a/packages/client/ui-primitives/package.json +++ b/packages/client/ui-primitives/package.json @@ -45,7 +45,8 @@ "mdast-util-gfm": "^3.1.0", "mdast-util-math": "^3.0.0", "micromark-extension-gfm": "^3.0.0", - "micromark-util-sanitize-uri": "^2.0.1" + "micromark-util-sanitize-uri": "^2.0.1", + "mermaid": "11.16.0" }, "files": [ "lib/index.js", diff --git a/packages/client/ui-primitives/src/index.ts b/packages/client/ui-primitives/src/index.ts index d9b12eda0e..7600a0f9ca 100644 --- a/packages/client/ui-primitives/src/index.ts +++ b/packages/client/ui-primitives/src/index.ts @@ -64,6 +64,8 @@ export type { } from './WebBlock.tsx' export { CodeBlock } from './markdown/CodeBlock.tsx' export type { CodeBlockProps } from './markdown/CodeBlock.tsx' +export { MermaidPreview } from './markdown/MermaidPreview.tsx' +export type { MermaidPreviewLabels } from './markdown/MermaidPreview.tsx' export { JsonBlock } from './markdown/JsonBlock.tsx' export { MarkdownText } from './markdown/MarkdownText.tsx' export type { MarkdownCodeLabels, MarkdownFileMentions, MarkdownLabels, MarkdownPathImages } from './markdown/MarkdownText.tsx' diff --git a/packages/client/ui-primitives/src/markdown/CodeBlock.module.css b/packages/client/ui-primitives/src/markdown/CodeBlock.module.css index 5f726e8474..28271cbbdf 100644 --- a/packages/client/ui-primitives/src/markdown/CodeBlock.module.css +++ b/packages/client/ui-primitives/src/markdown/CodeBlock.module.css @@ -56,6 +56,7 @@ display: flex; align-items: center; flex-shrink: 0; + gap: 12px; } .copyButton { diff --git a/packages/client/ui-primitives/src/markdown/CodeBlock.tsx b/packages/client/ui-primitives/src/markdown/CodeBlock.tsx index fff6a00a45..7f55844a91 100644 --- a/packages/client/ui-primitives/src/markdown/CodeBlock.tsx +++ b/packages/client/ui-primitives/src/markdown/CodeBlock.tsx @@ -31,6 +31,8 @@ export interface CodeBlockProps { copyLabel: string /** Copy-button label during the post-copy confirmation window. */ copiedLabel: string + /** Optional settled preview with localized switch labels; copying always retains the source text. */ + preview?: { content: ReactNode; previewLabel: string; sourceLabel: string } | undefined } /** @@ -59,7 +61,7 @@ function renderLine(line: readonly HighlightSpan[], index: number): ReactNode { ) } -export function CodeBlock({ code, lang, streaming, className, lineNumbers = false, copyLabel, copiedLabel }: CodeBlockProps) { +export function CodeBlock({ code, lang, streaming, className, lineNumbers = false, copyLabel, copiedLabel, preview }: CodeBlockProps) { const trimmed = code.endsWith('\n') ? code.slice(0, -1) : code const sourceLines = lineNumbers ? trimmed.split('\n') : undefined const rootRef = useRef(null) @@ -143,13 +145,13 @@ export function CodeBlock({ code, lang, streaming, className, lineNumbers = fals [streaming, highlighting, streamedBody, trimmed, lang, loaded], ) const [copied, setCopied] = useState(false) + const [showSource, setShowSource] = useState(false) + const previewAvailable = preview !== undefined && streaming !== true + const showingPreview = previewAvailable && !showSource const onCopy = useCallback(() => { if (copied) return - /* v8 ignore next -- both arms always mount a
; trimmed is the
-       typed fallback if the DOM shape ever diverges. */
-    const text = rootRef.current?.querySelector('pre')?.textContent ?? trimmed
-    void writeClipboard(text).then((ok) => {
+    void writeClipboard(trimmed).then((ok) => {
       if (!ok) return
       setCopied(true)
       window.setTimeout(() => { setCopied(false) }, 1000)
@@ -181,13 +183,18 @@ export function CodeBlock({ code, lang, streaming, className, lineNumbers = fals
         
{lang ?? ''}
+ {previewAvailable && ( + + )}
- {body} + {showingPreview ? preview.content : body} ) } diff --git a/packages/client/ui-primitives/src/markdown/MermaidPreview.module.css b/packages/client/ui-primitives/src/markdown/MermaidPreview.module.css new file mode 100644 index 0000000000..bd24e36251 --- /dev/null +++ b/packages/client/ui-primitives/src/markdown/MermaidPreview.module.css @@ -0,0 +1,26 @@ +.canvas { + overflow: auto; + padding: 16px; + background: var(--dsw-static-neutral-00); + border-radius: 0 0 12px 12px; +} + +.diagram { + display: block; + max-width: 100%; + height: auto; + margin: 0 auto; +} + +.status { + padding: 16px; + color: var(--dsw-alias-label-secondary); +} + +.staging { + position: fixed; + top: 0; + left: -100000px; + visibility: hidden; + pointer-events: none; +} diff --git a/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx b/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx new file mode 100644 index 0000000000..b59a09a48c --- /dev/null +++ b/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx @@ -0,0 +1,42 @@ +/** Read-only diagram preview with source fallback and per-source async ownership. */ + +import { useEffect, useState } from 'react' +import { renderMermaid } from './mermaid.ts' +import css from './MermaidPreview.module.css' + +/** Localized preview states; the diagram source remains verbatim. */ +export interface MermaidPreviewLabels { + diagram: string + loading: string + error: string +} + +type Result = { code: string; src: string } | { code: string; error: true } + +/** + * Display a complete Mermaid document on a light diagram canvas, or its source if rendering fails. + * @param props - Source and complete localized labels. Changing source discards the previous result. + * @returns A loading status, an inert SVG image, or an error with the original source. + */ +export function MermaidPreview({ code, labels }: { code: string; labels: MermaidPreviewLabels }) { + const [result, setResult] = useState(null) + useEffect(() => { + const controller = new AbortController() + void renderMermaid(code, controller.signal).then( + (src) => { if (!controller.signal.aborted) setResult({ code, src }) }, + () => { if (!controller.signal.aborted) setResult({ code, error: true }) }, + ) + return () => { controller.abort() } + }, [code]) + + if (result?.code !== code) return
{labels.loading}
+ if ('error' in result) { + return ( +
+
{labels.error}
+
{code}
+
+ ) + } + return
{labels.diagram}
+} diff --git a/packages/client/ui-primitives/src/markdown/mermaid.ts b/packages/client/ui-primitives/src/markdown/mermaid.ts new file mode 100644 index 0000000000..4db2a64b6c --- /dev/null +++ b/packages/client/ui-primitives/src/markdown/mermaid.ts @@ -0,0 +1,59 @@ +/** Lazy Mermaid runtime; each render owns and removes its temporary measurement DOM. */ + +import type { Mermaid } from 'mermaid' +import clsx from 'clsx' +import css from './MermaidPreview.module.css' + +let runtime: Promise | undefined +let nextDiagramId = 0 + +function loadMermaid(): Promise { + runtime ??= import('mermaid').then(({ default: mermaid }) => { + mermaid.initialize({ + startOnLoad: false, + securityLevel: 'strict', + suppressErrorRendering: true, + theme: 'neutral', + htmlLabels: false, + secure: [ + 'secure', 'securityLevel', 'startOnLoad', 'maxTextSize', 'maxEdges', + 'suppressErrorRendering', 'theme', 'themeVariables', 'themeCSS', 'htmlLabels', 'flowchart', + ], + }) + return mermaid + }).catch((error: unknown) => { + runtime = undefined + throw error + }) + return runtime +} + +/** + * Render untrusted diagram source as an SVG image URL, without installing SVG or link handlers in the UI. + * @param code - Complete Mermaid source. + * @param signal - Cancels work waiting for the runtime; an active Mermaid render finishes before cleanup. + * @returns An SVG data URL. Import, parse, rendering, and cancellation failures reject. + */ +export async function renderMermaid(code: string, signal: AbortSignal): Promise { + const mermaid = await loadMermaid() + signal.throwIfAborted() + const stage = document.createElement('div') + stage.className = clsx(css.staging) + stage.setAttribute('aria-hidden', 'true') + document.body.append(stage) + try { + // Mermaid's public render API serializes diagram work; the lower-level mermaidAPI does not. + const { svg } = await mermaid.render(`dsh-mermaid-${nextDiagramId++}`, code, stage) + const root = new DOMParser().parseFromString(svg, 'image/svg+xml').documentElement + const viewBox = root.getAttribute('viewBox') + if (viewBox !== null) { + // An SVG image needs intrinsic dimensions; Mermaid's percentage width is for inline SVG. + const [, , width, height] = viewBox.split(/\s+/) as [string, string, string, string] + root.setAttribute('width', width) + root.setAttribute('height', height) + } + return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(root))}` + } finally { + stage.remove() + } +} diff --git a/packages/client/ui-primitives/src/markdown/render.tsx b/packages/client/ui-primitives/src/markdown/render.tsx index 4d7805553b..d946c06893 100644 --- a/packages/client/ui-primitives/src/markdown/render.tsx +++ b/packages/client/ui-primitives/src/markdown/render.tsx @@ -23,6 +23,8 @@ import type * as Md from 'mdast' import type {} from 'mdast-util-math' import { normalizeUri } from 'micromark-util-sanitize-uri' import { CodeBlock } from './CodeBlock.tsx' +import { MermaidPreview } from './MermaidPreview.tsx' +import type { MermaidPreviewLabels } from './MermaidPreview.tsx' import { renderTexToReact } from './katex.tsx' import { LinkIcon, classifyLinkPath } from '../LinkIcon.tsx' import type { PositionedBlock } from './incremental.ts' @@ -40,6 +42,8 @@ export interface MarkdownCodeLabels { export interface MarkdownLabels { code: MarkdownCodeLabels footnotes: string + /** Opt into settled Mermaid fence previews by supplying their complete localized chrome. */ + mermaid?: MermaidPreviewLabels & { preview: string; source: string } } function sanitizeUrl(url: string): string { @@ -394,6 +398,11 @@ function renderCode(node: Md.Code, key: Key, context: MarkdownRenderContext): Re streaming={context.streaming} copyLabel={context.labels.code.copyLabel} copiedLabel={context.labels.code.copiedLabel} + preview={lang === 'mermaid' && !context.streaming && context.labels.mermaid !== undefined ? { + content: , + previewLabel: context.labels.mermaid.preview, + sourceLabel: context.labels.mermaid.source, + } : undefined} /> ) } diff --git a/packages/client/ui-primitives/tests/code-block.client.spec.tsx b/packages/client/ui-primitives/tests/code-block.client.spec.tsx index 4413cf46d2..83c016c8f0 100644 --- a/packages/client/ui-primitives/tests/code-block.client.spec.tsx +++ b/packages/client/ui-primitives/tests/code-block.client.spec.tsx @@ -122,7 +122,7 @@ describe('CodeBlock', () => { expect(view.getByText('plain text')).toBeTruthy() }) - it('shows the language banner and copies the pre textContent', async () => { + it('shows the language banner and copies the displayed source text', async () => { vi.useFakeTimers() const writeText = vi.fn().mockResolvedValue(undefined) Object.defineProperty(navigator, 'clipboard', { diff --git a/packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx b/packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx new file mode 100644 index 0000000000..4a716c4886 --- /dev/null +++ b/packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx @@ -0,0 +1,107 @@ +// @vitest-environment jsdom + +import { act, cleanup, fireEvent, render, screen } from '@testing-library/react' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { MermaidPreview } from '../src/markdown/MermaidPreview.tsx' +import { renderMermaid } from '../src/markdown/mermaid.ts' +import { MarkdownText } from '../src/markdown/MarkdownText.tsx' +import { markdownLabels } from './labels.client.ts' + +vi.mock('../src/markdown/mermaid.ts', () => ({ renderMermaid: vi.fn() })) + +const labels = { + diagram: 'Mermaid diagram', loading: 'Rendering diagram…', error: 'Unable to render this diagram.', + preview: 'Preview', source: 'Source', +} +const source = 'flowchart LR\n A[Input] --> B[Preview]' +const imageUrl = 'data:image/svg+xml;charset=utf-8,%3Csvg%2F%3E' + +afterEach(() => { cleanup(); vi.unstubAllGlobals() }) +beforeEach(() => { vi.resetAllMocks() }) + +describe('MermaidPreview', () => { + it('shows loading until rendering completes, then displays an image without inserting SVG', async () => { + const pending = Promise.withResolvers() + vi.mocked(renderMermaid).mockReturnValue(pending.promise) + const view = render() + expect(screen.getByRole('status').textContent).toBe(labels.loading) + expect(screen.queryByRole('img')).toBeNull() + await act(async () => { pending.resolve(imageUrl) }) + expect(screen.getByRole('img', { name: labels.diagram }).getAttribute('src')).toBe(imageUrl) + expect(view.container.querySelector('svg')).toBeNull() + expect(screen.queryByRole('status')).toBeNull() + }) + + it('retains invalid source and recovers when the source changes', async () => { + vi.mocked(renderMermaid).mockRejectedValueOnce(new Error('Parse error')) + const view = render() + expect((await screen.findByText(labels.error)).getAttribute('role')).toBe('status') + expect(view.container.querySelector('pre code')?.textContent).toBe('invalid') + const next = Promise.withResolvers() + vi.mocked(renderMermaid).mockReturnValue(next.promise) + view.rerender() + expect(screen.getByRole('status').textContent).toBe(labels.loading) + expect(view.container.querySelector('pre')).toBeNull() + await act(async () => { next.resolve(imageUrl) }) + expect(screen.getByRole('img').getAttribute('src')).toBe(imageUrl) + }) + + it.each(['resolve', 'reject'] as const)('ignores a stale %s after a newer source finishes', async (outcome) => { + const old = Promise.withResolvers() + const next = Promise.withResolvers() + vi.mocked(renderMermaid).mockReturnValueOnce(old.promise).mockReturnValueOnce(next.promise) + const view = render() + const oldSignal = vi.mocked(renderMermaid).mock.calls[0]![1] + view.rerender() + expect(oldSignal.aborted).toBe(true) + await act(async () => { next.resolve(imageUrl) }) + await act(async () => { + if (outcome === 'resolve') old.resolve('obsolete-image') + else old.reject(new Error('obsolete-error')) + }) + expect(screen.getByRole('img').getAttribute('src')).toBe(imageUrl) + expect(screen.queryByRole('status')).toBeNull() + }) + + it('cancels the owner when unmounted while loading', async () => { + const pending = Promise.withResolvers() + vi.mocked(renderMermaid).mockReturnValue(pending.promise) + const view = render() + const signal = vi.mocked(renderMermaid).mock.calls[0]![1] + view.unmount() + expect(signal.aborted).toBe(true) + await act(async () => { pending.reject(new Error('cancelled')) }) + expect(screen.queryByRole('img')).toBeNull() + }) +}) + +describe('Markdown Mermaid fences', () => { + it('keeps streaming source literal, then offers preview, source and source copying', async () => { + const writeText = vi.fn().mockResolvedValue(undefined) + vi.stubGlobal('navigator', Object.create(navigator, { clipboard: { value: { writeText } } })) + vi.mocked(renderMermaid).mockResolvedValue(imageUrl) + const props = { text: `\`\`\`mermaid\n${source}\n\`\`\``, labels: { ...markdownLabels, mermaid: labels } } + const view = render() + expect(view.container.querySelector('pre code')?.textContent).toBe(source) + expect(renderMermaid).not.toHaveBeenCalled() + expect(screen.queryByRole('button', { name: labels.source })).toBeNull() + view.rerender() + await screen.findByRole('img', { name: labels.diagram }) + fireEvent.click(screen.getByRole('button', { name: markdownLabels.code.copyLabel })) + await screen.findByRole('button', { name: markdownLabels.code.copiedLabel }) + expect(writeText).toHaveBeenCalledWith(source) + fireEvent.click(screen.getByRole('button', { name: labels.source })) + expect(view.container.querySelector('pre code')?.textContent).toBe(source) + expect(screen.queryByRole('img')).toBeNull() + fireEvent.click(screen.getByRole('button', { name: labels.preview })) + await screen.findByRole('img', { name: labels.diagram }) + }) + + it('leaves other languages and consumers without preview labels as code', () => { + const view = render() + expect(view.container.querySelector('pre code')?.textContent).toBe(source) + view.rerender() + expect(view.container.querySelector('pre code')?.textContent).toBe('flowchart LR') + expect(renderMermaid).not.toHaveBeenCalled() + }) +}) diff --git a/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts b/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts new file mode 100644 index 0000000000..8b79a42b9a --- /dev/null +++ b/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts @@ -0,0 +1,83 @@ +// @vitest-environment jsdom + +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' + +const initialize = vi.fn() +const renderDiagram = vi.fn() + +beforeEach(() => { + vi.resetModules() + vi.resetAllMocks() + vi.doMock('mermaid', () => ({ default: { initialize, render: renderDiagram } })) +}) +afterEach(() => { vi.doUnmock('mermaid') }) + +describe('Mermaid runtime', () => { + it('shares lazy initialization and removes each measurement container after rendering', async () => { + const { renderMermaid } = await import('../src/markdown/mermaid.ts') + expect(initialize).not.toHaveBeenCalled() + const stages: HTMLElement[] = [] + const ids: string[] = [] + renderDiagram.mockImplementation(async (id: string, code: string, stage: HTMLElement) => { + expect(stage.isConnected).toBe(true) + expect(stage.getAttribute('aria-hidden')).toBe('true') + stages.push(stage) + ids.push(id) + return { svg: `${code}` } + }) + const results = await Promise.all([ + renderMermaid('中文', new AbortController().signal), + renderMermaid('second', new AbortController().signal), + ]) + expect(initialize).toHaveBeenCalledOnce() + expect(initialize).toHaveBeenCalledWith(expect.objectContaining({ + startOnLoad: false, securityLevel: 'strict', suppressErrorRendering: true, htmlLabels: false, + secure: [ + 'secure', 'securityLevel', 'startOnLoad', 'maxTextSize', 'maxEdges', + 'suppressErrorRendering', 'theme', 'themeVariables', 'themeCSS', 'htmlLabels', 'flowchart', + ], + })) + expect(results.map(url => decodeURIComponent(url.split(',')[1]!))).toEqual(['中文', 'second']) + expect(new Set(ids).size).toBe(2) + expect(stages.every(stage => !stage.isConnected)).toBe(true) + }) + + it('removes measurement DOM even when Mermaid rejects', async () => { + const { renderMermaid } = await import('../src/markdown/mermaid.ts') + let stage: HTMLElement | undefined + const error = new Error('bad diagram') + renderDiagram.mockImplementation(async (_id: string, _code: string, target: HTMLElement) => { + stage = target + target.innerHTML = 'partial render' + throw error + }) + await expect(renderMermaid('bad', new AbortController().signal)).rejects.toBe(error) + expect(stage?.isConnected).toBe(false) + }) + + it('preserves intrinsic diagram size instead of stretching percentage-width SVG images', async () => { + const { renderMermaid } = await import('../src/markdown/mermaid.ts') + renderDiagram.mockResolvedValue({ svg: '' }) + const url = await renderMermaid('flowchart LR', new AbortController().signal) + const svg = new DOMParser().parseFromString(decodeURIComponent(url.split(',')[1]!), 'image/svg+xml').documentElement + expect(svg.getAttribute('width')).toBe('420') + expect(svg.getAttribute('height')).toBe('180') + }) + + it('does not start cancelled work after loading the runtime', async () => { + const { renderMermaid } = await import('../src/markdown/mermaid.ts') + const controller = new AbortController() + controller.abort() + await expect(renderMermaid('unused', controller.signal)).rejects.toMatchObject({ name: 'AbortError' }) + expect(renderDiagram).not.toHaveBeenCalled() + }) + + it('allows another attempt after runtime initialization fails', async () => { + const { renderMermaid } = await import('../src/markdown/mermaid.ts') + initialize.mockImplementationOnce(() => { throw new Error('initialization failed') }) + await expect(renderMermaid('first', new AbortController().signal)).rejects.toThrow('initialization failed') + renderDiagram.mockResolvedValue({ svg: '' }) + await expect(renderMermaid('retry', new AbortController().signal)).resolves.toContain('data:image/svg+xml') + expect(initialize).toHaveBeenCalledTimes(2) + }) +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bcea481379..d1c1098a48 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3323,6 +3323,9 @@ importers: mdast-util-math: specifier: ^3.0.0 version: 3.0.0 + mermaid: + specifier: 11.16.0 + version: 11.16.0 micromark-core-commonmark: specifier: ^2.0.3 version: 2.0.3 diff --git a/tsconfig.host.json b/tsconfig.host.json index c5a3f118b3..e7abea1600 100644 --- a/tsconfig.host.json +++ b/tsconfig.host.json @@ -67,6 +67,7 @@ "apps/web/tests/math-rendering.e2e.ts", "apps/web/tests/markdown-cjk-strong.e2e.ts", "apps/web/tests/markdown-inline-code-links.e2e.ts", + "apps/web/tests/markdown-mermaid.e2e.ts", "apps/web/tests/clickable-links-gallery.e2e.ts", "apps/web/tests/queue-actions.e2e.ts", "apps/web/tests/queue-image.e2e.ts", From fc0c885287f327d67ea2b6df49960d1287b054ed Mon Sep 17 00:00:00 2001 From: fz Date: Mon, 7 Sep 2026 23:37:48 +0800 Subject: [PATCH 02/32] style(ui): simplify Mermaid preview controls --- .../2026-09-07-web-mermaid-preview.i18n.yaml | 4 +- .../feature/2026-09-07-web-mermaid-preview.md | 4 +- .../2026-09-07-web-mermaid-preview.zh.md | 4 +- .../expected/markdown-mermaid/ui.expected.md | 13 ++- .../expected/markdown-mermaid/zh.expected.md | 6 +- apps/web/tests/markdown-mermaid.e2e.ts | 25 +++++- packages/client/ui-chat/README.i18n.yaml | 4 +- packages/client/ui-chat/README.md | 2 +- packages/client/ui-chat/README.zh.md | 2 +- .../client/ui-primitives/README.i18n.yaml | 4 +- packages/client/ui-primitives/README.md | 2 +- packages/client/ui-primitives/README.zh.md | 2 +- .../src/markdown/CodeBlock.module.css | 81 +++++++++++++++++++ .../ui-primitives/src/markdown/CodeBlock.tsx | 41 +++++++--- .../src/markdown/MermaidPreview.module.css | 2 +- .../tests/mermaid-preview.client.spec.tsx | 4 + 16 files changed, 165 insertions(+), 35 deletions(-) diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml index f40e8c5054..5bc79823f6 100644 --- a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml +++ b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md -2026-09-07-web-mermaid-preview.md: c891b4133e48a555de945c250679555f91f44c2f -2026-09-07-web-mermaid-preview.zh.md: a4c79c430a07b2655c85354a4406da3914bbd4c4 +2026-09-07-web-mermaid-preview.md: df50e7c7f8b78a869d7d5b761864c06648f8d064 +2026-09-07-web-mermaid-preview.zh.md: 282e6fb4365a56425f2b341e2367e4a2cdae5c1c diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md index c891b4133e..df50e7c7f8 100644 --- a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md +++ b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md @@ -10,7 +10,7 @@ Assistant replies can describe diagrams in Mermaid code fences, but readers must ## Decision -Chat enables settled fence previews through `MarkdownLabels.mermaid`. The shared Markdown renderer uses the parsed fence language; streaming fences and consumers without those labels retain code display. The static [UI primitives package](../../../../packages/client/ui-primitives/README.md) owns `MermaidPreview`, which accepts source and localized labels without Session, file, or Cordis dependencies. `CodeBlock.preview` reuses the banner and copy action; copying always reads the source prop. +Chat enables settled fence previews through `MarkdownLabels.mermaid`. The shared Markdown renderer uses the parsed fence language; streaming fences and consumers without those labels retain code display. The static [UI primitives package](../../../../packages/client/ui-primitives/README.md) owns `MermaidPreview`, which accepts source and localized labels without Session, file, or Cordis dependencies. `CodeBlock.preview` owns view switching and source copying. Previews omit the language banner and expose compact icon actions on hover or keyboard focus; touch devices keep those actions visible. Source and preview share the same focused toggle button, and copying always reads the source prop. Mermaid loads on demand. Its public render API serializes diagram work, and each call removes its temporary measurement DOM in `finally`. Strict security, disabled HTML labels, the neutral theme, and error-rendering policy cannot be overridden by diagram configuration. Generated SVG is displayed as an image without installing diagram links or scripts. Intrinsic dimensions come from the SVG viewBox; large diagrams shrink to fit, and the canvas stays light in both application themes. @@ -18,6 +18,8 @@ Source replacement and unmounting cancel result publication. Cancellation before ## Alternatives considered +**Keep the code banner above diagrams.** A language label and permanent text controls distract from the diagram. Overlay actions retain source access without reserving a title row. + **Render each streamed chunk.** Incomplete diagrams are frequently invalid, and repeated layout work competes with text streaming. The existing message-settlement boundary provides a complete source value. **Put rendering inside Chat or add a general preview registry.** A shared primitive with plain props satisfies reuse without another registry or feature-plugin dependency. This follows the [shared-control rule](../architecture/2026-09-05-shared-client-control-primitives.md). diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md index a4c79c430a..282e6fb436 100644 --- a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md +++ b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md @@ -10,7 +10,7 @@ Assistant 回复可以在 Mermaid 代码 fence 中描述图表,但读者必须 ## 决策 -Chat 通过 `MarkdownLabels.mermaid` 启用已定稿 fence 预览。共享 Markdown 渲染器使用解析后的 fence 语言;流式 fence 和未传入这些 label 的调用方保留代码显示。静态 [UI primitives 包](../../../../packages/client/ui-primitives/README.zh.md)拥有 `MermaidPreview`,它接收源码与本地化 label,不依赖 Session、文件或 Cordis。`CodeBlock.preview` 复用标题栏和复制操作;复制始终读取源码 prop。 +Chat 通过 `MarkdownLabels.mermaid` 启用已定稿 fence 预览。共享 Markdown 渲染器使用解析后的 fence 语言;流式 fence 和未传入这些 label 的调用方保留代码显示。静态 [UI primitives 包](../../../../packages/client/ui-primitives/README.zh.md)拥有 `MermaidPreview`,它接收源码与本地化 label,不依赖 Session、文件或 Cordis。`CodeBlock.preview` 拥有视图切换与源码复制。预览省略语言标题栏,悬停或键盘聚焦时显示紧凑的图标操作;触屏上保持操作可见。源码与预览使用同一个已聚焦的切换按钮,复制始终读取源码 prop。 Mermaid 按需加载。它的公开 render API 串行执行图表工作,每次调用在 `finally` 中移除临时测量 DOM。图表配置无法覆盖严格安全模式、禁用 HTML label、中性主题和错误渲染策略。生成的 SVG 以图片显示,不安装图内链接或脚本。固有尺寸取自 SVG viewBox;大图缩小以适应宽度,画布在两种应用主题下均保持浅色。 @@ -18,6 +18,8 @@ Mermaid 按需加载。它的公开 render API 串行执行图表工作,每次 ## 考虑过的替代方案 +**在图表上方保留代码标题栏。** 语言标记和常驻的文字操作分散了对图表的注意力。浮层操作无需占用标题行即可保留源码入口。 + **渲染每个流式分片。** 不完整的图表经常无效,反复布局也会与文本流式输出竞争。已有的消息定稿边界提供完整源码值。 **把渲染放在 Chat 内或增加通用预览注册表。** 接收普通 prop 的共享原语无需另一套注册表或功能插件依赖即可满足复用。这遵循[共享控件规则](../architecture/2026-09-05-shared-client-control-primitives.zh.md)。 diff --git a/apps/web/tests/expected/markdown-mermaid/ui.expected.md b/apps/web/tests/expected/markdown-mermaid/ui.expected.md index 2b9d095829..58657a3bf6 100644 --- a/apps/web/tests/expected/markdown-mermaid/ui.expected.md +++ b/apps/web/tests/expected/markdown-mermaid/ui.expected.md @@ -4,6 +4,8 @@ - button "Session log": - text: Session log - img + - button "Open the sidebar": + - img - tablist: - tab "Chat" [selected] - tab "Trajectory" @@ -11,20 +13,17 @@ - button "Copy": - img - heading "Mermaid previews" [level=1] -- text: mermaid +- button "Source" +- button "Copy" +- tooltip "Copy" +- img "Mermaid diagram" - button "Source" - button "Copy" - img "Mermaid diagram" -- text: mermaid -- button "Source" -- button "Copy" -- img "Mermaid diagram" -- text: mermaid - button "Source" - button "Copy" - status: Unable to render this diagram. The source is shown below. - code: flowchart LR A[unfinished -- text: mermaid - button "Source" - button "Copy" - img "Mermaid diagram" diff --git a/apps/web/tests/expected/markdown-mermaid/zh.expected.md b/apps/web/tests/expected/markdown-mermaid/zh.expected.md index 07cb8ac9d6..e3a3b84157 100644 --- a/apps/web/tests/expected/markdown-mermaid/zh.expected.md +++ b/apps/web/tests/expected/markdown-mermaid/zh.expected.md @@ -4,6 +4,8 @@ - button "Session 日志": - text: Session 日志 - img + - button "展开侧栏": + - img - tablist: - tab "对话" [selected] - tab "轨迹" @@ -11,20 +13,16 @@ - button "复制": - img - heading "Mermaid previews" [level=1] -- text: mermaid - button "源码" - button "复制" - img "Mermaid 图表" -- text: mermaid - button "源码" - button "复制" - img "Mermaid 图表" -- text: mermaid - button "源码" - button "复制" - status: 无法渲染此图表,源码如下。 - code: flowchart LR A[unfinished -- text: mermaid - button "源码" - button "复制" - img "Mermaid 图表" diff --git a/apps/web/tests/markdown-mermaid.e2e.ts b/apps/web/tests/markdown-mermaid.e2e.ts index d23ca2f8ad..3c6986801f 100644 --- a/apps/web/tests/markdown-mermaid.e2e.ts +++ b/apps/web/tests/markdown-mermaid.e2e.ts @@ -94,9 +94,20 @@ describe('web e2e: Mermaid chat previews', () => { expect(await page.locator('pre code').allTextContents()).toContain(INVALID) expect(await images.first().evaluate(node => decodeURIComponent((node as HTMLImageElement).src))).toContain('共享渲染器') const first = page.locator('.md-code-block').first() + const controls = first.locator('[class*="bannerWrap"]') + expect(await first.getByText('mermaid', { exact: true }).count()).toBe(0) + await page.mouse.move(0, 0) + expect(await controls.evaluate(node => getComputedStyle(node).opacity)).toBe('0') + await first.hover() + expect(await controls.evaluate(node => getComputedStyle(node).opacity)).toBe('1') await first.getByRole('button', { name: 'Copy', exact: true }).click() expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(FLOW) - await first.getByRole('button', { name: 'Source', exact: true }).click() + await page.mouse.move(0, 0) + await first.getByRole('button', { name: 'Source', exact: true }).focus() + expect(await controls.evaluate(node => getComputedStyle(node).opacity)).toBe('1') + await page.keyboard.press('Enter') + expect(await first.getByRole('button', { name: 'Preview', exact: true }) + .evaluate(node => node === document.activeElement)).toBe(true) expect(await first.locator('pre code').textContent()).toBe(FLOW) await first.getByRole('button', { name: 'Preview', exact: true }).click() await first.getByRole('img').waitFor() @@ -106,6 +117,8 @@ describe('web e2e: Mermaid chat previews', () => { expect(dialogs).toEqual([]) expect(tripwire.pageErrors).toEqual([]) expect(tripwire.warnings).toEqual([]) + await page.getByRole('heading', { name: 'Mermaid previews' }).click() + await page.mouse.move(0, 0) const snapshot = (await captureStableAria(page, '[class*="centerCol"]', scaffold.workspaceCwd)) .split(SEED_ID).join('{{seededId}}') await compareOrRefreshGolden(join(SNAPSHOT_DIR, 'ui.expected.md'), snapshot, MODE) @@ -113,11 +126,19 @@ describe('web e2e: Mermaid chat previews', () => { }, 60_000) it.skipIf(MODE === 'record')('localizes the preview and failure states in Chinese', async () => { - const page = await browser.newPage({ viewport: { width: 1680, height: 1000 }, locale: 'zh-CN', timezoneId: 'Asia/Shanghai' }) + const page = await browser.newPage({ viewport: { width: 1680, height: 1000 }, locale: 'zh-CN', timezoneId: 'Asia/Shanghai', hasTouch: true }) await openConversation(page, scaffold) await expect.poll(() => page.getByRole('img', { name: 'Mermaid 图表' }).count(), { timeout: 20_000 }).toBe(3) expect(await page.getByRole('button', { name: '源码', exact: true }).count()).toBe(4) + const controls = page.locator('.md-code-block').first().locator('[class*="bannerWrap"]') + expect(await controls.evaluate(node => getComputedStyle(node).opacity)).toBe('1') + expect(await page.getByRole('button', { name: '源码', exact: true }).first() + .evaluate(node => node.getBoundingClientRect().width)).toBe(44) expect(await page.getByText('无法渲染此图表,源码如下。', { exact: true }).count()).toBe(1) + const firstImage = page.getByRole('img', { name: 'Mermaid 图表' }).first() + await expect.poll(() => firstImage.evaluate(node => (node as HTMLImageElement).naturalWidth)).toBeGreaterThan(0) + expect(await controls.evaluate(node => node.getBoundingClientRect().top)) + .toBeGreaterThanOrEqual(await firstImage.evaluate(node => node.getBoundingClientRect().bottom)) const snapshot = (await captureStableAria(page, '[class*="centerCol"]', scaffold.workspaceCwd)) .split(SEED_ID).join('{{seededId}}') await compareOrRefreshGolden(join(SNAPSHOT_DIR, 'zh.expected.md'), snapshot, MODE) diff --git a/packages/client/ui-chat/README.i18n.yaml b/packages/client/ui-chat/README.i18n.yaml index 39b3cefe79..386c06ea91 100644 --- a/packages/client/ui-chat/README.i18n.yaml +++ b/packages/client/ui-chat/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-chat/README.md -README.md: 6115e18f303cfa6ecc63379eabf8a7ad6f56b121 -README.zh.md: 3cb069cdf6cedb6d0c5c045f95e106c2c26959b6 +README.md: 951f88e5fa61a27802fb7df11a3347ba9676a66c +README.zh.md: 3a180afb43c4262d6054e1f19deefa490b9b36de diff --git a/packages/client/ui-chat/README.md b/packages/client/ui-chat/README.md index 6115e18f30..951f88e5fa 100644 --- a/packages/client/ui-chat/README.md +++ b/packages/client/ui-chat/README.md @@ -33,7 +33,7 @@ Each nonempty appended `system/message` owns a collapsed prompt row, including a ## Mermaid previews -Settled Assistant Markdown shows `mermaid` code fences as diagrams. Each fence offers Source/Preview switching and copies the original Mermaid source in either view. Streaming fences remain code until the message settles; invalid diagrams show an error and their source without disrupting other blocks. Chat enables the shared [Mermaid preview primitive](../ui-primitives/README.md) through localized labels. This is a presentation change and adds no model prompt, tool, or Session event. +Settled Assistant Markdown shows `mermaid` code fences as diagrams. Diagrams have no language banner. Source/Preview and Copy icon actions appear on hover or keyboard focus and remain visible on touch devices; both views copy the original Mermaid source. Streaming fences remain code until the message settles; invalid diagrams show an error and their source without disrupting other blocks. Chat enables the shared [Mermaid preview primitive](../ui-primitives/README.md) through localized labels. This is a presentation change and adds no model prompt, tool, or Session event. ----- diff --git a/packages/client/ui-chat/README.zh.md b/packages/client/ui-chat/README.zh.md index 3cb069cdf6..3a180afb43 100644 --- a/packages/client/ui-chat/README.zh.md +++ b/packages/client/ui-chat/README.zh.md @@ -35,7 +35,7 @@ kind: "package-reference" ## Mermaid 预览 -已定稿的 Assistant Markdown 把 `mermaid` 代码 fence 显示为图表。每个 fence 支持源码/预览切换,在任一视图中复制的都是原始 Mermaid 源码。流式 fence 在消息定稿前保持代码显示;非法图表显示错误与源码,不影响其他块。Chat 通过本地化 label 启用共享的 [Mermaid 预览原语](../ui-primitives/README.zh.md)。这项展示变更不增加模型提示词、工具或 Session 事件。 +已定稿的 Assistant Markdown 把 `mermaid` 代码 fence 显示为图表。图表不显示语言标题栏。源码/预览切换与复制图标在悬停或键盘聚焦时出现,触屏上保持可见;两种视图复制的都是原始 Mermaid 源码。流式 fence 在消息定稿前保持代码显示;非法图表显示错误与源码,不影响其他块。Chat 通过本地化 label 启用共享的 [Mermaid 预览原语](../ui-primitives/README.zh.md)。这项展示变更不增加模型提示词、工具或 Session 事件。 ----- diff --git a/packages/client/ui-primitives/README.i18n.yaml b/packages/client/ui-primitives/README.i18n.yaml index 7b19fb03f8..a8e5104e37 100644 --- a/packages/client/ui-primitives/README.i18n.yaml +++ b/packages/client/ui-primitives/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-primitives/README.md -README.md: 1e9ee01f6c2243c8b980e45cf512dda1af330af0 -README.zh.md: 02c0417c359070c2f4a4ca11a22709c401847cec +README.md: f2694588e2ce96f10055802adaf5ff23b9cae9f1 +README.zh.md: cbd7fec0c1708b9d902dff2302c9472ed2bbb56b diff --git a/packages/client/ui-primitives/README.md b/packages/client/ui-primitives/README.md index 1e9ee01f6c..f2694588e2 100644 --- a/packages/client/ui-primitives/README.md +++ b/packages/client/ui-primitives/README.md @@ -76,7 +76,7 @@ The catalog above lists what each export is for; this section covers the behavio `MermaidPreview` renders complete Mermaid source on a light canvas. Rendering loads Mermaid on demand, uses strict security, and exposes the generated SVG as an image with no diagram link handlers. A render failure shows the original source with the supplied error label; replacing the source discards late results from the previous render. The diagram keeps its intrinsic size and shrinks to fit the available width. -Supply `MarkdownLabels.mermaid` to enable `mermaid` fence previews in a Markdown consumer; without it, fences remain code. Previews start after the message settles. `CodeBlock.preview` supplies an optional alternate body and localized Source/Preview switch labels while the existing Copy button always copies the source. [The Mermaid decision](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md) records the rendering and reuse choices. +Supply `MarkdownLabels.mermaid` to enable `mermaid` fence previews in a Markdown consumer; without it, fences remain code. Previews start after the message settles. `CodeBlock.preview` supplies an optional headerless body with icon actions for source switching and copying. Actions appear on hover or keyboard focus, and stay visible on touch devices; copying always retains the source. [The Mermaid decision](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md) records the rendering and reuse choices. ### Localizing copy diff --git a/packages/client/ui-primitives/README.zh.md b/packages/client/ui-primitives/README.zh.md index 02c0417c35..cbd7fec0c1 100644 --- a/packages/client/ui-primitives/README.zh.md +++ b/packages/client/ui-primitives/README.zh.md @@ -76,7 +76,7 @@ kind: "package-library" `MermaidPreview` 在浅色画布上渲染完整的 Mermaid 源码。渲染按需加载 Mermaid、使用严格安全模式,并把生成的 SVG 显示为图片,不绑定图内链接处理器。渲染失败时显示原始源码与传入的错误文案;替换源码后会丢弃前一次渲染的延迟结果。图表保留固有尺寸,并在可用宽度不足时缩小。 -为 Markdown 调用方传入 `MarkdownLabels.mermaid` 即可启用 `mermaid` fence 预览;未传入时,fence 保持代码显示。预览在消息定稿后开始。`CodeBlock.preview` 提供可选的替代正文和本地化的「源码/预览」切换文案,现有「复制」按钮始终复制源码。[Mermaid 决策](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md)记录了渲染与复用选择。 +为 Markdown 调用方传入 `MarkdownLabels.mermaid` 即可启用 `mermaid` fence 预览;未传入时,fence 保持代码显示。预览在消息定稿后开始。`CodeBlock.preview` 提供无标题栏的替代正文,以及切换源码和复制的图标操作。操作在悬停或键盘聚焦时出现,触屏上保持可见;复制始终保留源码。[Mermaid 决策](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md)记录了渲染与复用选择。 ### 本地化文案 diff --git a/packages/client/ui-primitives/src/markdown/CodeBlock.module.css b/packages/client/ui-primitives/src/markdown/CodeBlock.module.css index 28271cbbdf..c25252aaf9 100644 --- a/packages/client/ui-primitives/src/markdown/CodeBlock.module.css +++ b/packages/client/ui-primitives/src/markdown/CodeBlock.module.css @@ -122,3 +122,84 @@ content: counter(source-line); user-select: none; } + +/* Alternate content is a figure; its actions overlay instead of taking a title row. */ +.preview.showingPreview { + background: transparent; +} + +.preview .bannerWrap { + position: absolute; + top: 8px; + right: 8px; + z-index: 1; + background: transparent; +} + +.preview .banner { + padding: 2px; + background: var(--dsw-alias-bg-base); + border: 0; + border-radius: 8px; + box-shadow: var(--dsw-elevation-panel); +} + +.preview .action { + gap: 2px; +} + +.iconButton { + display: inline-flex; + align-items: center; + justify-content: center; + width: 32px; + height: 32px; + border-radius: 6px; + color: var(--dsw-alias-label-secondary); +} + +.iconButton span { + display: flex; +} + +.iconButton:hover { + color: var(--dsw-alias-label-primary); + background: var(--dsw-alias-interactive-bg-hover); +} + +.preview:not(.showingPreview) :where(pre) { + padding-top: 48px; +} + +@media (hover: hover) and (pointer: fine) { + .preview .bannerWrap { + opacity: 0; + pointer-events: none; + } + + .preview:hover .bannerWrap, + .preview:focus-within .bannerWrap { + opacity: 1; + pointer-events: auto; + } +} + +@media (pointer: coarse) { + .preview { + padding-bottom: 56px; + } + + .preview .bannerWrap { + top: auto; + bottom: 8px; + } + + .preview .iconButton { + width: 44px; + height: 44px; + } + + .preview:not(.showingPreview) :where(pre) { + padding-top: 16px; + } +} diff --git a/packages/client/ui-primitives/src/markdown/CodeBlock.tsx b/packages/client/ui-primitives/src/markdown/CodeBlock.tsx index 7f55844a91..3613ed4f16 100644 --- a/packages/client/ui-primitives/src/markdown/CodeBlock.tsx +++ b/packages/client/ui-primitives/src/markdown/CodeBlock.tsx @@ -2,6 +2,8 @@ import { Fragment, useCallback, useMemo, useRef, useState, useSyncExternalStore import type { CSSProperties, ReactNode } from 'react' import clsx from 'clsx' import { writeClipboard } from '../clipboard.ts' +import { Tooltip } from '../Tooltip.tsx' +import { IconCheckOutline16, IconCodeOutline16, IconCopyOutline16 } from '../icons/index.tsx' import { StreamingHighlightSession, grammarLoadCount, highlightToHtml, subscribeGrammarLoaded, } from './highlight.ts' @@ -31,7 +33,7 @@ export interface CodeBlockProps { copyLabel: string /** Copy-button label during the post-copy confirmation window. */ copiedLabel: string - /** Optional settled preview with localized switch labels; copying always retains the source text. */ + /** Headerless settled preview with hover/focus actions; copying always retains the source text. */ preview?: { content: ReactNode; previewLabel: string; sourceLabel: string } | undefined } @@ -173,24 +175,45 @@ export function CodeBlock({ code, lang, streaming, className, lineNumbers = fals
) + const copyActionLabel = copied ? copiedLabel : copyLabel + const copyAction = ( + + ) + return ( -
-
{lang ?? ''}
+ {!previewAvailable &&
{lang ?? ''}
}
{previewAvailable && ( - + + + )} - + {previewAvailable + ? {copyAction} + : copyAction}
diff --git a/packages/client/ui-primitives/src/markdown/MermaidPreview.module.css b/packages/client/ui-primitives/src/markdown/MermaidPreview.module.css index bd24e36251..f96c14418b 100644 --- a/packages/client/ui-primitives/src/markdown/MermaidPreview.module.css +++ b/packages/client/ui-primitives/src/markdown/MermaidPreview.module.css @@ -2,7 +2,7 @@ overflow: auto; padding: 16px; background: var(--dsw-static-neutral-00); - border-radius: 0 0 12px 12px; + border-radius: 12px; } .diagram { diff --git a/packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx b/packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx index 4a716c4886..4f477902f7 100644 --- a/packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx +++ b/packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx @@ -87,12 +87,16 @@ describe('Markdown Mermaid fences', () => { expect(screen.queryByRole('button', { name: labels.source })).toBeNull() view.rerender() await screen.findByRole('img', { name: labels.diagram }) + expect(screen.queryByText('mermaid')).toBeNull() + expect(screen.getByRole('button', { name: labels.source }).textContent).toBe('') + expect(screen.getByRole('button', { name: markdownLabels.code.copyLabel }).textContent).toBe('') fireEvent.click(screen.getByRole('button', { name: markdownLabels.code.copyLabel })) await screen.findByRole('button', { name: markdownLabels.code.copiedLabel }) expect(writeText).toHaveBeenCalledWith(source) fireEvent.click(screen.getByRole('button', { name: labels.source })) expect(view.container.querySelector('pre code')?.textContent).toBe(source) expect(screen.queryByRole('img')).toBeNull() + expect(screen.queryByText('mermaid')).toBeNull() fireEvent.click(screen.getByRole('button', { name: labels.preview })) await screen.findByRole('img', { name: labels.diagram }) }) From 220103670aef3ae830cf91f47abfccd31c1bdca2 Mon Sep 17 00:00:00 2001 From: fz Date: Tue, 8 Sep 2026 00:24:41 +0800 Subject: [PATCH 03/32] fix(ui): retain Mermaid previews and support hybrid touch controls --- .../2026-09-07-web-mermaid-preview.i18n.yaml | 4 +-- .../feature/2026-09-07-web-mermaid-preview.md | 2 +- .../2026-09-07-web-mermaid-preview.zh.md | 2 +- apps/web/tests/markdown-mermaid.e2e.ts | 32 ++++++++++++++++++- .../client/ui-primitives/README.i18n.yaml | 4 +-- packages/client/ui-primitives/README.md | 3 +- packages/client/ui-primitives/README.zh.md | 3 +- .../src/markdown/CodeBlock.module.css | 4 ++- .../ui-primitives/src/markdown/CodeBlock.tsx | 3 +- .../ui-primitives/src/markdown/render.tsx | 2 +- .../tests/mermaid-preview.client.spec.tsx | 7 ++-- 11 files changed, 52 insertions(+), 14 deletions(-) diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml index 5bc79823f6..f86ae95548 100644 --- a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml +++ b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md -2026-09-07-web-mermaid-preview.md: df50e7c7f8b78a869d7d5b761864c06648f8d064 -2026-09-07-web-mermaid-preview.zh.md: 282e6fb4365a56425f2b341e2367e4a2cdae5c1c +2026-09-07-web-mermaid-preview.md: 811f688713491333587404d32946317d81ff2795 +2026-09-07-web-mermaid-preview.zh.md: 0fdb9cf318561f20fdb7042121bc3517c4d6c9a0 diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md index df50e7c7f8..811f688713 100644 --- a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md +++ b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md @@ -10,7 +10,7 @@ Assistant replies can describe diagrams in Mermaid code fences, but readers must ## Decision -Chat enables settled fence previews through `MarkdownLabels.mermaid`. The shared Markdown renderer uses the parsed fence language; streaming fences and consumers without those labels retain code display. The static [UI primitives package](../../../../packages/client/ui-primitives/README.md) owns `MermaidPreview`, which accepts source and localized labels without Session, file, or Cordis dependencies. `CodeBlock.preview` owns view switching and source copying. Previews omit the language banner and expose compact icon actions on hover or keyboard focus; touch devices keep those actions visible. Source and preview share the same focused toggle button, and copying always reads the source prop. +Chat enables settled fence previews through `MarkdownLabels.mermaid`. The shared Markdown renderer uses the parsed fence language; streaming fences and consumers without those labels retain code display. The static [UI primitives package](../../../../packages/client/ui-primitives/README.md) owns `MermaidPreview`, which accepts source and localized labels without Session, file, or Cordis dependencies. `CodeBlock.preview` owns view switching and source copying. Previews omit the language banner and expose compact icon actions on hover or keyboard focus; devices with any touch input keep those actions visible below the diagram. Switching to source hides the mounted preview, so returning preserves completed rendering and pending work. Source and preview share the same focused toggle button, and copying always reads the source prop. Mermaid loads on demand. Its public render API serializes diagram work, and each call removes its temporary measurement DOM in `finally`. Strict security, disabled HTML labels, the neutral theme, and error-rendering policy cannot be overridden by diagram configuration. Generated SVG is displayed as an image without installing diagram links or scripts. Intrinsic dimensions come from the SVG viewBox; large diagrams shrink to fit, and the canvas stays light in both application themes. diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md index 282e6fb436..0fdb9cf318 100644 --- a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md +++ b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md @@ -10,7 +10,7 @@ Assistant 回复可以在 Mermaid 代码 fence 中描述图表,但读者必须 ## 决策 -Chat 通过 `MarkdownLabels.mermaid` 启用已定稿 fence 预览。共享 Markdown 渲染器使用解析后的 fence 语言;流式 fence 和未传入这些 label 的调用方保留代码显示。静态 [UI primitives 包](../../../../packages/client/ui-primitives/README.zh.md)拥有 `MermaidPreview`,它接收源码与本地化 label,不依赖 Session、文件或 Cordis。`CodeBlock.preview` 拥有视图切换与源码复制。预览省略语言标题栏,悬停或键盘聚焦时显示紧凑的图标操作;触屏上保持操作可见。源码与预览使用同一个已聚焦的切换按钮,复制始终读取源码 prop。 +Chat 通过 `MarkdownLabels.mermaid` 启用已定稿 fence 预览。共享 Markdown 渲染器使用解析后的 fence 语言;流式 fence 和未传入这些 label 的调用方保留代码显示。静态 [UI primitives 包](../../../../packages/client/ui-primitives/README.zh.md)拥有 `MermaidPreview`,它接收源码与本地化 label,不依赖 Session、文件或 Cordis。`CodeBlock.preview` 拥有视图切换与源码复制。预览省略语言标题栏,悬停或键盘聚焦时显示紧凑的图标操作;具备任何触控输入的设备均在图表下方保持操作可见。切换到源码时隐藏已挂载的预览,因此返回时保留已完成的渲染与进行中的工作。源码与预览使用同一个已聚焦的切换按钮,复制始终读取源码 prop。 Mermaid 按需加载。它的公开 render API 串行执行图表工作,每次调用在 `finally` 中移除临时测量 DOM。图表配置无法覆盖严格安全模式、禁用 HTML label、中性主题和错误渲染策略。生成的 SVG 以图片显示,不安装图内链接或脚本。固有尺寸取自 SVG viewBox;大图缩小以适应宽度,画布在两种应用主题下均保持浅色。 diff --git a/apps/web/tests/markdown-mermaid.e2e.ts b/apps/web/tests/markdown-mermaid.e2e.ts index 3c6986801f..928e6cbf40 100644 --- a/apps/web/tests/markdown-mermaid.e2e.ts +++ b/apps/web/tests/markdown-mermaid.e2e.ts @@ -94,6 +94,7 @@ describe('web e2e: Mermaid chat previews', () => { expect(await page.locator('pre code').allTextContents()).toContain(INVALID) expect(await images.first().evaluate(node => decodeURIComponent((node as HTMLImageElement).src))).toContain('共享渲染器') const first = page.locator('.md-code-block').first() + const diagram = await first.getByRole('img').elementHandle() const controls = first.locator('[class*="bannerWrap"]') expect(await first.getByText('mermaid', { exact: true }).count()).toBe(0) await page.mouse.move(0, 0) @@ -109,8 +110,10 @@ describe('web e2e: Mermaid chat previews', () => { expect(await first.getByRole('button', { name: 'Preview', exact: true }) .evaluate(node => node === document.activeElement)).toBe(true) expect(await first.locator('pre code').textContent()).toBe(FLOW) + expect(await diagram!.evaluate(node => node.isConnected)).toBe(true) + expect(await diagram!.isVisible()).toBe(false) await first.getByRole('button', { name: 'Preview', exact: true }).click() - await first.getByRole('img').waitFor() + expect(await diagram!.isVisible()).toBe(true) await first.getByRole('button', { name: 'Copy', exact: true }).waitFor() expect(await page.locator('body').evaluate(node => getComputedStyle(node).display)).not.toBe('none') expect(await page.locator('[id^="dsh-mermaid-"]').count()).toBe(0) @@ -145,4 +148,31 @@ describe('web e2e: Mermaid chat previews', () => { await assertFixtureInventory(SNAPSHOT_DIR, ['ui.expected.md', 'zh.expected.md']) await page.close() }, 60_000) + + it.skipIf(MODE === 'record')('keeps actions visible when a mouse and touchscreen are both available', async () => { + const hybridBrowser = await chromium.launch({ + args: ['--blink-settings=availablePointerTypes=6,primaryPointerType=4,availableHoverTypes=2,primaryHoverType=2'], + }) + try { + const page = await newEnglishPage(hybridBrowser) + expect(await page.evaluate(() => + matchMedia('(hover: hover) and (pointer: fine) and (any-pointer: coarse)').matches)).toBe(true) + await openConversation(page, scaffold) + const first = page.locator('.md-code-block').first() + const diagram = first.getByRole('img', { name: 'Mermaid diagram' }) + await expect.poll(() => diagram.evaluate(node => (node as HTMLImageElement).naturalWidth)).toBeGreaterThan(0) + await page.mouse.move(0, 0) + const controls = first.locator('[class*="bannerWrap"]') + expect(await controls.evaluate(node => getComputedStyle(node).opacity)).toBe('1') + expect(await controls.evaluate(node => getComputedStyle(node).pointerEvents)).toBe('auto') + expect(await first.getByRole('button', { name: 'Source', exact: true }) + .evaluate(node => node.getBoundingClientRect().width)).toBe(44) + expect(await controls.evaluate(node => node.getBoundingClientRect().top)) + .toBeGreaterThanOrEqual(await diagram.evaluate(node => node.getBoundingClientRect().bottom)) + await first.getByRole('button', { name: 'Source', exact: true }).click() + expect(await first.locator('pre code').textContent()).toBe(FLOW) + } finally { + await hybridBrowser.close() + } + }, 60_000) }) diff --git a/packages/client/ui-primitives/README.i18n.yaml b/packages/client/ui-primitives/README.i18n.yaml index a8e5104e37..a0fd81c2bc 100644 --- a/packages/client/ui-primitives/README.i18n.yaml +++ b/packages/client/ui-primitives/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-primitives/README.md -README.md: f2694588e2ce96f10055802adaf5ff23b9cae9f1 -README.zh.md: cbd7fec0c1708b9d902dff2302c9472ed2bbb56b +README.md: 0ba4d6baaa54bbacc82202c490423b37613874df +README.zh.md: 06a266b61a79d4ff5e38ca0de9877a6d8ec66af0 diff --git a/packages/client/ui-primitives/README.md b/packages/client/ui-primitives/README.md index f2694588e2..0ba4d6baaa 100644 --- a/packages/client/ui-primitives/README.md +++ b/packages/client/ui-primitives/README.md @@ -76,7 +76,7 @@ The catalog above lists what each export is for; this section covers the behavio `MermaidPreview` renders complete Mermaid source on a light canvas. Rendering loads Mermaid on demand, uses strict security, and exposes the generated SVG as an image with no diagram link handlers. A render failure shows the original source with the supplied error label; replacing the source discards late results from the previous render. The diagram keeps its intrinsic size and shrinks to fit the available width. -Supply `MarkdownLabels.mermaid` to enable `mermaid` fence previews in a Markdown consumer; without it, fences remain code. Previews start after the message settles. `CodeBlock.preview` supplies an optional headerless body with icon actions for source switching and copying. Actions appear on hover or keyboard focus, and stay visible on touch devices; copying always retains the source. [The Mermaid decision](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md) records the rendering and reuse choices. +Supply `MarkdownLabels.mermaid` to enable `mermaid` fence previews in a Markdown consumer; without it, fences remain code. Previews start after the message settles. `CodeBlock.preview` supplies an optional headerless body with icon actions for source switching and copying. Actions appear on hover or keyboard focus, and stay visible below the diagram whenever a touchscreen is available, including with a mouse attached. Switching to source keeps the preview mounted, so returning reuses its result; copying always retains the source. [The Mermaid decision](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md) records the rendering and reuse choices. ### Localizing copy @@ -145,6 +145,7 @@ None; this package neither assembles nor sends a provider request. These limits define how the atoms behave at the edges; they are current package constraints, not a component roadmap. +- **Mermaid rendering runs on the browser thread** — every mounted settled preview starts rendering, including off-screen diagrams. Mermaid serializes layouts; work already submitted to it cannot be interrupted. Preview virtualization and worker rendering are not provided. - **Streaming defers cross-boundary reference resolution** — a reference-style link or footnote whose definition sits on the other side of the incremental freeze boundary renders as literal text while the reply streams; the settled full parse at finalize resolves it. - **A long highlighted fence retains its complete token DOM** — streaming avoids re-parsing, re-tokenizing, and reconciling the completed prefix, but it does not discard old colors or virtualize token spans. Final DOM cardinality therefore still follows the fence's token count; nested/container fences and a pathological single long line remain on the general tail path. - **Glyph-level icons are redrawn approximations** — the fish logo and the sparkle mark come from font glyphs whose vector geometry is not exportable from the local design data; hand-authored recreations stand in until an exact export path exists. diff --git a/packages/client/ui-primitives/README.zh.md b/packages/client/ui-primitives/README.zh.md index cbd7fec0c1..06a266b61a 100644 --- a/packages/client/ui-primitives/README.zh.md +++ b/packages/client/ui-primitives/README.zh.md @@ -76,7 +76,7 @@ kind: "package-library" `MermaidPreview` 在浅色画布上渲染完整的 Mermaid 源码。渲染按需加载 Mermaid、使用严格安全模式,并把生成的 SVG 显示为图片,不绑定图内链接处理器。渲染失败时显示原始源码与传入的错误文案;替换源码后会丢弃前一次渲染的延迟结果。图表保留固有尺寸,并在可用宽度不足时缩小。 -为 Markdown 调用方传入 `MarkdownLabels.mermaid` 即可启用 `mermaid` fence 预览;未传入时,fence 保持代码显示。预览在消息定稿后开始。`CodeBlock.preview` 提供无标题栏的替代正文,以及切换源码和复制的图标操作。操作在悬停或键盘聚焦时出现,触屏上保持可见;复制始终保留源码。[Mermaid 决策](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md)记录了渲染与复用选择。 +为 Markdown 调用方传入 `MarkdownLabels.mermaid` 即可启用 `mermaid` fence 预览;未传入时,fence 保持代码显示。预览在消息定稿后开始。`CodeBlock.preview` 提供无标题栏的替代正文,以及切换源码和复制的图标操作。操作在悬停或键盘聚焦时出现;只要设备具备触屏,就在图表下方保持可见,包括同时连接鼠标的情况。切换到源码时保留已挂载的预览,返回时复用其结果;复制始终保留源码。[Mermaid 决策](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md)记录了渲染与复用选择。 ### 本地化文案 @@ -145,6 +145,7 @@ kind: "package-library" 这些限制说明原子组件在边缘情况下的行为;它们是当前包约束,不是组件路线图。 +- **Mermaid 渲染在浏览器线程上执行**:每个已挂载的定稿预览都会开始渲染,包括视口外的图表。Mermaid 串行执行布局,已提交给它的工作无法中断。当前不提供预览虚拟化或 worker 渲染。 - **流式期间跨边界引用解析被推迟**:定义落在增量冻结边界另一侧的引用式链接或脚注,在回复流式输出期间渲染为字面文本;定稿时的全量解析会将其解析。 - **长高亮 fence 会保留完整 token DOM**:流式路径避免重新解析、重新 tokenize 和 reconcile 已完成前缀,但不会丢弃旧颜色或虚拟化 token span。因此最终 DOM 数量仍随 fence 的 token 数增长;嵌套/容器内 fence 与病态的单个超长行仍走通用尾部路径。 - **字形级图标是重新绘制的近似版本**:鱼形标志与闪光标记来自字体字形,而本地设计数据无法导出其矢量几何;在获得精确导出路径前,使用手工重建版本代替。 diff --git a/packages/client/ui-primitives/src/markdown/CodeBlock.module.css b/packages/client/ui-primitives/src/markdown/CodeBlock.module.css index c25252aaf9..33a114d102 100644 --- a/packages/client/ui-primitives/src/markdown/CodeBlock.module.css +++ b/packages/client/ui-primitives/src/markdown/CodeBlock.module.css @@ -184,7 +184,7 @@ } } -@media (pointer: coarse) { +@media (any-pointer: coarse) { .preview { padding-bottom: 56px; } @@ -192,6 +192,8 @@ .preview .bannerWrap { top: auto; bottom: 8px; + opacity: 1; + pointer-events: auto; } .preview .iconButton { diff --git a/packages/client/ui-primitives/src/markdown/CodeBlock.tsx b/packages/client/ui-primitives/src/markdown/CodeBlock.tsx index 3613ed4f16..2504f7eddc 100644 --- a/packages/client/ui-primitives/src/markdown/CodeBlock.tsx +++ b/packages/client/ui-primitives/src/markdown/CodeBlock.tsx @@ -217,7 +217,8 @@ export function CodeBlock({ code, lang, streaming, className, lineNumbers = fals
- {showingPreview ? preview.content : body} + {previewAvailable && } + {!showingPreview && body} ) } diff --git a/packages/client/ui-primitives/src/markdown/render.tsx b/packages/client/ui-primitives/src/markdown/render.tsx index d946c06893..eb3d3c2172 100644 --- a/packages/client/ui-primitives/src/markdown/render.tsx +++ b/packages/client/ui-primitives/src/markdown/render.tsx @@ -42,7 +42,7 @@ export interface MarkdownCodeLabels { export interface MarkdownLabels { code: MarkdownCodeLabels footnotes: string - /** Opt into settled Mermaid fence previews by supplying their complete localized chrome. */ + /** Opt into settled Mermaid fence previews by supplying their complete localized labels. */ mermaid?: MermaidPreviewLabels & { preview: string; source: string } } diff --git a/packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx b/packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx index 4f477902f7..c7cf95a9d4 100644 --- a/packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx +++ b/packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx @@ -86,7 +86,7 @@ describe('Markdown Mermaid fences', () => { expect(renderMermaid).not.toHaveBeenCalled() expect(screen.queryByRole('button', { name: labels.source })).toBeNull() view.rerender() - await screen.findByRole('img', { name: labels.diagram }) + const diagram = await screen.findByRole('img', { name: labels.diagram }) expect(screen.queryByText('mermaid')).toBeNull() expect(screen.getByRole('button', { name: labels.source }).textContent).toBe('') expect(screen.getByRole('button', { name: markdownLabels.code.copyLabel }).textContent).toBe('') @@ -96,9 +96,12 @@ describe('Markdown Mermaid fences', () => { fireEvent.click(screen.getByRole('button', { name: labels.source })) expect(view.container.querySelector('pre code')?.textContent).toBe(source) expect(screen.queryByRole('img')).toBeNull() + expect(diagram.isConnected).toBe(true) expect(screen.queryByText('mermaid')).toBeNull() fireEvent.click(screen.getByRole('button', { name: labels.preview })) - await screen.findByRole('img', { name: labels.diagram }) + expect(screen.getByRole('img', { name: labels.diagram })).toBe(diagram) + expect(screen.queryByRole('status')).toBeNull() + expect(renderMermaid).toHaveBeenCalledOnce() }) it('leaves other languages and consumers without preview labels as code', () => { From 0bfd594875662bce0007371195e9354a5cf84ac4 Mon Sep 17 00:00:00 2001 From: fz Date: Tue, 8 Sep 2026 12:41:09 +0800 Subject: [PATCH 04/32] refactor(ui): use tagged Mermaid preview results --- .../src/markdown/MermaidPreview.tsx | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx b/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx index b59a09a48c..5dadb6a6b3 100644 --- a/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx +++ b/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx @@ -11,7 +11,12 @@ export interface MermaidPreviewLabels { error: string } -type Result = { code: string; src: string } | { code: string; error: true } +type Result = { kind: 'ok'; code: string; src: string } | { kind: 'error'; code: string } + +/* v8 ignore next 3 -- closed-union backstop; only reached if a result is forged */ +function assertNever(value: never): never { + throw new Error(`unreachable Mermaid result: ${String(value)}`) +} /** * Display a complete Mermaid document on a light diagram canvas, or its source if rendering fails. @@ -23,20 +28,24 @@ export function MermaidPreview({ code, labels }: { code: string; labels: Mermaid useEffect(() => { const controller = new AbortController() void renderMermaid(code, controller.signal).then( - (src) => { if (!controller.signal.aborted) setResult({ code, src }) }, - () => { if (!controller.signal.aborted) setResult({ code, error: true }) }, + (src) => { if (!controller.signal.aborted) setResult({ kind: 'ok', code, src }) }, + () => { if (!controller.signal.aborted) setResult({ kind: 'error', code }) }, ) return () => { controller.abort() } }, [code]) if (result?.code !== code) return
{labels.loading}
- if ('error' in result) { - return ( -
-
{labels.error}
-
{code}
-
- ) + switch (result.kind) { + case 'ok': + return
{labels.diagram}
+ case 'error': + return ( +
+
{labels.error}
+
{code}
+
+ ) + /* v8 ignore next -- closed-union backstop; only reached if a result is forged */ + default: return assertNever(result) } - return
{labels.diagram}
} From 4fabbd39c588039e8967f95f3d427b1158b0cce7 Mon Sep 17 00:00:00 2001 From: fz Date: Tue, 8 Sep 2026 12:52:41 +0800 Subject: [PATCH 05/32] test(web): scope Mermaid snapshots to diagram content --- .../expected/markdown-mermaid/ui.expected.md | 37 ------------------- .../expected/markdown-mermaid/zh.expected.md | 37 ------------------- apps/web/tests/markdown-mermaid.e2e.ts | 7 ++-- 3 files changed, 3 insertions(+), 78 deletions(-) diff --git a/apps/web/tests/expected/markdown-mermaid/ui.expected.md b/apps/web/tests/expected/markdown-mermaid/ui.expected.md index 58657a3bf6..ac9ceb3164 100644 --- a/apps/web/tests/expected/markdown-mermaid/ui.expected.md +++ b/apps/web/tests/expected/markdown-mermaid/ui.expected.md @@ -1,17 +1,3 @@ -- banner: - - navigation "Session hierarchy": - - button "Mermaid previews" [disabled] - - button "Session log": - - text: Session log - - img - - button "Open the sidebar": - - img - - tablist: - - tab "Chat" [selected] - - tab "Trajectory" -- text: Preview these Mermaid diagrams. {{clock}} -- button "Copy": - - img - heading "Mermaid previews" [level=1] - button "Source" - button "Copy" @@ -27,26 +13,3 @@ - button "Source" - button "Copy" - img "Mermaid diagram" -- button "Copy": - - img -- button "Good response": - - img -- button "Bad response": - - img -- button "Branch into a new conversation": - - img -- button "Ran for {{duration}}": - - img - - text: Ran for {{duration}} -- text: {{clock}} -- textbox "Message or run a task... / commands, @ files or sessions" -- button "Commands": - - img -- button "Add attachment": - - img -- 'button "Access mode, current: Workspace Write"': Workspace Write -- button "Select model, current DeepSeek-V4-Flash": - - text: DeepSeek-V4-Flash - - img -- button "Send message" [disabled] -- text: 1 turns · 1 steps LLM {{duration}} diff --git a/apps/web/tests/expected/markdown-mermaid/zh.expected.md b/apps/web/tests/expected/markdown-mermaid/zh.expected.md index e3a3b84157..066e88f589 100644 --- a/apps/web/tests/expected/markdown-mermaid/zh.expected.md +++ b/apps/web/tests/expected/markdown-mermaid/zh.expected.md @@ -1,17 +1,3 @@ -- banner: - - navigation "会话层级": - - button "Mermaid previews" [disabled] - - button "Session 日志": - - text: Session 日志 - - img - - button "展开侧栏": - - img - - tablist: - - tab "对话" [selected] - - tab "轨迹" -- text: Preview these Mermaid diagrams. {{clock}} -- button "复制": - - img - heading "Mermaid previews" [level=1] - button "源码" - button "复制" @@ -26,26 +12,3 @@ - button "源码" - button "复制" - img "Mermaid 图表" -- button "复制": - - img -- button "好的回答": - - img -- button "有问题的回答": - - img -- button "在新对话中分支": - - img -- button "用时 {{duration}}": - - img - - text: 用时 {{duration}} -- text: {{clock}} -- textbox "发消息或做任务… / 调用指令 @ 文件或对话" -- button "指令": - - img -- button "添加附件": - - img -- button "访问模式,当前:工作区内修改": 工作区内修改 -- button "选择模型,当前 DeepSeek-V4-Flash": - - text: DeepSeek-V4-Flash - - img -- button "发送消息" [disabled] -- text: 1 轮 · 1 步 LLM {{duration}} diff --git a/apps/web/tests/markdown-mermaid.e2e.ts b/apps/web/tests/markdown-mermaid.e2e.ts index 928e6cbf40..82789caa63 100644 --- a/apps/web/tests/markdown-mermaid.e2e.ts +++ b/apps/web/tests/markdown-mermaid.e2e.ts @@ -15,6 +15,7 @@ import { newEnglishPage, saveFailureShot } from './support.ts' const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/markdown-mermaid', import.meta.url)) const MODE = webSnapshotMode() const SEED_ID = 'markdown-mermaid-web-e2e' +const DIAGRAM_MESSAGE = '[class*="markdown"]:has(.md-code-block)' const FLOW = 'flowchart LR\n A[输入] --> B[共享渲染器] --> C[图形预览]' const SEQUENCE = 'sequenceDiagram\n participant U as User\n participant R as Renderer\n U->>R: Mermaid source\n R-->>U: Diagram' const INVALID = 'flowchart LR\n A[unfinished' @@ -122,8 +123,7 @@ describe('web e2e: Mermaid chat previews', () => { expect(tripwire.warnings).toEqual([]) await page.getByRole('heading', { name: 'Mermaid previews' }).click() await page.mouse.move(0, 0) - const snapshot = (await captureStableAria(page, '[class*="centerCol"]', scaffold.workspaceCwd)) - .split(SEED_ID).join('{{seededId}}') + const snapshot = await captureStableAria(page, DIAGRAM_MESSAGE, scaffold.workspaceCwd) await compareOrRefreshGolden(join(SNAPSHOT_DIR, 'ui.expected.md'), snapshot, MODE) await page.close() }, 60_000) @@ -142,8 +142,7 @@ describe('web e2e: Mermaid chat previews', () => { await expect.poll(() => firstImage.evaluate(node => (node as HTMLImageElement).naturalWidth)).toBeGreaterThan(0) expect(await controls.evaluate(node => node.getBoundingClientRect().top)) .toBeGreaterThanOrEqual(await firstImage.evaluate(node => node.getBoundingClientRect().bottom)) - const snapshot = (await captureStableAria(page, '[class*="centerCol"]', scaffold.workspaceCwd)) - .split(SEED_ID).join('{{seededId}}') + const snapshot = await captureStableAria(page, DIAGRAM_MESSAGE, scaffold.workspaceCwd) await compareOrRefreshGolden(join(SNAPSHOT_DIR, 'zh.expected.md'), snapshot, MODE) await assertFixtureInventory(SNAPSHOT_DIR, ['ui.expected.md', 'zh.expected.md']) await page.close() From a8f9d81f3a68266f4d268b877fd2715697062c87 Mon Sep 17 00:00:00 2001 From: yudshj Date: Wed, 9 Sep 2026 12:18:09 +0800 Subject: [PATCH 06/32] feat(client): preview Graphviz, SVG, and HTML Markdown fences --- .../2026-09-07-web-mermaid-preview.i18n.yaml | 4 +- .../feature/2026-09-07-web-mermaid-preview.md | 2 + .../2026-09-07-web-mermaid-preview.zh.md | 2 + ...6-09-09-markdown-static-previews.i18n.yaml | 6 + .../2026-09-09-markdown-static-previews.md | 31 + .../2026-09-09-markdown-static-previews.zh.md | 31 + THIRD_PARTY_NOTICES.md | 4 + .../expected/markdown-mermaid/ui.expected.md | 9 + .../expected/markdown-mermaid/zh.expected.md | 9 + apps/web/tests/markdown-mermaid.e2e.ts | 55 +- apps/web/vite.config.ts | 16 +- packages/client/locale/src/locales/en.ts | 5 + packages/client/locale/src/locales/zh.ts | 5 + packages/client/ui-chat/README.i18n.yaml | 4 +- packages/client/ui-chat/README.md | 2 +- packages/client/ui-chat/README.zh.md | 2 +- .../ui-chat/src/client/markdown-labels.ts | 9 + .../client/ui-primitives/README.i18n.yaml | 4 +- packages/client/ui-primitives/README.md | 6 +- packages/client/ui-primitives/README.zh.md | 6 +- .../THIRD_PARTY_PREVIEW_NOTICES.txt | 688 ++++++++++++++++++ packages/client/ui-primitives/package.json | 5 +- .../src/markdown/MermaidPreview.module.css | 9 + .../src/markdown/MermaidPreview.tsx | 52 +- .../src/markdown/SourcePreview.tsx | 56 ++ .../ui-primitives/src/markdown/graphviz.ts | 22 + .../src/markdown/preview-document.ts | 44 ++ .../ui-primitives/src/markdown/render.tsx | 41 +- .../tests/fence-previews.client.spec.tsx | 103 +++ .../tests/graphviz-runtime.client.spec.ts | 35 + pnpm-lock.yaml | 11 + scripts/check-workspace-constraints.spec.ts | 14 + scripts/check-workspace-constraints.ts | 2 +- scripts/gen-third-party-notices.spec.ts | 24 + scripts/gen-third-party-notices.ts | 34 + 35 files changed, 1290 insertions(+), 62 deletions(-) create mode 100644 .agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml create mode 100644 .agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md create mode 100644 .agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md create mode 100644 packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt create mode 100644 packages/client/ui-primitives/src/markdown/SourcePreview.tsx create mode 100644 packages/client/ui-primitives/src/markdown/graphviz.ts create mode 100644 packages/client/ui-primitives/src/markdown/preview-document.ts create mode 100644 packages/client/ui-primitives/tests/fence-previews.client.spec.tsx create mode 100644 packages/client/ui-primitives/tests/graphviz-runtime.client.spec.ts diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml index f86ae95548..190b6ffb3e 100644 --- a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml +++ b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md -2026-09-07-web-mermaid-preview.md: 811f688713491333587404d32946317d81ff2795 -2026-09-07-web-mermaid-preview.zh.md: 0fdb9cf318561f20fdb7042121bc3517c4d6c9a0 +2026-09-07-web-mermaid-preview.md: 246b38e764e1e5812427f935c4a41c28f0fa24a0 +2026-09-07-web-mermaid-preview.zh.md: c1dd25c1b6dc21c36d92e0d7c1477fcea9ae99c2 diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md index 811f688713..246b38e764 100644 --- a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md +++ b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md @@ -26,6 +26,8 @@ Source replacement and unmounting cancel result publication. Cancellation before **Insert interactive SVG into the message.** The requested preview needs diagram display and source access. Displaying the result as an image keeps diagram links and event handlers inactive. +The [static fence preview decision](2026-09-09-markdown-static-previews.md) owns Graphviz, SVG, and HTML sandboxing and shared preview license distribution. + ## Consequences The feature changes presentation without changing persisted messages, provider requests, tools, or Host APIs. Mermaid adds lazily loaded browser assets. Rendering still runs on the browser thread, and work already handed to the library cannot be interrupted. The initial feature has no editing, export, zoom controls, or interactive diagram links. diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md index 0fdb9cf318..c1dd25c1b6 100644 --- a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md +++ b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md @@ -26,6 +26,8 @@ Mermaid 按需加载。它的公开 render API 串行执行图表工作,每次 **把可交互 SVG 插入消息。** 此次预览需求只需要图表显示与源码访问。将结果显示为图片后,图内链接和事件处理器不会生效。 +[静态 fence 预览决策](2026-09-09-markdown-static-previews.zh.md)负责 Graphviz、SVG、HTML 的 sandbox 及共享预览许可证分发。 + ## 后果 功能只改变展示,不改变持久化消息、提供者请求、工具或 Host API。Mermaid 增加按需加载的浏览器资源。渲染仍在浏览器线程上执行,已交给库的工作无法中断。首版不包含编辑、导出、缩放控件或可交互图内链接。 diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml new file mode 100644 index 0000000000..6cb3a179eb --- /dev/null +++ b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml @@ -0,0 +1,6 @@ +# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each +# side as of the last confirmed-consistent state. Both languages carry equal authority; +# after editing either side, bring the other along and re-record with: +# pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md +2026-09-09-markdown-static-previews.md: fd3772cabc2160f07e79b06dffa4374fe104cbd1 +2026-09-09-markdown-static-previews.zh.md: 92f4b030879acaeb484eed33e078574750a1801e diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md new file mode 100644 index 0000000000..fd3772cabc --- /dev/null +++ b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md @@ -0,0 +1,31 @@ +# Agent Note: Static Markdown fence previews + +Status: implemented + +English | [中文](2026-09-09-markdown-static-previews.zh.md) + +## Problem + +Readers need to see DOT diagrams, SVG artwork, and HTML examples directly in Assistant replies. These sources are untrusted, and a renderer's npm license field may omit compiled components with separate distribution obligations. + +## Decision + +The shared Markdown renderer enables settled `graphviz`/`dot`, `svg`, and `html` fences through localized `MarkdownLabels.preview`. `CodeBlock.preview` owns default visualization, source switching, and verbatim copying. `SourcePreview` owns loading, failure, and cancellation of stale result publication for both these documents and the [Mermaid preview](2026-09-07-web-mermaid-preview.md). Consumers without preview labels and streaming messages retain code. + +HTML uses DOMPurify with navigation attributes and document-loading elements forbidden, followed by an opaque `sandbox=""` iframe. A trusted CSP precedes source markup and permits only inline CSS, data images, and data fonts. Scripts, external resources, child frames, form submission, and same-origin access are unavailable. SVG is parsed as XML and placed in an image inside the frame, so SVG scripts and links never become active. Frames have a fixed scrollable viewport: measuring their content would require additional origin access or trusted frame scripts. Mermaid keeps its existing strict renderer and inert image presentation. + +Graphviz uses the pinned, unmodified `@viz-js/viz` 3.30.0 WebAssembly distribution with the `dot` layout engine. Its npm MIT declaration covers the wrapper; its build provenance identifies Graphviz 16.0.0 (EPL-2.0), Expat 2.8.4 (MIT), and Emscripten 5.0.7 (MIT/NCSA). Distribution retains these component terms and the exact Graphviz source download under EPL-2.0 section 3.1. [Full preview notices](../../../../packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt) also retain Mermaid's MIT text and select Apache-2.0 for DOMPurify. The UI primitives package ships the notices and the Web build emits the same bytes alongside its assets. License review covers embedded payloads separately from the general permissive npm-metadata policy. + +## Alternatives considered + +**Execute HTML scripts in a frame.** Static chat examples do not need script execution. An empty sandbox plus sanitization and CSP gives the preview fewer capabilities and avoids introducing a frame messaging protocol. + +**Insert rendered markup into Chat.** HTML styles and executable SVG would share the application document. Iframes isolate layout and origin; SVG image mode additionally disables SVG behavior. + +**Treat Viz.js as MIT-only or use a remote Graphviz service.** The compiled Graphviz license still applies locally; a remote renderer would send conversation content off-device. The bundled renderer retains source availability and legal notices without network rendering. + +## Consequences + +No Session event, prompt, or tool changes. Inline HTML styles work, while interactive scripts, external assets, and links do not. Graphviz adds a lazy WebAssembly asset and synchronous browser-thread layout; source cancellation prevents publication but cannot preempt active layout. Mermaid's existing layout limitations remain documented in its owning note. + +Component tests cover source copying, default preview, fallback, cancellation, and recovery. The keyless [browser scenario](../../../../apps/web/tests/markdown-mermaid.e2e.ts) verifies opaque frames, real image decoding, source toggling, blocked script/navigation/resource attempts, locale snapshots, and served license text. Notices checks pin the reviewed wrapper and native provenance so upgrades require renewed review. diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md new file mode 100644 index 0000000000..92f4b03087 --- /dev/null +++ b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md @@ -0,0 +1,31 @@ +# Agent Note: 静态 Markdown fence 预览 + +Status: implemented + +[English](2026-09-09-markdown-static-previews.md) | 中文 + +## Problem + +读者需要直接在 Assistant 回复中查看 DOT 图表、SVG 图像和 HTML 示例。这些源码不可信,而渲染器的 npm 许可证字段可能遗漏编译组件各自的分发义务。 + +## Decision + +共享 Markdown 渲染器通过本地化的 `MarkdownLabels.preview` 启用定稿后的 `graphviz`/`dot`、`svg` 和 `html` fence。`CodeBlock.preview` 负责默认可视化、源码切换与原样复制。`SourcePreview` 为这些文档及 [Mermaid 预览](2026-09-07-web-mermaid-preview.zh.md)负责加载、失败和取消过期结果发布。未提供预览文案的调用方与流式消息保留代码显示。 + +HTML 先由 DOMPurify 清理,禁止导航属性与文档加载元素,再进入不透明来源的 `sandbox=""` iframe。可信 CSP 位于源码标记之前,仅允许内联 CSS、data 图片与 data 字体。脚本、外部资源、子 iframe、表单提交与同源访问均不可用。SVG 按 XML 解析后作为图片放进 iframe,因此 SVG 脚本与链接不会激活。iframe 使用固定的可滚动视口:测量内容需要额外的来源访问权限或可信 iframe 脚本。Mermaid 保留既有的严格渲染器与不可执行图片展示。 + +Graphviz 使用固定且未修改的 `@viz-js/viz` 3.30.0 WebAssembly 发布包,布局引擎为 `dot`。其 npm MIT 声明覆盖包装层;构建来源记录标明 Graphviz 16.0.0(EPL-2.0)、Expat 2.8.4(MIT)与 Emscripten 5.0.7(MIT/NCSA)。分发保留各组件条款,并按 EPL-2.0 第 3.1 节提供准确的 Graphviz 源码下载地址。[完整预览声明](../../../../packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt)还保留 Mermaid 的 MIT 文本,并为 DOMPurify 选择 Apache-2.0。UI primitives 包携带该声明,Web 构建在资源旁输出相同字节。内嵌产物的许可证检查独立于通用的宽松 npm 元数据策略。 + +## Alternatives considered + +**在 iframe 内执行 HTML 脚本。** 静态聊天示例不需要脚本执行。空 sandbox、清理与 CSP 降低预览权限,也避免引入 iframe 消息协议。 + +**把渲染标记插入 Chat。** HTML 样式和可执行 SVG 会与应用共享文档。iframe 隔离布局与来源,SVG 图片模式额外禁用 SVG 行为。 + +**将 Viz.js 视为仅使用 MIT,或使用远程 Graphviz 服务。** 本地编译的 Graphviz 仍受其许可证约束;远程渲染会把对话内容发送到设备之外。内置渲染器保留源码可获取性与法律声明,无需网络渲染。 + +## Consequences + +不改变 Session 事件、提示词或工具。HTML 内联样式可用,交互脚本、外部资源和链接不可用。Graphviz 增加按需加载的 WebAssembly 资源与浏览器线程同步布局;源码取消可以阻止结果发布,但无法抢占进行中的布局。Mermaid 既有布局限制仍记录在其所属决策中。 + +组件测试覆盖源码复制、默认预览、回退、取消与恢复。无密钥[浏览器场景](../../../../apps/web/tests/markdown-mermaid.e2e.ts)验证不透明来源 iframe、真实图片解码、源码切换、脚本/导航/资源请求被阻止、本地化快照和已提供的许可证文本。声明检查固定已审查的包装层与原生构建来源,升级时须重新审查。 diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index c2705ac530..2452325d62 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -55,6 +55,7 @@ External packages installed for runtime use or distributed inside the prebuilt b | [`@shikijs/langs`](https://github.com/shikijs/shiki) | MIT | | [`@standard-schema/spec`](https://github.com/standard-schema/standard-schema) | MIT | | [`@tanstack/react-virtual`](https://github.com/TanStack/virtual) | MIT | +| [`@viz-js/viz`](https://github.com/mdaines/viz-js) | MIT | | [`@vscode/ripgrep`](https://github.com/microsoft/vscode-ripgrep) | MIT | | [`@xterm/headless`](https://github.com/xtermjs/xterm.js) | MIT | | [`@yarnpkg/parsers`](https://github.com/yarnpkg/berry) | BSD-2-Clause | @@ -66,6 +67,7 @@ External packages installed for runtime use or distributed inside the prebuilt b | [`commander`](https://github.com/tj/commander.js) | MIT | | [`compression`](https://github.com/expressjs/compression) | MIT | | [`diff`](https://github.com/kpdecker/jsdiff) | BSD-3-Clause | +| [`dompurify`](https://github.com/cure53/DOMPurify) | (MPL-2.0 OR Apache-2.0) | | [`e2b`](https://github.com/e2b-dev/e2b) | MIT | | [`electron-updater`](https://github.com/electron-userland/electron-builder) | MIT | | [`eventsource-parser`](https://github.com/rexxars/eventsource-parser) | MIT | @@ -113,6 +115,8 @@ External packages installed for runtime use or distributed inside the prebuilt b | [`zod`](https://github.com/colinhacks/zod) | MIT | | [`zustand`](https://github.com/pmndrs/zustand) | MIT | +The Markdown preview distribution also contains Graphviz 16.0.0 (EPL-2.0), Expat 2.8.4 (MIT), and Emscripten 5.0.7 runtime code (MIT/NCSA) inside `@viz-js/viz` 3.30.0. The wrapper's MIT metadata does not relicense these components. [Preview notices](packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt) preserve their full license texts and Graphviz source availability, together with Mermaid's MIT and DOMPurify's selected Apache-2.0 terms. The UI primitives npm package includes this file; the Web build emits it as `preview-third-party-notices.txt`. + pnpm applies local patches to the following packages at install time, so shipped artifacts carry modified copies; each patch file is the complete record of the modification: - `@yao-pkg/pkg@6.21.0` — [`patches/@yao-pkg__pkg@6.21.0.patch`](patches/@yao-pkg__pkg@6.21.0.patch) diff --git a/apps/web/tests/expected/markdown-mermaid/ui.expected.md b/apps/web/tests/expected/markdown-mermaid/ui.expected.md index ac9ceb3164..369f0ef21d 100644 --- a/apps/web/tests/expected/markdown-mermaid/ui.expected.md +++ b/apps/web/tests/expected/markdown-mermaid/ui.expected.md @@ -13,3 +13,12 @@ - button "Source" - button "Copy" - img "Mermaid diagram" +- button "Source" +- button "Copy" +- iframe +- button "Source" +- button "Copy" +- iframe +- button "Source" +- button "Copy" +- iframe diff --git a/apps/web/tests/expected/markdown-mermaid/zh.expected.md b/apps/web/tests/expected/markdown-mermaid/zh.expected.md index 066e88f589..74a348e8be 100644 --- a/apps/web/tests/expected/markdown-mermaid/zh.expected.md +++ b/apps/web/tests/expected/markdown-mermaid/zh.expected.md @@ -12,3 +12,12 @@ - button "源码" - button "复制" - img "Mermaid 图表" +- button "源码" +- button "复制" +- iframe +- button "源码" +- button "复制" +- iframe +- button "源码" +- button "复制" +- iframe diff --git a/apps/web/tests/markdown-mermaid.e2e.ts b/apps/web/tests/markdown-mermaid.e2e.ts index 82789caa63..c009e1d836 100644 --- a/apps/web/tests/markdown-mermaid.e2e.ts +++ b/apps/web/tests/markdown-mermaid.e2e.ts @@ -26,6 +26,15 @@ const UNTRUSTED = [ ' click B "javascript:alert(1)"', ].join('\n') +const DOT = 'digraph { rankdir=LR; Input -> Preview }' +const SVG = 'SVG preview' +const HTML = `

Static HTML

+ + +Disabled navigation + +` + function fixture(): string { const session = Session.create(SessionId('markdown-mermaid-source')) session.append('turn/start', { turn: 1 }) @@ -41,6 +50,7 @@ function fixture(): string { content: [{ type: 'text', text: [ '# Mermaid previews', ...[FLOW, SEQUENCE, INVALID, UNTRUSTED].map(code => `\`\`\`mermaid\n${code}\n\`\`\``), + ...[['dot', DOT], ['svg', SVG], ['html', HTML]].map(([lang, code]) => `\`\`\`${lang}\n${code}\n\`\`\``), ].join('\n\n') }], source: { kind: 'model', provider: 'fixture', model: 'fixture' }, }), @@ -132,7 +142,7 @@ describe('web e2e: Mermaid chat previews', () => { const page = await browser.newPage({ viewport: { width: 1680, height: 1000 }, locale: 'zh-CN', timezoneId: 'Asia/Shanghai', hasTouch: true }) await openConversation(page, scaffold) await expect.poll(() => page.getByRole('img', { name: 'Mermaid 图表' }).count(), { timeout: 20_000 }).toBe(3) - expect(await page.getByRole('button', { name: '源码', exact: true }).count()).toBe(4) + expect(await page.getByRole('button', { name: '源码', exact: true }).count()).toBe(7) const controls = page.locator('.md-code-block').first().locator('[class*="bannerWrap"]') expect(await controls.evaluate(node => getComputedStyle(node).opacity)).toBe('1') expect(await page.getByRole('button', { name: '源码', exact: true }).first() @@ -148,6 +158,49 @@ describe('web e2e: Mermaid chat previews', () => { await page.close() }, 60_000) + it.skipIf(MODE === 'record')('previews DOT, SVG, and static HTML inside isolated frames', async () => { + const page = await newEnglishPage(browser) + const requests: string[] = [] + const dialogs: string[] = [] + // Routing observes requests eligible for transport; Chromium also emits 'request' for CSP-blocked URLs. + await page.route('https://preview.invalid/**', async (route) => { + requests.push(route.request().url()) + await route.abort() + }) + page.on('dialog', (dialog) => { dialogs.push(dialog.message()); void dialog.dismiss() }) + await page.context().grantPermissions(['clipboard-read', 'clipboard-write']) + await openConversation(page, scaffold) + for (const [title, code] of [['Graphviz diagram', DOT], ['SVG preview', SVG], ['HTML preview', HTML]]) { + const frame = page.locator(`iframe[title="${title}"]`) + await frame.waitFor() + expect(await frame.getAttribute('sandbox')).toBe('') + const body = frame.contentFrame() + if (title === 'HTML preview') { + await body.getByRole('heading', { name: 'Static HTML' }).waitFor() + expect(await body.getByRole('heading').evaluate(node => getComputedStyle(node).color)).toBe('rgb(0, 128, 0)') + await body.getByText('Disabled navigation').click() + expect(await frame.evaluate(node => (node as HTMLIFrameElement).contentDocument)).toBeNull() + } else { + await expect.poll(() => body.locator('img').evaluate(node => (node as HTMLImageElement).naturalWidth)).toBeGreaterThan(0) + } + const block = page.locator('.md-code-block').filter({ has: frame }) + await block.hover() + await block.getByRole('button', { name: 'Copy', exact: true }).click() + expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(code) + await block.getByRole('button', { name: 'Source', exact: true }).click() + expect(await block.locator('pre code').textContent()).toBe(code) + await block.getByRole('button', { name: 'Preview', exact: true }).click() + expect(await frame.isVisible()).toBe(true) + } + expect(await page.locator('body').getAttribute('data-preview-escaped')).toBeNull() + expect(dialogs).toEqual([]) + expect(requests).toEqual([]) + const notices = await page.request.get(new URL('/preview-third-party-notices.txt', scaffold.authenticatedUrl).href) + expect(notices.ok()).toBe(true) + expect(await notices.text()).toContain('Eclipse Public License - v 2.0') + await page.close() + }) + it.skipIf(MODE === 'record')('keeps actions visible when a mouse and touchscreen are both available', async () => { const hybridBrowser = await chromium.launch({ args: ['--blink-settings=availablePointerTypes=6,primaryPointerType=4,availableHoverTypes=2,primaryHoverType=2'], diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts index 0e15b4f088..f6c90861f1 100644 --- a/apps/web/vite.config.ts +++ b/apps/web/vite.config.ts @@ -27,6 +27,20 @@ function clientDocumentTitle(): Plugin { } } +/** Preserve preview licenses and Graphviz source availability in every browser distribution. */ +function previewNotices(): Plugin { + return { + name: 'dsh-preview-notices', + async generateBundle() { + this.emitFile({ + type: 'asset', + fileName: 'preview-third-party-notices.txt', + source: await readFile(src('../../packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt'), 'utf8'), + }) + }, + } +} + /** Fail before a Vite dev or preview server can expose the boot-manifest-free shell. */ function rejectStandaloneServe(): Plugin { return { @@ -147,7 +161,7 @@ export default defineConfig({ // Relative asset URLs: preview.html mounts the same output under any base // directory, and the served index resolves identically from the site root. base: './', - plugins: [rejectStandaloneServe(), clientDocumentTitle(), react(), emitPreviewPage()], + plugins: [previewNotices(), rejectStandaloneServe(), clientDocumentTitle(), react(), emitPreviewPage()], build: { // The worker bootstrap holds its page at top-level await; Vite's default // `modules` target (es2020-era) rejects that syntax. diff --git a/packages/client/locale/src/locales/en.ts b/packages/client/locale/src/locales/en.ts index 6261002e3a..1d97566db1 100644 --- a/packages/client/locale/src/locales/en.ts +++ b/packages/client/locale/src/locales/en.ts @@ -38,6 +38,11 @@ export const en = { 'json.expandNode': 'Expand JSON node', 'json.label': 'JSON', 'markdown.footnotes': 'Footnotes', + 'markdown.preview.graphviz': 'Graphviz diagram', + 'markdown.preview.svg': 'SVG preview', + 'markdown.preview.html': 'HTML preview', + 'markdown.preview.loading': 'Rendering preview…', + 'markdown.preview.error': 'Unable to render this preview. The source is shown below.', 'markdown.mermaid.diagram': 'Mermaid diagram', 'markdown.mermaid.preview': 'Preview', 'markdown.mermaid.source': 'Source', diff --git a/packages/client/locale/src/locales/zh.ts b/packages/client/locale/src/locales/zh.ts index 9a03ac9b7f..a799548c28 100644 --- a/packages/client/locale/src/locales/zh.ts +++ b/packages/client/locale/src/locales/zh.ts @@ -36,6 +36,11 @@ export const zh = { 'json.expandNode': '展开 JSON 节点', 'json.label': 'JSON', 'markdown.footnotes': '脚注', + 'markdown.preview.graphviz': 'Graphviz 图表', + 'markdown.preview.svg': 'SVG 预览', + 'markdown.preview.html': 'HTML 预览', + 'markdown.preview.loading': '正在渲染预览…', + 'markdown.preview.error': '无法渲染此预览,源码如下。', 'markdown.mermaid.diagram': 'Mermaid 图表', 'markdown.mermaid.preview': '预览', 'markdown.mermaid.source': '源码', diff --git a/packages/client/ui-chat/README.i18n.yaml b/packages/client/ui-chat/README.i18n.yaml index 386c06ea91..554709bb19 100644 --- a/packages/client/ui-chat/README.i18n.yaml +++ b/packages/client/ui-chat/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-chat/README.md -README.md: 951f88e5fa61a27802fb7df11a3347ba9676a66c -README.zh.md: 3a180afb43c4262d6054e1f19deefa490b9b36de +README.md: 1bd7f008e46b695899c703c928ebe8bb76fbe4c8 +README.zh.md: 5919622396dde5b0c8cbf51f71999672a11f13ec diff --git a/packages/client/ui-chat/README.md b/packages/client/ui-chat/README.md index 951f88e5fa..1bd7f008e4 100644 --- a/packages/client/ui-chat/README.md +++ b/packages/client/ui-chat/README.md @@ -33,7 +33,7 @@ Each nonempty appended `system/message` owns a collapsed prompt row, including a ## Mermaid previews -Settled Assistant Markdown shows `mermaid` code fences as diagrams. Diagrams have no language banner. Source/Preview and Copy icon actions appear on hover or keyboard focus and remain visible on touch devices; both views copy the original Mermaid source. Streaming fences remain code until the message settles; invalid diagrams show an error and their source without disrupting other blocks. Chat enables the shared [Mermaid preview primitive](../ui-primitives/README.md) through localized labels. This is a presentation change and adds no model prompt, tool, or Session event. +Settled Assistant Markdown shows `mermaid` code fences as diagrams. Diagrams have no language banner. Source/Preview and Copy icon actions appear on hover or keyboard focus and remain visible on touch devices; both views copy the original Mermaid source. Streaming fences remain code until the message settles; invalid diagrams show an error and their source without disrupting other blocks. Chat enables the shared [Mermaid preview primitive](../ui-primitives/README.md) through localized labels. Chat also previews `graphviz`/`dot`, `svg`, and static `html` fences in isolated iframes, with the same default visualization, source switching, and copying. HTML scripts, navigation, and remote resources are disabled. This is a presentation change and adds no model prompt, tool, or Session event. ----- diff --git a/packages/client/ui-chat/README.zh.md b/packages/client/ui-chat/README.zh.md index 3a180afb43..5919622396 100644 --- a/packages/client/ui-chat/README.zh.md +++ b/packages/client/ui-chat/README.zh.md @@ -35,7 +35,7 @@ kind: "package-reference" ## Mermaid 预览 -已定稿的 Assistant Markdown 把 `mermaid` 代码 fence 显示为图表。图表不显示语言标题栏。源码/预览切换与复制图标在悬停或键盘聚焦时出现,触屏上保持可见;两种视图复制的都是原始 Mermaid 源码。流式 fence 在消息定稿前保持代码显示;非法图表显示错误与源码,不影响其他块。Chat 通过本地化 label 启用共享的 [Mermaid 预览原语](../ui-primitives/README.zh.md)。这项展示变更不增加模型提示词、工具或 Session 事件。 +已定稿的 Assistant Markdown 把 `mermaid` 代码 fence 显示为图表。图表不显示语言标题栏。源码/预览切换与复制图标在悬停或键盘聚焦时出现,触屏上保持可见;两种视图复制的都是原始 Mermaid 源码。流式 fence 在消息定稿前保持代码显示;非法图表显示错误与源码,不影响其他块。Chat 通过本地化 label 启用共享的 [Mermaid 预览原语](../ui-primitives/README.zh.md)。Chat 还在隔离 iframe 中预览 `graphviz`/`dot`、`svg` 和静态 `html` fence,共用默认可视化、源码切换与复制操作。HTML 脚本、导航与远程资源均被禁用。这项展示变更不增加模型提示词、工具或 Session 事件。 ----- diff --git a/packages/client/ui-chat/src/client/markdown-labels.ts b/packages/client/ui-chat/src/client/markdown-labels.ts index d42e6e5f83..ea70175c57 100644 --- a/packages/client/ui-chat/src/client/markdown-labels.ts +++ b/packages/client/ui-chat/src/client/markdown-labels.ts @@ -12,6 +12,15 @@ export function markdownLabels(t: ChatViewSlotProps['t']): MarkdownLabels { return { code: { copyLabel: t('copy'), copiedLabel: t('copied') }, footnotes: t('markdown.footnotes'), + preview: { + graphviz: t('markdown.preview.graphviz'), + svg: t('markdown.preview.svg'), + html: t('markdown.preview.html'), + preview: t('markdown.mermaid.preview'), + source: t('markdown.mermaid.source'), + loading: t('markdown.preview.loading'), + error: t('markdown.preview.error'), + }, mermaid: { diagram: t('markdown.mermaid.diagram'), preview: t('markdown.mermaid.preview'), diff --git a/packages/client/ui-primitives/README.i18n.yaml b/packages/client/ui-primitives/README.i18n.yaml index a0fd81c2bc..bdd6417054 100644 --- a/packages/client/ui-primitives/README.i18n.yaml +++ b/packages/client/ui-primitives/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-primitives/README.md -README.md: 0ba4d6baaa54bbacc82202c490423b37613874df -README.zh.md: 06a266b61a79d4ff5e38ca0de9877a6d8ec66af0 +README.md: a1e877c5249817c7ab2e9fa1f6a8ad9582c44a3a +README.zh.md: 81923da65cc21f794d2e7f5d822feb69c06f7499 diff --git a/packages/client/ui-primitives/README.md b/packages/client/ui-primitives/README.md index 0ba4d6baaa..a1e877c524 100644 --- a/packages/client/ui-primitives/README.md +++ b/packages/client/ui-primitives/README.md @@ -78,6 +78,10 @@ The catalog above lists what each export is for; this section covers the behavio Supply `MarkdownLabels.mermaid` to enable `mermaid` fence previews in a Markdown consumer; without it, fences remain code. Previews start after the message settles. `CodeBlock.preview` supplies an optional headerless body with icon actions for source switching and copying. Actions appear on hover or keyboard focus, and stay visible below the diagram whenever a touchscreen is available, including with a mouse attached. Switching to source keeps the preview mounted, so returning reuses its result; copying always retains the source. [The Mermaid decision](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md) records the rendering and reuse choices. +Supply `MarkdownLabels.preview` to enable `graphviz`/`dot`, `svg`, and `html` fences. Each settled fence defaults to visualization and shares the source/copy controls. Graphviz loads `@viz-js/viz` on demand and renders DOT with the `dot` engine. SVG and Graphviz output are inert images inside opaque sandbox iframes; malformed SVG and DOT retain their source with an error. HTML accepts complete documents or fragments and preserves inline styles, but strips scripts and navigation. Frames have no sandbox permissions, and their Content Security Policy blocks external resources, embedded frames, forms, and scripts. Frames use a 400px scrollable viewport. Raw HTML outside a code fence remains ordinary Markdown input. + +[Preview license notices](THIRD_PARTY_PREVIEW_NOTICES.txt) ship with this package and the Web frontend. Mermaid is MIT; Viz.js is MIT but embeds Graphviz under EPL-2.0. The notices retain license texts and the exact Graphviz source download. Dependency upgrades require reviewing the embedded payload as well as npm metadata; the [preview decision](../../../.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md) records the distribution and sandbox choices. + ### Localizing copy The atoms cannot read the application locale, so every piece of user-facing copy arrives through required label props. `HoverCard`, `TerminalBlock`, `JsonTree`, `CodeBlock`, `MarkdownText`, `JsonBlock`, `ConnectionIndicator`, `Modal`, `DiffBlock`, `ReadBlock`, `SearchBlock`, and `WebBlock` accept complete localized labels. The package owns no language fallback; omission fails typechecking, and each feature maps its typed `t` seat into the primitive's label interface. @@ -145,7 +149,7 @@ None; this package neither assembles nor sends a provider request. These limits define how the atoms behave at the edges; they are current package constraints, not a component roadmap. -- **Mermaid rendering runs on the browser thread** — every mounted settled preview starts rendering, including off-screen diagrams. Mermaid serializes layouts; work already submitted to it cannot be interrupted. Preview virtualization and worker rendering are not provided. +- **Diagram rendering runs on the browser thread** — every mounted settled preview starts rendering, including off-screen diagrams. Mermaid serializes layouts; Graphviz performs synchronous WebAssembly layout. Submitted layout work cannot be interrupted. Preview virtualization and worker rendering are not provided. - **Streaming defers cross-boundary reference resolution** — a reference-style link or footnote whose definition sits on the other side of the incremental freeze boundary renders as literal text while the reply streams; the settled full parse at finalize resolves it. - **A long highlighted fence retains its complete token DOM** — streaming avoids re-parsing, re-tokenizing, and reconciling the completed prefix, but it does not discard old colors or virtualize token spans. Final DOM cardinality therefore still follows the fence's token count; nested/container fences and a pathological single long line remain on the general tail path. - **Glyph-level icons are redrawn approximations** — the fish logo and the sparkle mark come from font glyphs whose vector geometry is not exportable from the local design data; hand-authored recreations stand in until an exact export path exists. diff --git a/packages/client/ui-primitives/README.zh.md b/packages/client/ui-primitives/README.zh.md index 06a266b61a..81923da65c 100644 --- a/packages/client/ui-primitives/README.zh.md +++ b/packages/client/ui-primitives/README.zh.md @@ -78,6 +78,10 @@ kind: "package-library" 为 Markdown 调用方传入 `MarkdownLabels.mermaid` 即可启用 `mermaid` fence 预览;未传入时,fence 保持代码显示。预览在消息定稿后开始。`CodeBlock.preview` 提供无标题栏的替代正文,以及切换源码和复制的图标操作。操作在悬停或键盘聚焦时出现;只要设备具备触屏,就在图表下方保持可见,包括同时连接鼠标的情况。切换到源码时保留已挂载的预览,返回时复用其结果;复制始终保留源码。[Mermaid 决策](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md)记录了渲染与复用选择。 +传入 `MarkdownLabels.preview` 可启用 `graphviz`/`dot`、`svg` 和 `html` fence。每个定稿 fence 默认显示可视化,并共享源码切换与复制操作。Graphviz 按需加载 `@viz-js/viz`,用 `dot` 引擎渲染 DOT。SVG 与 Graphviz 输出作为不可执行的图片放入不透明来源的 sandbox iframe;非法 SVG 与 DOT 显示错误并保留源码。HTML 接受完整文档或片段、保留内联样式,同时移除脚本与导航。iframe 不授予任何 sandbox 权限,Content Security Policy 阻止外部资源、嵌套 iframe、表单与脚本。iframe 使用可滚动的 400px 视口。代码 fence 外的原始 HTML 仍按普通 Markdown 输入处理。 + +[预览许可证声明](THIRD_PARTY_PREVIEW_NOTICES.txt)随本包与 Web 前端分发。Mermaid 使用 MIT;Viz.js 使用 MIT,但内嵌 Graphviz 使用 EPL-2.0。声明保留完整许可证文本及准确的 Graphviz 源码下载地址。升级依赖时必须同时检查内嵌产物和 npm 元数据;[预览决策](../../../.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md)记录分发与 sandbox 选择。 + ### 本地化文案 这些原子组件无法读取应用 locale,因此每段面向用户的文案都必须通过 label prop 提供。`HoverCard`、`TerminalBlock`、`JsonTree`、`CodeBlock`、`MarkdownText`、`JsonBlock`、`ConnectionIndicator`、`Modal`、`DiffBlock`、`ReadBlock`、`SearchBlock` 与 `WebBlock` 接收完整的本地化 label。本包不拥有语言回退;遗漏会导致类型检查失败,各功能会把带类型的 `t` 席位映射到 primitive 的 label 接口。 @@ -145,7 +149,7 @@ kind: "package-library" 这些限制说明原子组件在边缘情况下的行为;它们是当前包约束,不是组件路线图。 -- **Mermaid 渲染在浏览器线程上执行**:每个已挂载的定稿预览都会开始渲染,包括视口外的图表。Mermaid 串行执行布局,已提交给它的工作无法中断。当前不提供预览虚拟化或 worker 渲染。 +- **图表渲染在浏览器线程上执行**:每个已挂载的定稿预览都会开始渲染,包括视口外的图表。Mermaid 串行执行布局;Graphviz 同步执行 WebAssembly 布局。已提交的布局工作无法中断。当前不提供预览虚拟化或 worker 渲染。 - **流式期间跨边界引用解析被推迟**:定义落在增量冻结边界另一侧的引用式链接或脚注,在回复流式输出期间渲染为字面文本;定稿时的全量解析会将其解析。 - **长高亮 fence 会保留完整 token DOM**:流式路径避免重新解析、重新 tokenize 和 reconcile 已完成前缀,但不会丢弃旧颜色或虚拟化 token span。因此最终 DOM 数量仍随 fence 的 token 数增长;嵌套/容器内 fence 与病态的单个超长行仍走通用尾部路径。 - **字形级图标是重新绘制的近似版本**:鱼形标志与闪光标记来自字体字形,而本地设计数据无法导出其矢量几何;在获得精确导出路径前,使用手工重建版本代替。 diff --git a/packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt b/packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt new file mode 100644 index 0000000000..3e1156a536 --- /dev/null +++ b/packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt @@ -0,0 +1,688 @@ +Markdown preview third-party notices + +Mermaid 11.16.0: MIT; source https://github.com/mermaid-js/mermaid/tree/mermaid%4011.16.0 +@viz-js/viz 3.30.0: MIT JavaScript wrapper; source and build instructions: +https://github.com/mdaines/viz-js/tree/99da545270e6e7b127a5c7ba65974b8a604a6358 + +The Viz.js WebAssembly payload contains Graphviz 16.0.0 under EPL-2.0, +Expat 2.8.4 under MIT, and Emscripten 5.0.7 runtime code under MIT/NCSA. +Graphviz remains under EPL-2.0; it is not relicensed as MIT by DeepSeek Harness. +Graphviz source code is available under EPL-2.0 at: +https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/16.0.0/graphviz-16.0.0.tar.gz +SHA-256: 36a1de1aaf5a2023b14f95170a5f8f0b12522d1c305b517fc261966597050749 +Viz.js's backend build instructions and additions are available at the commit above. +DeepSeek Harness uses the unmodified upstream Viz.js package. + +Expat source: https://github.com/libexpat/libexpat/tree/R_2_8_4 +Emscripten source: https://github.com/emscripten-core/emscripten/tree/5.0.7 +DOMPurify 3.4.11: Apache-2.0 OR MPL-2.0; this distribution selects Apache-2.0. +Source: https://github.com/cure53/DOMPurify/tree/3.4.11 + +The following license texts and copyright notices apply to their respective components. + + +===== Mermaid ===== + +The MIT License (MIT) + +Copyright (c) 2014 - 2022 Knut Sveidqvist + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +===== Viz.js ===== + +MIT License + +Copyright (c) Michael Daines + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +===== Graphviz ===== + +Eclipse Public License - v 2.0 + + THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE + PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION + OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + + a) in the case of the initial Contributor, the initial content + Distributed under this Agreement, and + + b) in the case of each subsequent Contributor: + i) changes to the Program, and + ii) additions to the Program; + where such changes and/or additions to the Program originate from + and are Distributed by that particular Contributor. A Contribution + "originates" from a Contributor if it was added to the Program by + such Contributor itself or anyone acting on such Contributor's behalf. + Contributions do not include changes or additions to the Program that + are not Modified Works. + +"Contributor" means any person or entity that Distributes the Program. + +"Licensed Patents" mean patent claims licensable by a Contributor which +are necessarily infringed by the use or sale of its Contribution alone +or when combined with the Program. + +"Program" means the Contributions Distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this Agreement +or any Secondary License (as applicable), including Contributors. + +"Derivative Works" shall mean any work, whether in Source Code or other +form, that is based on (or derived from) the Program and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. + +"Modified Works" shall mean any work in Source Code or other form that +results from an addition to, deletion from, or modification of the +contents of the Program, including, for purposes of clarity any new file +in Source Code form that contains any contents of the Program. Modified +Works shall not include works that contain only declarations, +interfaces, types, classes, structures, or files of the Program solely +in each case in order to link to, bind by name, or subclass the Program +or Modified Works thereof. + +"Distribute" means the acts of a) distributing or b) making available +in any manner that enables the transfer of a copy. + +"Source Code" means the form of a Program preferred for making +modifications, including but not limited to software source code, +documentation source, and configuration files. + +"Secondary License" means either the GNU General Public License, +Version 2.0, or any later versions of that license, including any +exceptions or additional permissions as identified by the initial +Contributor. + +2. GRANT OF RIGHTS + + a) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free copyright + license to reproduce, prepare Derivative Works of, publicly display, + publicly perform, Distribute and sublicense the Contribution of such + Contributor, if any, and such Derivative Works. + + b) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free patent + license under Licensed Patents to make, use, sell, offer to sell, + import and otherwise transfer the Contribution of such Contributor, + if any, in Source Code or other form. This patent license shall + apply to the combination of the Contribution and the Program if, at + the time the Contribution is added by the Contributor, such addition + of the Contribution causes such combination to be covered by the + Licensed Patents. The patent license shall not apply to any other + combinations which include the Contribution. No hardware per se is + licensed hereunder. + + c) Recipient understands that although each Contributor grants the + licenses to its Contributions set forth herein, no assurances are + provided by any Contributor that the Program does not infringe the + patent or other intellectual property rights of any other entity. + Each Contributor disclaims any liability to Recipient for claims + brought by any other entity based on infringement of intellectual + property rights or otherwise. As a condition to exercising the + rights and licenses granted hereunder, each Recipient hereby + assumes sole responsibility to secure any other intellectual + property rights needed, if any. For example, if a third party + patent license is required to allow Recipient to Distribute the + Program, it is Recipient's responsibility to acquire that license + before distributing the Program. + + d) Each Contributor represents that to its knowledge it has + sufficient copyright rights in its Contribution, if any, to grant + the copyright license set forth in this Agreement. + + e) Notwithstanding the terms of any Secondary License, no + Contributor makes additional grants to any Recipient (other than + those set forth in this Agreement) as a result of such Recipient's + receipt of the Program under the terms of a Secondary License + (if permitted under the terms of Section 3). + +3. REQUIREMENTS + +3.1 If a Contributor Distributes the Program in any form, then: + + a) the Program must also be made available as Source Code, in + accordance with section 3.2, and the Contributor must accompany + the Program with a statement that the Source Code for the Program + is available under this Agreement, and informs Recipients how to + obtain it in a reasonable manner on or through a medium customarily + used for software exchange; and + + b) the Contributor may Distribute the Program under a license + different than this Agreement, provided that such license: + i) effectively disclaims on behalf of all other Contributors all + warranties and conditions, express and implied, including + warranties or conditions of title and non-infringement, and + implied warranties or conditions of merchantability and fitness + for a particular purpose; + + ii) effectively excludes on behalf of all other Contributors all + liability for damages, including direct, indirect, special, + incidental and consequential damages, such as lost profits; + + iii) does not attempt to limit or alter the recipients' rights + in the Source Code under section 3.2; and + + iv) requires any subsequent distribution of the Program by any + party to be under a license that satisfies the requirements + of this section 3. + +3.2 When the Program is Distributed as Source Code: + + a) it must be made available under this Agreement, or if the + Program (i) is combined with other material in a separate file or + files made available under a Secondary License, and (ii) the initial + Contributor attached to the Source Code the notice described in + Exhibit A of this Agreement, then the Program may be made available + under the terms of such Secondary Licenses, and + + b) a copy of this Agreement must be included with each copy of + the Program. + +3.3 Contributors may not remove or alter any copyright, patent, +trademark, attribution notices, disclaimers of warranty, or limitations +of liability ("notices") contained within the Program from any copy of +the Program which they Distribute, provided that Contributors may add +their own appropriate notices. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities +with respect to end users, business partners and the like. While this +license is intended to facilitate the commercial use of the Program, +the Contributor who includes the Program in a commercial product +offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes +the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and indemnify every +other Contributor ("Indemnified Contributor") against any losses, +damages and costs (collectively "Losses") arising from claims, lawsuits +and other legal actions brought by a third party against the Indemnified +Contributor to the extent caused by the acts or omissions of such +Commercial Contributor in connection with its distribution of the Program +in a commercial product offering. The obligations in this section do not +apply to any claims or Losses relating to any actual or alleged +intellectual property infringement. In order to qualify, an Indemnified +Contributor must: a) promptly notify the Commercial Contributor in +writing of such claim, and b) allow the Commercial Contributor to control, +and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may +participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those performance +claims and warranties, and if a court requires any other Contributor to +pay any damages as a result, the Commercial Contributor must pay +those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF +TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR +PURPOSE. Each Recipient is solely responsible for determining the +appropriateness of using and distributing the Program and assumes all +risks associated with its exercise of rights under this Agreement, +including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs +or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS +SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE +EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other software +or hardware) infringes such Recipient's patent(s), then such Recipient's +rights granted under Section 2(b) shall terminate as of the date such +litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign the +responsibility to serve as the Agreement Steward to a suitable separate +entity. Each new version of the Agreement will be given a distinguishing +version number. The Program (including Contributions) may always be +Distributed subject to the version of the Agreement under which it was +received. In addition, after a new version of the Agreement is published, +Contributor may elect to Distribute the Program (including its +Contributions) under the new version. + +Except as expressly stated in Sections 2(a) and 2(b) above, Recipient +receives no rights or licenses to the intellectual property of any +Contributor under this Agreement, whether expressly, by implication, +estoppel or otherwise. All rights in the Program not expressly granted +under this Agreement are reserved. Nothing in this Agreement is intended +to be enforceable by any entity that is not a Contributor or Recipient. +No third-party beneficiary rights are created under this Agreement. + +Exhibit A - Form of Secondary Licenses Notice + +"This Source Code may also be made available under the following +Secondary Licenses when the conditions for such availability set forth +in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), +version(s), and exceptions or additional permissions here}." + + Simply including a copy of this Agreement, including this Exhibit A + is not sufficient to license the Source Code under Secondary Licenses. + + If it is not possible or desirable to put the notice in a particular + file, then You may include the notice in a location (such as a LICENSE + file in a relevant directory) where a recipient would be likely to + look for such a notice. + + You may add additional accurate notices of copyright ownership. + + +===== Expat ===== + +Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper +Copyright (c) 2001-2025 Expat maintainers + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +===== Emscripten ===== + +Emscripten is available under 2 licenses, the MIT license and the +University of Illinois/NCSA Open Source License. + +Both are permissive open source licenses, with little if any +practical difference between them. + +The reason for offering both is that (1) the MIT license is +well-known, while (2) the University of Illinois/NCSA Open Source +License allows Emscripten's code to be integrated upstream into +LLVM, which uses that license, should the opportunity arise. + +The full text of both licenses follows. + +============================================================================== + +Copyright (c) 2010-2014 Emscripten authors, see AUTHORS file. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +============================================================================== + +Copyright (c) 2010-2014 Emscripten authors, see AUTHORS file. +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal with the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimers. + + Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimers + in the documentation and/or other materials provided with the + distribution. + + Neither the names of Mozilla, + nor the names of its contributors may be used to endorse + or promote products derived from this Software without specific prior + written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. + +============================================================================== + +This program uses portions of Node.js source code located in src/library_path.js, +in accordance with the terms of the MIT license. Node's license follows: + + """ + Copyright Joyent, Inc. and other Node contributors. All rights reserved. + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + IN THE SOFTWARE. + """ + +The musl libc project is bundled in this repo, and it has the MIT license, see +system/lib/libc/musl/COPYRIGHT + +The third_party/ subdirectory contains code with other licenses. None of it is +used by default, but certain options use it (e.g., the optional closure compiler +flag will run closure compiler from third_party/). + + +===== DOMPurify ===== + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/client/ui-primitives/package.json b/packages/client/ui-primitives/package.json index 6502b6564d..587cd95ee6 100644 --- a/packages/client/ui-primitives/package.json +++ b/packages/client/ui-primitives/package.json @@ -46,11 +46,14 @@ "mdast-util-math": "^3.0.0", "micromark-extension-gfm": "^3.0.0", "micromark-util-sanitize-uri": "^2.0.1", - "mermaid": "11.16.0" + "mermaid": "11.16.0", + "@viz-js/viz": "3.30.0", + "dompurify": "3.4.11" }, "files": [ "lib/index.js", "lib/**/*.css", + "THIRD_PARTY_PREVIEW_NOTICES.txt", "lib/types/**/*.d.ts" ], "peerDependencies": { diff --git a/packages/client/ui-primitives/src/markdown/MermaidPreview.module.css b/packages/client/ui-primitives/src/markdown/MermaidPreview.module.css index f96c14418b..e21d84e284 100644 --- a/packages/client/ui-primitives/src/markdown/MermaidPreview.module.css +++ b/packages/client/ui-primitives/src/markdown/MermaidPreview.module.css @@ -24,3 +24,12 @@ visibility: hidden; pointer-events: none; } + +.frame { + display: block; + width: 100%; + height: 400px; + border: 0; + border-radius: 12px; + background: var(--dsw-static-neutral-00); +} diff --git a/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx b/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx index 5dadb6a6b3..dc330e9da8 100644 --- a/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx +++ b/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx @@ -1,51 +1,17 @@ -/** Read-only diagram preview with source fallback and per-source async ownership. */ +/** Mermaid image preview using the shared asynchronous source renderer. */ -import { useEffect, useState } from 'react' import { renderMermaid } from './mermaid.ts' -import css from './MermaidPreview.module.css' +import { SourcePreview } from './SourcePreview.tsx' +import type { PreviewLabels } from './SourcePreview.tsx' -/** Localized preview states; the diagram source remains verbatim. */ -export interface MermaidPreviewLabels { - diagram: string - loading: string - error: string -} - -type Result = { kind: 'ok'; code: string; src: string } | { kind: 'error'; code: string } - -/* v8 ignore next 3 -- closed-union backstop; only reached if a result is forged */ -function assertNever(value: never): never { - throw new Error(`unreachable Mermaid result: ${String(value)}`) -} +/** Localized Mermaid preview states; source remains verbatim. */ +export type MermaidPreviewLabels = PreviewLabels /** - * Display a complete Mermaid document on a light diagram canvas, or its source if rendering fails. - * @param props - Source and complete localized labels. Changing source discards the previous result. - * @returns A loading status, an inert SVG image, or an error with the original source. + * Display a complete Mermaid document as an inert SVG image. + * @param props - Source and complete localized labels. + * @returns A loading status, diagram image, or error with the original source. */ export function MermaidPreview({ code, labels }: { code: string; labels: MermaidPreviewLabels }) { - const [result, setResult] = useState(null) - useEffect(() => { - const controller = new AbortController() - void renderMermaid(code, controller.signal).then( - (src) => { if (!controller.signal.aborted) setResult({ kind: 'ok', code, src }) }, - () => { if (!controller.signal.aborted) setResult({ kind: 'error', code }) }, - ) - return () => { controller.abort() } - }, [code]) - - if (result?.code !== code) return
{labels.loading}
- switch (result.kind) { - case 'ok': - return
{labels.diagram}
- case 'error': - return ( -
-
{labels.error}
-
{code}
-
- ) - /* v8 ignore next -- closed-union backstop; only reached if a result is forged */ - default: return assertNever(result) - } + return } diff --git a/packages/client/ui-primitives/src/markdown/SourcePreview.tsx b/packages/client/ui-primitives/src/markdown/SourcePreview.tsx new file mode 100644 index 0000000000..376b69710a --- /dev/null +++ b/packages/client/ui-primitives/src/markdown/SourcePreview.tsx @@ -0,0 +1,56 @@ +/** Read-only diagram preview with source fallback and per-source async ownership. */ + +import { useEffect, useState } from 'react' +import css from './MermaidPreview.module.css' + +/** Localized preview states; the diagram source remains verbatim. */ +export interface PreviewLabels { + diagram: string + loading: string + error: string +} + +type Result = { kind: 'ok'; code: string; src: string } | { kind: 'error'; code: string } + +/* v8 ignore next 3 -- closed-union backstop; only reached if a result is forged */ +function assertNever(value: never): never { + throw new Error(`unreachable preview result: ${String(value)}`) +} + +/** + * Display a complete document or diagram, retaining the source when rendering fails. + * @param props - Source and complete localized labels. Changing source discards the previous result. + * @returns A loading status, an inert image or sandboxed document, or an error with the original source. + */ +export function SourcePreview({ code, labels, render, document: isDocument = false }: { + code: string + labels: PreviewLabels + render: (code: string, signal: AbortSignal) => string | Promise + document?: boolean +}) { + const [result, setResult] = useState(null) + useEffect(() => { + const controller = new AbortController() + void (async () => await render(code, controller.signal))().then( + (src) => { if (!controller.signal.aborted) setResult({ kind: 'ok', code, src }) }, + () => { if (!controller.signal.aborted) setResult({ kind: 'error', code }) }, + ) + return () => { controller.abort() } + }, [code, render]) + + if (result?.code !== code) return
{labels.loading}
+ switch (result.kind) { + case 'ok': + if (isDocument) return +
`, new AbortController().signal) + const parsed = new DOMParser().parseFromString(doc, 'text/html') + expect(parsed.querySelector('h1')?.textContent).toBe('Example') + expect(parsed.querySelector('style')?.textContent).toBe('h1 { color: green }') + expect(parsed.querySelector('script, iframe, base, [href], [action], [formaction], [onload]')).toBeNull() + expect(parsed.querySelectorAll('meta[http-equiv]').length).toBe(1) + expect(parsed.querySelector('meta[http-equiv]')?.getAttribute('content')).toContain("default-src 'none'") + }) + + it('encodes SVG as an image rather than executable document markup', () => { + const code = '' + const parsed = new DOMParser().parseFromString(renderSvg(code, new AbortController().signal), 'text/html') + expect(parsed.querySelector('svg, script')).toBeNull() + expect(decodeURIComponent(parsed.querySelector('img')!.getAttribute('src')!)).toContain(code) + }) + + it.each(['', '', ''])('rejects non-SVG or malformed XML: %s', (code) => { + expect(() => renderSvg(code, new AbortController().signal)).toThrow('Invalid SVG document') + }) + + it.each([renderHtml, renderSvg])('does not prepare a cancelled document', (renderDocument) => { + const controller = new AbortController() + controller.abort() + expect(() => renderDocument(svg, controller.signal)).toThrow(controller.signal.reason) + }) +}) diff --git a/packages/client/ui-primitives/tests/graphviz-runtime.client.spec.ts b/packages/client/ui-primitives/tests/graphviz-runtime.client.spec.ts new file mode 100644 index 0000000000..354c0f9eaa --- /dev/null +++ b/packages/client/ui-primitives/tests/graphviz-runtime.client.spec.ts @@ -0,0 +1,35 @@ +// @vitest-environment jsdom + +import { afterEach, beforeEach, expect, it, vi } from 'vitest' + +const instance = vi.fn() +beforeEach(() => { + vi.resetModules() + instance.mockReset() + vi.doMock('@viz-js/viz', () => ({ instance })) +}) +afterEach(() => { vi.doUnmock('@viz-js/viz') }) + +it('retries failed initialization and reuses the loaded runtime', async () => { + const renderString = vi.fn().mockReturnValue('') + instance.mockRejectedValueOnce(new Error('WASM unavailable')).mockResolvedValue({ renderString }) + const { renderGraphviz } = await import('../src/markdown/graphviz.ts') + await expect(renderGraphviz('digraph {}', new AbortController().signal)).rejects.toThrow('WASM unavailable') + await expect(renderGraphviz('digraph {}', new AbortController().signal)).resolves.toContain('data:image/svg+xml') + await renderGraphviz('digraph {}', new AbortController().signal) + expect(instance).toHaveBeenCalledTimes(2) +}) + +it('skips layout after cancellation during runtime loading', async () => { + const pending = Promise.withResolvers<{ renderString: ReturnType }>() + instance.mockReturnValue(pending.promise) + const { renderGraphviz } = await import('../src/markdown/graphviz.ts') + const controller = new AbortController() + const result = renderGraphviz('digraph {}', controller.signal) + const rejection = expect(result).rejects.toMatchObject({ name: 'AbortError' }) + controller.abort() + const renderString = vi.fn() + pending.resolve({ renderString }) + await rejection + expect(renderString).not.toHaveBeenCalled() +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d1c1098a48..6f08b3708d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3305,12 +3305,18 @@ importers: '@types/react-dom': specifier: ~18.3.0 version: 18.3.7(@types/react@18.3.31) + '@viz-js/viz': + specifier: 3.30.0 + version: 3.30.0 anser: specifier: ^2.3.5 version: 2.3.5 clsx: specifier: ^2.0.0 version: 2.1.1 + dompurify: + specifier: 3.4.11 + version: 3.4.11 katex: specifier: ^0.16.47 version: 0.16.47 @@ -14255,6 +14261,9 @@ packages: '@vitest/utils@4.1.8': resolution: {integrity: sha512-uOJamYALNhfJ6iolExyQM40yIQwDqYnkKtQ5VCiSe17E33H0aQ/u+1GlRuz4LZBk6Mm3sg90G9hEbmEt37C1Zg==} + '@viz-js/viz@3.30.0': + resolution: {integrity: sha512-2zmcP55QY44uQfZ+GvgNHmGd8S6KUD+2eMur9AbYybSzrOd/m8nMUg0ZircJNiJRKGgVBKAE8kh0hAwpUFUFQQ==} + '@vscode/ripgrep-darwin-arm64@1.18.0': resolution: {integrity: sha512-r3ktHSvbFycQNF6sl7sNDPocpsI7J+mEzh1IaZFkY0spm3k2Z9t8hPAeOK7+p0l6p6/swkQC14XWX01low+94Q==} cpu: [arm64] @@ -20864,6 +20873,8 @@ snapshots: convert-source-map: 2.0.0 tinyrainbow: 3.1.0 + '@viz-js/viz@3.30.0': {} + '@vscode/ripgrep-darwin-arm64@1.18.0': optional: true diff --git a/scripts/check-workspace-constraints.spec.ts b/scripts/check-workspace-constraints.spec.ts index 5ac40d3c99..d3dcddb787 100644 --- a/scripts/check-workspace-constraints.spec.ts +++ b/scripts/check-workspace-constraints.spec.ts @@ -3,6 +3,7 @@ import { describe, expect, it } from 'vitest' import { checkDshFamilyVersion, + checkWorkspaceManifest, checkExperimentalDependencyIsolation, checkExperimentalManifest, expectedDshPackageFiles, @@ -121,3 +122,16 @@ describe('package payload constraints', () => { ]) }) }) + +it('requires preview license notices in the published UI primitives payload', () => { + const name = '@deepseek-ai/dsh-client-ui-primitives' + const files = expectedDshPackageFiles({ name }) + expect(files).toContain('THIRD_PARTY_PREVIEW_NOTICES.txt') + const check = (entries: readonly string[]) => checkWorkspaceManifest({ + dir: 'packages/client/ui-primitives', manifest: { name, files: [...entries] }, + }).filter(message => message.includes('package.json files')) + expect(check(files)).toEqual([]) + expect(check(files.filter(file => file !== 'THIRD_PARTY_PREVIEW_NOTICES.txt'))).toEqual([ + expect.stringContaining('package.json files must be'), + ]) +}) diff --git a/scripts/check-workspace-constraints.ts b/scripts/check-workspace-constraints.ts index e7b0e948e8..73f32d72a6 100644 --- a/scripts/check-workspace-constraints.ts +++ b/scripts/check-workspace-constraints.ts @@ -154,7 +154,7 @@ const packageFileExtras: Readonly> = { // them through its own CSS pipeline, so the sheets are published artifacts. // The glob covers whichever sheets a package emits; sourcemaps stay // unpublished, as everywhere else in the repository. - '@deepseek-ai/dsh-client-ui-primitives': ['lib/**/*.css'], + '@deepseek-ai/dsh-client-ui-primitives': ['lib/**/*.css', 'THIRD_PARTY_PREVIEW_NOTICES.txt'], '@deepseek-ai/dsh-client-ui-dockkit': ['lib/**/*.css'], '@deepseek-ai/dsh-client-web': ['lib/**/*.css'], '@deepseek-ai/dsh-client-ui-theme': ['lib/styles'], diff --git a/scripts/gen-third-party-notices.spec.ts b/scripts/gen-third-party-notices.spec.ts index fabce6e8c9..46b1b35d11 100644 --- a/scripts/gen-third-party-notices.spec.ts +++ b/scripts/gen-third-party-notices.spec.ts @@ -4,6 +4,7 @@ import { tmpdir } from 'node:os' import { describe, expect, it } from 'vitest' import { CLAUDE_AGENT_SDK_PACKAGE, + assertPreviewDistribution, assertRuntimeLicenses, claudeDistributionFromManifest, collectPythonDependencies, @@ -395,3 +396,26 @@ describe('manifestPatterns', () => { ]) }) }) + +describe('preview distribution licenses', () => { + const dependencies = { mermaid: '11.16.0', '@viz-js/viz': '3.30.0', dompurify: '3.4.11' } + const sources = [ + 'pkg:docker/emscripten/emsdk@5.0.7?platform=linux%2Famd64', + 'https://github.com/libexpat/libexpat/releases/download/R_2_8_4/expat-2.8.4.tar.gz', + 'https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/16.0.0/graphviz-16.0.0.tar.gz', + ] + it('accepts the reviewed wrapper and native sources', () => { + expect(() => { assertPreviewDistribution(dependencies, sources) }).not.toThrow() + const notices = readFileSync(resolve(root, 'packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt'), 'utf8') + expect(notices).toContain('Eclipse Public License - v 2.0') + expect(notices).toContain(sources[2]) + expect(notices).toContain(readFileSync(resolve(root, 'packages/client/ui-primitives/node_modules/mermaid/LICENSE'), 'utf8').trim()) + expect(notices).toContain(readFileSync(resolve(root, 'packages/client/ui-primitives/node_modules/dompurify/LICENSE'), 'utf8').trim()) + }) + it.each(Object.keys(dependencies))('rejects an unreviewed %s upgrade', (name) => { + expect(() => { assertPreviewDistribution({ ...dependencies, [name]: '99.0.0' }, sources) }).toThrow('preview notices: review') + }) + it.each([sources.slice(1), [...sources, 'https://example.com/new-library'], [...sources.slice(0, 2), 'graphviz-next']])('rejects changed embedded sources', (...uris) => { + expect(() => { assertPreviewDistribution(dependencies, uris) }).toThrow('native sources') + }) +}) diff --git a/scripts/gen-third-party-notices.ts b/scripts/gen-third-party-notices.ts index 9e83956e5e..2130723202 100644 --- a/scripts/gen-third-party-notices.ts +++ b/scripts/gen-third-party-notices.ts @@ -685,6 +685,28 @@ ${rows.join('\n')} ` } +/** + * Require renewed license review when a preview dependency or embedded source changes. + * @param dependencies - UI primitives' browser build dependencies. + * @param sources - Native source URIs from the installed Viz.js build provenance. + * @returns Nothing; throws when a version or native source differs from the reviewed distribution. + */ +export function assertPreviewDistribution(dependencies: Record, sources: readonly string[]): void { + for (const [name, version] of Object.entries({ mermaid: '11.16.0', '@viz-js/viz': '3.30.0', dompurify: '3.4.11' })) { + if (dependencies[name] !== version) { + throw new Error(`preview notices: review ${name} ${String(dependencies[name])} licenses and update THIRD_PARTY_PREVIEW_NOTICES.txt`) + } + } + const expected = [ + 'pkg:docker/emscripten/emsdk@5.0.7?platform=linux%2Famd64', + 'https://github.com/libexpat/libexpat/releases/download/R_2_8_4/expat-2.8.4.tar.gz', + 'https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/16.0.0/graphviz-16.0.0.tar.gz', + ] + if (sources.length !== expected.length || expected.some(uri => !sources.includes(uri))) { + throw new Error('preview notices: review the changed Viz.js native sources and their distribution licenses') + } +} + /** * Render the complete notices document. * @returns The exact bytes THIRD_PARTY_NOTICES.md must hold after resolving browser inputs. @@ -695,6 +717,16 @@ export async function render(): Promise { // the manifests map it was resolved from; render() owns that single load. workspaceLinkedManifestCache.clear() const { manifests, names } = loadWorkspaceManifests() + const previewPackage = 'packages/client/ui-primitives' + const provenance = JSON.parse(readFileSync(resolve(root, previewPackage, 'node_modules/@viz-js/viz/lib/provenance.json'), 'utf8')) as { + predicate: { buildDefinition: { resolvedDependencies: { uri: string }[] } } + } + const previewDependencies = manifests.get(`${previewPackage}/package.json`)?.devDependencies + if (previewDependencies === undefined) throw new Error('preview notices: missing UI primitives browser dependencies') + assertPreviewDistribution( + previewDependencies, + provenance.predicate.buildDefinition.resolvedDependencies.map(source => source.uri), + ) const npm = collectNpmDeps(manifests, names, browser) const runtimeDeps = npm.filter(dep => dep.runtime) const devDeps = npm.filter(dep => !dep.runtime) @@ -735,6 +767,8 @@ External packages installed for runtime use or distributed inside the prebuilt b ${renderNpmTable(runtimeDeps)} +The Markdown preview distribution also contains Graphviz 16.0.0 (EPL-2.0), Expat 2.8.4 (MIT), and Emscripten 5.0.7 runtime code (MIT/NCSA) inside \`@viz-js/viz\` 3.30.0. The wrapper's MIT metadata does not relicense these components. [Preview notices](packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt) preserve their full license texts and Graphviz source availability, together with Mermaid's MIT and DOMPurify's selected Apache-2.0 terms. The UI primitives npm package includes this file; the Web build emits it as \`preview-third-party-notices.txt\`. + pnpm applies local patches to the following packages at install time, so shipped artifacts carry modified copies; each patch file is the complete record of the modification: ${patchedLines.join('\n')} From fb84576ea7a4cae41b52997901d722ab02cbc2f5 Mon Sep 17 00:00:00 2001 From: yudshj Date: Wed, 9 Sep 2026 13:11:55 +0800 Subject: [PATCH 07/32] refactor(web): unify markdown preview components and notes --- .../2026-09-07-web-mermaid-preview.i18n.yaml | 6 --- .../feature/2026-09-07-web-mermaid-preview.md | 35 ------------- .../2026-09-07-web-mermaid-preview.zh.md | 35 ------------- ...6-09-09-markdown-static-previews.i18n.yaml | 4 +- .../2026-09-09-markdown-static-previews.md | 24 ++++++--- .../2026-09-09-markdown-static-previews.zh.md | 24 ++++++--- packages/client/locale/src/locales/en.ts | 4 +- packages/client/locale/src/locales/zh.ts | 4 +- .../ui-chat/src/client/markdown-labels.ts | 25 ++++------ .../client/ui-primitives/README.i18n.yaml | 4 +- packages/client/ui-primitives/README.md | 7 ++- packages/client/ui-primitives/README.zh.md | 7 ++- packages/client/ui-primitives/src/index.ts | 2 - .../src/markdown/CodeBlock.module.css | 50 +++++++++---------- .../src/markdown/MermaidPreview.tsx | 17 ------- ...ew.module.css => SourcePreview.module.css} | 0 .../src/markdown/SourcePreview.tsx | 2 +- .../ui-primitives/src/markdown/mermaid.ts | 2 +- .../ui-primitives/src/markdown/render.tsx | 30 ++++------- .../tests/fence-previews.client.spec.tsx | 22 ++++---- ...pec.tsx => source-preview.client.spec.tsx} | 43 ++++++++++++---- 21 files changed, 144 insertions(+), 203 deletions(-) delete mode 100644 .agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml delete mode 100644 .agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md delete mode 100644 .agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md delete mode 100644 packages/client/ui-primitives/src/markdown/MermaidPreview.tsx rename packages/client/ui-primitives/src/markdown/{MermaidPreview.module.css => SourcePreview.module.css} (100%) rename packages/client/ui-primitives/tests/{mermaid-preview.client.spec.tsx => source-preview.client.spec.tsx} (73%) diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml deleted file mode 100644 index 190b6ffb3e..0000000000 --- a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.i18n.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each -# side as of the last confirmed-consistent state. Both languages carry equal authority; -# after editing either side, bring the other along and re-record with: -# pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md -2026-09-07-web-mermaid-preview.md: 246b38e764e1e5812427f935c4a41c28f0fa24a0 -2026-09-07-web-mermaid-preview.zh.md: c1dd25c1b6dc21c36d92e0d7c1477fcea9ae99c2 diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md deleted file mode 100644 index 246b38e764..0000000000 --- a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md +++ /dev/null @@ -1,35 +0,0 @@ -# Agent Note: Mermaid previews in Chat code fences - -Status: implemented - -English | [中文](2026-09-07-web-mermaid-preview.zh.md) - -## Problem - -Assistant replies can describe diagrams in Mermaid code fences, but readers must interpret the source or copy it to another renderer. Rendering must handle incomplete streaming input and untrusted diagram content while remaining reusable outside Chat. - -## Decision - -Chat enables settled fence previews through `MarkdownLabels.mermaid`. The shared Markdown renderer uses the parsed fence language; streaming fences and consumers without those labels retain code display. The static [UI primitives package](../../../../packages/client/ui-primitives/README.md) owns `MermaidPreview`, which accepts source and localized labels without Session, file, or Cordis dependencies. `CodeBlock.preview` owns view switching and source copying. Previews omit the language banner and expose compact icon actions on hover or keyboard focus; devices with any touch input keep those actions visible below the diagram. Switching to source hides the mounted preview, so returning preserves completed rendering and pending work. Source and preview share the same focused toggle button, and copying always reads the source prop. - -Mermaid loads on demand. Its public render API serializes diagram work, and each call removes its temporary measurement DOM in `finally`. Strict security, disabled HTML labels, the neutral theme, and error-rendering policy cannot be overridden by diagram configuration. Generated SVG is displayed as an image without installing diagram links or scripts. Intrinsic dimensions come from the SVG viewBox; large diagrams shrink to fit, and the canvas stays light in both application themes. - -Source replacement and unmounting cancel result publication. Cancellation before runtime loading completes prevents rendering; an active Mermaid render finishes and releases its DOM but cannot publish to a cancelled component. Failures show a localized error and the original source. Replacing invalid source with a valid diagram recovers the preview. - -## Alternatives considered - -**Keep the code banner above diagrams.** A language label and permanent text controls distract from the diagram. Overlay actions retain source access without reserving a title row. - -**Render each streamed chunk.** Incomplete diagrams are frequently invalid, and repeated layout work competes with text streaming. The existing message-settlement boundary provides a complete source value. - -**Put rendering inside Chat or add a general preview registry.** A shared primitive with plain props satisfies reuse without another registry or feature-plugin dependency. This follows the [shared-control rule](../architecture/2026-09-05-shared-client-control-primitives.md). - -**Insert interactive SVG into the message.** The requested preview needs diagram display and source access. Displaying the result as an image keeps diagram links and event handlers inactive. - -The [static fence preview decision](2026-09-09-markdown-static-previews.md) owns Graphviz, SVG, and HTML sandboxing and shared preview license distribution. - -## Consequences - -The feature changes presentation without changing persisted messages, provider requests, tools, or Host APIs. Mermaid adds lazily loaded browser assets. Rendering still runs on the browser thread, and work already handed to the library cannot be interrupted. The initial feature has no editing, export, zoom controls, or interactive diagram links. - -Component tests cover delayed completion, stale success and failure, unmounting, source fallback, and copying. The keyless [browser scenario](../../../../apps/web/tests/markdown-mermaid.e2e.ts) exercises the assembled Chat with Chinese flowcharts, sequence diagrams, malformed source, configuration overrides, and English/Chinese UI snapshots. diff --git a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md b/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md deleted file mode 100644 index c1dd25c1b6..0000000000 --- a/.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md +++ /dev/null @@ -1,35 +0,0 @@ -# Agent Note: Chat 代码 fence 中的 Mermaid 预览 - -Status: implemented - -[English](2026-09-07-web-mermaid-preview.md) | 中文 - -## 问题 - -Assistant 回复可以在 Mermaid 代码 fence 中描述图表,但读者必须理解源码或把它复制到其他渲染器。渲染需要处理不完整的流式输入与不可信图表内容,同时保持在 Chat 之外的可复用性。 - -## 决策 - -Chat 通过 `MarkdownLabels.mermaid` 启用已定稿 fence 预览。共享 Markdown 渲染器使用解析后的 fence 语言;流式 fence 和未传入这些 label 的调用方保留代码显示。静态 [UI primitives 包](../../../../packages/client/ui-primitives/README.zh.md)拥有 `MermaidPreview`,它接收源码与本地化 label,不依赖 Session、文件或 Cordis。`CodeBlock.preview` 拥有视图切换与源码复制。预览省略语言标题栏,悬停或键盘聚焦时显示紧凑的图标操作;具备任何触控输入的设备均在图表下方保持操作可见。切换到源码时隐藏已挂载的预览,因此返回时保留已完成的渲染与进行中的工作。源码与预览使用同一个已聚焦的切换按钮,复制始终读取源码 prop。 - -Mermaid 按需加载。它的公开 render API 串行执行图表工作,每次调用在 `finally` 中移除临时测量 DOM。图表配置无法覆盖严格安全模式、禁用 HTML label、中性主题和错误渲染策略。生成的 SVG 以图片显示,不安装图内链接或脚本。固有尺寸取自 SVG viewBox;大图缩小以适应宽度,画布在两种应用主题下均保持浅色。 - -替换源码与卸载组件会取消结果发布。在运行时加载完成前取消可阻止渲染;已经开始的 Mermaid 渲染会完成并释放 DOM,但无法向已取消的组件发布结果。失败时显示本地化错误和原始源码。用有效图表替换非法源码可恢复预览。 - -## 考虑过的替代方案 - -**在图表上方保留代码标题栏。** 语言标记和常驻的文字操作分散了对图表的注意力。浮层操作无需占用标题行即可保留源码入口。 - -**渲染每个流式分片。** 不完整的图表经常无效,反复布局也会与文本流式输出竞争。已有的消息定稿边界提供完整源码值。 - -**把渲染放在 Chat 内或增加通用预览注册表。** 接收普通 prop 的共享原语无需另一套注册表或功能插件依赖即可满足复用。这遵循[共享控件规则](../architecture/2026-09-05-shared-client-control-primitives.zh.md)。 - -**把可交互 SVG 插入消息。** 此次预览需求只需要图表显示与源码访问。将结果显示为图片后,图内链接和事件处理器不会生效。 - -[静态 fence 预览决策](2026-09-09-markdown-static-previews.zh.md)负责 Graphviz、SVG、HTML 的 sandbox 及共享预览许可证分发。 - -## 后果 - -功能只改变展示,不改变持久化消息、提供者请求、工具或 Host API。Mermaid 增加按需加载的浏览器资源。渲染仍在浏览器线程上执行,已交给库的工作无法中断。首版不包含编辑、导出、缩放控件或可交互图内链接。 - -组件测试覆盖延迟完成、过期成功与失败、卸载、源码回退和复制。无密钥[浏览器场景](../../../../apps/web/tests/markdown-mermaid.e2e.ts)通过完整 Chat 组合验证中文流程图、时序图、非法源码、配置覆盖以及英文/中文 UI 快照。 diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml index 6cb3a179eb..c70073de17 100644 --- a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml +++ b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md -2026-09-09-markdown-static-previews.md: fd3772cabc2160f07e79b06dffa4374fe104cbd1 -2026-09-09-markdown-static-previews.zh.md: 92f4b030879acaeb484eed33e078574750a1801e +2026-09-09-markdown-static-previews.md: a6d1802546e9e976da7ae4d1ecc024924414e9a4 +2026-09-09-markdown-static-previews.zh.md: 42488547efafdbf5b1944b1300af13f359365d74 diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md index fd3772cabc..a6d1802546 100644 --- a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md +++ b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md @@ -6,26 +6,38 @@ English | [中文](2026-09-09-markdown-static-previews.zh.md) ## Problem -Readers need to see DOT diagrams, SVG artwork, and HTML examples directly in Assistant replies. These sources are untrusted, and a renderer's npm license field may omit compiled components with separate distribution obligations. +Readers need to see Mermaid and DOT diagrams, SVG artwork, and HTML examples directly in Assistant replies without interpreting source or copying it to another renderer. These sources are untrusted, and a renderer's npm license field may omit compiled components with separate distribution obligations. ## Decision -The shared Markdown renderer enables settled `graphviz`/`dot`, `svg`, and `html` fences through localized `MarkdownLabels.preview`. `CodeBlock.preview` owns default visualization, source switching, and verbatim copying. `SourcePreview` owns loading, failure, and cancellation of stale result publication for both these documents and the [Mermaid preview](2026-09-07-web-mermaid-preview.md). Consumers without preview labels and streaming messages retain code. +The shared Markdown renderer enables settled `mermaid`, `graphviz`/`dot`, `svg`, and `html` fences through localized `MarkdownLabels.preview` and the parsed fence language. The [UI primitives package](../../../../packages/client/ui-primitives/README.md) owns `SourcePreview`, which accepts a renderer, source, and labels without Session, file, or Cordis dependencies. Mermaid and Graphviz each supply a `.ts` renderer to that same component. Consumers without preview labels and streaming messages retain code. -HTML uses DOMPurify with navigation attributes and document-loading elements forbidden, followed by an opaque `sandbox=""` iframe. A trusted CSP precedes source markup and permits only inline CSS, data images, and data fonts. Scripts, external resources, child frames, form submission, and same-origin access are unavailable. SVG is parsed as XML and placed in an image inside the frame, so SVG scripts and links never become active. Frames have a fixed scrollable viewport: measuring their content would require additional origin access or trusted frame scripts. Mermaid keeps its existing strict renderer and inert image presentation. +`CodeBlock.preview` owns default visualization, source switching, and verbatim copying. Previews omit the language banner and expose compact icon actions on hover or keyboard focus; devices with any touch input keep actions visible below the diagram. Switching to source hides the mounted preview, preserving completed rendering and pending work. Both views use the same focused toggle button, and copying always reads the source prop. + +`SourcePreview` owns loading, failure, and cancellation of stale result publication. Source replacement and unmounting cancel publication; cancellation before runtime loading completes skips layout. Failures show a localized error and the original source, and replacing invalid source with valid input recovers the preview. + +Mermaid loads on demand. Its public render API serializes diagram work, and each call removes its temporary measurement DOM in `finally`. Strict security, disabled HTML labels, the neutral theme, and error-rendering policy cannot be overridden by diagram configuration. Generated SVG is displayed as an image without installing links or scripts. Intrinsic dimensions come from the SVG viewBox; large diagrams shrink to fit, and the canvas stays light in both application themes. + +HTML uses DOMPurify with navigation attributes and document-loading elements forbidden, followed by an opaque `sandbox=""` iframe. A trusted CSP precedes source markup and permits only inline CSS, data images, and data fonts. Scripts, external resources, child frames, form submission, and same-origin access are unavailable. SVG is parsed as XML and placed in an image inside the frame, so SVG scripts and links never become active. Frames have a fixed scrollable viewport: measuring their content would require additional origin access or trusted frame scripts. Graphviz uses the pinned, unmodified `@viz-js/viz` 3.30.0 WebAssembly distribution with the `dot` layout engine. Its npm MIT declaration covers the wrapper; its build provenance identifies Graphviz 16.0.0 (EPL-2.0), Expat 2.8.4 (MIT), and Emscripten 5.0.7 (MIT/NCSA). Distribution retains these component terms and the exact Graphviz source download under EPL-2.0 section 3.1. [Full preview notices](../../../../packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt) also retain Mermaid's MIT text and select Apache-2.0 for DOMPurify. The UI primitives package ships the notices and the Web build emits the same bytes alongside its assets. License review covers embedded payloads separately from the general permissive npm-metadata policy. ## Alternatives considered +**Keep the code banner above diagrams.** A language label and permanent text controls distract from the diagram. Overlay actions retain source access without reserving a title row. + +**Render each streamed chunk.** Incomplete diagrams are frequently invalid, and repeated layout work competes with text streaming. Message settlement provides complete source. + +**Put rendering inside Chat or add a general preview registry.** A shared primitive with plain props satisfies reuse without another registry or feature-plugin dependency. This follows the [shared-control rule](../architecture/2026-09-05-shared-client-control-primitives.md). + **Execute HTML scripts in a frame.** Static chat examples do not need script execution. An empty sandbox plus sanitization and CSP gives the preview fewer capabilities and avoids introducing a frame messaging protocol. -**Insert rendered markup into Chat.** HTML styles and executable SVG would share the application document. Iframes isolate layout and origin; SVG image mode additionally disables SVG behavior. +**Insert rendered markup into Chat.** The requested preview needs diagram display and source access; HTML styles and executable SVG would share the application document. Iframes isolate layout and origin; SVG image mode additionally disables SVG behavior. **Treat Viz.js as MIT-only or use a remote Graphviz service.** The compiled Graphviz license still applies locally; a remote renderer would send conversation content off-device. The bundled renderer retains source availability and legal notices without network rendering. ## Consequences -No Session event, prompt, or tool changes. Inline HTML styles work, while interactive scripts, external assets, and links do not. Graphviz adds a lazy WebAssembly asset and synchronous browser-thread layout; source cancellation prevents publication but cannot preempt active layout. Mermaid's existing layout limitations remain documented in its owning note. +The feature changes presentation without changing persisted messages, provider requests, tools, or Host APIs. Inline HTML styles work, while interactive scripts, external assets, and links do not. Mermaid and Graphviz add lazy browser assets and run layout on the browser thread. Cancellation cannot preempt active layout; Mermaid finishes and releases its measurement DOM even when its result cannot be published. The previews have no editing, export, zoom controls, or interactive diagram links. -Component tests cover source copying, default preview, fallback, cancellation, and recovery. The keyless [browser scenario](../../../../apps/web/tests/markdown-mermaid.e2e.ts) verifies opaque frames, real image decoding, source toggling, blocked script/navigation/resource attempts, locale snapshots, and served license text. Notices checks pin the reviewed wrapper and native provenance so upgrades require renewed review. +Component tests cover source copying, default preview, delayed completion, stale success and failure, unmounting, fallback, cancellation, runtime loading failure, and recovery. The keyless [browser scenario](../../../../apps/web/tests/markdown-mermaid.e2e.ts) verifies Chinese Mermaid flowcharts, sequence diagrams, malformed source, configuration overrides, opaque frames, real image decoding, source toggling, blocked script/navigation/resource attempts, English/Chinese UI snapshots, and served license text. Notices checks pin the reviewed wrapper and native provenance so upgrades require renewed review. diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md index 92f4b03087..42488547ef 100644 --- a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md +++ b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md @@ -6,26 +6,38 @@ Status: implemented ## Problem -读者需要直接在 Assistant 回复中查看 DOT 图表、SVG 图像和 HTML 示例。这些源码不可信,而渲染器的 npm 许可证字段可能遗漏编译组件各自的分发义务。 +读者需要直接在 Assistant 回复中查看 Mermaid 和 DOT 图表、SVG 图像和 HTML 示例,而不必解读源码或复制到其他渲染器。这些源码不可信,而渲染器的 npm 许可证字段可能遗漏编译组件各自的分发义务。 ## Decision -共享 Markdown 渲染器通过本地化的 `MarkdownLabels.preview` 启用定稿后的 `graphviz`/`dot`、`svg` 和 `html` fence。`CodeBlock.preview` 负责默认可视化、源码切换与原样复制。`SourcePreview` 为这些文档及 [Mermaid 预览](2026-09-07-web-mermaid-preview.zh.md)负责加载、失败和取消过期结果发布。未提供预览文案的调用方与流式消息保留代码显示。 +共享 Markdown 渲染器通过本地化的 `MarkdownLabels.preview` 和解析后的 fence 语言启用定稿后的 `mermaid`、`graphviz`/`dot`、`svg` 和 `html` fence。[UI primitives 包](../../../../packages/client/ui-primitives/README.zh.md)拥有 `SourcePreview`,它接收渲染器、源码和文案,不依赖 Session、文件或 Cordis。Mermaid 与 Graphviz 各自向同一组件提供 `.ts` 渲染器。未提供预览文案的调用方与流式消息保留代码显示。 -HTML 先由 DOMPurify 清理,禁止导航属性与文档加载元素,再进入不透明来源的 `sandbox=""` iframe。可信 CSP 位于源码标记之前,仅允许内联 CSS、data 图片与 data 字体。脚本、外部资源、子 iframe、表单提交与同源访问均不可用。SVG 按 XML 解析后作为图片放进 iframe,因此 SVG 脚本与链接不会激活。iframe 使用固定的可滚动视口:测量内容需要额外的来源访问权限或可信 iframe 脚本。Mermaid 保留既有的严格渲染器与不可执行图片展示。 +`CodeBlock.preview` 负责默认可视化、源码切换与原样复制。预览省略语言横幅,在悬停或键盘聚焦时显示紧凑的图标操作;具有任何触控输入的设备始终在图表下方显示操作。切换到源码会隐藏已挂载的预览,保留完成的渲染和待完成的工作。两种视图使用同一个保持焦点的切换按钮,复制始终读取源码属性。 + +`SourcePreview` 负责加载、失败和取消过期结果发布。替换源码和卸载组件会取消结果发布;在运行时加载完成前取消会跳过布局。失败时显示本地化错误与原始源码,用有效输入替换无效源码后可以恢复预览。 + +Mermaid 按需加载。其公开渲染 API 串行执行图表工作,每次调用都在 `finally` 中删除临时测量 DOM。图表配置无法覆盖严格安全模式、禁用 HTML 标签、中性色主题和错误渲染策略。生成的 SVG 作为图片显示,不安装链接或脚本。固有尺寸来自 SVG viewBox;大图缩小以适应宽度,两种应用主题下的画布均保持浅色。 + +HTML 先由 DOMPurify 清理,禁止导航属性与文档加载元素,再进入不透明来源的 `sandbox=""` iframe。可信 CSP 位于源码标记之前,仅允许内联 CSS、data 图片与 data 字体。脚本、外部资源、子 iframe、表单提交与同源访问均不可用。SVG 按 XML 解析后作为图片放进 iframe,因此 SVG 脚本与链接不会激活。iframe 使用固定的可滚动视口:测量内容需要额外的来源访问权限或可信 iframe 脚本。 Graphviz 使用固定且未修改的 `@viz-js/viz` 3.30.0 WebAssembly 发布包,布局引擎为 `dot`。其 npm MIT 声明覆盖包装层;构建来源记录标明 Graphviz 16.0.0(EPL-2.0)、Expat 2.8.4(MIT)与 Emscripten 5.0.7(MIT/NCSA)。分发保留各组件条款,并按 EPL-2.0 第 3.1 节提供准确的 Graphviz 源码下载地址。[完整预览声明](../../../../packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt)还保留 Mermaid 的 MIT 文本,并为 DOMPurify 选择 Apache-2.0。UI primitives 包携带该声明,Web 构建在资源旁输出相同字节。内嵌产物的许可证检查独立于通用的宽松 npm 元数据策略。 ## Alternatives considered +**在图表上方保留代码横幅。** 语言标签和常驻文字控件会分散对图表的注意力。浮层操作保留源码访问,不占用标题行。 + +**渲染每个流式片段。** 未完成的图表通常无效,反复布局会与文本流式输出争用资源。消息定稿可提供完整源码。 + +**在 Chat 内部渲染,或添加通用预览注册表。** 使用普通属性的共享基础组件即可满足复用,无需另加注册表或功能插件依赖。这遵循[共享控件规则](../architecture/2026-09-05-shared-client-control-primitives.zh.md)。 + **在 iframe 内执行 HTML 脚本。** 静态聊天示例不需要脚本执行。空 sandbox、清理与 CSP 降低预览权限,也避免引入 iframe 消息协议。 -**把渲染标记插入 Chat。** HTML 样式和可执行 SVG 会与应用共享文档。iframe 隔离布局与来源,SVG 图片模式额外禁用 SVG 行为。 +**把渲染标记插入 Chat。** 所需预览只需显示图表和访问源码;HTML 样式和可执行 SVG 会与应用共享文档。iframe 隔离布局与来源,SVG 图片模式额外禁用 SVG 行为。 **将 Viz.js 视为仅使用 MIT,或使用远程 Graphviz 服务。** 本地编译的 Graphviz 仍受其许可证约束;远程渲染会把对话内容发送到设备之外。内置渲染器保留源码可获取性与法律声明,无需网络渲染。 ## Consequences -不改变 Session 事件、提示词或工具。HTML 内联样式可用,交互脚本、外部资源和链接不可用。Graphviz 增加按需加载的 WebAssembly 资源与浏览器线程同步布局;源码取消可以阻止结果发布,但无法抢占进行中的布局。Mermaid 既有布局限制仍记录在其所属决策中。 +该功能改变呈现,不改变持久化消息、provider 请求、工具或 Host API。HTML 内联样式可用,交互脚本、外部资源和链接不可用。Mermaid 和 Graphviz 增加按需加载的浏览器资源,并在浏览器线程上执行布局。取消无法抢占进行中的布局;即使结果无法发布,Mermaid 仍会完成并释放测量 DOM。预览不提供编辑、导出、缩放控件或交互式图表链接。 -组件测试覆盖源码复制、默认预览、回退、取消与恢复。无密钥[浏览器场景](../../../../apps/web/tests/markdown-mermaid.e2e.ts)验证不透明来源 iframe、真实图片解码、源码切换、脚本/导航/资源请求被阻止、本地化快照和已提供的许可证文本。声明检查固定已审查的包装层与原生构建来源,升级时须重新审查。 +组件测试覆盖源码复制、默认预览、延迟完成、过期成功与失败、卸载、回退、取消、运行时加载失败与恢复。无密钥[浏览器场景](../../../../apps/web/tests/markdown-mermaid.e2e.ts)验证中文 Mermaid 流程图、时序图、无效源码、配置覆盖、不透明来源 iframe、真实图片解码、源码切换、脚本/导航/资源请求被阻止、中英文 UI 快照和已提供的许可证文本。声明检查固定已审查的包装层与原生构建来源,升级时须重新审查。 diff --git a/packages/client/locale/src/locales/en.ts b/packages/client/locale/src/locales/en.ts index 1d97566db1..374de7c7b0 100644 --- a/packages/client/locale/src/locales/en.ts +++ b/packages/client/locale/src/locales/en.ts @@ -44,8 +44,8 @@ export const en = { 'markdown.preview.loading': 'Rendering preview…', 'markdown.preview.error': 'Unable to render this preview. The source is shown below.', 'markdown.mermaid.diagram': 'Mermaid diagram', - 'markdown.mermaid.preview': 'Preview', - 'markdown.mermaid.source': 'Source', + 'markdown.preview.preview': 'Preview', + 'markdown.preview.source': 'Source', 'markdown.mermaid.loading': 'Rendering diagram…', 'markdown.mermaid.error': 'Unable to render this diagram. The source is shown below.', 'markdown.truncatedCharacters': '… truncated at {total} characters', diff --git a/packages/client/locale/src/locales/zh.ts b/packages/client/locale/src/locales/zh.ts index a799548c28..df1aa1d19e 100644 --- a/packages/client/locale/src/locales/zh.ts +++ b/packages/client/locale/src/locales/zh.ts @@ -42,8 +42,8 @@ export const zh = { 'markdown.preview.loading': '正在渲染预览…', 'markdown.preview.error': '无法渲染此预览,源码如下。', 'markdown.mermaid.diagram': 'Mermaid 图表', - 'markdown.mermaid.preview': '预览', - 'markdown.mermaid.source': '源码', + 'markdown.preview.preview': '预览', + 'markdown.preview.source': '源码', 'markdown.mermaid.loading': '正在渲染图表…', 'markdown.mermaid.error': '无法渲染此图表,源码如下。', 'markdown.truncatedCharacters': '… 已截断,共 {total} 字符', diff --git a/packages/client/ui-chat/src/client/markdown-labels.ts b/packages/client/ui-chat/src/client/markdown-labels.ts index ea70175c57..c77cb8e9e4 100644 --- a/packages/client/ui-chat/src/client/markdown-labels.ts +++ b/packages/client/ui-chat/src/client/markdown-labels.ts @@ -9,24 +9,21 @@ import type { ChatViewSlotProps } from './contract/slots.ts' * @returns Labels for code fences and footnotes. */ export function markdownLabels(t: ChatViewSlotProps['t']): MarkdownLabels { + const status = { loading: t('markdown.preview.loading'), error: t('markdown.preview.error') } return { code: { copyLabel: t('copy'), copiedLabel: t('copied') }, footnotes: t('markdown.footnotes'), preview: { - graphviz: t('markdown.preview.graphviz'), - svg: t('markdown.preview.svg'), - html: t('markdown.preview.html'), - preview: t('markdown.mermaid.preview'), - source: t('markdown.mermaid.source'), - loading: t('markdown.preview.loading'), - error: t('markdown.preview.error'), - }, - mermaid: { - diagram: t('markdown.mermaid.diagram'), - preview: t('markdown.mermaid.preview'), - source: t('markdown.mermaid.source'), - loading: t('markdown.mermaid.loading'), - error: t('markdown.mermaid.error'), + preview: t('markdown.preview.preview'), + source: t('markdown.preview.source'), + mermaid: { + diagram: t('markdown.mermaid.diagram'), + loading: t('markdown.mermaid.loading'), + error: t('markdown.mermaid.error'), + }, + graphviz: { ...status, diagram: t('markdown.preview.graphviz') }, + svg: { ...status, diagram: t('markdown.preview.svg') }, + html: { ...status, diagram: t('markdown.preview.html') }, }, } } diff --git a/packages/client/ui-primitives/README.i18n.yaml b/packages/client/ui-primitives/README.i18n.yaml index bdd6417054..a3d90c6a34 100644 --- a/packages/client/ui-primitives/README.i18n.yaml +++ b/packages/client/ui-primitives/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-primitives/README.md -README.md: a1e877c5249817c7ab2e9fa1f6a8ad9582c44a3a -README.zh.md: 81923da65cc21f794d2e7f5d822feb69c06f7499 +README.md: a4fe046ba31212b2029e7689a542b55dd9eceb8b +README.zh.md: 59a3f0cae2b9253c303e0fb244e13c61e17d0417 diff --git a/packages/client/ui-primitives/README.md b/packages/client/ui-primitives/README.md index a1e877c524..a4fe046ba3 100644 --- a/packages/client/ui-primitives/README.md +++ b/packages/client/ui-primitives/README.md @@ -53,7 +53,6 @@ Check this table before writing a control in a feature package. A plugin cannot | `Toast` | Transient top-center banner held for the owner's `holdMs`. | | `JsonTree`, `JsonBlock` | Read-only JSON inspection. | | `MarkdownText`, `CodeBlock` | Untrusted GFM with TeX math, and highlighted code. `CodeBlock` accepts opt-in `lineNumbers`; copied source excludes the gutter. | -| `MermaidPreview` | Read-only Mermaid diagram image with loading and source fallback states. | | `TerminalBlock`, `ReadBlock`, `DiffBlock`, `SearchBlock`, `WebBlock` | The agent-output card matching each tool-result intent. | | `icons/*`, `FishLogo`, `BrandWordmark`, `ReferenceIcon`, `LinkIcon`, `DocumentFileIcon` | Glyphs and brand marks, all riding `currentColor`. | | `FileTypeIcon` | The coloured file-type sheet (code, html, image, markdown, pdf, sheet, slides, document, other); `classifyFileType` picks the kind from a path's extension. | @@ -74,11 +73,11 @@ The catalog above lists what each export is for; this section covers the behavio `MarkdownText` renders untrusted GFM and TeX math, blocks unsafe links and images, and can turn resolved file mentions into explicit controls. When the owner passes a `pathImages` vocabulary, image destinations that are local media paths rewrite to displayable URLs on settled renders only (the same streaming gate as file mentions); without a vocabulary, local destinations remain inert alt text. A load or decode failure replaces the image with its authored alt text, or the original destination when alt is empty. Changing the image source permits a fresh load. While a reply streams, it freezes completed blocks, advances a top-level open fence by completed lines, and highlights that fence from saved Shiki grammar state. Completed token lines enter fixed-size React groups, so later chunks reconcile only the growing group; an unchanged fence retains that DOM when the final full parse resolves cross-document syntax. `TerminalBlock`, `ReadBlock`, `DiffBlock`, `SearchBlock`, and `WebBlock` render the matching tool-result intent with copy controls, overflow handling, and ANSI processing where applicable. `JsonTree` and `JsonBlock` inspect JSON values read-only, while `projectUserText` projects sent user text into inline plain runs and reference chips for the message bubble and queue rows. -`MermaidPreview` renders complete Mermaid source on a light canvas. Rendering loads Mermaid on demand, uses strict security, and exposes the generated SVG as an image with no diagram link handlers. A render failure shows the original source with the supplied error label; replacing the source discards late results from the previous render. The diagram keeps its intrinsic size and shrinks to fit the available width. +Supply `MarkdownLabels.preview` to enable settled `mermaid`, `graphviz`/`dot`, `svg`, and `html` fences. Each language supplies localized preview states, and consumers without these labels retain code. Mermaid renders complete source on a light canvas. Rendering loads Mermaid on demand, uses strict security, and exposes the generated SVG as an image with no diagram link handlers. A render failure shows the original source with the supplied error label; replacing the source discards late results from the previous render. The diagram keeps its intrinsic size and shrinks to fit the available width. -Supply `MarkdownLabels.mermaid` to enable `mermaid` fence previews in a Markdown consumer; without it, fences remain code. Previews start after the message settles. `CodeBlock.preview` supplies an optional headerless body with icon actions for source switching and copying. Actions appear on hover or keyboard focus, and stay visible below the diagram whenever a touchscreen is available, including with a mouse attached. Switching to source keeps the preview mounted, so returning reuses its result; copying always retains the source. [The Mermaid decision](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.md) records the rendering and reuse choices. +`CodeBlock.preview` supplies an optional headerless body with icon actions for source switching and copying. Actions appear on hover or keyboard focus, and stay visible below the diagram whenever a touchscreen is available, including with a mouse attached. Switching to source keeps the preview mounted, so returning reuses its result; copying always retains the source. -Supply `MarkdownLabels.preview` to enable `graphviz`/`dot`, `svg`, and `html` fences. Each settled fence defaults to visualization and shares the source/copy controls. Graphviz loads `@viz-js/viz` on demand and renders DOT with the `dot` engine. SVG and Graphviz output are inert images inside opaque sandbox iframes; malformed SVG and DOT retain their source with an error. HTML accepts complete documents or fragments and preserves inline styles, but strips scripts and navigation. Frames have no sandbox permissions, and their Content Security Policy blocks external resources, embedded frames, forms, and scripts. Frames use a 400px scrollable viewport. Raw HTML outside a code fence remains ordinary Markdown input. +Each settled fence defaults to visualization and shares the source/copy controls. Graphviz loads `@viz-js/viz` on demand and renders DOT with the `dot` engine. SVG and Graphviz output are inert images inside opaque sandbox iframes; malformed SVG and DOT retain their source with an error. HTML accepts complete documents or fragments and preserves inline styles, but strips scripts and navigation. Frames have no sandbox permissions, and their Content Security Policy blocks external resources, embedded frames, forms, and scripts. Frames use a 400px scrollable viewport. Raw HTML outside a code fence remains ordinary Markdown input. [Preview license notices](THIRD_PARTY_PREVIEW_NOTICES.txt) ship with this package and the Web frontend. Mermaid is MIT; Viz.js is MIT but embeds Graphviz under EPL-2.0. The notices retain license texts and the exact Graphviz source download. Dependency upgrades require reviewing the embedded payload as well as npm metadata; the [preview decision](../../../.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md) records the distribution and sandbox choices. diff --git a/packages/client/ui-primitives/README.zh.md b/packages/client/ui-primitives/README.zh.md index 81923da65c..59a3f0cae2 100644 --- a/packages/client/ui-primitives/README.zh.md +++ b/packages/client/ui-primitives/README.zh.md @@ -53,7 +53,6 @@ kind: "package-library" | `Toast` | 顶部居中的瞬时横幅,保持时长由所有者的 `holdMs` 决定。 | | `JsonTree`、`JsonBlock` | 只读 JSON 查看。 | | `MarkdownText`、`CodeBlock` | 不可信 GFM 与 TeX 数学,以及高亮代码。`CodeBlock` 可通过 `lineNumbers` 开启行号;复制的源码不含行号栏。 | -| `MermaidPreview` | 只读 Mermaid 图表图片,包含加载状态与源码回退状态。 | | `TerminalBlock`、`ReadBlock`、`DiffBlock`、`SearchBlock`、`WebBlock` | 与各类工具结果意图对应的 agent 输出卡片。 | | `icons/*`、`FishLogo`、`BrandWordmark`、`ReferenceIcon`、`LinkIcon`、`DocumentFileIcon` | 字形与品牌标识,全部随 `currentColor`。 | | `FileTypeIcon` | 彩色文件类型纸片(code、html、image、markdown、pdf、sheet、slides、document、other);`classifyFileType` 按路径扩展名选出类型。 | @@ -74,11 +73,11 @@ kind: "package-library" `MarkdownText` 渲染不可信的 GFM 与 TeX 公式、阻止不安全的链接与图片,并可把已解析的文件提及转换为显式控件。当 owner 传入 `pathImages` 词表时,本地媒体路径的图片目标只在落定渲染阶段重写为可展示 URL(与 file mentions 相同的流式门);不传词表时本地目标保持惰性 alt 文本。加载或解码失败后,图片替换为作者的 alt 文本;alt 为空时显示原始目标路径。图片源变化后可重新加载。回复流式输出时,它冻结已完成的块、按已完成行推进顶层未闭合 fence,并从保存的 Shiki grammar state 为该 fence 增量高亮。已完成的 token 行进入固定大小的 React 分组,后续分片只 reconcile 正在增长的分组;最终全量解析解决跨文档语法时,未变化的 fence 会保留该 DOM。`TerminalBlock`、`ReadBlock`、`DiffBlock`、`SearchBlock` 与 `WebBlock` 把对应的工具结果意图渲染为带复制控件、溢出处理及适用时 ANSI 处理的卡片。`JsonTree` 与 `JsonBlock` 以只读方式检查 JSON 值;`projectUserText` 把已发送的用户文本投影为行内普通文本段与引用 chip,供消息气泡和排队行使用。 -`MermaidPreview` 在浅色画布上渲染完整的 Mermaid 源码。渲染按需加载 Mermaid、使用严格安全模式,并把生成的 SVG 显示为图片,不绑定图内链接处理器。渲染失败时显示原始源码与传入的错误文案;替换源码后会丢弃前一次渲染的延迟结果。图表保留固有尺寸,并在可用宽度不足时缩小。 +提供 `MarkdownLabels.preview` 可启用定稿后的 `mermaid`、`graphviz`/`dot`、`svg` 和 `html` fence。每种语言提供本地化预览状态,未提供这些文案的调用方保留代码显示。Mermaid 在浅色画布上渲染完整源码。渲染按需加载 Mermaid、使用严格安全模式,并把生成的 SVG 显示为图片,不绑定图内链接处理器。渲染失败时显示原始源码与传入的错误文案;替换源码后会丢弃前一次渲染的延迟结果。图表保留固有尺寸,并在可用宽度不足时缩小。 -为 Markdown 调用方传入 `MarkdownLabels.mermaid` 即可启用 `mermaid` fence 预览;未传入时,fence 保持代码显示。预览在消息定稿后开始。`CodeBlock.preview` 提供无标题栏的替代正文,以及切换源码和复制的图标操作。操作在悬停或键盘聚焦时出现;只要设备具备触屏,就在图表下方保持可见,包括同时连接鼠标的情况。切换到源码时保留已挂载的预览,返回时复用其结果;复制始终保留源码。[Mermaid 决策](../../../.agents/notes/implemented/feature/2026-09-07-web-mermaid-preview.zh.md)记录了渲染与复用选择。 +`CodeBlock.preview` 提供无标题栏的替代正文,以及切换源码和复制的图标操作。操作在悬停或键盘聚焦时出现;只要设备具备触屏,就在图表下方保持可见,包括同时连接鼠标的情况。切换到源码时保留已挂载的预览,返回时复用其结果;复制始终保留源码。 -传入 `MarkdownLabels.preview` 可启用 `graphviz`/`dot`、`svg` 和 `html` fence。每个定稿 fence 默认显示可视化,并共享源码切换与复制操作。Graphviz 按需加载 `@viz-js/viz`,用 `dot` 引擎渲染 DOT。SVG 与 Graphviz 输出作为不可执行的图片放入不透明来源的 sandbox iframe;非法 SVG 与 DOT 显示错误并保留源码。HTML 接受完整文档或片段、保留内联样式,同时移除脚本与导航。iframe 不授予任何 sandbox 权限,Content Security Policy 阻止外部资源、嵌套 iframe、表单与脚本。iframe 使用可滚动的 400px 视口。代码 fence 外的原始 HTML 仍按普通 Markdown 输入处理。 +每个定稿 fence 默认显示可视化,并共享源码切换与复制操作。Graphviz 按需加载 `@viz-js/viz`,用 `dot` 引擎渲染 DOT。SVG 与 Graphviz 输出作为不可执行的图片放入不透明来源的 sandbox iframe;非法 SVG 与 DOT 显示错误并保留源码。HTML 接受完整文档或片段、保留内联样式,同时移除脚本与导航。iframe 不授予任何 sandbox 权限,Content Security Policy 阻止外部资源、嵌套 iframe、表单与脚本。iframe 使用可滚动的 400px 视口。代码 fence 外的原始 HTML 仍按普通 Markdown 输入处理。 [预览许可证声明](THIRD_PARTY_PREVIEW_NOTICES.txt)随本包与 Web 前端分发。Mermaid 使用 MIT;Viz.js 使用 MIT,但内嵌 Graphviz 使用 EPL-2.0。声明保留完整许可证文本及准确的 Graphviz 源码下载地址。升级依赖时必须同时检查内嵌产物和 npm 元数据;[预览决策](../../../.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md)记录分发与 sandbox 选择。 diff --git a/packages/client/ui-primitives/src/index.ts b/packages/client/ui-primitives/src/index.ts index 7600a0f9ca..d9b12eda0e 100644 --- a/packages/client/ui-primitives/src/index.ts +++ b/packages/client/ui-primitives/src/index.ts @@ -64,8 +64,6 @@ export type { } from './WebBlock.tsx' export { CodeBlock } from './markdown/CodeBlock.tsx' export type { CodeBlockProps } from './markdown/CodeBlock.tsx' -export { MermaidPreview } from './markdown/MermaidPreview.tsx' -export type { MermaidPreviewLabels } from './markdown/MermaidPreview.tsx' export { JsonBlock } from './markdown/JsonBlock.tsx' export { MarkdownText } from './markdown/MarkdownText.tsx' export type { MarkdownCodeLabels, MarkdownFileMentions, MarkdownLabels, MarkdownPathImages } from './markdown/MarkdownText.tsx' diff --git a/packages/client/ui-primitives/src/markdown/CodeBlock.module.css b/packages/client/ui-primitives/src/markdown/CodeBlock.module.css index 33a114d102..91c122c61c 100644 --- a/packages/client/ui-primitives/src/markdown/CodeBlock.module.css +++ b/packages/client/ui-primitives/src/markdown/CodeBlock.module.css @@ -98,31 +98,6 @@ color: var(--dsw-alias-label-primary); } -.numbered :where(pre) code { - display: block; - counter-reset: source-line; - white-space: normal; -} - -.numbered :where(pre) code > :global(.line) { - position: relative; - display: block; - min-height: 1lh; - padding-inline-start: calc(var(--dsl-code-block-line-number-width) + 12px); - counter-increment: source-line; - white-space: var(--dsl-code-block-line-white-space, pre-wrap); -} - -.numbered :where(pre) code > :global(.line)::before { - position: absolute; - inset-inline-start: 0; - width: var(--dsl-code-block-line-number-width); - color: var(--dsw-alias-label-tertiary); - text-align: end; - content: counter(source-line); - user-select: none; -} - /* Alternate content is a figure; its actions overlay instead of taking a title row. */ .preview.showingPreview { background: transparent; @@ -205,3 +180,28 @@ padding-top: 16px; } } + +.numbered :where(pre) code { + display: block; + counter-reset: source-line; + white-space: normal; +} + +.numbered :where(pre) code > :global(.line) { + position: relative; + display: block; + min-height: 1lh; + padding-inline-start: calc(var(--dsl-code-block-line-number-width) + 12px); + counter-increment: source-line; + white-space: var(--dsl-code-block-line-white-space, pre-wrap); +} + +.numbered :where(pre) code > :global(.line)::before { + position: absolute; + inset-inline-start: 0; + width: var(--dsl-code-block-line-number-width); + color: var(--dsw-alias-label-tertiary); + text-align: end; + content: counter(source-line); + user-select: none; +} diff --git a/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx b/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx deleted file mode 100644 index dc330e9da8..0000000000 --- a/packages/client/ui-primitives/src/markdown/MermaidPreview.tsx +++ /dev/null @@ -1,17 +0,0 @@ -/** Mermaid image preview using the shared asynchronous source renderer. */ - -import { renderMermaid } from './mermaid.ts' -import { SourcePreview } from './SourcePreview.tsx' -import type { PreviewLabels } from './SourcePreview.tsx' - -/** Localized Mermaid preview states; source remains verbatim. */ -export type MermaidPreviewLabels = PreviewLabels - -/** - * Display a complete Mermaid document as an inert SVG image. - * @param props - Source and complete localized labels. - * @returns A loading status, diagram image, or error with the original source. - */ -export function MermaidPreview({ code, labels }: { code: string; labels: MermaidPreviewLabels }) { - return -} diff --git a/packages/client/ui-primitives/src/markdown/MermaidPreview.module.css b/packages/client/ui-primitives/src/markdown/SourcePreview.module.css similarity index 100% rename from packages/client/ui-primitives/src/markdown/MermaidPreview.module.css rename to packages/client/ui-primitives/src/markdown/SourcePreview.module.css diff --git a/packages/client/ui-primitives/src/markdown/SourcePreview.tsx b/packages/client/ui-primitives/src/markdown/SourcePreview.tsx index 376b69710a..be0871673c 100644 --- a/packages/client/ui-primitives/src/markdown/SourcePreview.tsx +++ b/packages/client/ui-primitives/src/markdown/SourcePreview.tsx @@ -1,7 +1,7 @@ /** Read-only diagram preview with source fallback and per-source async ownership. */ import { useEffect, useState } from 'react' -import css from './MermaidPreview.module.css' +import css from './SourcePreview.module.css' /** Localized preview states; the diagram source remains verbatim. */ export interface PreviewLabels { diff --git a/packages/client/ui-primitives/src/markdown/mermaid.ts b/packages/client/ui-primitives/src/markdown/mermaid.ts index 4db2a64b6c..888a01cdca 100644 --- a/packages/client/ui-primitives/src/markdown/mermaid.ts +++ b/packages/client/ui-primitives/src/markdown/mermaid.ts @@ -2,7 +2,7 @@ import type { Mermaid } from 'mermaid' import clsx from 'clsx' -import css from './MermaidPreview.module.css' +import css from './SourcePreview.module.css' let runtime: Promise | undefined let nextDiagramId = 0 diff --git a/packages/client/ui-primitives/src/markdown/render.tsx b/packages/client/ui-primitives/src/markdown/render.tsx index cb1bd91eb1..f96884df64 100644 --- a/packages/client/ui-primitives/src/markdown/render.tsx +++ b/packages/client/ui-primitives/src/markdown/render.tsx @@ -26,8 +26,8 @@ import { CodeBlock } from './CodeBlock.tsx' import { SourcePreview } from './SourcePreview.tsx' import { renderGraphviz } from './graphviz.ts' import { renderHtml, renderSvg } from './preview-document.ts' -import { MermaidPreview } from './MermaidPreview.tsx' -import type { MermaidPreviewLabels } from './MermaidPreview.tsx' +import { renderMermaid } from './mermaid.ts' +import type { PreviewLabels } from './SourcePreview.tsx' import { renderTexToReact } from './katex.tsx' import { LinkIcon, classifyLinkPath } from '../LinkIcon.tsx' import type { PositionedBlock } from './incremental.ts' @@ -45,17 +45,14 @@ export interface MarkdownCodeLabels { export interface MarkdownLabels { code: MarkdownCodeLabels footnotes: string - /** Opt into settled Mermaid fence previews by supplying their complete localized labels. */ - mermaid?: MermaidPreviewLabels & { preview: string; source: string } - /** Opt into settled Graphviz, SVG, and static HTML previews with complete localized labels. */ + /** Opt into settled Mermaid, Graphviz, SVG, and static HTML previews with complete localized labels. */ preview?: { - graphviz: string - svg: string - html: string + mermaid: PreviewLabels + graphviz: PreviewLabels + svg: PreviewLabels + html: PreviewLabels preview: string source: string - loading: string - error: string } } @@ -418,20 +415,13 @@ function renderCode(node: Md.Code, key: Key, context: MarkdownRenderContext): Re /** Resolve the supported fence language without treating arbitrary HTML in Markdown as a preview. */ function fencePreview(lang: string | undefined, code: string, labels: MarkdownLabels) { - if (lang === 'mermaid' && labels.mermaid !== undefined) { - return { - content: , - previewLabel: labels.mermaid.preview, - sourceLabel: labels.mermaid.source, - } - } if (labels.preview === undefined) return undefined const kind = lang === 'dot' ? 'graphviz' : lang - if (kind !== 'graphviz' && kind !== 'svg' && kind !== 'html') return undefined - const render = { graphviz: renderGraphviz, svg: renderSvg, html: renderHtml }[kind] + if (kind !== 'mermaid' && kind !== 'graphviz' && kind !== 'svg' && kind !== 'html') return undefined + const render = { mermaid: renderMermaid, graphviz: renderGraphviz, svg: renderSvg, html: renderHtml }[kind] return { content: ( - + ), previewLabel: labels.preview.preview, sourceLabel: labels.preview.source, diff --git a/packages/client/ui-primitives/tests/fence-previews.client.spec.tsx b/packages/client/ui-primitives/tests/fence-previews.client.spec.tsx index 50e4b3d2d9..8e8b4abf58 100644 --- a/packages/client/ui-primitives/tests/fence-previews.client.spec.tsx +++ b/packages/client/ui-primitives/tests/fence-previews.client.spec.tsx @@ -7,16 +7,20 @@ import { renderGraphviz } from '../src/markdown/graphviz.ts' import { renderHtml, renderSvg } from '../src/markdown/preview-document.ts' import { markdownLabels } from './labels.client.ts' +const status = { loading: 'Loading', error: 'Cannot preview' } const preview = { - graphviz: 'Graphviz diagram', svg: 'SVG preview', html: 'HTML preview', - preview: 'Preview', source: 'Source', loading: 'Loading', error: 'Cannot preview', + mermaid: { ...status, diagram: 'Mermaid diagram' }, + graphviz: { ...status, diagram: 'Graphviz diagram' }, + svg: { ...status, diagram: 'SVG preview' }, + html: { ...status, diagram: 'HTML preview' }, + preview: 'Preview', source: 'Source', } const svg = '示例' const cases = [ - ['graphviz', 'digraph { Input -> Preview }', preview.graphviz], - ['dot', 'digraph { Input -> Preview }', preview.graphviz], - ['svg', svg, preview.svg], - ['html', '

Example

', preview.html], + ['graphviz', 'digraph { Input -> Preview }', preview.graphviz.diagram], + ['dot', 'digraph { Input -> Preview }', preview.graphviz.diagram], + ['svg', svg, preview.svg.diagram], + ['html', '

Example

', preview.html.diagram], ] as const afterEach(() => { cleanup(); vi.unstubAllGlobals() }) @@ -53,11 +57,11 @@ describe('Markdown fence previews', () => { it.each(['svg', 'graphviz'])('retains invalid %s source and recovers after replacement', async (lang) => { const view = render() - await screen.findByText(preview.error) + await screen.findByText(status.error) expect(view.container.querySelector('pre code')?.textContent).toBe('broken') view.rerender() - await screen.findByTitle(preview.svg) - expect(screen.queryByText(preview.error)).toBeNull() + await screen.findByTitle(preview.svg.diagram) + expect(screen.queryByText(status.error)).toBeNull() }) it('requires an opted-in code fence and leaves raw HTML and other languages unrendered', () => { diff --git a/packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx b/packages/client/ui-primitives/tests/source-preview.client.spec.tsx similarity index 73% rename from packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx rename to packages/client/ui-primitives/tests/source-preview.client.spec.tsx index c7cf95a9d4..fe356f64bb 100644 --- a/packages/client/ui-primitives/tests/mermaid-preview.client.spec.tsx +++ b/packages/client/ui-primitives/tests/source-preview.client.spec.tsx @@ -2,7 +2,8 @@ import { act, cleanup, fireEvent, render, screen } from '@testing-library/react' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { MermaidPreview } from '../src/markdown/MermaidPreview.tsx' +import { SourcePreview } from '../src/markdown/SourcePreview.tsx' +import { CodeBlock } from '../src/markdown/CodeBlock.tsx' import { renderMermaid } from '../src/markdown/mermaid.ts' import { MarkdownText } from '../src/markdown/MarkdownText.tsx' import { markdownLabels } from './labels.client.ts' @@ -13,17 +14,21 @@ const labels = { diagram: 'Mermaid diagram', loading: 'Rendering diagram…', error: 'Unable to render this diagram.', preview: 'Preview', source: 'Source', } +const preview = { + preview: labels.preview, source: labels.source, + mermaid: labels, graphviz: labels, svg: labels, html: labels, +} const source = 'flowchart LR\n A[Input] --> B[Preview]' const imageUrl = 'data:image/svg+xml;charset=utf-8,%3Csvg%2F%3E' afterEach(() => { cleanup(); vi.unstubAllGlobals() }) beforeEach(() => { vi.resetAllMocks() }) -describe('MermaidPreview', () => { +describe('SourcePreview', () => { it('shows loading until rendering completes, then displays an image without inserting SVG', async () => { const pending = Promise.withResolvers() vi.mocked(renderMermaid).mockReturnValue(pending.promise) - const view = render() + const view = render() expect(screen.getByRole('status').textContent).toBe(labels.loading) expect(screen.queryByRole('img')).toBeNull() await act(async () => { pending.resolve(imageUrl) }) @@ -34,12 +39,12 @@ describe('MermaidPreview', () => { it('retains invalid source and recovers when the source changes', async () => { vi.mocked(renderMermaid).mockRejectedValueOnce(new Error('Parse error')) - const view = render() + const view = render() expect((await screen.findByText(labels.error)).getAttribute('role')).toBe('status') expect(view.container.querySelector('pre code')?.textContent).toBe('invalid') const next = Promise.withResolvers() vi.mocked(renderMermaid).mockReturnValue(next.promise) - view.rerender() + view.rerender() expect(screen.getByRole('status').textContent).toBe(labels.loading) expect(view.container.querySelector('pre')).toBeNull() await act(async () => { next.resolve(imageUrl) }) @@ -50,9 +55,9 @@ describe('MermaidPreview', () => { const old = Promise.withResolvers() const next = Promise.withResolvers() vi.mocked(renderMermaid).mockReturnValueOnce(old.promise).mockReturnValueOnce(next.promise) - const view = render() + const view = render() const oldSignal = vi.mocked(renderMermaid).mock.calls[0]![1] - view.rerender() + view.rerender() expect(oldSignal.aborted).toBe(true) await act(async () => { next.resolve(imageUrl) }) await act(async () => { @@ -66,7 +71,7 @@ describe('MermaidPreview', () => { it('cancels the owner when unmounted while loading', async () => { const pending = Promise.withResolvers() vi.mocked(renderMermaid).mockReturnValue(pending.promise) - const view = render() + const view = render() const signal = vi.mocked(renderMermaid).mock.calls[0]![1] view.unmount() expect(signal.aborted).toBe(true) @@ -76,11 +81,29 @@ describe('MermaidPreview', () => { }) describe('Markdown Mermaid fences', () => { + it('retains a preview when switching to numbered source', async () => { + vi.mocked(renderMermaid).mockResolvedValue(imageUrl) + const view = render(, + previewLabel: labels.preview, sourceLabel: labels.source, + }} />) + const diagram = await screen.findByRole('img', { name: labels.diagram }) + expect(view.container.querySelector('[data-line-numbers]')).not.toBeNull() + fireEvent.click(screen.getByRole('button', { name: labels.source })) + expect([...view.container.querySelectorAll('code > .line')].map(line => line.textContent)).toEqual(source.split('\n')) + expect(diagram.isConnected).toBe(true) + expect(screen.queryByRole('img')).toBeNull() + fireEvent.click(screen.getByRole('button', { name: labels.preview })) + expect(screen.getByRole('img', { name: labels.diagram })).toBe(diagram) + expect(renderMermaid).toHaveBeenCalledOnce() + }) + it('keeps streaming source literal, then offers preview, source and source copying', async () => { const writeText = vi.fn().mockResolvedValue(undefined) vi.stubGlobal('navigator', Object.create(navigator, { clipboard: { value: { writeText } } })) vi.mocked(renderMermaid).mockResolvedValue(imageUrl) - const props = { text: `\`\`\`mermaid\n${source}\n\`\`\``, labels: { ...markdownLabels, mermaid: labels } } + const props = { text: `\`\`\`mermaid\n${source}\n\`\`\``, labels: { ...markdownLabels, preview } } const view = render() expect(view.container.querySelector('pre code')?.textContent).toBe(source) expect(renderMermaid).not.toHaveBeenCalled() @@ -107,7 +130,7 @@ describe('Markdown Mermaid fences', () => { it('leaves other languages and consumers without preview labels as code', () => { const view = render() expect(view.container.querySelector('pre code')?.textContent).toBe(source) - view.rerender() + view.rerender() expect(view.container.querySelector('pre code')?.textContent).toBe('flowchart LR') expect(renderMermaid).not.toHaveBeenCalled() }) From 9e050260e4559707a65c904bf0a9427c98096d05 Mon Sep 17 00:00:00 2001 From: "HYD@OVERTON" Date: Wed, 9 Sep 2026 17:04:20 +0800 Subject: [PATCH 08/32] feat(web): adapt diagram previews to application theme --- ...6-09-09-markdown-static-previews.i18n.yaml | 4 +- .../2026-09-09-markdown-static-previews.md | 2 +- .../2026-09-09-markdown-static-previews.zh.md | 2 +- apps/web/tests/markdown-mermaid.e2e.ts | 28 +++++++ .../client/ui-primitives/README.i18n.yaml | 4 +- packages/client/ui-primitives/README.md | 4 +- packages/client/ui-primitives/README.zh.md | 4 +- .../src/markdown/SourcePreview.module.css | 4 +- .../src/markdown/SourcePreview.tsx | 29 ++++++-- .../ui-primitives/src/markdown/graphviz.ts | 23 +++++- .../ui-primitives/src/markdown/mermaid.ts | 74 ++++++++++++++----- .../src/markdown/preview-document.ts | 4 +- .../src/markdown/preview-theme.ts | 27 +++++++ .../tests/graphviz-runtime.client.spec.ts | 32 ++++++++ .../tests/mermaid-runtime.client.spec.ts | 43 ++++++++++- .../tests/source-preview.client.spec.tsx | 25 +++++++ 16 files changed, 267 insertions(+), 42 deletions(-) create mode 100644 packages/client/ui-primitives/src/markdown/preview-theme.ts diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml index c70073de17..8712ee2070 100644 --- a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml +++ b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md -2026-09-09-markdown-static-previews.md: a6d1802546e9e976da7ae4d1ecc024924414e9a4 -2026-09-09-markdown-static-previews.zh.md: 42488547efafdbf5b1944b1300af13f359365d74 +2026-09-09-markdown-static-previews.md: a5fa79fcc8c192dbcd3949debbabbccf85cb3b62 +2026-09-09-markdown-static-previews.zh.md: 30efe897702377c180c9e1650fda93ae42f6e580 diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md index a6d1802546..a5fa79fcc8 100644 --- a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md +++ b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md @@ -16,7 +16,7 @@ The shared Markdown renderer enables settled `mermaid`, `graphviz`/`dot`, `svg`, `SourcePreview` owns loading, failure, and cancellation of stale result publication. Source replacement and unmounting cancel publication; cancellation before runtime loading completes skips layout. Failures show a localized error and the original source, and replacing invalid source with valid input recovers the preview. -Mermaid loads on demand. Its public render API serializes diagram work, and each call removes its temporary measurement DOM in `finally`. Strict security, disabled HTML labels, the neutral theme, and error-rendering policy cannot be overridden by diagram configuration. Generated SVG is displayed as an image without installing links or scripts. Intrinsic dimensions come from the SVG viewBox; large diagrams shrink to fit, and the canvas stays light in both application themes. +Mermaid loads on demand. A shared queue serializes theme initialization with diagram work, and each call removes its temporary measurement DOM in `finally`. Strict security, disabled HTML labels, the application palette, and error-rendering policy cannot be overridden by diagram configuration. Generated SVG is displayed as an image without installing links or scripts. Intrinsic dimensions come from the SVG viewBox; large diagrams shrink to fit, and the canvas follows the code-block background. Mounted previews observe document theme attributes and regenerate only when resolved colors change; obsolete renders cannot publish. Graphviz default colors follow the same palette, while authored DOT, SVG, and HTML colors remain intact. HTML uses DOMPurify with navigation attributes and document-loading elements forbidden, followed by an opaque `sandbox=""` iframe. A trusted CSP precedes source markup and permits only inline CSS, data images, and data fonts. Scripts, external resources, child frames, form submission, and same-origin access are unavailable. SVG is parsed as XML and placed in an image inside the frame, so SVG scripts and links never become active. Frames have a fixed scrollable viewport: measuring their content would require additional origin access or trusted frame scripts. diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md index 42488547ef..30efe89770 100644 --- a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md +++ b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md @@ -16,7 +16,7 @@ Status: implemented `SourcePreview` 负责加载、失败和取消过期结果发布。替换源码和卸载组件会取消结果发布;在运行时加载完成前取消会跳过布局。失败时显示本地化错误与原始源码,用有效输入替换无效源码后可以恢复预览。 -Mermaid 按需加载。其公开渲染 API 串行执行图表工作,每次调用都在 `finally` 中删除临时测量 DOM。图表配置无法覆盖严格安全模式、禁用 HTML 标签、中性色主题和错误渲染策略。生成的 SVG 作为图片显示,不安装链接或脚本。固有尺寸来自 SVG viewBox;大图缩小以适应宽度,两种应用主题下的画布均保持浅色。 +Mermaid 按需加载。共享队列将主题初始化与图表渲染一起串行执行,每次调用都在 `finally` 中删除临时测量 DOM。图表配置无法覆盖严格安全模式、禁用 HTML 标签、应用配色和错误渲染策略。生成的 SVG 作为图片显示,不安装链接或脚本。固有尺寸来自 SVG viewBox;大图缩小以适应宽度,画布使用代码块背景。已挂载的预览观察文档主题属性,仅在解析后的配色变化时重新生成;过期渲染不能发布结果。Graphviz 的默认颜色采用同一配色,DOT、SVG 和 HTML 中明确指定的颜色保持原样。 HTML 先由 DOMPurify 清理,禁止导航属性与文档加载元素,再进入不透明来源的 `sandbox=""` iframe。可信 CSP 位于源码标记之前,仅允许内联 CSS、data 图片与 data 字体。脚本、外部资源、子 iframe、表单提交与同源访问均不可用。SVG 按 XML 解析后作为图片放进 iframe,因此 SVG 脚本与链接不会激活。iframe 使用固定的可滚动视口:测量内容需要额外的来源访问权限或可信 iframe 脚本。 diff --git a/apps/web/tests/markdown-mermaid.e2e.ts b/apps/web/tests/markdown-mermaid.e2e.ts index c009e1d836..d970cc9e11 100644 --- a/apps/web/tests/markdown-mermaid.e2e.ts +++ b/apps/web/tests/markdown-mermaid.e2e.ts @@ -88,6 +88,34 @@ describe('web e2e: Mermaid chat previews', () => { await scaffold?.close() }) + it.skipIf(MODE === 'record')('updates existing diagrams when the document switches between light and dark', async () => { + const page = await newEnglishPage(browser) + try { + await openConversation(page, scaffold) + const image = page.getByRole('img', { name: 'Mermaid diagram' }).first() + await image.waitFor() + let previous = await image.getAttribute('src') + for (const scheme of ['dark', 'light'] as const) { + await page.evaluate((value) => { + document.documentElement.style.colorScheme = value + document.body.toggleAttribute('data-ds-dark-theme', value === 'dark') + }, scheme) + await expect.poll(() => image.getAttribute('src')).not.toBe(previous) + await expect.poll(() => image.evaluate(node => (node as HTMLImageElement).naturalWidth)).toBeGreaterThan(0) + const colors = await image.evaluate(node => ({ + canvas: getComputedStyle(node.parentElement!).backgroundColor, + expected: getComputedStyle(document.body).getPropertyValue('--dsw-alias-markdown-code-block').trim(), + })) + expect(colors.canvas).toBe(colors.expected) + await expect.poll(() => page.getByTitle('HTML preview', { exact: true }).getAttribute('srcdoc')) + .toContain(`color-scheme:${scheme}`) + previous = await image.getAttribute('src') + } + } finally { + await page.close() + } + }) + it.skipIf(MODE === 'record')('renders diagrams, switches to source, copies source, and contains malformed content', async () => { const page = await newEnglishPage(browser) onTestFailed(() => saveFailureShot(page, 'web-e2e-markdown-mermaid')) diff --git a/packages/client/ui-primitives/README.i18n.yaml b/packages/client/ui-primitives/README.i18n.yaml index a3d90c6a34..b3a61421d4 100644 --- a/packages/client/ui-primitives/README.i18n.yaml +++ b/packages/client/ui-primitives/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-primitives/README.md -README.md: a4fe046ba31212b2029e7689a542b55dd9eceb8b -README.zh.md: 59a3f0cae2b9253c303e0fb244e13c61e17d0417 +README.md: 8bdd2b7f90ebe4a998be8158351e49f815343c78 +README.zh.md: b861f9e17ff73f20717aed63b5b087358daeae10 diff --git a/packages/client/ui-primitives/README.md b/packages/client/ui-primitives/README.md index a4fe046ba3..8bdd2b7f90 100644 --- a/packages/client/ui-primitives/README.md +++ b/packages/client/ui-primitives/README.md @@ -73,12 +73,14 @@ The catalog above lists what each export is for; this section covers the behavio `MarkdownText` renders untrusted GFM and TeX math, blocks unsafe links and images, and can turn resolved file mentions into explicit controls. When the owner passes a `pathImages` vocabulary, image destinations that are local media paths rewrite to displayable URLs on settled renders only (the same streaming gate as file mentions); without a vocabulary, local destinations remain inert alt text. A load or decode failure replaces the image with its authored alt text, or the original destination when alt is empty. Changing the image source permits a fresh load. While a reply streams, it freezes completed blocks, advances a top-level open fence by completed lines, and highlights that fence from saved Shiki grammar state. Completed token lines enter fixed-size React groups, so later chunks reconcile only the growing group; an unchanged fence retains that DOM when the final full parse resolves cross-document syntax. `TerminalBlock`, `ReadBlock`, `DiffBlock`, `SearchBlock`, and `WebBlock` render the matching tool-result intent with copy controls, overflow handling, and ANSI processing where applicable. `JsonTree` and `JsonBlock` inspect JSON values read-only, while `projectUserText` projects sent user text into inline plain runs and reference chips for the message bubble and queue rows. -Supply `MarkdownLabels.preview` to enable settled `mermaid`, `graphviz`/`dot`, `svg`, and `html` fences. Each language supplies localized preview states, and consumers without these labels retain code. Mermaid renders complete source on a light canvas. Rendering loads Mermaid on demand, uses strict security, and exposes the generated SVG as an image with no diagram link handlers. A render failure shows the original source with the supplied error label; replacing the source discards late results from the previous render. The diagram keeps its intrinsic size and shrinks to fit the available width. +Supply `MarkdownLabels.preview` to enable settled `mermaid`, `graphviz`/`dot`, `svg`, and `html` fences. Each language supplies localized preview states, and consumers without these labels retain code. Mermaid and Graphviz use the active document palette on the code-block background and update mounted previews when the theme changes. Explicit colors in DOT, SVG, and HTML remain authored content. Rendering loads Mermaid on demand, uses strict security, and exposes the generated SVG as an image with no diagram link handlers. A render failure shows the original source with the supplied error label; replacing the source discards late results from the previous render. The diagram keeps its intrinsic size and shrinks to fit the available width. `CodeBlock.preview` supplies an optional headerless body with icon actions for source switching and copying. Actions appear on hover or keyboard focus, and stay visible below the diagram whenever a touchscreen is available, including with a mouse attached. Switching to source keeps the preview mounted, so returning reuses its result; copying always retains the source. Each settled fence defaults to visualization and shares the source/copy controls. Graphviz loads `@viz-js/viz` on demand and renders DOT with the `dot` engine. SVG and Graphviz output are inert images inside opaque sandbox iframes; malformed SVG and DOT retain their source with an error. HTML accepts complete documents or fragments and preserves inline styles, but strips scripts and navigation. Frames have no sandbox permissions, and their Content Security Policy blocks external resources, embedded frames, forms, and scripts. Frames use a 400px scrollable viewport. Raw HTML outside a code fence remains ordinary Markdown input. +Internal render functions accept optional native `MermaidConfig` and Viz.js `RenderOptions` for developer customization. Attribute and theme-variable overrides merge with document defaults; Mermaid preview restrictions and Graphviz SVG output remain fixed. These parameters have no settings UI. + [Preview license notices](THIRD_PARTY_PREVIEW_NOTICES.txt) ship with this package and the Web frontend. Mermaid is MIT; Viz.js is MIT but embeds Graphviz under EPL-2.0. The notices retain license texts and the exact Graphviz source download. Dependency upgrades require reviewing the embedded payload as well as npm metadata; the [preview decision](../../../.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md) records the distribution and sandbox choices. ### Localizing copy diff --git a/packages/client/ui-primitives/README.zh.md b/packages/client/ui-primitives/README.zh.md index 59a3f0cae2..b861f9e17f 100644 --- a/packages/client/ui-primitives/README.zh.md +++ b/packages/client/ui-primitives/README.zh.md @@ -73,12 +73,14 @@ kind: "package-library" `MarkdownText` 渲染不可信的 GFM 与 TeX 公式、阻止不安全的链接与图片,并可把已解析的文件提及转换为显式控件。当 owner 传入 `pathImages` 词表时,本地媒体路径的图片目标只在落定渲染阶段重写为可展示 URL(与 file mentions 相同的流式门);不传词表时本地目标保持惰性 alt 文本。加载或解码失败后,图片替换为作者的 alt 文本;alt 为空时显示原始目标路径。图片源变化后可重新加载。回复流式输出时,它冻结已完成的块、按已完成行推进顶层未闭合 fence,并从保存的 Shiki grammar state 为该 fence 增量高亮。已完成的 token 行进入固定大小的 React 分组,后续分片只 reconcile 正在增长的分组;最终全量解析解决跨文档语法时,未变化的 fence 会保留该 DOM。`TerminalBlock`、`ReadBlock`、`DiffBlock`、`SearchBlock` 与 `WebBlock` 把对应的工具结果意图渲染为带复制控件、溢出处理及适用时 ANSI 处理的卡片。`JsonTree` 与 `JsonBlock` 以只读方式检查 JSON 值;`projectUserText` 把已发送的用户文本投影为行内普通文本段与引用 chip,供消息气泡和排队行使用。 -提供 `MarkdownLabels.preview` 可启用定稿后的 `mermaid`、`graphviz`/`dot`、`svg` 和 `html` fence。每种语言提供本地化预览状态,未提供这些文案的调用方保留代码显示。Mermaid 在浅色画布上渲染完整源码。渲染按需加载 Mermaid、使用严格安全模式,并把生成的 SVG 显示为图片,不绑定图内链接处理器。渲染失败时显示原始源码与传入的错误文案;替换源码后会丢弃前一次渲染的延迟结果。图表保留固有尺寸,并在可用宽度不足时缩小。 +提供 `MarkdownLabels.preview` 可启用定稿后的 `mermaid`、`graphviz`/`dot`、`svg` 和 `html` fence。每种语言提供本地化预览状态,未提供这些文案的调用方保留代码显示。Mermaid 与 Graphviz 在代码块背景上使用当前文档配色,主题切换时同步更新已挂载的预览。DOT、SVG 与 HTML 中明确指定的颜色仍保留原样。渲染按需加载 Mermaid、使用严格安全模式,并把生成的 SVG 显示为图片,不绑定图内链接处理器。渲染失败时显示原始源码与传入的错误文案;替换源码后会丢弃前一次渲染的延迟结果。图表保留固有尺寸,并在可用宽度不足时缩小。 `CodeBlock.preview` 提供无标题栏的替代正文,以及切换源码和复制的图标操作。操作在悬停或键盘聚焦时出现;只要设备具备触屏,就在图表下方保持可见,包括同时连接鼠标的情况。切换到源码时保留已挂载的预览,返回时复用其结果;复制始终保留源码。 每个定稿 fence 默认显示可视化,并共享源码切换与复制操作。Graphviz 按需加载 `@viz-js/viz`,用 `dot` 引擎渲染 DOT。SVG 与 Graphviz 输出作为不可执行的图片放入不透明来源的 sandbox iframe;非法 SVG 与 DOT 显示错误并保留源码。HTML 接受完整文档或片段、保留内联样式,同时移除脚本与导航。iframe 不授予任何 sandbox 权限,Content Security Policy 阻止外部资源、嵌套 iframe、表单与脚本。iframe 使用可滚动的 400px 视口。代码 fence 外的原始 HTML 仍按普通 Markdown 输入处理。 +内部渲染函数接受可选的原生 `MermaidConfig` 与 Viz.js `RenderOptions`,供开发者定制。属性与主题变量覆盖项和文档默认值合并;Mermaid 预览限制与 Graphviz SVG 输出保持固定。这些参数没有设置界面。 + [预览许可证声明](THIRD_PARTY_PREVIEW_NOTICES.txt)随本包与 Web 前端分发。Mermaid 使用 MIT;Viz.js 使用 MIT,但内嵌 Graphviz 使用 EPL-2.0。声明保留完整许可证文本及准确的 Graphviz 源码下载地址。升级依赖时必须同时检查内嵌产物和 npm 元数据;[预览决策](../../../.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md)记录分发与 sandbox 选择。 ### 本地化文案 diff --git a/packages/client/ui-primitives/src/markdown/SourcePreview.module.css b/packages/client/ui-primitives/src/markdown/SourcePreview.module.css index e21d84e284..46a674ed0a 100644 --- a/packages/client/ui-primitives/src/markdown/SourcePreview.module.css +++ b/packages/client/ui-primitives/src/markdown/SourcePreview.module.css @@ -1,7 +1,7 @@ .canvas { overflow: auto; padding: 16px; - background: var(--dsw-static-neutral-00); + background: var(--dsw-alias-markdown-code-block); border-radius: 12px; } @@ -31,5 +31,5 @@ height: 400px; border: 0; border-radius: 12px; - background: var(--dsw-static-neutral-00); + background: var(--dsw-alias-markdown-code-block); } diff --git a/packages/client/ui-primitives/src/markdown/SourcePreview.tsx b/packages/client/ui-primitives/src/markdown/SourcePreview.tsx index be0871673c..3ce07fb34d 100644 --- a/packages/client/ui-primitives/src/markdown/SourcePreview.tsx +++ b/packages/client/ui-primitives/src/markdown/SourcePreview.tsx @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react' import css from './SourcePreview.module.css' +import { readPreviewTheme } from './preview-theme.ts' /** Localized preview states; the diagram source remains verbatim. */ export interface PreviewLabels { @@ -19,7 +20,7 @@ function assertNever(value: never): never { /** * Display a complete document or diagram, retaining the source when rendering fails. - * @param props - Source and complete localized labels. Changing source discards the previous result. + * @param props - Source and complete localized labels. Source and document theme changes cancel obsolete renders. * @returns A loading status, an inert image or sandboxed document, or an error with the original source. */ export function SourcePreview({ code, labels, render, document: isDocument = false }: { @@ -30,12 +31,26 @@ export function SourcePreview({ code, labels, render, document: isDocument = fal }) { const [result, setResult] = useState(null) useEffect(() => { - const controller = new AbortController() - void (async () => await render(code, controller.signal))().then( - (src) => { if (!controller.signal.aborted) setResult({ kind: 'ok', code, src }) }, - () => { if (!controller.signal.aborted) setResult({ kind: 'error', code }) }, - ) - return () => { controller.abort() } + let controller: AbortController | undefined + let palette: string | undefined + const update = () => { + const next = JSON.stringify(readPreviewTheme()) + if (next === palette) return + palette = next + controller?.abort() + const current = new AbortController() + controller = current + void (async () => await render(code, current.signal))().then( + (src) => { if (!current.signal.aborted) setResult({ kind: 'ok', code, src }) }, + () => { if (!current.signal.aborted) setResult({ kind: 'error', code }) }, + ) + } + // Isolated image/frame documents cannot inherit the host's CSS variables. + const observer = new MutationObserver(update) + observer.observe(document.documentElement, { attributes: true, attributeFilter: ['style'] }) + observer.observe(document.body, { attributes: true, attributeFilter: ['style', 'data-ds-dark-theme'] }) + update() + return () => { observer.disconnect(); controller?.abort() } }, [code, render]) if (result?.code !== code) return
{labels.loading}
diff --git a/packages/client/ui-primitives/src/markdown/graphviz.ts b/packages/client/ui-primitives/src/markdown/graphviz.ts index 8c00f84766..fc8f90315b 100644 --- a/packages/client/ui-primitives/src/markdown/graphviz.ts +++ b/packages/client/ui-primitives/src/markdown/graphviz.ts @@ -1,22 +1,37 @@ /** Lazy Graphviz WebAssembly layout; generated SVG is displayed only as an inert image. */ -import type { instance } from '@viz-js/viz' +import type { instance, RenderOptions } from '@viz-js/viz' import { renderSvg } from './preview-document.ts' +import { readPreviewTheme } from './preview-theme.ts' let runtime: ReturnType | undefined /** - * Render Graphviz DOT as a sandboxed preview document. + * Render Graphviz DOT with document-theme defaults; authored attributes override those defaults. * @param code - Complete Graphviz DOT source. * @param signal - Cancels work waiting for the runtime; synchronous layout cannot be interrupted. + * @param options - Native overrides; attribute maps merge over theme defaults and output remains SVG regardless of format. * @returns A srcdoc document. Import, layout, invalid source, and cancellation failures reject. */ -export async function renderGraphviz(code: string, signal: AbortSignal): Promise { +export async function renderGraphviz(code: string, signal: AbortSignal, options?: RenderOptions): Promise { runtime ??= import('@viz-js/viz').then(module => module.instance()).catch((error: unknown) => { runtime = undefined throw error }) const viz = await runtime signal.throwIfAborted() - return renderSvg(viz.renderString(code, { format: 'svg', engine: 'dot' }), signal) + const palette = readPreviewTheme() + const color = (value: string): string => value.replace( + /^rgb\(\s*(\d+)[, ]+\s*(\d+)[, ]+\s*(\d+)\s*\)$/, + (_match, r: string, g: string, b: string) => `#${[r, g, b].map(channel => Number(channel).toString(16).padStart(2, '0')).join('')}`, + ) + return renderSvg(viz.renderString(code, { + engine: 'dot', ...options, format: 'svg', + graphAttributes: { bgcolor: 'transparent', fontcolor: color(palette.text), ...options?.graphAttributes }, + nodeAttributes: { + color: color(palette.border), fontcolor: color(palette.text), fillcolor: color(palette.surface), style: 'filled', + ...options?.nodeAttributes, + }, + edgeAttributes: { color: color(palette.line), fontcolor: color(palette.text), ...options?.edgeAttributes }, + }), signal) } diff --git a/packages/client/ui-primitives/src/markdown/mermaid.ts b/packages/client/ui-primitives/src/markdown/mermaid.ts index 888a01cdca..9d7b8c721e 100644 --- a/packages/client/ui-primitives/src/markdown/mermaid.ts +++ b/packages/client/ui-primitives/src/markdown/mermaid.ts @@ -1,48 +1,86 @@ /** Lazy Mermaid runtime; each render owns and removes its temporary measurement DOM. */ -import type { Mermaid } from 'mermaid' +import type { Mermaid, MermaidConfig } from 'mermaid' import clsx from 'clsx' import css from './SourcePreview.module.css' +import { readPreviewTheme } from './preview-theme.ts' let runtime: Promise | undefined let nextDiagramId = 0 +let pending: Promise = Promise.resolve() function loadMermaid(): Promise { - runtime ??= import('mermaid').then(({ default: mermaid }) => { - mermaid.initialize({ - startOnLoad: false, - securityLevel: 'strict', - suppressErrorRendering: true, - theme: 'neutral', - htmlLabels: false, - secure: [ - 'secure', 'securityLevel', 'startOnLoad', 'maxTextSize', 'maxEdges', - 'suppressErrorRendering', 'theme', 'themeVariables', 'themeCSS', 'htmlLabels', 'flowchart', - ], - }) - return mermaid - }).catch((error: unknown) => { + runtime ??= import('mermaid').then(({ default: mermaid }) => mermaid).catch((error: unknown) => { runtime = undefined throw error }) return runtime } +function initialize(mermaid: Mermaid, config: MermaidConfig | undefined): void { + const palette = readPreviewTheme() + mermaid.initialize({ + theme: 'base', + ...config, + startOnLoad: false, + securityLevel: 'strict', + suppressErrorRendering: true, + themeVariables: { + darkMode: palette.dark, + background: palette.background, + primaryColor: palette.surface, + primaryTextColor: palette.text, + primaryBorderColor: palette.border, + secondaryColor: palette.surface, + tertiaryColor: palette.surface, + lineColor: palette.line, + textColor: palette.text, + actorBkg: palette.surface, + actorBorder: palette.border, + actorTextColor: palette.text, + actorLineColor: palette.border, + signalColor: palette.line, + signalTextColor: palette.text, + labelBoxBkgColor: palette.surface, + labelTextColor: palette.text, + edgeLabelBackground: palette.background, + ...config?.themeVariables as Record | undefined, + }, + htmlLabels: false, + // Mermaid still accepts this legacy override alongside the global HTML-label setting. + // oxlint-disable-next-line typescript/no-deprecated + flowchart: { ...config?.flowchart, htmlLabels: false }, + secure: [ + 'secure', 'securityLevel', 'startOnLoad', 'maxTextSize', 'maxEdges', + 'suppressErrorRendering', 'theme', 'themeVariables', 'themeCSS', 'htmlLabels', 'flowchart', + ...(config?.secure ?? []), + ], + }) +} + /** - * Render untrusted diagram source as an SVG image URL, without installing SVG or link handlers in the UI. + * Render untrusted diagram source using the document palette, without installing SVG or link handlers in the UI. * @param code - Complete Mermaid source. * @param signal - Cancels work waiting for the runtime; an active Mermaid render finishes before cleanup. + * @param config - Native overrides of theme defaults; strict security, manual rendering, and disabled HTML labels remain fixed. * @returns An SVG data URL. Import, parse, rendering, and cancellation failures reject. */ -export async function renderMermaid(code: string, signal: AbortSignal): Promise { +export async function renderMermaid(code: string, signal: AbortSignal, config?: MermaidConfig): Promise { + const task = pending.then(() => renderOne(code, signal, config)) + pending = task.catch(() => { /* The caller owns rejection; subsequent diagrams still render. */ }) + return task +} + +async function renderOne(code: string, signal: AbortSignal, config: MermaidConfig | undefined): Promise { const mermaid = await loadMermaid() signal.throwIfAborted() + initialize(mermaid, config) const stage = document.createElement('div') stage.className = clsx(css.staging) stage.setAttribute('aria-hidden', 'true') document.body.append(stage) try { - // Mermaid's public render API serializes diagram work; the lower-level mermaidAPI does not. + // Initialization and rendering share the queue because Mermaid owns global configuration. const { svg } = await mermaid.render(`dsh-mermaid-${nextDiagramId++}`, code, stage) const root = new DOMParser().parseFromString(svg, 'image/svg+xml').documentElement const viewBox = root.getAttribute('viewBox') diff --git a/packages/client/ui-primitives/src/markdown/preview-document.ts b/packages/client/ui-primitives/src/markdown/preview-document.ts index c0de8b4497..15aa3bf2f3 100644 --- a/packages/client/ui-primitives/src/markdown/preview-document.ts +++ b/packages/client/ui-primitives/src/markdown/preview-document.ts @@ -1,12 +1,14 @@ /** Static preview documents: opaque sandbox frames with no scripts, navigation, or remote resources. */ import DOMPurify from 'dompurify' +import { readPreviewTheme } from './preview-theme.ts' // This policy belongs to the preview document, before any source-controlled markup. const CSP = "default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src data:; font-src data:; base-uri 'none'; form-action 'none'" function documentOf(body: string): string { - return `${body}` + const scheme = readPreviewTheme().dark ? 'dark' : 'light' + return `${body}` } /** diff --git a/packages/client/ui-primitives/src/markdown/preview-theme.ts b/packages/client/ui-primitives/src/markdown/preview-theme.ts new file mode 100644 index 0000000000..e497e10a80 --- /dev/null +++ b/packages/client/ui-primitives/src/markdown/preview-theme.ts @@ -0,0 +1,27 @@ +/** Resolved document colors used by isolated diagram renderers. */ + +interface PreviewTheme { + dark: boolean + background: string + surface: string + text: string + line: string + border: string +} + +/** + * Read the palette after the application's theme presenter updates the DOM. + * @returns Semantic preview colors and the resolved browser color scheme. + */ +export function readPreviewTheme(): PreviewTheme { + const style = getComputedStyle(document.body) + const color = (name: string): string => style.getPropertyValue(`--dsw-alias-${name}`).trim() + return { + dark: getComputedStyle(document.documentElement).colorScheme === 'dark', + background: color('markdown-code-block'), + surface: color('bg-layer-2'), + text: color('label-primary'), + line: color('label-secondary'), + border: color('label-tertiary'), + } +} diff --git a/packages/client/ui-primitives/tests/graphviz-runtime.client.spec.ts b/packages/client/ui-primitives/tests/graphviz-runtime.client.spec.ts index 354c0f9eaa..1a7b170516 100644 --- a/packages/client/ui-primitives/tests/graphviz-runtime.client.spec.ts +++ b/packages/client/ui-primitives/tests/graphviz-runtime.client.spec.ts @@ -33,3 +33,35 @@ it('skips layout after cancellation during runtime loading', async () => { await rejection expect(renderString).not.toHaveBeenCalled() }) + +it('uses theme defaults without rewriting authored DOT attributes', async () => { + const previous = document.body.getAttribute('style') + try { + document.body.style.setProperty('--dsw-alias-label-primary', 'rgb(230, 231, 232)') + document.body.style.setProperty('--dsw-alias-label-secondary', '#aabbcc') + document.body.style.setProperty('--dsw-alias-label-tertiary', '#8899aa') + document.body.style.setProperty('--dsw-alias-bg-layer-2', '#222222') + const renderString = vi.fn().mockReturnValue('') + instance.mockResolvedValue({ renderString }) + const { renderGraphviz } = await import('../src/markdown/graphviz.ts') + const code = 'digraph { a [color="red"]; a -> b }' + await renderGraphviz(code, new AbortController().signal) + expect(renderString).toHaveBeenCalledWith(code, expect.objectContaining({ + nodeAttributes: { color: '#8899aa', fontcolor: '#e6e7e8', fillcolor: '#222222', style: 'filled' }, + edgeAttributes: { color: '#aabbcc', fontcolor: '#e6e7e8' }, + })) + await renderGraphviz(code, new AbortController().signal, { + engine: 'neato', format: 'plain', yInvert: true, + graphAttributes: { ranksep: 1 }, nodeAttributes: { shape: 'box' }, edgeAttributes: { color: 'red' }, + }) + expect(renderString).toHaveBeenLastCalledWith(code, { + engine: 'neato', format: 'svg', yInvert: true, + graphAttributes: { bgcolor: 'transparent', fontcolor: '#e6e7e8', ranksep: 1 }, + nodeAttributes: { color: '#8899aa', fontcolor: '#e6e7e8', fillcolor: '#222222', style: 'filled', shape: 'box' }, + edgeAttributes: { color: 'red', fontcolor: '#e6e7e8' }, + }) + } finally { + if (previous === null) document.body.removeAttribute('style') + else document.body.setAttribute('style', previous) + } +}) diff --git a/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts b/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts index 8b79a42b9a..863abde53d 100644 --- a/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts +++ b/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts @@ -13,7 +13,24 @@ beforeEach(() => { afterEach(() => { vi.doUnmock('mermaid') }) describe('Mermaid runtime', () => { - it('shares lazy initialization and removes each measurement container after rendering', async () => { + it('accepts native configuration without weakening preview restrictions', async () => { + const { renderMermaid } = await import('../src/markdown/mermaid.ts') + renderDiagram.mockResolvedValue({ svg: '' }) + await renderMermaid('flowchart LR', new AbortController().signal, { + // oxlint-disable-next-line typescript/no-deprecated + layout: 'dagre', flowchart: { nodeSpacing: 40, htmlLabels: true }, + themeVariables: { primaryColor: '#123456' }, + securityLevel: 'loose', startOnLoad: true, suppressErrorRendering: false, htmlLabels: true, secure: [], + }) + expect(initialize.mock.calls[0]![0]).toMatchObject({ + layout: 'dagre', flowchart: { nodeSpacing: 40, htmlLabels: false }, + themeVariables: { primaryColor: '#123456', darkMode: false }, + securityLevel: 'strict', startOnLoad: false, suppressErrorRendering: true, htmlLabels: false, + }) + expect(initialize.mock.calls[0]![0]).toHaveProperty('secure', expect.arrayContaining(['securityLevel'])) + }) + + it('reuses the runtime and removes each measurement container after rendering', async () => { const { renderMermaid } = await import('../src/markdown/mermaid.ts') expect(initialize).not.toHaveBeenCalled() const stages: HTMLElement[] = [] @@ -29,7 +46,7 @@ describe('Mermaid runtime', () => { renderMermaid('中文', new AbortController().signal), renderMermaid('second', new AbortController().signal), ]) - expect(initialize).toHaveBeenCalledOnce() + expect(initialize).toHaveBeenCalledTimes(2) expect(initialize).toHaveBeenCalledWith(expect.objectContaining({ startOnLoad: false, securityLevel: 'strict', suppressErrorRendering: true, htmlLabels: false, secure: [ @@ -42,6 +59,28 @@ describe('Mermaid runtime', () => { expect(stages.every(stage => !stage.isConnected)).toBe(true) }) + it('keeps theme initialization with its render and recovers the queue after failure', async () => { + const { renderMermaid } = await import('../src/markdown/mermaid.ts') + const first = Promise.withResolvers<{ svg: string }>() + renderDiagram.mockReturnValueOnce(first.promise).mockResolvedValue({ svg: '' }) + const light = renderMermaid('first', new AbortController().signal) + const failure = expect(light).rejects.toThrow('invalid') + await vi.waitFor(() => { expect(renderDiagram).toHaveBeenCalledOnce() }) + const previous = document.documentElement.style.colorScheme + try { + document.documentElement.style.colorScheme = 'dark' + const dark = renderMermaid('second', new AbortController().signal) + await Promise.resolve() + expect(initialize).toHaveBeenCalledOnce() + first.reject(new Error('invalid')) + await failure + await dark + expect(initialize.mock.calls[1]![0]).toMatchObject({ themeVariables: { darkMode: true } }) + } finally { + document.documentElement.style.colorScheme = previous + } + }) + it('removes measurement DOM even when Mermaid rejects', async () => { const { renderMermaid } = await import('../src/markdown/mermaid.ts') let stage: HTMLElement | undefined diff --git a/packages/client/ui-primitives/tests/source-preview.client.spec.tsx b/packages/client/ui-primitives/tests/source-preview.client.spec.tsx index fe356f64bb..7e63f06929 100644 --- a/packages/client/ui-primitives/tests/source-preview.client.spec.tsx +++ b/packages/client/ui-primitives/tests/source-preview.client.spec.tsx @@ -25,6 +25,31 @@ afterEach(() => { cleanup(); vi.unstubAllGlobals() }) beforeEach(() => { vi.resetAllMocks() }) describe('SourcePreview', () => { + it('updates mounted previews on theme changes and ignores obsolete completions', async () => { + const previous = document.documentElement.style.colorScheme + const old = Promise.withResolvers() + vi.mocked(renderMermaid).mockReturnValueOnce(old.promise).mockResolvedValue(imageUrl) + const view = render() + try { + const oldSignal = vi.mocked(renderMermaid).mock.calls[0]![1] + await act(async () => { document.documentElement.style.colorScheme = 'dark' }) + expect(oldSignal.aborted).toBe(true) + const image = await screen.findByRole('img') + await act(async () => { old.resolve('obsolete') }) + expect(image.getAttribute('src')).toBe(imageUrl) + await act(async () => { document.body.style.setProperty('--unrelated', '1') }) + expect(renderMermaid).toHaveBeenCalledTimes(2) + await act(async () => { document.documentElement.style.colorScheme = 'light' }) + expect(renderMermaid).toHaveBeenCalledTimes(3) + view.unmount() + await act(async () => { document.documentElement.style.colorScheme = 'dark' }) + expect(renderMermaid).toHaveBeenCalledTimes(3) + } finally { + view.unmount() + document.documentElement.style.colorScheme = previous + document.body.style.removeProperty('--unrelated') + } + }) it('shows loading until rendering completes, then displays an image without inserting SVG', async () => { const pending = Promise.withResolvers() vi.mocked(renderMermaid).mockReturnValue(pending.promise) From 4e0a405a9b0723b5b0d817077265590ef8ea3258 Mon Sep 17 00:00:00 2001 From: yudshj Date: Wed, 9 Sep 2026 18:01:36 +0800 Subject: [PATCH 09/32] fix(web): size diagram previews to image content --- ...9-content-sized-diagram-previews.i18n.yaml | 6 ++ ...26-09-09-content-sized-diagram-previews.md | 25 +++++ ...09-09-content-sized-diagram-previews.zh.md | 25 +++++ ...6-09-09-markdown-static-previews.i18n.yaml | 4 +- .../2026-09-09-markdown-static-previews.md | 2 +- .../2026-09-09-markdown-static-previews.zh.md | 2 +- .../expected/markdown-mermaid/ui.expected.md | 4 +- .../expected/markdown-mermaid/zh.expected.md | 4 +- apps/web/tests/markdown-mermaid.e2e.ts | 92 ++++++++++++++++--- .../client/ui-primitives/README.i18n.yaml | 4 +- packages/client/ui-primitives/README.md | 2 +- packages/client/ui-primitives/README.zh.md | 2 +- .../ui-primitives/src/markdown/graphviz.ts | 2 +- .../src/markdown/preview-document.ts | 10 +- .../ui-primitives/src/markdown/render.tsx | 2 +- .../tests/fence-previews.client.spec.tsx | 31 ++++--- 16 files changed, 170 insertions(+), 47 deletions(-) create mode 100644 .agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.i18n.yaml create mode 100644 .agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.md create mode 100644 .agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.zh.md diff --git a/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.i18n.yaml b/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.i18n.yaml new file mode 100644 index 0000000000..be4173fd02 --- /dev/null +++ b/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.i18n.yaml @@ -0,0 +1,6 @@ +# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each +# side as of the last confirmed-consistent state. Both languages carry equal authority; +# after editing either side, bring the other along and re-record with: +# pnpm run verify-translation-pairing --write .agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.md +2026-09-09-content-sized-diagram-previews.md: ceb29238eec09f2dde312835dbf376855998a507 +2026-09-09-content-sized-diagram-previews.zh.md: 2689602bfe3469f53e532367877f7e49d52d3d5d diff --git a/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.md b/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.md new file mode 100644 index 0000000000..ceb29238ee --- /dev/null +++ b/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.md @@ -0,0 +1,25 @@ +# Agent Note: Content-sized diagram previews + +Status: implemented + +English | [中文](2026-09-09-content-sized-diagram-previews.zh.md) + +## Problem + +Short Graphviz and SVG images leave large empty regions when displayed inside 400px frames. A 59px Graphviz diagram occupies a 400px preview even though its rendered dimensions are already available to the browser. + +## Decision + +Mermaid, Graphviz, and SVG share the inert image canvas in `SourcePreview`. The browser derives its height from the image, preserves aspect ratio when shrinking to the available width, and adds 16px padding. Source switching retains the image and copying reads the original code. Theme changes regenerate Graphviz colors without introducing a separate sizing observer. + +This replaces the diagram-frame choice in [Static Markdown fence previews](../feature/2026-09-09-markdown-static-previews.md); that note continues to own HTML isolation, rendering lifecycle, and license obligations. HTML retains its opaque, script-free, 400px frame. SVG image mode disables scripts, link interaction, and external resource loading without inserting source-controlled markup into the application document. + +## Alternatives considered + +**Set iframe height to auto.** An iframe does not derive its outer height from its inner document. This still reserves an unrelated viewport. + +**Add a frame measurement script or same-origin access.** A diagram already has image dimensions. Extra execution or origin permissions and resize messaging are unnecessary for that content. + +## Consequences + +Short diagrams occupy only their rendered height and canvas padding. The browser geometry regression compares image and container height in light and dark modes, then verifies proportional scaling in a narrow viewport. Browser security checks include SVG scripts, event handlers, nested HTML, and external images; copy and source toggling remain covered. HTML automatic height remains outside this change because arbitrary document layout has different measurement and isolation requirements. diff --git a/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.zh.md b/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.zh.md new file mode 100644 index 0000000000..2689602bfe --- /dev/null +++ b/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.zh.md @@ -0,0 +1,25 @@ +# Agent Note: 按内容定高的图表预览 + +Status: implemented + +[English](2026-09-09-content-sized-diagram-previews.md) | 中文 + +## Problem + +较矮的 Graphviz 与 SVG 图片显示在 400px iframe 中时,会留下大块空白。浏览器已经知道图片的渲染尺寸,但一张 59px 高的 Graphviz 图表仍占据 400px 的预览区域。 + +## Decision + +Mermaid、Graphviz 与 SVG 共享 `SourcePreview` 的不可执行图片画布。浏览器根据图片决定高度,在可用宽度不足时按比例缩小,并添加 16px 内边距。源码切换保留图片,复制读取原始代码。主题变化重新生成 Graphviz 配色,无需单独的尺寸观察器。 + +这替代了[静态 Markdown fence 预览](../feature/2026-09-09-markdown-static-previews.zh.md)中的图表 iframe 选择;该记录继续维护 HTML 隔离、渲染生命周期与许可证义务。HTML 保留不透明来源、禁用脚本的 400px iframe。SVG 图片模式禁用脚本、链接交互与外部资源加载,无需把源码控制的标记插入应用文档。 + +## Alternatives considered + +**把 iframe 高度设为 auto。** iframe 不会根据内部文档决定外部高度,仍然会保留与内容无关的视口。 + +**添加 iframe 测量脚本或同源访问。** 图表已经具备图片尺寸,不需要额外执行权限、来源权限或尺寸消息协议。 + +## Consequences + +较矮图表只占据渲染高度与画布内边距。浏览器几何回归用例在浅色和深色下比较图片与容器高度,再验证窄视口中的等比例缩放。浏览器安全检查包含 SVG 脚本、事件处理器、嵌套 HTML 与外部图片,并保留复制和源码切换覆盖。HTML 自动高度不属于本次改动,因为任意文档布局具有不同的测量与隔离要求。 diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml index 8712ee2070..8a24afcd59 100644 --- a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml +++ b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md -2026-09-09-markdown-static-previews.md: a5fa79fcc8c192dbcd3949debbabbccf85cb3b62 -2026-09-09-markdown-static-previews.zh.md: 30efe897702377c180c9e1650fda93ae42f6e580 +2026-09-09-markdown-static-previews.md: f3a0363e3d7c4cb19ca67dfc5011e936f7c024cf +2026-09-09-markdown-static-previews.zh.md: 24f87cd73504c1fbd274e1420a3692b3ca55ed5e diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md index a5fa79fcc8..f3a0363e3d 100644 --- a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md +++ b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md @@ -18,7 +18,7 @@ The shared Markdown renderer enables settled `mermaid`, `graphviz`/`dot`, `svg`, Mermaid loads on demand. A shared queue serializes theme initialization with diagram work, and each call removes its temporary measurement DOM in `finally`. Strict security, disabled HTML labels, the application palette, and error-rendering policy cannot be overridden by diagram configuration. Generated SVG is displayed as an image without installing links or scripts. Intrinsic dimensions come from the SVG viewBox; large diagrams shrink to fit, and the canvas follows the code-block background. Mounted previews observe document theme attributes and regenerate only when resolved colors change; obsolete renders cannot publish. Graphviz default colors follow the same palette, while authored DOT, SVG, and HTML colors remain intact. -HTML uses DOMPurify with navigation attributes and document-loading elements forbidden, followed by an opaque `sandbox=""` iframe. A trusted CSP precedes source markup and permits only inline CSS, data images, and data fonts. Scripts, external resources, child frames, form submission, and same-origin access are unavailable. SVG is parsed as XML and placed in an image inside the frame, so SVG scripts and links never become active. Frames have a fixed scrollable viewport: measuring their content would require additional origin access or trusted frame scripts. +HTML uses DOMPurify with navigation attributes and document-loading elements forbidden, followed by an opaque `sandbox=""` iframe. A trusted CSP precedes source markup and permits only inline CSS, data images, and data fonts. Scripts, external resources, child frames, form submission, and same-origin access are unavailable. SVG is parsed as XML and displayed with Graphviz output as inert images in a [content-sized canvas](../bug-fix/2026-09-09-content-sized-diagram-previews.md), so SVG scripts and links never become active. HTML frames have a fixed scrollable viewport: measuring their content would require additional origin access or trusted frame scripts. Graphviz uses the pinned, unmodified `@viz-js/viz` 3.30.0 WebAssembly distribution with the `dot` layout engine. Its npm MIT declaration covers the wrapper; its build provenance identifies Graphviz 16.0.0 (EPL-2.0), Expat 2.8.4 (MIT), and Emscripten 5.0.7 (MIT/NCSA). Distribution retains these component terms and the exact Graphviz source download under EPL-2.0 section 3.1. [Full preview notices](../../../../packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt) also retain Mermaid's MIT text and select Apache-2.0 for DOMPurify. The UI primitives package ships the notices and the Web build emits the same bytes alongside its assets. License review covers embedded payloads separately from the general permissive npm-metadata policy. diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md index 30efe89770..24f87cd735 100644 --- a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md +++ b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md @@ -18,7 +18,7 @@ Status: implemented Mermaid 按需加载。共享队列将主题初始化与图表渲染一起串行执行,每次调用都在 `finally` 中删除临时测量 DOM。图表配置无法覆盖严格安全模式、禁用 HTML 标签、应用配色和错误渲染策略。生成的 SVG 作为图片显示,不安装链接或脚本。固有尺寸来自 SVG viewBox;大图缩小以适应宽度,画布使用代码块背景。已挂载的预览观察文档主题属性,仅在解析后的配色变化时重新生成;过期渲染不能发布结果。Graphviz 的默认颜色采用同一配色,DOT、SVG 和 HTML 中明确指定的颜色保持原样。 -HTML 先由 DOMPurify 清理,禁止导航属性与文档加载元素,再进入不透明来源的 `sandbox=""` iframe。可信 CSP 位于源码标记之前,仅允许内联 CSS、data 图片与 data 字体。脚本、外部资源、子 iframe、表单提交与同源访问均不可用。SVG 按 XML 解析后作为图片放进 iframe,因此 SVG 脚本与链接不会激活。iframe 使用固定的可滚动视口:测量内容需要额外的来源访问权限或可信 iframe 脚本。 +HTML 先由 DOMPurify 清理,禁止导航属性与文档加载元素,再进入不透明来源的 `sandbox=""` iframe。可信 CSP 位于源码标记之前,仅允许内联 CSS、data 图片与 data 字体。脚本、外部资源、子 iframe、表单提交与同源访问均不可用。SVG 按 XML 解析后,与 Graphviz 输出一同作为不可执行图片显示在[按内容定高的画布](../bug-fix/2026-09-09-content-sized-diagram-previews.zh.md)中,因此 SVG 脚本与链接不会激活。HTML iframe 使用固定的可滚动视口:测量内容需要额外的来源访问权限或可信 iframe 脚本。 Graphviz 使用固定且未修改的 `@viz-js/viz` 3.30.0 WebAssembly 发布包,布局引擎为 `dot`。其 npm MIT 声明覆盖包装层;构建来源记录标明 Graphviz 16.0.0(EPL-2.0)、Expat 2.8.4(MIT)与 Emscripten 5.0.7(MIT/NCSA)。分发保留各组件条款,并按 EPL-2.0 第 3.1 节提供准确的 Graphviz 源码下载地址。[完整预览声明](../../../../packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt)还保留 Mermaid 的 MIT 文本,并为 DOMPurify 选择 Apache-2.0。UI primitives 包携带该声明,Web 构建在资源旁输出相同字节。内嵌产物的许可证检查独立于通用的宽松 npm 元数据策略。 diff --git a/apps/web/tests/expected/markdown-mermaid/ui.expected.md b/apps/web/tests/expected/markdown-mermaid/ui.expected.md index 369f0ef21d..985f68fee0 100644 --- a/apps/web/tests/expected/markdown-mermaid/ui.expected.md +++ b/apps/web/tests/expected/markdown-mermaid/ui.expected.md @@ -15,10 +15,10 @@ - img "Mermaid diagram" - button "Source" - button "Copy" -- iframe +- img "Graphviz diagram" - button "Source" - button "Copy" -- iframe +- img "SVG preview" - button "Source" - button "Copy" - iframe diff --git a/apps/web/tests/expected/markdown-mermaid/zh.expected.md b/apps/web/tests/expected/markdown-mermaid/zh.expected.md index 74a348e8be..52d7053ded 100644 --- a/apps/web/tests/expected/markdown-mermaid/zh.expected.md +++ b/apps/web/tests/expected/markdown-mermaid/zh.expected.md @@ -14,10 +14,10 @@ - img "Mermaid 图表" - button "源码" - button "复制" -- iframe +- img "Graphviz 图表" - button "源码" - button "复制" -- iframe +- img "SVG 预览" - button "源码" - button "复制" - iframe diff --git a/apps/web/tests/markdown-mermaid.e2e.ts b/apps/web/tests/markdown-mermaid.e2e.ts index d970cc9e11..95249740bf 100644 --- a/apps/web/tests/markdown-mermaid.e2e.ts +++ b/apps/web/tests/markdown-mermaid.e2e.ts @@ -27,7 +27,12 @@ const UNTRUSTED = [ ].join('\n') const DOT = 'digraph { rankdir=LR; Input -> Preview }' -const SVG = 'SVG preview' +const SVG = ` +SVG preview + + +
+
` const HTML = `

Static HTML

@@ -88,6 +93,52 @@ describe('web e2e: Mermaid chat previews', () => { await scaffold?.close() }) + it.skipIf(MODE === 'record').each(['light', 'dark'] as const)( + 'tightly wraps short diagram previews in %s mode', async (scheme) => { + const page = await newEnglishPage(browser) + try { + await page.emulateMedia({ colorScheme: scheme }) + await openConversation(page, scaffold) + await expect.poll(() => page.evaluate(() => getComputedStyle(document.documentElement).colorScheme)).toBe(scheme) + + const mermaid = page.getByRole('img', { name: 'Mermaid diagram' }).first() + await mermaid.evaluate(async (node: HTMLImageElement) => { await node.decode() }) + const mermaidHeight = await mermaid.evaluate(node => node.getBoundingClientRect().height) + const canvasHeight = await mermaid.evaluate(node => node.parentElement!.getBoundingClientRect().height) + // Compact diagrams need at most the Mermaid canvas's 16px padding on each side. + expect(canvasHeight - mermaidHeight).toBeLessThanOrEqual(32) + + for (const title of ['Graphviz diagram', 'SVG preview']) { + const image = page.getByRole('img', { name: title, exact: true }) + await image.evaluate(async (node: HTMLImageElement) => { await node.decode() }) + const imageHeight = await image.evaluate(node => node.getBoundingClientRect().height) + const containerHeight = await image.evaluate(node => node.parentElement!.getBoundingClientRect().height) + expect(imageHeight).toBeGreaterThan(0) + expect(containerHeight).toBeGreaterThanOrEqual(imageHeight) + expect.soft(containerHeight - imageHeight, + `${scheme} ${title}: ${containerHeight}px container around ${imageHeight}px content`, + ).toBeLessThanOrEqual(32) + } + await page.setViewportSize({ width: 360, height: 800 }) + const svg = page.getByRole('img', { name: 'SVG preview', exact: true }) + await expect.poll(() => svg.evaluate((node) => { + const { width, height } = node.getBoundingClientRect() + return width > 0 && height > 0 && width < 460 + })).toBe(true) + const compact = await svg.evaluate((node: HTMLImageElement) => ({ + width: node.getBoundingClientRect().width, + height: node.getBoundingClientRect().height, + canvasHeight: node.parentElement!.getBoundingClientRect().height, + ratio: node.naturalWidth / node.naturalHeight, + })) + expect(compact.width / compact.height).toBeCloseTo(compact.ratio, 1) + expect(compact.canvasHeight - compact.height).toBeLessThanOrEqual(32) + } finally { + await page.close() + } + }, + ) + it.skipIf(MODE === 'record')('updates existing diagrams when the document switches between light and dark', async () => { const page = await newEnglishPage(browser) try { @@ -102,10 +153,19 @@ describe('web e2e: Mermaid chat previews', () => { }, scheme) await expect.poll(() => image.getAttribute('src')).not.toBe(previous) await expect.poll(() => image.evaluate(node => (node as HTMLImageElement).naturalWidth)).toBeGreaterThan(0) - const colors = await image.evaluate(node => ({ - canvas: getComputedStyle(node.parentElement!).backgroundColor, - expected: getComputedStyle(document.body).getPropertyValue('--dsw-alias-markdown-code-block').trim(), - })) + const colors = await image.evaluate((node) => { + const reference = document.createElement('span') + reference.style.backgroundColor = 'var(--dsw-alias-markdown-code-block)' + document.body.append(reference) + try { + return { + canvas: getComputedStyle(node.parentElement!).backgroundColor, + expected: getComputedStyle(reference).backgroundColor, + } + } finally { + reference.remove() + } + }) expect(colors.canvas).toBe(colors.expected) await expect.poll(() => page.getByTitle('HTML preview', { exact: true }).getAttribute('srcdoc')) .toContain(`color-scheme:${scheme}`) @@ -186,7 +246,7 @@ describe('web e2e: Mermaid chat previews', () => { await page.close() }, 60_000) - it.skipIf(MODE === 'record')('previews DOT, SVG, and static HTML inside isolated frames', async () => { + it.skipIf(MODE === 'record')('previews inert DOT and SVG images and isolates static HTML', async () => { const page = await newEnglishPage(browser) const requests: string[] = [] const dialogs: string[] = [] @@ -198,27 +258,29 @@ describe('web e2e: Mermaid chat previews', () => { page.on('dialog', (dialog) => { dialogs.push(dialog.message()); void dialog.dismiss() }) await page.context().grantPermissions(['clipboard-read', 'clipboard-write']) await openConversation(page, scaffold) - for (const [title, code] of [['Graphviz diagram', DOT], ['SVG preview', SVG], ['HTML preview', HTML]]) { - const frame = page.locator(`iframe[title="${title}"]`) - await frame.waitFor() - expect(await frame.getAttribute('sandbox')).toBe('') - const body = frame.contentFrame() + for (const [title, code] of [['Graphviz diagram', DOT], ['SVG preview', SVG], ['HTML preview', HTML]] as const) { + const preview = title === 'HTML preview' + ? page.getByTitle(title, { exact: true }) + : page.getByRole('img', { name: title, exact: true, includeHidden: true }) + await preview.waitFor() if (title === 'HTML preview') { + expect(await preview.getAttribute('sandbox')).toBe('') + const body = preview.contentFrame() await body.getByRole('heading', { name: 'Static HTML' }).waitFor() expect(await body.getByRole('heading').evaluate(node => getComputedStyle(node).color)).toBe('rgb(0, 128, 0)') await body.getByText('Disabled navigation').click() - expect(await frame.evaluate(node => (node as HTMLIFrameElement).contentDocument)).toBeNull() + expect(await preview.evaluate(node => (node as HTMLIFrameElement).contentDocument)).toBeNull() } else { - await expect.poll(() => body.locator('img').evaluate(node => (node as HTMLImageElement).naturalWidth)).toBeGreaterThan(0) + await expect.poll(() => preview.evaluate(node => (node as HTMLImageElement).naturalWidth)).toBeGreaterThan(0) } - const block = page.locator('.md-code-block').filter({ has: frame }) + const block = page.locator('.md-code-block').filter({ has: preview }) await block.hover() await block.getByRole('button', { name: 'Copy', exact: true }).click() expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(code) await block.getByRole('button', { name: 'Source', exact: true }).click() expect(await block.locator('pre code').textContent()).toBe(code) await block.getByRole('button', { name: 'Preview', exact: true }).click() - expect(await frame.isVisible()).toBe(true) + expect(await preview.isVisible()).toBe(true) } expect(await page.locator('body').getAttribute('data-preview-escaped')).toBeNull() expect(dialogs).toEqual([]) diff --git a/packages/client/ui-primitives/README.i18n.yaml b/packages/client/ui-primitives/README.i18n.yaml index b3a61421d4..bca6072d44 100644 --- a/packages/client/ui-primitives/README.i18n.yaml +++ b/packages/client/ui-primitives/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-primitives/README.md -README.md: 8bdd2b7f90ebe4a998be8158351e49f815343c78 -README.zh.md: b861f9e17ff73f20717aed63b5b087358daeae10 +README.md: e6f63196375a4f96416ea05efc03cb72e8182823 +README.zh.md: 323a09e396c9b40b1401909a81998bf35af0ae6f diff --git a/packages/client/ui-primitives/README.md b/packages/client/ui-primitives/README.md index 8bdd2b7f90..e6f6319637 100644 --- a/packages/client/ui-primitives/README.md +++ b/packages/client/ui-primitives/README.md @@ -77,7 +77,7 @@ Supply `MarkdownLabels.preview` to enable settled `mermaid`, `graphviz`/`dot`, ` `CodeBlock.preview` supplies an optional headerless body with icon actions for source switching and copying. Actions appear on hover or keyboard focus, and stay visible below the diagram whenever a touchscreen is available, including with a mouse attached. Switching to source keeps the preview mounted, so returning reuses its result; copying always retains the source. -Each settled fence defaults to visualization and shares the source/copy controls. Graphviz loads `@viz-js/viz` on demand and renders DOT with the `dot` engine. SVG and Graphviz output are inert images inside opaque sandbox iframes; malformed SVG and DOT retain their source with an error. HTML accepts complete documents or fragments and preserves inline styles, but strips scripts and navigation. Frames have no sandbox permissions, and their Content Security Policy blocks external resources, embedded frames, forms, and scripts. Frames use a 400px scrollable viewport. Raw HTML outside a code fence remains ordinary Markdown input. +Each settled fence defaults to visualization and shares the source/copy controls. Graphviz loads `@viz-js/viz` on demand and renders DOT with the `dot` engine. SVG and Graphviz output are inert images in the same content-sized canvas as Mermaid; malformed SVG and DOT retain their source with an error. HTML accepts complete documents or fragments and preserves inline styles, but strips scripts and navigation. HTML frames have no sandbox permissions, and their Content Security Policy blocks external resources, embedded frames, forms, and scripts. Diagram canvases follow the rendered image height with 16px padding and shrink images proportionally to fit the available width. HTML frames use a 400px scrollable viewport. Raw HTML outside a code fence remains ordinary Markdown input. Internal render functions accept optional native `MermaidConfig` and Viz.js `RenderOptions` for developer customization. Attribute and theme-variable overrides merge with document defaults; Mermaid preview restrictions and Graphviz SVG output remain fixed. These parameters have no settings UI. diff --git a/packages/client/ui-primitives/README.zh.md b/packages/client/ui-primitives/README.zh.md index b861f9e17f..323a09e396 100644 --- a/packages/client/ui-primitives/README.zh.md +++ b/packages/client/ui-primitives/README.zh.md @@ -77,7 +77,7 @@ kind: "package-library" `CodeBlock.preview` 提供无标题栏的替代正文,以及切换源码和复制的图标操作。操作在悬停或键盘聚焦时出现;只要设备具备触屏,就在图表下方保持可见,包括同时连接鼠标的情况。切换到源码时保留已挂载的预览,返回时复用其结果;复制始终保留源码。 -每个定稿 fence 默认显示可视化,并共享源码切换与复制操作。Graphviz 按需加载 `@viz-js/viz`,用 `dot` 引擎渲染 DOT。SVG 与 Graphviz 输出作为不可执行的图片放入不透明来源的 sandbox iframe;非法 SVG 与 DOT 显示错误并保留源码。HTML 接受完整文档或片段、保留内联样式,同时移除脚本与导航。iframe 不授予任何 sandbox 权限,Content Security Policy 阻止外部资源、嵌套 iframe、表单与脚本。iframe 使用可滚动的 400px 视口。代码 fence 外的原始 HTML 仍按普通 Markdown 输入处理。 +每个定稿 fence 默认显示可视化,并共享源码切换与复制操作。Graphviz 按需加载 `@viz-js/viz`,用 `dot` 引擎渲染 DOT。SVG 与 Graphviz 输出作为不可执行的图片,使用与 Mermaid 相同的按内容定高画布;非法 SVG 与 DOT 显示错误并保留源码。HTML 接受完整文档或片段、保留内联样式,同时移除脚本与导航。HTML iframe 不授予任何 sandbox 权限,Content Security Policy 阻止外部资源、嵌套 iframe、表单与脚本。图表画布随渲染后的图片高度收缩,保留 16px 内边距,并在可用宽度不足时等比例缩小图片。HTML iframe 使用可滚动的 400px 视口。代码 fence 外的原始 HTML 仍按普通 Markdown 输入处理。 内部渲染函数接受可选的原生 `MermaidConfig` 与 Viz.js `RenderOptions`,供开发者定制。属性与主题变量覆盖项和文档默认值合并;Mermaid 预览限制与 Graphviz SVG 输出保持固定。这些参数没有设置界面。 diff --git a/packages/client/ui-primitives/src/markdown/graphviz.ts b/packages/client/ui-primitives/src/markdown/graphviz.ts index fc8f90315b..766fe0633c 100644 --- a/packages/client/ui-primitives/src/markdown/graphviz.ts +++ b/packages/client/ui-primitives/src/markdown/graphviz.ts @@ -11,7 +11,7 @@ let runtime: ReturnType | undefined * @param code - Complete Graphviz DOT source. * @param signal - Cancels work waiting for the runtime; synchronous layout cannot be interrupted. * @param options - Native overrides; attribute maps merge over theme defaults and output remains SVG regardless of format. - * @returns A srcdoc document. Import, layout, invalid source, and cancellation failures reject. + * @returns An SVG image data URL. Import, layout, invalid source, and cancellation failures reject. */ export async function renderGraphviz(code: string, signal: AbortSignal, options?: RenderOptions): Promise { runtime ??= import('@viz-js/viz').then(module => module.instance()).catch((error: unknown) => { diff --git a/packages/client/ui-primitives/src/markdown/preview-document.ts b/packages/client/ui-primitives/src/markdown/preview-document.ts index 15aa3bf2f3..f62e227f44 100644 --- a/packages/client/ui-primitives/src/markdown/preview-document.ts +++ b/packages/client/ui-primitives/src/markdown/preview-document.ts @@ -1,4 +1,4 @@ -/** Static preview documents: opaque sandbox frames with no scripts, navigation, or remote resources. */ +/** Static HTML documents and SVG image URLs without executable source markup. */ import DOMPurify from 'dompurify' import { readPreviewTheme } from './preview-theme.ts' @@ -28,10 +28,10 @@ export function renderHtml(code: string, signal: AbortSignal): string { } /** - * Prepare an SVG image inside an isolated document, without activating SVG scripts or links. + * Prepare an SVG image URL without activating SVG scripts, links, or external resources. * @param code - Complete SVG XML; malformed XML or a non-SVG root throws. * @param signal - Prevents preparation after the preview owner is cancelled. - * @returns A srcdoc document containing a responsive inert SVG image. + * @returns A data URL for an image whose intrinsic dimensions determine the preview height. */ export function renderSvg(code: string, signal: AbortSignal): string { signal.throwIfAborted() @@ -40,7 +40,5 @@ export function renderSvg(code: string, signal: AbortSignal): string { || parsed.documentElement.namespaceURI !== 'http://www.w3.org/2000/svg') { throw new Error('Invalid SVG document') } - // Double-quoted attributes keep encodeURIComponent's literal apostrophes inert. - const url = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(code)}` - return documentOf(``) + return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(code)}` } diff --git a/packages/client/ui-primitives/src/markdown/render.tsx b/packages/client/ui-primitives/src/markdown/render.tsx index f96884df64..0f67ce6a7d 100644 --- a/packages/client/ui-primitives/src/markdown/render.tsx +++ b/packages/client/ui-primitives/src/markdown/render.tsx @@ -421,7 +421,7 @@ function fencePreview(lang: string | undefined, code: string, labels: MarkdownLa const render = { mermaid: renderMermaid, graphviz: renderGraphviz, svg: renderSvg, html: renderHtml }[kind] return { content: ( - + ), previewLabel: labels.preview.preview, sourceLabel: labels.preview.source, diff --git a/packages/client/ui-primitives/tests/fence-previews.client.spec.tsx b/packages/client/ui-primitives/tests/fence-previews.client.spec.tsx index 8e8b4abf58..f7fe436821 100644 --- a/packages/client/ui-primitives/tests/fence-previews.client.spec.tsx +++ b/packages/client/ui-primitives/tests/fence-previews.client.spec.tsx @@ -35,22 +35,29 @@ describe('Markdown fence previews', () => { expect(view.container.querySelector('iframe')).toBeNull() expect(view.container.querySelector('pre code')?.textContent).toBe(code) view.rerender() - const frame = await screen.findByTitle(title) - expect(frame.getAttribute('sandbox')).toBe('') - expect(frame.getAttribute('referrerpolicy')).toBe('no-referrer') - expect(frame.getAttribute('srcdoc')).toContain('Content-Security-Policy') + const findPreview = async () => lang === 'html' ? await screen.findByTitle(title) : await screen.findByRole('img', { name: title }) + const element = await findPreview() + if (lang === 'html') { + expect(element.getAttribute('sandbox')).toBe('') + expect(element.getAttribute('referrerpolicy')).toBe('no-referrer') + expect(element.getAttribute('srcdoc')).toContain('Content-Security-Policy') + } else { + expect(element.getAttribute('src')).toMatch(/^data:image\/svg\+xml/) + expect(view.container.querySelector('iframe')).toBeNull() + expect(element.parentElement!.querySelector('svg')).toBeNull() + } expect(view.container.querySelector('pre code')).toBeNull() fireEvent.click(screen.getByRole('button', { name: 'Source' })) expect(view.container.querySelector('pre code')?.textContent).toBe(code) - expect(frame.closest('[hidden]')).not.toBeNull() + expect(element.closest('[hidden]')).not.toBeNull() fireEvent.click(screen.getByRole('button', { name: markdownLabels.code.copyLabel })) await waitFor(() => { expect(writeText).toHaveBeenCalledWith(code) }) fireEvent.click(screen.getByRole('button', { name: 'Preview' })) - expect(screen.getByTitle(title)).toBe(frame) - expect(frame.closest('[hidden]')).toBeNull() + expect(await findPreview()).toBe(element) + expect(element.closest('[hidden]')).toBeNull() view.unmount() render() - await screen.findByTitle(title) + await findPreview() fireEvent.click(screen.getByRole('button', { name: markdownLabels.code.copyLabel })) await waitFor(() => { expect(writeText).toHaveBeenCalledTimes(2) }) }) @@ -60,7 +67,7 @@ describe('Markdown fence previews', () => { await screen.findByText(status.error) expect(view.container.querySelector('pre code')?.textContent).toBe('broken') view.rerender() - await screen.findByTitle(preview.svg.diagram) + await screen.findByRole('img', { name: preview.svg.diagram }) expect(screen.queryByText(status.error)).toBeNull() }) @@ -90,9 +97,9 @@ describe('static preview documents', () => { it('encodes SVG as an image rather than executable document markup', () => { const code = '' - const parsed = new DOMParser().parseFromString(renderSvg(code, new AbortController().signal), 'text/html') - expect(parsed.querySelector('svg, script')).toBeNull() - expect(decodeURIComponent(parsed.querySelector('img')!.getAttribute('src')!)).toContain(code) + const url = renderSvg(code, new AbortController().signal) + expect(url).toMatch(/^data:image\/svg\+xml;charset=utf-8,/) + expect(decodeURIComponent(url.slice(url.indexOf(',') + 1))).toBe(code) }) it.each(['', '', ''])('rejects non-SVG or malformed XML: %s', (code) => { From 3c4c6c3d7b7079d1ea3f721ddf3d519ba8ba7cc9 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Wed, 9 Sep 2026 18:20:01 +0800 Subject: [PATCH 10/32] fix(ci): cancel superseded PR and master validation --- .../2026-07-26-ci-failover-runbook.i18n.yaml | 4 +- .../process/2026-07-26-ci-failover-runbook.md | 10 +-- .../2026-07-26-ci-failover-runbook.zh.md | 10 +-- ...26-09-06-master-only-platform-ci.i18n.yaml | 4 +- .../2026-09-06-master-only-platform-ci.md | 2 +- .../2026-09-06-master-only-platform-ci.zh.md | 2 +- .../2026-09-09-cancel-superseded-ci.i18n.yaml | 6 ++ .../2026-09-09-cancel-superseded-ci.md | 39 +++++++++++ .../2026-09-09-cancel-superseded-ci.zh.md | 39 +++++++++++ .../2026-06-19-real-api-e2e-ci.i18n.yaml | 4 +- .../testing/2026-06-19-real-api-e2e-ci.md | 2 +- .../testing/2026-06-19-real-api-e2e-ci.zh.md | 2 +- .../workflows/build-exe-for-python-sdk.yml | 3 +- .github/workflows/ci-master.yml | 9 +-- .github/workflows/ci.yml | 10 ++- .github/workflows/e2e.yml | 6 +- .github/workflows/release-vendor.yml | 2 +- .github/workflows/release.yml | 2 +- scripts/ci-workflow.spec.ts | 65 +++++++++++++------ scripts/tests/ci-master-platforms.spec.ts | 41 +++++++++++- scripts/tests/ci-release-selfhosted.spec.ts | 2 +- 21 files changed, 198 insertions(+), 66 deletions(-) create mode 100644 .agents/notes/implemented/process/2026-09-09-cancel-superseded-ci.i18n.yaml create mode 100644 .agents/notes/implemented/process/2026-09-09-cancel-superseded-ci.md create mode 100644 .agents/notes/implemented/process/2026-09-09-cancel-superseded-ci.zh.md diff --git a/.agents/notes/implemented/process/2026-07-26-ci-failover-runbook.i18n.yaml b/.agents/notes/implemented/process/2026-07-26-ci-failover-runbook.i18n.yaml index 90fdf49b49..62e46dfa22 100644 --- a/.agents/notes/implemented/process/2026-07-26-ci-failover-runbook.i18n.yaml +++ b/.agents/notes/implemented/process/2026-07-26-ci-failover-runbook.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write .agents/notes/implemented/process/2026-07-26-ci-failover-runbook.md -2026-07-26-ci-failover-runbook.md: f24cb8b8239141cd1ccf468a566dba620dd3cfdd -2026-07-26-ci-failover-runbook.zh.md: 57c4a92a3af720d9b11b7a1ce7a1515b83c77339 +2026-07-26-ci-failover-runbook.md: 559fa61bcf416bed3bd58b3ffcbc145038cdce22 +2026-07-26-ci-failover-runbook.zh.md: e2098b928b1a1f158bcbfabd940ca23a5cd0e28e diff --git a/.agents/notes/implemented/process/2026-07-26-ci-failover-runbook.md b/.agents/notes/implemented/process/2026-07-26-ci-failover-runbook.md index f24cb8b823..559fa61bcf 100644 --- a/.agents/notes/implemented/process/2026-07-26-ci-failover-runbook.md +++ b/.agents/notes/implemented/process/2026-07-26-ci-failover-runbook.md @@ -12,11 +12,7 @@ The three required Linux worker jobs in [CI](../../../../.github/workflows/ci.ym The three primary Linux jobs (`node-24`, `node-24-coverage`, `node-24-consumers`), the three `node-compat` matrix entries, and `all-checks-passed` resolve through `DSH_CI_FAILOVER_LINUX`; the native Windows jobs resolve through `DSH_CI_FAILOVER_WINDOWS`. A platform switch does not redirect the other platform. Set to `selfhosted` by a repository writer, the applicable trusted jobs select `vm-backup` or `dsh-win-ci`; otherwise they retain their workflow-defined hosted fallbacks. Node compatibility jobs require a same-repository, non-fork head and a non-Dependabot author, use isolated runtime setup, and retain `ubuntu-latest` fallback. Linux failover bounds snapshot concurrency and skips hosted package-cache restores. The verdict follows its workers so it does not remain queued on an unavailable hosted pool. Each switch is writer-manageable repository state, not a merge, so it works while checks are red. The `serial / linux (self-hosted standby)` and `serial / windows (self-hosted standby)` lanes re-prove the complete unsharded aggregates on master pushes. -`ci-master.yml` exempts exactly one event from `cancel-in-progress` (`${{ github.event_name != 'push' }}`), so one master push does not cancel the drill still running from the previous one. Each drill runs its complete unsharded aggregate with one gate worker, which takes longer than the interval between master merges; under unconditional cancellation a drill is superseded before reaching a verdict and the lane yields no readiness evidence for a responder to check. - -The exemption is narrower than "a drill always finishes", in two ways. GitHub keeps a single pending entry per group, so a newer pending run displaces an older one and intermediate push runs still end as `cancelled` during busy periods. And the expression is evaluated against the *newly triggered* run, so a run whose own event is not `push` — a benchmark dispatched on master within `ci-master.yml`, sharing its group `CI master-` — evaluates to `true` and does cancel a drill that is mid-flight. That is a rare manual action and the next master push restores the evidence, so it does not warrant further mechanism. What the carve-out buys is that the lane periodically reaches a verdict at all, which is what makes it usable as evidence. - -The decision belongs at workflow level because cancellation applies to the whole superseded run: a job-level `concurrency` group does not exempt its job. The negated form is load-bearing rather than cosmetic: naming `pull_request` alone would also stop cancelling `workflow_dispatch`, and each runner benchmark fans out to twelve larger runners for up to fifteen minutes inside this same group on master, so a re-dispatch would queue ahead of a drill instead of replacing a stale measurement. What bounds the cost is that a master push in `ci-master.yml` carries the [post-merge runtime and Wine checks](2026-09-06-master-only-platform-ci.md) and these two drills; the pull-request jobs live in the separate `ci.yml` (which does not see `push`), and the benchmarks are `workflow_dispatch`-gated within `ci-master.yml`. `scripts/ci-workflow.spec.ts` pins that push-reachable set — classifying by exact condition, since a negated event test mentions the event it excludes — so a new push-reachable job cannot quietly start accumulating uncancelled runs. +The [superseded-CI cancellation policy](2026-09-09-cancel-superseded-ci.md) governs master pushes and manual runs in the same workflow/ref group, including standby drills. Rapid master updates can starve a drill before it reaches a verdict. Use the latest completed standby verdict and check its age and commit before treating it as readiness evidence; a cancelled or merely scheduled run is not proof of readiness. ### Release rehearsals share the Linux switch @@ -44,7 +40,7 @@ The two switches are independent: flip only the one whose platform is degraded. ## Capacity during failover -Capacity includes the master standby, main-CI jobs, and three release-rehearsal jobs for each eligible PR or master push while the Linux switch is set. Each trusted PR also adds three Node compatibility jobs at gate concurrency one, including the build-backed Node 22 leg and cold temporary runtime downloads. The release workflows do not cancel running rehearsals when another run arrives, so overlapping refs can add sustained build, pack, and install load. Check current CPU, memory, disk, and queue pressure before extending self-hosted operation; extra registrations on this VM add scheduling slots, not machine resources. Do not infer spare capacity from the standby alone. When host resources permit extra registrations, use an org registration token (org Settings → Actions → Runners → New runner). Clone an existing runner directory **excluding its identity files** — `rsync -a --exclude '.runner*' --exclude '.credentials*' --exclude '_diag' --exclude '_work' / /` (the globs also catch `.runner_migrated`/`.credentials_migrated`, which GitHub writes on migrated runners and which equally trigger the already-configured refusal) — then run `config.sh` (copying `.runner`/`.credentials` verbatim makes it refuse with "already configured"), and **start the listener**: `sudo ./svc.sh install ubuntu && sudo ./svc.sh start`. Registration alone leaves the runner offline; a started service adds a scheduling slot, not CPU or memory. +Capacity includes the master standby, main-CI jobs, and three release-rehearsal jobs for each eligible PR or master push while the Linux switch is set. Each trusted PR also adds three Node compatibility jobs at gate concurrency one, including the build-backed Node 22 leg and cold temporary runtime downloads. The release rehearsal workflows cancel superseded runs within each workflow/ref group under the [cancellation policy](2026-09-09-cancel-superseded-ci.md); different refs can still add concurrent build, pack, and install load. Check current CPU, memory, disk, and queue pressure before extending self-hosted operation; extra registrations on this VM add scheduling slots, not machine resources. Do not infer spare capacity from the standby alone. When host resources permit extra registrations, use an org registration token (org Settings → Actions → Runners → New runner). Clone an existing runner directory **excluding its identity files** — `rsync -a --exclude '.runner*' --exclude '.credentials*' --exclude '_diag' --exclude '_work' / /` (the globs also catch `.runner_migrated`/`.credentials_migrated`, which GitHub writes on migrated runners and which equally trigger the already-configured refusal) — then run `config.sh` (copying `.runner`/`.credentials` verbatim makes it refuse with "already configured"), and **start the listener**: `sudo ./svc.sh install ubuntu && sudo ./svc.sh start`. Registration alone leaves the runner offline; a started service adds a scheduling slot, not CPU or memory. ### Switch back @@ -63,4 +59,4 @@ The variables are writer-manageable repository state; a pull request event itsel ## Consequences -Recovering from a hosted-pool outage is flipping the affected platform's variable (any writer) plus a re-run, with no merge on the critical path. The cost is a second runner topology per platform to keep working: the standby lanes exercise them on every master push so the failover targets never go stale, and the snapshot-concurrency and cache-restore branches in `ci.yml` carry a `selfhosted` leg (Linux only) that must stay in step with the hosted leg. Splitting the switch by platform adds one more variable to manage but bounds the blast radius of each switch to the jobs of a single platform. +Recovering from a hosted-pool outage is flipping the affected platform's variable (any writer) plus a re-run, with no merge on the critical path. The cost is a second runner topology per platform to keep working: master pushes schedule the standby lanes, but only completed verdicts establish readiness under the [cancellation policy](2026-09-09-cancel-superseded-ci.md), and the snapshot-concurrency and cache-restore branches in `ci.yml` carry a `selfhosted` leg (Linux only) that must stay in step with the hosted leg. Splitting the switch by platform adds one more variable to manage but bounds the blast radius of each switch to the jobs of a single platform. diff --git a/.agents/notes/implemented/process/2026-07-26-ci-failover-runbook.zh.md b/.agents/notes/implemented/process/2026-07-26-ci-failover-runbook.zh.md index 57c4a92a3a..e2098b928b 100644 --- a/.agents/notes/implemented/process/2026-07-26-ci-failover-runbook.zh.md +++ b/.agents/notes/implemented/process/2026-07-26-ci-failover-runbook.zh.md @@ -12,11 +12,7 @@ Status: implemented 三个主要 Linux 作业(`node-24`、`node-24-coverage`、`node-24-consumers`)、三个 `node-compat` 矩阵条目和 `all-checks-passed` 通过 `DSH_CI_FAILOVER_LINUX` 解析;原生 Windows 作业通过 `DSH_CI_FAILOVER_WINDOWS` 解析。一个平台的开关不会重定向另一个平台。仓库写者将变量设为 `selfhosted` 时,适用的可信作业选择 `vm-backup` 或 `dsh-win-ci`;否则保留工作流定义的托管回退。Node 兼容性作业要求同仓库且非 fork 的头部以及非 Dependabot 作者,使用隔离运行时设置,并保留 `ubuntu-latest` 回退。Linux 故障切换限制快照并发,并跳过托管软件包缓存恢复。判定作业跟随工作作业,避免继续在不可用的托管池排队。每个开关都是写者可管理的仓库状态而非一次合并,因此在检查失败时仍然有效。`serial / linux (self-hosted standby)` 与 `serial / windows (self-hosted standby)` 通道在 master 推送上重新验证完整的未分片聚合流程。 -`ci-master.yml` 只豁免一个事件不做取消(`${{ github.event_name != 'push' }}`),因此一次 master 推送不会取消上一次推送留下的、仍在运行的演练。每次演练以单门禁工作进程执行完整的未分片聚合流程,耗时长于 master 合并的间隔;在无条件取消下,演练会在得出结论前被后续运行取代,该通道无法产出供响应者查看的就绪证据。 - -这项豁免比「演练总能跑完」要窄,有两点限制。其一,GitHub 每个组只保留一个待运行条目,更新的待运行条目会顶掉更早的,繁忙时段中间的推送运行仍会以 `cancelled` 结束。其二,该表达式是针对**新触发的运行**求值的,因此自身事件不是 `push` 的运行——例如在 `ci-master.yml` 内的 master 上派发的基准测试,与其演练共用 `CI master-` 组——求值为 `true`,会取消正在运行中的演练。这属于罕见的手动操作,且下一次 master 推送即可恢复证据,因此不值得为它再加机制。这项豁免换来的是该通道**周期性**地得出结论,而这正是它能作为证据的前提。 - -这个决定必须放在工作流级:取消作用于被取代的整个运行,作业级 `concurrency` 组并不能豁免其所属作业。采用否定式写法而非仅指名 `pull_request`,是有实质作用的:后者会连 `workflow_dispatch` 一起停止取消,而每次运行器基准测试会在 master 上的同一并发组内同时占用 12 台大规格运行器、最长 15 分钟,届时重复派发会排在演练之前,而不是替换掉已过时的测量。成本之所以可控,是因为 `ci-master.yml` 中一次 master 推送承载[合并后的运行时与 Wine 检查](2026-09-06-master-only-platform-ci.zh.md)和这两条演练;拉取请求作业位于独立的 `ci.yml`(不监听 `push`),而基准测试在 `ci-master.yml` 内受 `workflow_dispatch` 门控。`scripts/ci-workflow.spec.ts` 会锁定这个推送可达集合——按条件精确匹配,因为否定式事件判断会包含它所排除的事件名——使新的推送可达作业无法悄悄开始累积未取消的运行。 +[被取代 CI 的取消策略](2026-09-09-cancel-superseded-ci.zh.md) 管理同一工作流/引用组内的 master 推送和手动运行,包括热备演练。master 快速更新可能让演练因反复被取消而始终无法得出结论。判断就绪状态时,使用最近一次已完成的热备结论,并核对其时间和提交;已取消或仅被调度的运行不构成就绪证据。 ### 发布演练共用 Linux 开关 @@ -44,7 +40,7 @@ Status: implemented ## 切换期间的容量 -Linux 开关启用期间,容量需覆盖 master 热备、主 CI 作业,以及每个符合条件的 PR 或 master 推送的三个发布演练作业。每个可信 PR 还会增加三个门禁并发度为一的 Node 兼容性作业,包括需要构建的 Node 22 条目和冷临时运行时下载。发布工作流不会因为新运行到来而取消正在执行的演练,因此不同引用的重叠运行会增加持续的构建、打包和安装负载。延长自托管运行前,检查当前 CPU、内存、磁盘和队列压力;同一虚拟机上新增注册只增加调度槽位,不增加机器资源。不能只依据热备负载推断空闲容量。主机资源允许增加注册实例时,使用组织级注册 token(组织 Settings → Actions → Runners → New runner)。复制现有 runner 目录时**必须排除身份文件**——`rsync -a --exclude '.runner*' --exclude '.credentials*' --exclude '_diag' --exclude '_work' / /`(通配同时排除 `.runner_migrated`/`.credentials_migrated`——GitHub 会在迁移过的运行器上写入这些文件,它们同样会触发 already-configured 拒绝)——再跑 `config.sh`(原样拷贝 `.runner`/`.credentials` 会使其以 "already configured" 拒绝),然后**启动监听器**:`sudo ./svc.sh install ubuntu && sudo ./svc.sh start`。仅注册不会上线;启动服务增加的是调度槽位,而非 CPU 或内存。 +Linux 开关启用期间,容量需覆盖 master 热备、主 CI 作业,以及每个符合条件的 PR 或 master 推送的三个发布演练作业。每个可信 PR 还会增加三个门禁并发度为一的 Node 兼容性作业,包括需要构建的 Node 22 条目和冷临时运行时下载。发布演练工作流依据[取消策略](2026-09-09-cancel-superseded-ci.zh.md)取消各工作流/引用组内被取代的运行;不同引用仍可能增加并发构建、打包和安装负载。延长自托管运行前,检查当前 CPU、内存、磁盘和队列压力;同一虚拟机上新增注册只增加调度槽位,不增加机器资源。不能只依据热备负载推断空闲容量。主机资源允许增加注册实例时,使用组织级注册 token(组织 Settings → Actions → Runners → New runner)。复制现有 runner 目录时**必须排除身份文件**——`rsync -a --exclude '.runner*' --exclude '.credentials*' --exclude '_diag' --exclude '_work' / /`(通配同时排除 `.runner_migrated`/`.credentials_migrated`——GitHub 会在迁移过的运行器上写入这些文件,它们同样会触发 already-configured 拒绝)——再跑 `config.sh`(原样拷贝 `.runner`/`.credentials` 会使其以 "already configured" 拒绝),然后**启动监听器**:`sudo ./svc.sh install ubuntu && sudo ./svc.sh start`。仅注册不会上线;启动服务增加的是调度槽位,而非 CPU 或内存。 ### 切回 @@ -63,4 +59,4 @@ Linux 开关启用期间,容量需覆盖 master 热备、主 CI 作业,以 ## 后果 -从托管池故障中恢复只需切换受影响平台的变量(任何写者可设)加一次重跑,关键路径上没有合并。代价是每个平台都要维护第二套运行器拓扑:热备通道在每次 master 推送时都运行它们,避免故障切换目标变得陈旧;而 `ci.yml` 中的快照并发与缓存恢复分支带有一条 `selfhosted` 支路(仅 Linux),必须与托管支路保持同步。按平台拆分开关多了一个需要管理的变量,但把每个开关的影响范围限定在单个平台的作业上。 +从托管池故障中恢复只需切换受影响平台的变量(任何写者可设)加一次重跑,关键路径上没有合并。代价是每个平台都要维护第二套运行器拓扑:master 推送会调度热备通道,但依据[取消策略](2026-09-09-cancel-superseded-ci.zh.md),只有已完成的结论才能证明就绪状态;而 `ci.yml` 中的快照并发与缓存恢复分支带有一条 `selfhosted` 支路(仅 Linux),必须与托管支路保持同步。按平台拆分开关多了一个需要管理的变量,但把每个开关的影响范围限定在单个平台的作业上。 diff --git a/.agents/notes/implemented/process/2026-09-06-master-only-platform-ci.i18n.yaml b/.agents/notes/implemented/process/2026-09-06-master-only-platform-ci.i18n.yaml index 1ce78b6e0f..6006f0447a 100644 --- a/.agents/notes/implemented/process/2026-09-06-master-only-platform-ci.i18n.yaml +++ b/.agents/notes/implemented/process/2026-09-06-master-only-platform-ci.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write .agents/notes/implemented/process/2026-09-06-master-only-platform-ci.md -2026-09-06-master-only-platform-ci.md: 28284206c8c6d3fbb5de8ecadbcdf2035a5bb8c0 -2026-09-06-master-only-platform-ci.zh.md: eed843b0d235c80256343890e91b1de84f482174 +2026-09-06-master-only-platform-ci.md: d32864a4eafa81433c6d4fd0e47892b4d17091b1 +2026-09-06-master-only-platform-ci.zh.md: 4fb55d5e95f8fe75e6d1efb8b57295b8e8469e8d diff --git a/.agents/notes/implemented/process/2026-09-06-master-only-platform-ci.md b/.agents/notes/implemented/process/2026-09-06-master-only-platform-ci.md index 28284206c8..d32864a4ea 100644 --- a/.agents/notes/implemented/process/2026-09-06-master-only-platform-ci.md +++ b/.agents/notes/implemented/process/2026-09-06-master-only-platform-ci.md @@ -14,7 +14,7 @@ Python runtime builds on macOS Intel and ARM and Linux ARM64, plus Windows build Wine runs once as an independent hosted Ubuntu master job. Its existing image-keyed apt cache restore/save also supplies default-branch cache production, so it needs no separate cache-seeding job. The native Linux and Windows serial aggregates do not invoke Wine. Keeping Wine hosted avoids shared-host apt transactions and shared Wine-prefix cleanup on the persistent Linux VM. The script owns a scratch snapshot, a checkout-local Wine prefix, and a checksum-verified Windows Node cache; provisioning, failure propagation, and always-run cleanup remain intact. -The parent and reusable runtime workflows preserve running master-push checks against subsequent master pushes. GitHub concurrency still permits replacement of pending runs; manual benchmarks can cancel the parent run. A master push schedules all three selected carriers but does not guarantee every intermediate commit reaches a result. PR, manual, and release cancellation retain their existing behavior. +The [superseded-CI cancellation policy](2026-09-09-cancel-superseded-ci.md) applies to the parent and reusable runtime workflows: newer master pushes or manual runs cancel older validation in the same workflow/ref group, while release-owned builds remain protected. A master push schedules all three selected carriers but does not guarantee every intermediate commit reaches a result. This decision partially supersedes scheduling in the [installed-wheel validation](../testing/2026-08-23-installed-python-wheel-black-box-ci.md), [native Windows CI](2026-08-08-native-windows-pull-request-ci.md), [serial references](2026-07-21-serial-cross-platform-ci-reference.md), and [failover runbook](2026-07-26-ci-failover-runbook.md). Those notes remain active for artifact provenance, platform fidelity, serial completeness, and trust rules. diff --git a/.agents/notes/implemented/process/2026-09-06-master-only-platform-ci.zh.md b/.agents/notes/implemented/process/2026-09-06-master-only-platform-ci.zh.md index eed843b0d2..4fb55d5e95 100644 --- a/.agents/notes/implemented/process/2026-09-06-master-only-platform-ci.zh.md +++ b/.agents/notes/implemented/process/2026-09-06-master-only-platform-ci.zh.md @@ -14,7 +14,7 @@ macOS Intel、ARM 与 Linux ARM64 上的 Python 运行时构建,以及通过 W Wine 作为独立的托管 Ubuntu master 作业运行一次。其现有的按镜像标识的 apt 缓存恢复和保存也负责生成默认分支缓存,因此不需要单独的缓存预热作业。原生 Linux 与 Windows 串行聚合不调用 Wine。Wine 保持托管运行,避免在持久 Linux VM 上执行共享宿主机 apt 事务和共享 Wine prefix 清理。脚本负责临时快照、checkout 内的 Wine prefix 和经过校验和验证的 Windows Node 缓存;环境准备、失败传播及始终执行的清理保持不变。 -父工作流与可复用运行时工作流均保留正在执行的 master 推送检查,不被后续 master 推送取消。GitHub 并发机制仍允许替换待执行的运行;手动基准测试可以取消父工作流。master 推送会调度全部三个选定载体,但不保证每个中间提交都得到结果。PR(Pull Request)、手动和发布运行的取消行为保持不变。 +[被取代 CI 的取消策略](2026-09-09-cancel-superseded-ci.zh.md) 适用于父工作流与可复用运行时工作流:更新的 master 推送或手动运行会取消同一工作流/引用组内的旧验证,而发布所属的构建仍受保护。master 推送会调度全部三个选定载体,但不保证每个中间提交都得到结果。 本决策部分取代[安装后 wheel 包验证](../testing/2026-08-23-installed-python-wheel-black-box-ci.zh.md)、[原生 Windows CI](2026-08-08-native-windows-pull-request-ci.zh.md)、[串行参考](2026-07-21-serial-cross-platform-ci-reference.zh.md)和[故障切换手册](2026-07-26-ci-failover-runbook.zh.md)中的调度策略。这些记录仍保留产物来源、平台保真度、串行完整性与信任规则的决策价值。 diff --git a/.agents/notes/implemented/process/2026-09-09-cancel-superseded-ci.i18n.yaml b/.agents/notes/implemented/process/2026-09-09-cancel-superseded-ci.i18n.yaml new file mode 100644 index 0000000000..5ef13299ed --- /dev/null +++ b/.agents/notes/implemented/process/2026-09-09-cancel-superseded-ci.i18n.yaml @@ -0,0 +1,6 @@ +# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each +# side as of the last confirmed-consistent state. Both languages carry equal authority; +# after editing either side, bring the other along and re-record with: +# pnpm run verify-translation-pairing --write .agents/notes/implemented/process/2026-09-09-cancel-superseded-ci.md +2026-09-09-cancel-superseded-ci.md: 8de1f757870a2b18852a224ec2f1cc33d9f6a95e +2026-09-09-cancel-superseded-ci.zh.md: 3ae6ec6ad58b0dfc94e803a33ba92ded4e239485 diff --git a/.agents/notes/implemented/process/2026-09-09-cancel-superseded-ci.md b/.agents/notes/implemented/process/2026-09-09-cancel-superseded-ci.md new file mode 100644 index 0000000000..8de1f75787 --- /dev/null +++ b/.agents/notes/implemented/process/2026-09-09-cancel-superseded-ci.md @@ -0,0 +1,39 @@ +# Agent Note: Cancel superseded CI validation + +Status: implemented + +English | [中文](2026-09-09-cancel-superseded-ci.zh.md) + +## Problem + +Validation of an obsolete PR revision or master commit consumes runner capacity without establishing the newest revision’s status. Unconditional aggregate verdicts and coverage-history uploads can also keep cancelled runs doing bookkeeping. Preserving older post-merge runs favors historical completion over current validation, especially on the shared self-hosted pools. + +## Decision + +Validation favors the newest run within each workflow/ref group. [CI](../../../../.github/workflows/ci.yml), [CI master](../../../../.github/workflows/ci-master.yml), [real-API e2e](../../../../.github/workflows/e2e.yml), and the credential-free [dsh](../../../../.github/workflows/release.yml) and [vendor](../../../../.github/workflows/release-vendor.yml) pack validations use `cancel-in-progress: true` with `${{ github.workflow }}-${{ github.ref }}`. Different PR refs and different workflows do not cancel each other. Event type is not part of the group: master pushes and manual benchmarks can supersede each other in CI master, and e2e pushes, scheduled runs, and manual runs can supersede each other on the same ref. + +The [reusable Python runtime builder](../../../../.github/workflows/build-exe-for-python-sdk.yml) uses `${{ !inputs.release }}`. Its `build-single-exe-${{ github.workflow }}-${{ github.ref }}` group remains distinct from its caller’s group, and the caller workflow name isolates ordinary CI from release-owned builds. Release-owned builds are exempt because they belong to an intentional publication transaction. Publication, deployment, and metadata workflows retain their own policies; this decision does not apply cancellation indiscriminately across workflows. + +The PR aggregate uses `${{ !cancelled() && github.event_name == 'pull_request' }}`. The explicit status function preserves evaluation after failed or skipped dependencies rather than accepting GitHub’s default success-only condition. The aggregate still fails on any failure, cancellation, or skip among its dependencies when the workflow itself is not cancelled; cancellation of the whole workflow suppresses its obsolete verdict. Coverage duration history uses `!cancelled()` too: failed coverage can still save useful measurements, but cancelled coverage does not upload them. Wine’s `always()` cleanup remains necessary resource cleanup rather than optional bookkeeping. + +This reverses the cancellation exemption in the [failover runbook](2026-07-26-ci-failover-runbook.md), [master-only platform CI](2026-09-06-master-only-platform-ci.md), and [real-API e2e decision](../testing/2026-06-19-real-api-e2e-ci.md). Those notes retain independent value for pool trust and switching, platform coverage, and secret exposure. The [release rehearsal decision](2026-09-06-release-rehearsal-selfhosted.md) retains runner selection and isolation ownership. None is fully superseded or archived. + +## Alternatives considered + +**Preserve running master-push drills.** The former `${{ github.event_name != 'push' }}` exemption favored periodic readiness evidence: each standby executes its complete unsharded aggregate with one gate worker and can outlast the interval between master merges. Even that policy did not guarantee every drill completed. GitHub retains one pending run per group, replacing intermediate pending pushes; cancellation is evaluated on the newly triggered run, so a manual benchmark sharing the master group could still cancel a drill. That rare manual interruption was accepted on the expectation of evidence from a subsequent push. The exemption’s cost was bounded by the master-only runtime checks, Wine, and two drills; PR jobs remained in a separate workflow, and exact-condition regression checks pinned the push-reachable job set. This policy is rejected in favor of freeing capacity for current validation, explicitly accepting standby starvation. + +**Protect a drill with job-level concurrency, or cancel only PR events.** A job-level group cannot exempt a job from cancellation of its entire workflow. A PR-only cancellation condition also exempts manual dispatch: a repeated runner benchmark can occupy twelve larger runners for up to fifteen minutes rather than replacing an obsolete measurement. Workflow-level cancellation covers both pushes and manual runs. + +**Keep every post-merge, nightly, and pack run.** Historical completion provides more per-commit and per-trigger evidence, but obsolete validation competes with the newest run. These validations do not publish packages, so preserving every run is not the same requirement as protecting an intentional publication transaction. + +**Replace every `always()` condition.** Failure aggregation and resource cleanup have different obligations. A success-only aggregate can hide failed dependencies behind a skipped required check; removing unconditional Wine cleanup can leave resources running. Only cancelled-run bookkeeping is suppressed. + +## Consequences + +Rapid master updates can repeatedly cancel the longer standby drills before they produce a verdict. Operators use the latest completed standby verdict, checking its age and commit before relying on it for failover readiness; a scheduled, running, or cancelled drill is not readiness evidence. The policy does not guarantee that every intermediate commit, nightly trigger, or benchmark completes. Different refs can still compete for shared host capacity. + +Cancellation is a request handled by GitHub Actions and its runners, not a guarantee of immediate termination or bounded queue delay. Cleanup can still take time. The policy makes obsolete validation cancellable; it does not promise a fixed runtime or cancellation latency. + +## Verification + +[Workflow regressions](../../../../scripts/ci-workflow.spec.ts) pin workflow/ref isolation, release-owned exemptions, aggregate status conditions, coverage-history cancellation, and retained Wine cleanup. [Platform routing regressions](../../../../scripts/tests/ci-master-platforms.spec.ts) preserve the master/PR target split and release matrix; [release rehearsal regressions](../../../../scripts/tests/ci-release-selfhosted.spec.ts) preserve cancellation alongside runner eligibility and publication isolation. These configuration checks do not reproduce GitHub scheduling or runner shutdown. Live supersession and completed standby evidence remain CI verification responsibilities. diff --git a/.agents/notes/implemented/process/2026-09-09-cancel-superseded-ci.zh.md b/.agents/notes/implemented/process/2026-09-09-cancel-superseded-ci.zh.md new file mode 100644 index 0000000000..3ae6ec6ad5 --- /dev/null +++ b/.agents/notes/implemented/process/2026-09-09-cancel-superseded-ci.zh.md @@ -0,0 +1,39 @@ +# Agent Note: 取消被取代的 CI 验证 + +Status: implemented + +[English](2026-09-09-cancel-superseded-ci.md) | 中文 + +## 问题 + +验证已被取代的 PR(Pull Request)修订或 master 提交会消耗运行器容量,却不能确定最新修订的状态。无条件执行的聚合判定和覆盖率耗时历史上传,还可能让已取消的运行继续处理记账任务。保留旧的合并后运行,意味着优先完成历史验证而非当前验证,在共享自托管池上尤其如此。 + +## 决策 + +验证优先保留各工作流/引用组内最新的运行。[CI](../../../../.github/workflows/ci.yml)、[CI master](../../../../.github/workflows/ci-master.yml)、[真实 API e2e](../../../../.github/workflows/e2e.yml),以及无凭据的 [dsh](../../../../.github/workflows/release.yml) 和 [vendor](../../../../.github/workflows/release-vendor.yml) 打包验证,均在 `${{ github.workflow }}-${{ github.ref }}` 组中使用 `cancel-in-progress: true`。不同 PR 引用和不同工作流不会相互取消。事件类型不参与分组:CI master 中的 master 推送与手动基准测试可以相互取代,e2e 的推送、定时运行和手动运行也可以在同一引用上相互取代。 + +[可复用 Python 运行时构建器](../../../../.github/workflows/build-exe-for-python-sdk.yml)使用 `${{ !inputs.release }}`。其 `build-single-exe-${{ github.workflow }}-${{ github.ref }}` 组与调用方的组保持区分,调用方工作流名称将普通 CI 与发布所属的构建隔离。发布所属的构建获得豁免,因为它们属于一次有意发起的发布事务。发布、部署和元数据工作流保留各自的策略;本决策不会不加区分地对所有工作流应用取消。 + +PR 聚合使用 `${{ !cancelled() && github.event_name == 'pull_request' }}`。显式状态函数使其在依赖失败或跳过后仍然求值,而非采用 GitHub 默认的仅成功条件。当工作流本身未被取消时,聚合仍会因任意依赖失败、取消或跳过而失败;整个工作流被取消时则抑制其已失去用途的判定。覆盖率耗时历史也使用 `!cancelled()`:覆盖率失败时仍可保存有用的测量数据,但被取消的覆盖率运行不上传。Wine 的 `always()` 清理仍是必要的资源清理,而非可选记账任务。 + +本决策推翻[故障切换手册](2026-07-26-ci-failover-runbook.zh.md)、[仅 master 执行的平台 CI](2026-09-06-master-only-platform-ci.zh.md) 和[真实 API e2e 决策](../testing/2026-06-19-real-api-e2e-ci.zh.md)中的取消豁免。这些记录对运行器池信任与切换、平台覆盖和密钥暴露仍有独立价值。[发布演练决策](2026-09-06-release-rehearsal-selfhosted.zh.md)仍负责运行器选择与隔离。没有记录被完全取代或归档。 + +## 曾考虑的替代方案 + +**保留正在执行的 master 推送演练。** 原有 `${{ github.event_name != 'push' }}` 豁免优先保证周期性就绪证据:每条热备以单门禁工作进程执行完整的未分片聚合流程,耗时可能长于 master 合并间隔。即便该策略也不保证每次演练完成。GitHub 每个组仅保留一个待运行条目,会替换中间的待执行推送;取消条件针对新触发的运行求值,因此共享 master 组的手动基准测试仍可取消演练。当时接受了这种罕见的手动中断,期望后续推送提供证据。豁免成本被限定为仅 master 执行的运行时检查、Wine 和两条演练;PR 作业仍在独立工作流中,按精确条件匹配的回归检查固定推送可达作业集合。为释放容量给当前验证而否决该策略,明确接受热备因反复被取消而无法完成。 + +**用作业级并发保护演练,或仅取消 PR 事件。** 作业级分组不能让作业免于整个工作流的取消。仅针对 PR 的取消条件还会豁免手动触发:重复派发的运行器基准测试可能占用十二台大型运行器长达十五分钟,而非替换陈旧的测量。工作流级取消同时覆盖推送和手动运行。 + +**保留每次合并后、每夜和打包运行。** 完成历史运行能提供更多按提交和触发划分的证据,但已被取代的验证会与最新运行竞争。这些验证不发布包,因此保留每次运行与保护有意发起的发布事务并不是同一项要求。 + +**替换每个 `always()` 条件。** 失败聚合与资源清理承担不同义务。仅成功时执行的聚合可能把依赖失败隐藏为跳过的必需检查;移除无条件 Wine 清理则可能留下仍在运行的资源。只有已取消运行的记账任务被抑制。 + +## 后果 + +master 快速更新可能反复取消耗时更长的热备演练,使其无法产出结论。运维人员使用最近一次已完成的热备结论,并在依赖它判断故障切换就绪状态前核对其时间和提交;已调度、正在执行或已取消的演练都不构成就绪证据。该策略不保证每个中间提交、每夜触发或基准测试都能完成。不同引用仍会竞争共享主机容量。 + +取消是由 GitHub Actions 及其运行器处理的请求,不保证立即终止或限定排队时长。清理仍可能耗时。该策略让已被取代的验证可以被取消,但不承诺固定运行时长或取消延迟。 + +## 验证 + +[工作流回归测试](../../../../scripts/ci-workflow.spec.ts)固定工作流/引用隔离、发布所属构建豁免、聚合状态条件、覆盖率历史取消及保留的 Wine 清理。[平台路由回归测试](../../../../scripts/tests/ci-master-platforms.spec.ts)保留 master/PR 目标划分与发布矩阵;[发布演练回归测试](../../../../scripts/tests/ci-release-selfhosted.spec.ts)在验证取消策略的同时保留运行器准入与发布隔离。这些配置检查不重现 GitHub 调度或运行器停止过程。真实运行取代行为与已完成热备证据仍由 CI 负责验证。 diff --git a/.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.i18n.yaml b/.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.i18n.yaml index 676b7c29a9..e50f4af442 100644 --- a/.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.i18n.yaml +++ b/.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write .agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.md -2026-06-19-real-api-e2e-ci.md: 4f51032d90b6773d01db7bbfdced6328bd882ad0 -2026-06-19-real-api-e2e-ci.zh.md: 390df23aebec3a6a54bc48eb52022fe02e872164 +2026-06-19-real-api-e2e-ci.md: b218d77f0817416b01459fbb70f5cacffe048ee8 +2026-06-19-real-api-e2e-ci.zh.md: 52c988dad00ddb3ee7f0cd2d23da9771f0900808 diff --git a/.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.md b/.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.md index 4f51032d90..b218d77f08 100644 --- a/.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.md +++ b/.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.md @@ -54,7 +54,7 @@ The repo secret is named `DEEPSEEK_API_KEY_EXTERNAL`; it is mapped to the `DEEPS ### Scope, runtime shape -The job runs only `test:e2e` on Node 24; keyless gates and version compatibility belong to the main CI workflow. Tests run unbuilt through the workspace paths map with a bounded configurable worker pool, per-test retries, and a job timeout. Superseded PR runs are cancelled, while push and scheduled runs complete for post-merge signal. +The job runs only `test:e2e` on Node 24; keyless gates and version compatibility belong to the main CI workflow. Tests run unbuilt through the workspace paths map with a bounded configurable worker pool, per-test retries, and a job timeout. The [superseded-CI cancellation policy](../process/2026-09-09-cancel-superseded-ci.md) cancels older runs in the same workflow/ref group across PR, push, schedule, and manual triggers; a post-merge or nightly trigger does not guarantee completion. The DeepSeek native `web_search` probe is registered but skipped. The live Anthropic-compatible endpoint can return a successful response without structured source blocks, so its positive-source assertion is not a reliable merge signal; unit coverage still pins response parsing, but CI does not prove the live source-block wire shape. diff --git a/.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.zh.md b/.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.zh.md index 390df23aeb..52c988dad0 100644 --- a/.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.zh.md +++ b/.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.zh.md @@ -54,7 +54,7 @@ repo secret 命名为 `DEEPSEEK_API_KEY_EXTERNAL`;映射到适配器和测试 ### 范围与运行时形态 -job 仅在 Node 24 上运行 `test:e2e`;无密钥门禁和版本兼容性属于主 CI 工作流。测试通过 workspace paths 映射以未构建形式运行,使用有界的可配置 worker 池、逐测试重试和 job 超时。被取代的 PR 运行会被取消,而 push 和 schedule 运行完整执行以提供合并后信号。 +job 仅在 Node 24 上运行 `test:e2e`;无密钥门禁和版本兼容性属于主 CI 工作流。测试通过 workspace paths 映射以未构建形式运行,使用有界的可配置 worker 池、逐测试重试和 job 超时。[被取代 CI 的取消策略](../process/2026-09-09-cancel-superseded-ci.zh.md)会在 PR、push、schedule 和手动触发之间取消同一工作流/引用组内的旧运行;合并后或每夜触发并不保证完成。 DeepSeek 原生 `web_search` 探测已注册但会跳过。线上 Anthropic 兼容端点可能返回成功响应却没有结构化来源块,因此对来源存在性的正向断言不是可靠的合并信号;单元测试仍会锁定响应解析行为,但 CI 不会验证线上端点返回的来源块协议格式(wire format)。 diff --git a/.github/workflows/build-exe-for-python-sdk.yml b/.github/workflows/build-exe-for-python-sdk.yml index ae7dd61554..49866ba5ea 100644 --- a/.github/workflows/build-exe-for-python-sdk.yml +++ b/.github/workflows/build-exe-for-python-sdk.yml @@ -46,7 +46,8 @@ concurrency: # github.workflow identifies the caller inside a reusable workflow and keeps # an ordinary CI run from cancelling a full release validation on the same ref. group: build-single-exe-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' }} + # Release-owned builds are part of an intentional publication transaction. + cancel-in-progress: ${{ !inputs.release }} permissions: contents: read diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index df9f7f2bcc..dd861115d4 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -14,14 +14,11 @@ on: - larger-runner-benchmark - consolidated-runner-benchmark -# Master runs platform runtime checks, Wine, and two self-hosted standby drills. -# The drills outlast the interval between master merges, so -# push is exempt from cancellation (see ci-failover-runbook). workflow_dispatch -# keeps cancelling: a re-dispatched runner benchmark holds up to 12 larger -# runners for 15 minutes in this same group. +# New master pushes and manual runs replace obsolete checks in this workflow/ref. +# Standby drills share cancellation; use completed runs as readiness evidence. concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.event_name != 'push' }} + cancel-in-progress: true permissions: contents: read diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e05b444a4..e7cff1454e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -562,7 +562,7 @@ jobs: # Coverage flakes must not prevent the cache from building; the # measured durations remain useful even when a partition failed. The # per-run key keeps every save a fresh immutable cache entry. - if: always() + if: ${{ !cancelled() }} uses: actions/cache/save@v4 with: path: .coverage-times.json @@ -666,10 +666,8 @@ jobs: # `needs`. Native Windows build and process checks are required; Wine and # the deferred Python runtime targets live in ci-master.yml and do not # participate in this PR verdict. `needs` cannot cross workflow files. - # `if: always()` is load-bearing: without it a failed dependency - # would SKIP this job, and GitHub counts a skipped required check as passing - # — so this job always runs and fails on any non-success result, including - # 'cancelled' and 'skipped'. + # An explicit status function runs the verdict after failed/skipped needs + # without keeping a cancelled workflow alive for an obsolete verdict. all-checks-passed: name: all checks passed # This bookkeeping-only verdict must not depend on custom-pool @@ -684,7 +682,7 @@ jobs: && fromJSON('["self-hosted", "linux", "x64", "vm-backup"]') || 'ubuntu-latest' }} needs: [node-24, node-24-coverage, node-24-bench, node-24-consumers, node-compat, python-sdk, python-runtime, windows-build, windows-native-tests] - if: always() && github.event_name == 'pull_request' + if: ${{ !cancelled() && github.event_name == 'pull_request' }} steps: - name: Fail if any needed job did not succeed if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 099908616c..3b7ff878f8 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -36,11 +36,11 @@ on: # 00:17 UTC nightly = 08:17 Asia/Shanghai — off the top-of-hour cron stampede. - cron: '17 0 * * *' -# Cancel a superseded PR run (it is on a stale commit); never cancel a -# push/schedule run — it is already producing the post-merge/nightly signal. +# Keep only the newest validation in each workflow/ref, including master +# pushes, nightly runs, and manual dispatches. concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} + cancel-in-progress: true # Least privilege: this job only reads the repo to run tests. permissions: diff --git a/.github/workflows/release-vendor.yml b/.github/workflows/release-vendor.yml index ddf3c3f96c..75fb865767 100644 --- a/.github/workflows/release-vendor.yml +++ b/.github/workflows/release-vendor.yml @@ -20,7 +20,7 @@ permissions: concurrency: # Pack runs per ref so concurrent pull requests never displace each other. group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: false + cancel-in-progress: true env: PRIMARY_NODE_VERSION: '24' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1415d1f9e9..633186c8f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ permissions: concurrency: # Pack runs per ref so concurrent pull requests never displace each other. group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: false + cancel-in-progress: true env: PRIMARY_NODE_VERSION: '24' diff --git a/scripts/ci-workflow.spec.ts b/scripts/ci-workflow.spec.ts index 46177da403..c0aba73898 100644 --- a/scripts/ci-workflow.spec.ts +++ b/scripts/ci-workflow.spec.ts @@ -8,6 +8,43 @@ const runnerPrivatePnpmDestination = /^\$\{\{ runner\.temp \}\}\/setup-pnpm-\$\{ const nativeWindowsPnpmDestination = '${{ runner.temp }}/setup-pnpm-js-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}' describe('CI workflow', () => { + it.each(['ci.yml', 'ci-master.yml', 'e2e.yml', 'release.yml', 'release-vendor.yml'])( + '%s cancels superseded validation runs without crossing workflow or ref boundaries', (name) => { + const workflow = loadWorkflow('.github/workflows/' + name) + expect(workflow.concurrency).toEqual({ + group: '${{ github.workflow }}-${{ github.ref }}', + 'cancel-in-progress': true, + }) + }, + ) + + it('cancels reusable CI builds without cancelling release-owned builds', () => { + const workflow = loadWorkflow('.github/workflows/build-exe-for-python-sdk.yml') + expect(workflow.concurrency).toEqual({ + group: 'build-single-exe-${{ github.workflow }}-${{ github.ref }}', + 'cancel-in-progress': '${{ !inputs.release }}', + }) + }) + + it('does not cancel protected publication or deployment transactions', () => { + for (const name of ['release-publish.yml', 'release-vendor-publish.yml']) { + const publish = workflowJob(loadWorkflow('.github/workflows/' + name), 'publish') + expect(publish.concurrency).toMatchObject({ 'cancel-in-progress': false }) + } + for (const name of ['python-release.yml', 'node-addon-system-release.yml', 'docs-pages.yml']) { + expect(loadWorkflow('.github/workflows/' + name).concurrency).toMatchObject({ 'cancel-in-progress': false }) + } + }) + + it('skips coverage-history uploads on cancellation but retains Wine cleanup', () => { + const coverage = workflowJob(loadWorkflow('.github/workflows/ci.yml'), 'windows-coverage') + const wine = workflowJob(loadWorkflow('.github/workflows/ci-master.yml'), 'windows') + expect(coverage.steps).toContainEqual(expect.objectContaining({ + name: 'Save coverage duration history', if: '${{ !cancelled() }}', + })) + expect(wine.steps).toContainEqual(expect.objectContaining({ name: 'Shut down wineserver', if: 'always()' })) + }) + it('isolates every pnpm action setup destination per runner', () => { const files = ['.github/workflows/ci.yml', '.github/workflows/ci-master.yml'] const setups: Array<{ jobName: string; step: unknown }> = [] @@ -346,7 +383,7 @@ describe('CI workflow', () => { ) }) - it('exempts push from cancellation in ci-master, so one master merge does not cancel the running drill', () => { + it('cancels superseded master runs without changing the post-merge job inventory', () => { const workflow = loadWorkflow('.github/workflows/ci-master.yml') const prWorkflow = loadWorkflow('.github/workflows/ci.yml') if (!isRecord(workflow.jobs) || !isRecord(workflow.concurrency)) { @@ -356,21 +393,11 @@ describe('CI workflow', () => { throw new TypeError('ci workflow must define jobs') } - // Cancellation applies to the whole superseded RUN, so this has to be - // decided at workflow level and gated on the event: a job-level group - // cannot exempt its job from its run being cancelled. Only push is exempt — - // a drill takes longer than the interval between master merges. The negated - // form is load-bearing: `== 'pull_request'` would also stop cancelling - // workflow_dispatch, and a re-dispatched runner benchmark holds up to 12 - // larger runners for 15 minutes in this same group on master. - expect(workflow.concurrency['cancel-in-progress']).toBe("${{ github.event_name != 'push' }}") - - // The PR-only ci.yml still cancels a superseded run on a new push, so a - // fresh head does not stack a second full 9-job run behind a stale one. - // Unlike ci-master it has no push carve-out: every PR event supersedes. - expect(prWorkflow.concurrency).toMatchObject({ + expect(workflow.concurrency).toEqual({ + group: '${{ github.workflow }}-${{ github.ref }}', 'cancel-in-progress': true, }) + expect(prWorkflow.concurrency).toEqual(workflow.concurrency) // The exact event sets are what keep master-only jobs out of the PR check // panel: ci-master triggers only on push(master) + workflow_dispatch and @@ -382,13 +409,12 @@ describe('CI workflow', () => { expect(Object.keys(workflow.on).sort()).toEqual(['push', 'workflow_dispatch']) expect(Object.keys(prWorkflow.on)).toEqual(['pull_request']) - // Neither drill may carry a job-level group: it would not exempt the job - // from run-scoped cancellation. + // Drills share the parent run’s supersession policy. for (const name of ['serial-linux-selfhosted', 'serial-windows']) { const job = workflow.jobs[name] if (!isRecord(job)) throw new TypeError(`${name} must be defined`) expect(job.concurrency).toBeUndefined() - // Both stay master-push-only; that is what makes the push carve-out safe. + // Standby drills remain post-merge work, but share run cancellation. expect(job.if).toBe("github.event_name == 'push' && github.ref == 'refs/heads/master'") } @@ -409,10 +435,7 @@ describe('CI workflow', () => { .sort() expect(pushReachable).toEqual(['python-runtime', 'serial-linux-selfhosted', 'serial-windows', 'windows']) - // Why workflow_dispatch must keep cancelling: each benchmark fans out to a - // dozen larger runners at once, in this same group on master. If it stopped - // cancelling, a re-dispatch would queue ahead of a drill instead of - // replacing the stale measurement. + // Manual benchmarks retain their bounded fan-out. for (const name of ['larger-runner-benchmark', 'consolidated-runner-benchmark']) { const job = workflow.jobs[name] if (!isRecord(job) || !isRecord(job.strategy)) { diff --git a/scripts/tests/ci-master-platforms.spec.ts b/scripts/tests/ci-master-platforms.spec.ts index b07f71cd62..3cdbb00f9b 100644 --- a/scripts/tests/ci-master-platforms.spec.ts +++ b/scripts/tests/ci-master-platforms.spec.ts @@ -1,6 +1,7 @@ /** Scheduling policy for post-merge native runtime carriers and Wine. */ import { readFileSync } from 'node:fs' import { resolve } from 'node:path' +import { runInNewContext } from 'node:vm' import { load } from 'js-yaml' import { describe, expect, it } from 'vitest' import { gatesForMode } from '../run-gates.ts' @@ -34,7 +35,43 @@ function commands(job: Job): string[] { return (job.steps ?? []).flatMap(step => step.run ? [step.run] : []) } +// These boolean/string cases share Actions and JavaScript semantics. GitHub +// supplies status functions; this probe is not a general Actions interpreter. +function evaluateCondition(expression: string, cancelled: boolean, results: string[], event = 'pull_request'): boolean { + const source = expression.trim().replace(/^[$][{][{]|[}][}]$/g, '') + .replaceAll('needs.*.result', 'results') + return runInNewContext(source, { + cancelled: () => cancelled, + always: () => true, + contains: (values: string[], value: string) => values.includes(value), + results, + github: { event_name: event }, + }, { timeout: 1000 }) as boolean +} + describe('master-only platform scheduling', () => { + it.each(['success', 'failure', 'skipped', 'cancelled'])( + 'reports %s dependencies in active runs but never starts a cancelled-run verdict', (result) => { + const aggregate = workflow('ci.yml').jobs['all-checks-passed']! + const results = aggregate.needs!.map(() => 'success') + results[0] = result + const condition = aggregate.if as string + // A status function prevents Actions from implicitly gating on success(). + expect(condition).toContain('!cancelled()') + expect(evaluateCondition(condition, false, results)).toBe(true) + expect(evaluateCondition(condition, true, results)).toBe(false) + expect(evaluateCondition(condition, false, results, 'push')).toBe(false) + const failureStep = aggregate.steps!.find(step => step.name === 'Fail if any needed job did not succeed')! + expect(evaluateCondition(failureStep.if!, false, results)).toBe(result !== 'success') + expect(failureStep.run).toContain('exit 1') + }, + ) + + it('distinguishes the obsolete always verdict from the cancellable status guard', () => { + expect(evaluateCondition("always() && github.event_name == 'pull_request'", true, ['success'])).toBe(true) + expect(evaluateCondition(workflow('ci.yml').jobs['all-checks-passed']!.if as string, true, ['success'])).toBe(false) + }) + it('keeps only Linux and Windows x64 runtimes in required PR CI', () => { const pr = workflow('ci.yml') expect(Object.keys(pr.on)).toEqual(['pull_request']) @@ -49,7 +86,7 @@ describe('master-only platform scheduling', () => { expect(aggregate.needs).toContain('python-runtime') expect(aggregate.needs).not.toContain('windows') expect(aggregate.needs!.every(id => id in pr.jobs)).toBe(true) - expect(aggregate.if).toBe("always() && github.event_name == 'pull_request'") + expect(aggregate.if).toBe("${{ !cancelled() && github.event_name == 'pull_request' }}") expect(aggregate.steps).toContainEqual(expect.objectContaining({ if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')", })) @@ -70,7 +107,7 @@ describe('master-only platform scheduling', () => { expect(runtime['continue-on-error']).toBeUndefined() const builder = workflow('build-exe-for-python-sdk.yml') expect(builder.concurrency?.['cancel-in-progress']).toBe( - "${{ github.event_name != 'push' || github.ref != 'refs/heads/master' }}", + '${{ !inputs.release }}', ) const build = builder.jobs.build! const preflight = build.steps!.find(step => step.name === 'Preflight installed-wheel real API test (POSIX)')! diff --git a/scripts/tests/ci-release-selfhosted.spec.ts b/scripts/tests/ci-release-selfhosted.spec.ts index 4a357114ba..ade0291f5f 100644 --- a/scripts/tests/ci-release-selfhosted.spec.ts +++ b/scripts/tests/ci-release-selfhosted.spec.ts @@ -88,7 +88,7 @@ for (const [file, jobIds] of [['release.yml', ['dependencies', 'pack']], ['relea expect(Object.keys(release.jobs)).toEqual(jobIds) expect(release.on).toEqual({ pull_request: null, push: { branches: ['master'] }, workflow_dispatch: null }) expect(release.permissions).toEqual({ contents: 'read' }) - expect(release.concurrency).toEqual({ group: '${{ github.workflow }}-${{ github.ref }}', 'cancel-in-progress': false }) + expect(release.concurrency).toEqual({ group: '${{ github.workflow }}-${{ github.ref }}', 'cancel-in-progress': true }) }) for (const jobId of jobIds) { describe(jobId, () => { From 516bfd5f30fd4d388fddb7f73da9f4bc38b923eb Mon Sep 17 00:00:00 2001 From: Yudong Date: Wed, 9 Sep 2026 19:49:56 +0800 Subject: [PATCH 11/32] test(web): cover preview import recovery and color schemes --- .../tests/fence-previews.client.spec.tsx | 12 ++++++++++++ .../tests/mermaid-runtime.client.spec.ts | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/packages/client/ui-primitives/tests/fence-previews.client.spec.tsx b/packages/client/ui-primitives/tests/fence-previews.client.spec.tsx index f7fe436821..cc240f75c1 100644 --- a/packages/client/ui-primitives/tests/fence-previews.client.spec.tsx +++ b/packages/client/ui-primitives/tests/fence-previews.client.spec.tsx @@ -81,6 +81,18 @@ describe('Markdown fence previews', () => { }) describe('static preview documents', () => { + it.each(['light', 'dark'])('uses the document %s color scheme for HTML previews', (scheme) => { + const previous = document.documentElement.style.colorScheme + try { + document.documentElement.style.colorScheme = scheme + const doc = renderHtml('

Example

', new AbortController().signal) + const parsed = new DOMParser().parseFromString(doc, 'text/html') + expect(parsed.documentElement.style.colorScheme).toBe(scheme) + } finally { + document.documentElement.style.colorScheme = previous + } + }) + it('preserves HTML styling while removing scripts, navigation, and nested documents', () => { const doc = renderHtml(` diff --git a/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts b/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts index 863abde53d..c5a4ccd6d3 100644 --- a/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts +++ b/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts @@ -13,6 +13,17 @@ beforeEach(() => { afterEach(() => { vi.doUnmock('mermaid') }) describe('Mermaid runtime', () => { + it('allows another attempt after the runtime import fails', async () => { + vi.doMock('mermaid', () => { throw new Error('runtime unavailable') }) + const { renderMermaid } = await import('../src/markdown/mermaid.ts') + await expect(renderMermaid('first', new AbortController().signal)).rejects.toThrow() + expect(initialize).not.toHaveBeenCalled() + vi.doMock('mermaid', () => ({ default: { initialize, render: renderDiagram } })) + renderDiagram.mockResolvedValue({ svg: '' }) + await expect(renderMermaid('retry', new AbortController().signal)).resolves.toContain('data:image/svg+xml') + expect(renderDiagram).toHaveBeenCalledOnce() + }) + it('accepts native configuration without weakening preview restrictions', async () => { const { renderMermaid } = await import('../src/markdown/mermaid.ts') renderDiagram.mockResolvedValue({ svg: '' }) From 8870a13aa941fee98455fc4e82877b0bc0ca69a7 Mon Sep 17 00:00:00 2001 From: imccyu <276526105+imccyu@users.noreply.github.com> Date: Wed, 9 Sep 2026 20:01:24 +0800 Subject: [PATCH 12/32] feat(sidebar): preview image files --- ...9-08-document-preview-operations.i18n.yaml | 4 +- .../2026-09-08-document-preview-operations.md | 6 +- ...26-09-08-document-preview-operations.zh.md | 6 +- ...debar-text-preview-and-file-tree.i18n.yaml | 4 +- ...9-05-sidebar-text-preview-and-file-tree.md | 4 +- ...5-sidebar-text-preview-and-file-tree.zh.md | 4 +- apps/web/tests/document-preview.e2e.ts | 57 ++++++++- .../README.i18n.yaml | 4 +- .../ui-sidebar-documentpreview/README.md | 14 ++- .../ui-sidebar-documentpreview/README.zh.md | 14 ++- .../ui-sidebar-documentpreview/package.json | 2 +- .../src/client/image/ImageBody.module.css | 40 +++++++ .../src/client/image/ImageBody.tsx | 106 +++++++++++++++++ .../src/client/image/index.ts | 41 +++++++ .../src/client/image/locales.ts | 27 +++++ .../src/client/index.ts | 2 + .../tests/apply.client.spec.ts | 3 + .../tests/image-body.client.spec.tsx | 111 ++++++++++++++++++ .../tests/image-registration.client.spec.ts | 63 ++++++++++ .../src/client/slot-catalog.ts | 1 + 20 files changed, 485 insertions(+), 28 deletions(-) create mode 100644 packages/client/ui-sidebar-documentpreview/src/client/image/ImageBody.module.css create mode 100644 packages/client/ui-sidebar-documentpreview/src/client/image/ImageBody.tsx create mode 100644 packages/client/ui-sidebar-documentpreview/src/client/image/index.ts create mode 100644 packages/client/ui-sidebar-documentpreview/src/client/image/locales.ts create mode 100644 packages/client/ui-sidebar-documentpreview/tests/image-body.client.spec.tsx create mode 100644 packages/client/ui-sidebar-documentpreview/tests/image-registration.client.spec.ts diff --git a/.agents/notes/implemented/architecture/2026-09-08-document-preview-operations.i18n.yaml b/.agents/notes/implemented/architecture/2026-09-08-document-preview-operations.i18n.yaml index 70fc2a365d..7f1944282d 100644 --- a/.agents/notes/implemented/architecture/2026-09-08-document-preview-operations.i18n.yaml +++ b/.agents/notes/implemented/architecture/2026-09-08-document-preview-operations.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write .agents/notes/implemented/architecture/2026-09-08-document-preview-operations.md -2026-09-08-document-preview-operations.md: 316f33371d393846cce5b598ee23289cecd6c178 -2026-09-08-document-preview-operations.zh.md: 97759db32d139a44fe33fd2c5e2eb7ec0c8960fd +2026-09-08-document-preview-operations.md: 3703933273e743c8df32bf0352fc276fe21dcb93 +2026-09-08-document-preview-operations.zh.md: b4896e95959d0f276ee69dfeaee9528319981714 diff --git a/.agents/notes/implemented/architecture/2026-09-08-document-preview-operations.md b/.agents/notes/implemented/architecture/2026-09-08-document-preview-operations.md index 316f33371d..3703933273 100644 --- a/.agents/notes/implemented/architecture/2026-09-08-document-preview-operations.md +++ b/.agents/notes/implemented/architecture/2026-09-08-document-preview-operations.md @@ -18,7 +18,7 @@ Readable files use `dsh-resource://file/session//`. The path ma [Document Preview](../../../../packages/client/ui-sidebar-documentpreview/README.md) owns format selection and loading policy. Metadata registers with `ctx.documentPreviews`; components register separately into the keyed `sidebar.right.tab.document` Slot. Extension registrations precede builtins, then longer suffixes and registration order decide. The toolbar lists matching alternatives and remembers a manual choice per tab; plain text is the fallback. The child receives accumulated text or complete native bytes, the original resource address, and the standard `useResource` and `useTabInfo` hooks. Preview calls existing `read`, `readAll`, and `readRelated` through ordinary injection and decodes bytes in its own `rpc.ts`. Refresh remains per tab, with no resource reload, shared `changed` acknowledgement, extra resource wrapper, or content Session. -Markdown and code reuse the incremental primitives with cumulative paged text. HTML and PDF read complete `Uint8Array` data; Host transport remains base64. Published buffers are borrowed read-only and never persist into layout or Session JSON. PDF.js runs in an owned Worker with version-matched bundled font and decoder data, and copies input before transfer to preserve Preview's retained buffer. HTML runs in a Blob iframe with `sandbox="allow-scripts"`, without same-origin, popup, form, download, or top-navigation privileges. The browser retains its normal external-network rules. Bounded static local JS/CSS reads stay in the parent; the opaque frame creates its own asset Blobs, because it cannot load parent-origin Blobs. Replacing the document replaces the browsing context and revokes its root Blob. +Markdown and code reuse the incremental primitives with cumulative paged text. HTML, PDF, and images read complete `Uint8Array` data; Host transport remains base64. Published buffers are borrowed read-only and never persist into layout or Session JSON. PDF.js runs in an owned Worker with version-matched bundled font and decoder data, and copies input before transfer to preserve Preview's retained buffer. HTML runs in a Blob iframe with `sandbox="allow-scripts"`, without same-origin, popup, form, download, or top-navigation privileges. The browser retains its normal external-network rules. Bounded static local JS/CSS reads stay in the parent; the opaque frame creates its own asset Blobs, because it cannot load parent-origin Blobs. PNG, JPEG, GIF, WebP, BMP, ICO, and SVG use image-specific Blob URLs in an `` static-image context. They retain intrinsic CSS-pixel dimensions; auto margins centre images smaller than the shared scroller, while larger dimensions extend its horizontal or vertical scroll range. The renderer provides no zoom or drag-to-pan. SVG markup never enters the application DOM or an iframe, so scripts remain inert and cannot reach the parent page. Replacing HTML or an image revokes its root Blob URL. ## Alternatives considered @@ -34,6 +34,8 @@ Markdown and code reuse the incremental primitives with cumulative paged text. H **A local server, virtual host, or `file:` iframe.** These require extra hosting or filesystem authority. The preview is for static generated pages, not a complete application runtime; modules, dynamic filesystem requests, and arbitrary nested asset graphs are outside its support. +**Sanitize SVG into the application DOM or an iframe.** A sanitizer would add a second SVG parser and an evolving active-content policy before placing untrusted markup in an interactive document. The `` static-image context preserves native SVG rendering and intrinsic dimensions without giving the markup a script-capable DOM. + ## Consequences -Renderers can be replaced without changing the tab or file protocol. Full-file formats pay bounded whole-file memory and PDF adds bundled Worker/font/decoder bytes. Format selection and view state are page-local, not durable Session data. Preview owns RPC cancellation and native buffers independently of metadata observation. A tab retains its read version and the observation version captured at read start; refreshing it neither discards another tab's content nor clears its change notice. File reads remain non-transactional, and opaque versions are compared for equality, not ordering. The [recorded browser scenario](../../../../apps/web/tests/document-preview.e2e.ts) exercises the shared toolbar, incremental text, isolated HTML dependencies, and lazy continuous PDF Worker rendering. +Renderers can be replaced without changing the tab or file protocol. Full-file formats pay bounded whole-file memory and PDF adds bundled Worker/font/decoder bytes. Format selection and view state are page-local, not durable Session data. Preview owns RPC cancellation and native buffers independently of metadata observation. A tab retains its read version and the observation version captured at read start; refreshing it neither discards another tab's content nor clears its change notice. File reads remain non-transactional, and opaque versions are compared for equality, not ordering. The [recorded browser scenario](../../../../apps/web/tests/document-preview.e2e.ts) exercises the shared toolbar, incremental text, isolated HTML dependencies, intrinsic raster and SVG rendering with two-axis scrolling, inert SVG scripts, and lazy continuous PDF Worker rendering. diff --git a/.agents/notes/implemented/architecture/2026-09-08-document-preview-operations.zh.md b/.agents/notes/implemented/architecture/2026-09-08-document-preview-operations.zh.md index 97759db32d..b4896e9595 100644 --- a/.agents/notes/implemented/architecture/2026-09-08-document-preview-operations.zh.md +++ b/.agents/notes/implemented/architecture/2026-09-08-document-preview-operations.zh.md @@ -18,7 +18,7 @@ Document Preview 将资源观察与内容读取分开。[资源模型](2026-09-0 [Document Preview](../../../../packages/client/ui-sidebar-documentpreview/README.zh.md) 负责格式选择和加载策略。元数据通过 `ctx.documentPreviews` 注册;组件单独注册到 keyed `sidebar.right.tab.document` Slot。扩展注册优先于内置注册,其次比较后缀长度和注册顺序。工具栏列出匹配候选,按 tab 记住手动选择;纯文本是兜底。子组件收到累积文本或完整原生字节、原始资源地址,以及标准 `useResource` 和 `useTabInfo` 钩子。Preview 经普通注入调用既有 `read`、`readAll` 与 `readRelated`,在自己的 `rpc.ts` 解码字节。刷新仍按 tab 独立进行,不引入资源 reload、共享 `changed` 确认、额外资源包装层或内容 Session。 -Markdown 和代码通过累积的分页文本复用增量渲染原语。HTML 和 PDF 读取完整 `Uint8Array` 数据;Host 传输保持 base64。发布后的缓冲区只读借用,绝不持久化进布局或 Session JSON。PDF.js 在自有 Worker 中运行,字体和解码数据以相同版本随包发布,转移输入前先复制,以保留 Preview 的缓冲区。HTML 在 Blob iframe 中运行,设置 `sandbox="allow-scripts"`,不授予同源、弹窗、表单、下载或顶层导航权限。浏览器保持正常的外部网络规则。有上限的静态本地 JS/CSS 读取由父页面负责;不透明源 iframe 创建自己的资源 Blob,因为它不能加载父源创建的 Blob。替换文档会替换浏览上下文,并撤销其根 Blob。 +Markdown 和代码通过累积的分页文本复用增量渲染原语。HTML、PDF 和图片读取完整 `Uint8Array` 数据;Host 传输保持 base64。发布后的缓冲区只读借用,绝不持久化进布局或 Session JSON。PDF.js 在自有 Worker 中运行,字体和解码数据以相同版本随包发布,转移输入前先复制,以保留 Preview 的缓冲区。HTML 在 Blob iframe 中运行,设置 `sandbox="allow-scripts"`,不授予同源、弹窗、表单、下载或顶层导航权限。浏览器保持正常的外部网络规则。有上限的静态本地 JS/CSS 读取由父页面负责;不透明源 iframe 创建自己的资源 Blob,因为它不能加载父源创建的 Blob。PNG、JPEG、GIF、WebP、BMP、ICO 和 SVG 使用图片专用 Blob URL,在 `` 静态图片上下文中渲染。它们保留固有 CSS 像素尺寸;auto margin 让小于共享滚动区的图片居中,较大的尺寸则扩展横向或纵向滚动范围。渲染器不提供缩放或拖拽平移。SVG 标记绝不进入应用 DOM 或 iframe,因此脚本保持不可执行,也无法访问父页面。替换 HTML 或图片时会撤销其根 Blob URL。 ## 考虑过的替代方案 @@ -34,6 +34,8 @@ Markdown 和代码通过累积的分页文本复用增量渲染原语。HTML 和 **本地服务器、虚拟主机或 `file:` iframe。** 这些方案需要额外托管或文件系统权限。预览面向静态生成页面,而非完整应用运行时;模块、动态文件系统请求和任意嵌套资源图不在支持范围内。 +**清理 SVG 后放入应用 DOM 或 iframe。** sanitizer 会增加第二套 SVG parser 和一套持续演进的主动内容策略,之后仍要把不可信标记放进可交互文档。`` 静态图片上下文保留浏览器原生 SVG 渲染与固有尺寸,同时不给标记一个能运行脚本的 DOM。 + ## 影响 -替换渲染器不需要改变 Tab 或文件协议。全文格式承担有上限的整文件内存成本,PDF 增加随包发布的 Worker、字体和解码器字节。格式选择和查看状态仅属于当前页面,不是持久 Session 数据。Preview 独立于元数据观察,拥有 RPC 取消和原生缓冲区。tab 保留读取版本及读取开始时捕获的观察版本;刷新它既不丢弃其他 tab 的内容,也不清除其变更提示。文件读取仍非事务,不透明版本只比较相等性、不排序。[录制的浏览器场景](../../../../apps/web/tests/document-preview.e2e.ts) 覆盖共用工具栏、增量文本、隔离的 HTML 依赖,以及惰性连续 PDF Worker 渲染。 +替换渲染器不需要改变 Tab 或文件协议。全文格式承担有上限的整文件内存成本,PDF 增加随包发布的 Worker、字体和解码器字节。格式选择和查看状态仅属于当前页面,不是持久 Session 数据。Preview 独立于元数据观察,拥有 RPC 取消和原生缓冲区。tab 保留读取版本及读取开始时捕获的观察版本;刷新它既不丢弃其他 tab 的内容,也不清除其变更提示。文件读取仍非事务,不透明版本只比较相等性、不排序。[录制的浏览器场景](../../../../apps/web/tests/document-preview.e2e.ts) 覆盖共用工具栏、增量文本、隔离的 HTML 依赖、可双轴滚动的固有尺寸位图与 SVG 渲染、不可执行的 SVG 脚本,以及惰性连续 PDF Worker 渲染。 diff --git a/.agents/notes/implemented/feature/2026-09-05-sidebar-text-preview-and-file-tree.i18n.yaml b/.agents/notes/implemented/feature/2026-09-05-sidebar-text-preview-and-file-tree.i18n.yaml index 4e4b039406..5c04c6fdb7 100644 --- a/.agents/notes/implemented/feature/2026-09-05-sidebar-text-preview-and-file-tree.i18n.yaml +++ b/.agents/notes/implemented/feature/2026-09-05-sidebar-text-preview-and-file-tree.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-09-05-sidebar-text-preview-and-file-tree.md -2026-09-05-sidebar-text-preview-and-file-tree.md: 9c0b6db832f19ba758ba2d3851db72f9a1fdb785 -2026-09-05-sidebar-text-preview-and-file-tree.zh.md: a5173c20b5203942df3c6f86b2bef5961946fa08 +2026-09-05-sidebar-text-preview-and-file-tree.md: e25e1c55f5434f2b3b1b2703f886cf3c1e9fe80c +2026-09-05-sidebar-text-preview-and-file-tree.zh.md: f313d30fa68f9d8afba84a470e5e80902b13d1e3 diff --git a/.agents/notes/implemented/feature/2026-09-05-sidebar-text-preview-and-file-tree.md b/.agents/notes/implemented/feature/2026-09-05-sidebar-text-preview-and-file-tree.md index 9c0b6db832..e25e1c55f5 100644 --- a/.agents/notes/implemented/feature/2026-09-05-sidebar-text-preview-and-file-tree.md +++ b/.agents/notes/implemented/feature/2026-09-05-sidebar-text-preview-and-file-tree.md @@ -108,12 +108,12 @@ Copy is the `sidebarFiles` namespace, thirteen keys. Row states: `loading` 「 ## Testing -The text preview's `tests/` cover the registry claim and yielding (through the real `SidebarRightTabRegistry`), the address translation (`sessionFileOf` accepting the `session` scope and throwing on others), the store's page, version, reset, view, and forget actions, the face's in-flight, failure, aborted, and reload paths, the page arithmetic (`linesOf`, `offsetsOf`, `lastLineLoaded`), the body's first read, load-more, retry, change bar, navigation walk, jump-once, remount, wrap default and toggle, header controls, and forget-on-abort, the failure-line mapping, and the plugin's registrations and their removal on dispose. A Chromium probe against the built app recorded the fill and scroll numbers (`.artifacts/sidebar-tab-types/app-probe.log`, `ROUND3`): a short file's preview is the pane body's content height, a long file scrolls inside the preview body, and the pane body never scrolls. The file tree's `tests/` cover ordering, lazy loading, collapse memory, reload, the three entry types, truncation and failure rows, and forget-on-abort. `apps/web/tests/sidebar-right.e2e.ts` opens a produced file from the conversation into the preview over the real Remote carrier. +The text preview's `tests/` cover the registry claim and yielding (through the real `SidebarRightTabRegistry`), the address translation (`sessionFileOf` accepting the `session` scope and throwing on others), the store's page, version, reset, view, and forget actions, the face's in-flight, failure, aborted, and reload paths, the page arithmetic (`linesOf`, `offsetsOf`, `lastLineLoaded`), the body's first read, load-more, retry, change bar, navigation walk, jump-once, remount, wrap default and toggle, header controls, and forget-on-abort, the failure-line mapping, and the plugin's registrations and their removal on dispose. A Chromium probe against the built app recorded the fill and scroll numbers (`.artifacts/sidebar-tab-types/app-probe.log`, `ROUND3`): a short file's preview is the pane body's content height, a long file scrolls inside the preview body, and the pane body never scrolls. The file tree's `tests/` cover ordering, lazy loading, collapse memory, reload, the three entry types, truncation and failure rows, and forget-on-abort. `apps/web/tests/sidebar-right.e2e.ts` opens a produced file from the conversation into the preview over the real Remote carrier. `apps/web/tests/document-preview.e2e.ts` covers centred intrinsic-size images, two-axis image scrolling, and inert SVG scripts. ## Deferred - Virtualized or seekable page loading (pages load in order), a reload that restores the loaded range, throttled scroll persistence, and a wrap icon in `ui-primitives`. -- Images, search, a total line count, and an end-of-file marker. +- Search, a total line count, and an end-of-file marker. - Search, an artifact filter, drag-and-drop, rename, a context menu, current-file highlight, filesystem watching, and browsing above the workspace root in the file tree. - Product review of the guide's copy, and the guide's behaviour when a type contributes several entries. diff --git a/.agents/notes/implemented/feature/2026-09-05-sidebar-text-preview-and-file-tree.zh.md b/.agents/notes/implemented/feature/2026-09-05-sidebar-text-preview-and-file-tree.zh.md index a5173c20b5..f313d30fa6 100644 --- a/.agents/notes/implemented/feature/2026-09-05-sidebar-text-preview-and-file-tree.zh.md +++ b/.agents/notes/implemented/feature/2026-09-05-sidebar-text-preview-and-file-tree.zh.md @@ -108,12 +108,12 @@ face 是树唯一的异步半边。`start(tabId, root, signal)` 以根展开态 ## Testing -文本预览的 `tests/` 覆盖:注册表认领与让位(经真实的 `SidebarRightTabRegistry`)、地址翻译(`sessionFileOf` 接受 `session` 作用域、其他一律抛错)、store 的页、版本、reset、视图与 forget 各 action、face 的进行中、失败、abort 与重载路径、页算术(`linesOf`、`offsetsOf`、`lastLineLoaded`)、体的首读、加载更多、重试、变更提示条、导航补页、只跳一次、重新挂载、换行默认与切换、头部控件与 abort 即忘、失败行映射,以及插件的各项注册与 dispose 时的撤销。针对已构建应用的 Chromium 探针记录了撑满与滚动的数字(`.artifacts/sidebar-tab-types/app-probe.log`,`ROUND3`):短文件的预览高度等于 pane 体内容区高度,长文件在预览体内滚动,pane 体从不滚动。文件树的 `tests/` 覆盖排序、懒加载、折叠记忆、重新读取、三种条目类型、截断与失败行,以及 abort 即忘。`apps/web/tests/sidebar-right.e2e.ts` 经真实 Remote 载体把会话里的产物文件打开进预览。 +文本预览的 `tests/` 覆盖:注册表认领与让位(经真实的 `SidebarRightTabRegistry`)、地址翻译(`sessionFileOf` 接受 `session` 作用域、其他一律抛错)、store 的页、版本、reset、视图与 forget 各 action、face 的进行中、失败、abort 与重载路径、页算术(`linesOf`、`offsetsOf`、`lastLineLoaded`)、体的首读、加载更多、重试、变更提示条、导航补页、只跳一次、重新挂载、换行默认与切换、头部控件与 abort 即忘、失败行映射,以及插件的各项注册与 dispose 时的撤销。针对已构建应用的 Chromium 探针记录了撑满与滚动的数字(`.artifacts/sidebar-tab-types/app-probe.log`,`ROUND3`):短文件的预览高度等于 pane 体内容区高度,长文件在预览体内滚动,pane 体从不滚动。文件树的 `tests/` 覆盖排序、懒加载、折叠记忆、重新读取、三种条目类型、截断与失败行,以及 abort 即忘。`apps/web/tests/sidebar-right.e2e.ts` 经真实 Remote 载体把会话里的产物文件打开进预览。`apps/web/tests/document-preview.e2e.ts` 覆盖居中的固有尺寸图片、双轴图片滚动和不可执行的 SVG 脚本。 ## Deferred - 虚拟化或可 seek 的分页加载(页按顺序加载)、恢复已加载范围的重新载入、节流的滚动位置持久化,以及 `ui-primitives` 里的换行图标。 -- 图片、搜索、总行数与文件末尾标记。 +- 搜索、总行数与文件末尾标记。 - 文件树的搜索、产物过滤、拖拽、重命名、右键菜单、高亮当前文件、文件系统监听,以及浏览到工作区根之上。 - 引导页文案的产品评审,以及一个类型贡献多个入口时引导页的行为。 diff --git a/apps/web/tests/document-preview.e2e.ts b/apps/web/tests/document-preview.e2e.ts index 58b9913ce6..41af1afa6b 100644 --- a/apps/web/tests/document-preview.e2e.ts +++ b/apps/web/tests/document-preview.e2e.ts @@ -18,6 +18,10 @@ const PAGE_LINES = 64 const SHOT_DIR = fileURLToPath(new URL('../../../.artifacts/screenshots/0908-document-preview', import.meta.url)) const PROMPT = 'Reply with the single word LIGHTHOUSE and stop.' const MODE = webSnapshotMode() +const TINY_PNG = Buffer.from( + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=', + 'base64', +) /** Successful render evidence stays outside the committed snapshot inventory. */ async function successShot(page: Page, name: string): Promise { @@ -76,7 +80,7 @@ describe.skipIf(MODE === 'record')('web e2e: document preview through Files', () } }) - it('opens Markdown, isolated HTML, and a rendered PDF from the Session workspace', async () => { + it('opens text, isolated HTML, intrinsic images, and rendered PDF from the Session workspace', async () => { onTestFailed(async () => { await mkdir(SHOT_DIR, { recursive: true }) await saveFailureShot(page, `screenshots/0908-document-preview/smoke-${process.pid}`) @@ -118,6 +122,13 @@ describe.skipIf(MODE === 'record')('web e2e: document preview through Files', () writeFile(join(cwd, 'local.js'), 'document.getElementById("local-result").textContent="LOCAL_JS_OK";'), writeFile(join(cwd, 'local.css'), '#local-result { color: rgb(12, 34, 56); }'), writeFile(outsideScript, 'document.getElementById("outside-result").textContent="OUTSIDE_JS_OK";'), + writeFile(join(cwd, 'tiny.png'), TINY_PNG), + writeFile(join(cwd, 'large.svg'), [ + '', + '', + '', + '', + ].join('')), writeFile(join(cwd, 'smoke.pdf'), pdfFixture()), ]) @@ -292,6 +303,50 @@ describe.skipIf(MODE === 'record')('web e2e: document preview through Files', () `- Same tab: ${String(await pdfTab.getAttribute('data-dockkit-tab') === pdfTabId)}`, ].join('\n')) + await openFile('tiny.png') + await expect.poll(() => viewer.innerText()).toBe('Image') + const tinyImage = preview.getByRole('img', { name: 'Image preview: tiny.png', exact: true }) + await tinyImage.waitFor({ state: 'visible', timeout: 15_000 }) + expect(await tinyImage.evaluate(node => ({ + width: (node as HTMLImageElement).naturalWidth, + height: (node as HTMLImageElement).naturalHeight, + draggable: (node as HTMLImageElement).draggable, + }))).toEqual({ width: 1, height: 1, draggable: false }) + const centering = await tinyImage.evaluate((node) => { + const image = node.getBoundingClientRect() + const scroller = node.closest('[data-textpreview-body]')?.getBoundingClientRect() + if (scroller === undefined) throw new Error('image document scroller is unavailable') + return { + horizontal: Math.abs((image.left + image.width / 2) - (scroller.left + scroller.width / 2)), + vertical: Math.abs((image.top + image.height / 2) - (scroller.top + scroller.height / 2)), + } + }) + expect(centering.horizontal).toBeLessThan(10) + expect(centering.vertical).toBeLessThan(10) + + await openFile('large.svg') + await expect.poll(() => viewer.innerText()).toBe('Image') + const largeImage = preview.getByRole('img', { name: 'Image preview: large.svg', exact: true }) + await largeImage.waitFor({ state: 'visible', timeout: 15_000 }) + expect(await largeImage.evaluate(node => ({ + naturalWidth: (node as HTMLImageElement).naturalWidth, + naturalHeight: (node as HTMLImageElement).naturalHeight, + width: getComputedStyle(node).width, + height: getComputedStyle(node).height, + }))).toEqual({ naturalWidth: 1200, naturalHeight: 1600, width: '1200px', height: '1600px' }) + expect(await body.evaluate(node => ({ + horizontal: node.scrollWidth > node.clientWidth, + vertical: node.scrollHeight > node.clientHeight, + }))).toEqual({ horizontal: true, vertical: true }) + const scrolled = await body.evaluate((node) => { + node.scrollLeft = node.scrollWidth + node.scrollTop = node.scrollHeight + return { left: node.scrollLeft, top: node.scrollTop } + }) + expect(scrolled.left).toBeGreaterThan(0) + expect(scrolled.top).toBeGreaterThan(0) + expect(await page.locator('html').getAttribute('data-image-preview-escape')).toBeNull() + const releaseRead = Promise.withResolvers() let waitingForRead = false const readPage = scaffold.ctx.workspaceFiles.read.bind(scaffold.ctx.workspaceFiles) diff --git a/packages/client/ui-sidebar-documentpreview/README.i18n.yaml b/packages/client/ui-sidebar-documentpreview/README.i18n.yaml index 68e01296cc..91a920665d 100644 --- a/packages/client/ui-sidebar-documentpreview/README.i18n.yaml +++ b/packages/client/ui-sidebar-documentpreview/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-sidebar-documentpreview/README.md -README.md: 9f664664a5d00add4d2f360c1c6b6af2e885bf72 -README.zh.md: 2cdad6964ae26e8e10597a405b0925cf70d7a278 +README.md: fbfbfaf4d80e425e5fbc62c082509fb6c4a93962 +README.zh.md: c27a359b608d8b72ace0700c55c34a58a302ec60 diff --git a/packages/client/ui-sidebar-documentpreview/README.md b/packages/client/ui-sidebar-documentpreview/README.md index 9f664664a5..fbfbfaf4d8 100644 --- a/packages/client/ui-sidebar-documentpreview/README.md +++ b/packages/client/ui-sidebar-documentpreview/README.md @@ -1,5 +1,5 @@ --- -description: "Document previews in the right Sidebar: shared file loading and controls, selectable Markdown, code, PDF and HTML renderers, and plain-text fallback." +description: "Document previews in the right Sidebar: shared file loading and controls, selectable Markdown, code, image, PDF and HTML renderers, and plain-text fallback." kind: "package-reference" --- @@ -9,7 +9,7 @@ English | [中文](README.zh.md) ## Summary -Preview readable files in the right Sidebar and choose among registered renderers without opening another tab. Markdown and code receive accumulated text pages; PDF and HTML receive complete bytes; unknown file extensions use plain text. The tab owns loading, file status, renderer selection, wrap, and reload, while document bodies register through the same metadata registry and child slot. The Sidebar tab kind is `text`. +Preview readable files in the right Sidebar and choose among registered renderers without opening another tab. Markdown and code receive accumulated text pages; PDF, HTML, and common images receive complete bytes; unknown file extensions use plain text. The tab owns loading, file status, renderer selection, wrap, and reload, while document bodies register through the same metadata registry and child slot. The Sidebar tab kind is `text`. ## Table of Contents @@ -44,14 +44,16 @@ The body reads its record, navigation and lifetime through `useTabInfo().tab`. ` - The resource snapshot contains only `status`, `value`, and `failure`; `value` is `WorkspaceFileStat` metadata. Content reads do not wait for the first metadata frame once the provider is available. Observation failures take precedence over Preview's change notice; neither automatically replaces loaded content. - **Text pages** — plain text, Markdown, and code read through an inject callback to `remote.workspaceFiles.read(sessionId, path, { offset }, signal)`. The first mount reads page one; scrolling to the body end or **Load more** requests the next page until `eof`. The owner delivers the accumulated prefix as `{ kind: 'text', text, pages, eof }`, including source offsets and line counts. Markdown and code render that prefix incrementally; they do not render each page as a separate document. A newer-version page past page one restarts from the beginning rather than mixing versions. A failure before any content fills the body with the file-type icon, explanation, and retry; a later failure retains loaded content and adds the retry below it. -- **Complete bytes** — PDF and HTML use an inject callback to `remote.workspaceFiles.readAll(sessionId, path, signal)`. `rpc.ts` decodes the wire base64 into `data: Uint8Array` for `{ kind: 'bytes', data }`. The Host's `maxFileBytes` cap rejects oversized files rather than truncating them. PDF copies retained bytes before worker transfer, keeping the Preview buffer usable. Bytes stay in transient view state, never persisted layouts or Session JSONL. Loading-mode changes retire previous results. +- **Complete bytes** — PDF, HTML, and common images use an inject callback to `remote.workspaceFiles.readAll(sessionId, path, signal)`. `rpc.ts` decodes the wire base64 into `data: Uint8Array` for `{ kind: 'bytes', data }`. The Host's `maxFileBytes` cap rejects oversized files rather than truncating them. PDF copies retained bytes before worker transfer, keeping the Preview buffer usable. Bytes stay in transient view state, never persisted layouts or Session JSONL. Loading-mode changes retire previous results. - **Reload** — only the current Preview tab rereads through its Remote callbacks, preserving its scroll preference and retiring older requests. Its change notice compares the read version and the observation captured at read start with later `resource.value.version`; an already observed version does not become a new change after refresh. Reads neither refresh shared metadata nor clear another tab's notice. HTML runs in a Blob iframe with exactly `sandbox="allow-scripts"`, without `allow-same-origin`; scripts cannot access the parent application's origin or file reader. The renderer loads directly declared relative `.js` classic scripts and `.css` stylesheets through its ordinary inject callback to `remote.workspaceFiles.readRelated`, with fixed safety limits of 4 MiB per asset, 32 MiB total, and 64 distinct assets. Host code resolves the related path; `rpc.ts` decodes the returned bytes. Inside the renderer, base64 is used only to embed the iframe bootstrap payload in script text. A `` leaves dependency resolution to the browser, as do HTTPS resources. Local module imports, CSS `url()`/`@import`, and dynamic `fetch` do not use Host file access. Read failures, invalid UTF-8, or exceeded limits fail the preview rather than publishing a partial asset package. Replacing or unmounting the document releases its Blob URL. +PNG, JPEG, GIF, WebP, BMP, ICO, and SVG render through Blob URLs in an `` static-image context. The image keeps its intrinsic CSS-pixel dimensions; a smaller image centres in the shared scroller, and larger dimensions scroll on either axis. The renderer provides neither zoom nor drag-to-pan. SVG markup never enters the application DOM or an iframe, so its scripts cannot execute or reach the parent page. Replacing or unmounting the image revokes its Blob URL. + Shared copy comes from `sidebarDocumentPreview`; each builtin renderer owns its localized labels. -Initial reads, additional pages, and HTML/PDF preparation share a loading indicator that respects reduced-motion preferences. Loaded pages stay visible while another page loads. PDF pages form one vertical, width-fitted sequence and render lazily near the viewport. Code previews show source line numbers by default without including them in copied text; plain text uses the same font size and line height as code. Code sits on the pane's own background rather than the chat card's fill, and with wrap off both axes scroll in the shared document scroller while the copy banner stays pinned to the visible width. +Initial reads, additional pages, and HTML/PDF/image preparation share a loading indicator that respects reduced-motion preferences. Loaded pages stay visible while another page loads. PDF pages form one vertical, width-fitted sequence and render lazily near the viewport. Code previews show source line numbers by default without including them in copied text; plain text uses the same font size and line height as code. Code sits on the pane's own background rather than the chat card's fill, and with wrap off both axes scroll in the shared document scroller while the copy banner stays pinned to the visible width. ## Navigation @@ -71,8 +73,8 @@ No direct effect; what the user reads here never enters a model request. - **Preview, not editing.** The viewers provide no file editing or shared search interface; a directory address fails with `not-regular-file`. Unknown extensions use the plain-text reader and remain subject to its UTF-8/NUL checks. -- **Sequential text and bounded complete files.** Deep source lines require the preceding pages; PDF and HTML require a complete result within the Host's `maxFileBytes` cap. -- **Byte-view scroll state is not restored.** PDF and HTML can return to the top when their renderer remounts or reloads; HTML iframe scrolling belongs to its opaque browsing context. +- **Sequential text and bounded complete files.** Deep source lines require the preceding pages; PDF, HTML, and images require a complete result within the Host's `maxFileBytes` cap. +- **Byte-view scroll state is not restored.** PDF, HTML, and images can return to the top when their renderer remounts or reloads; image horizontal position is never restored, and HTML iframe scrolling belongs to its opaque browsing context. - **Finite local HTML dependencies.** Only direct classic `.js` and stylesheet `.css` references are packed. Browser-resolved resources retain browser origin and network restrictions; no runtime file-read bridge is exposed to the iframe. - **Package-local wrap glyphs.** `IconWrapFill16` and `IconNowrapFill16` live in `src/client/icons.tsx` until the shared icon set carries them; their props already match the shared icon contract. - **Scroll writes are unthrottled.** Every scroll event records its offset in the store; the line blocks are memoized so the resulting re-render hands React the same elements back. diff --git a/packages/client/ui-sidebar-documentpreview/README.zh.md b/packages/client/ui-sidebar-documentpreview/README.zh.md index 2cdad6964a..c27a359b60 100644 --- a/packages/client/ui-sidebar-documentpreview/README.zh.md +++ b/packages/client/ui-sidebar-documentpreview/README.zh.md @@ -1,5 +1,5 @@ --- -description: "右侧 Sidebar 的文档预览:共享文件加载与控件,可选 Markdown、代码、PDF 和 HTML 渲染器,并以纯文本兜底。" +description: "右侧 Sidebar 的文档预览:共享文件加载与控件,可选 Markdown、代码、图片、PDF 和 HTML 渲染器,并以纯文本兜底。" kind: "package-reference" --- @@ -9,7 +9,7 @@ kind: "package-reference" ## 概述 -在右侧 Sidebar 预览可读文件,无需另开 tab 即可切换已注册的渲染器。Markdown 和代码接收累计文本页;PDF 和 HTML 接收完整字节;未知文件扩展名使用纯文本。tab 负责加载、文件状态、渲染器选择、换行和重新载入,文档正文通过同一元数据注册表与子 slot 注册。Sidebar tab 的 kind 为 `text`。 +在右侧 Sidebar 预览可读文件,无需另开 tab 即可切换已注册的渲染器。Markdown 和代码接收累计文本页;PDF、HTML 和常见图片接收完整字节;未知文件扩展名使用纯文本。tab 负责加载、文件状态、渲染器选择、换行和重新载入,文档正文通过同一元数据注册表与子 slot 注册。Sidebar tab 的 kind 为 `text`。 ## 目录 @@ -44,14 +44,16 @@ tab 使用 `fileAddressFor` 构造的 Session 地址,携带相对或绝对路 - 资源快照仅包含 `status`、`value` 和 `failure`;`value` 是 `WorkspaceFileStat` 元数据。提供方可用后,内容读取无需等待首个元数据帧。观察失败优先于 Preview 的变更提示显示;两者都不会自动替换已加载内容。 - **文本页** —— 纯文本、Markdown 和代码通过 inject 回调调用 `remote.workspaceFiles.read(sessionId, path, { offset }, signal)`。首次挂载读取第一页;滚动到正文末尾或点击 **加载更多** 会读取下一页,直到 `eof`。owner 以 `{ kind: 'text', text, pages, eof }` 提供累计前缀,包含源码行偏移和行数。Markdown 和代码增量渲染此前缀,不把每页当成独立文档。第一页之后到达的更新版本页会使读取从头开始,避免混合版本。尚无内容时,失败会以文件类型图标、说明与重试按钮填满正文;较晚的失败保留已有内容并在其下提供重试。 -- **完整字节** —— PDF 和 HTML 通过 inject 回调调用 `remote.workspaceFiles.readAll(sessionId, path, signal)`。`rpc.ts` 将线路上的 base64 解码为 `data: Uint8Array`,供 `{ kind: 'bytes', data }` 使用。Host 的 `maxFileBytes` 上限拒绝超大文件,不截断。PDF 在传给 worker 前复制保留的字节,使 Preview 缓冲区仍可使用。字节仅保存在临时视图状态中,绝不进入持久布局或 Session JSONL。加载模式变化会淘汰先前结果。 +- **完整字节** —— PDF、HTML 和常见图片通过 inject 回调调用 `remote.workspaceFiles.readAll(sessionId, path, signal)`。`rpc.ts` 将线路上的 base64 解码为 `data: Uint8Array`,供 `{ kind: 'bytes', data }` 使用。Host 的 `maxFileBytes` 上限拒绝超大文件,不截断。PDF 在传给 worker 前复制保留的字节,使 Preview 缓冲区仍可使用。字节仅保存在临时视图状态中,绝不进入持久布局或 Session JSONL。加载模式变化会淘汰先前结果。 - **重新载入** —— 仅当前 Preview tab 通过自己的 Remote 回调重读,保留滚动偏好并淘汰旧请求。变更提示将读取版本及起读时的观察版本与后续 `resource.value.version` 比较;刷新前已观察到的版本不会被当成新变化。读取既不刷新共享元数据,也不清除其它 tab 的提示。 HTML 在 Blob iframe 中运行,沙箱属性严格为 `sandbox="allow-scripts"`,不含 `allow-same-origin`;脚本无法访问父应用的源或文件读取接口。渲染器通过普通 inject 回调调用 `remote.workspaceFiles.readRelated`,加载直接声明的相对 `.js` 经典脚本和 `.css` 样式表;固定安全上限为单个资源 4 MiB、总计 32 MiB、64 个不同资源。Host 代码解析关联路径,`rpc.ts` 解码返回的字节。在渲染器内部,base64 仅用于把 iframe 引导载荷嵌入脚本文本。`` 将依赖解析交给浏览器,HTTPS 资源也由浏览器处理。本地模块 import、CSS `url()`/`@import` 和动态 `fetch` 不使用 Host 文件访问。读取失败、无效 UTF-8 或超出上限都使预览失败,不发布部分资源包。替换或卸载文档会释放其 Blob URL。 +PNG、JPEG、GIF、WebP、BMP、ICO 和 SVG 通过 Blob URL 在 `` 静态图片上下文中渲染。图片保持固有 CSS 像素尺寸;小图在共享滚动区内居中,大图可沿任一轴滚动。渲染器既不提供缩放,也不提供拖拽平移。SVG 标记绝不进入应用 DOM 或 iframe,因此其中的脚本无法执行,也无法访问父页面。替换或卸载图片会撤销其 Blob URL。 + 共享文案来自 `sidebarDocumentPreview`;各内置渲染器拥有自己的本地化标签。 -首次读取、追加页及 HTML/PDF 准备共用加载指示器,并遵循减少动态效果偏好。下一页加载期间保留已显示的内容。PDF 页面组成一个纵向、适配宽度的连续序列,并在接近视口时惰性渲染。代码预览默认显示源码行号,但复制文本不包含行号;纯文本与代码使用相同字号和行高。代码直接坐在分栏自身的背景上,而不是会话卡片的填充色;关闭折行时两个轴都在共享文档滚动区滚动,复制条钉在可视宽度内不随横向滚动偏移。 +首次读取、追加页及 HTML/PDF/图片准备共用加载指示器,并遵循减少动态效果偏好。下一页加载期间保留已显示的内容。PDF 页面组成一个纵向、适配宽度的连续序列,并在接近视口时惰性渲染。代码预览默认显示源码行号,但复制文本不包含行号;纯文本与代码使用相同字号和行高。代码直接坐在分栏自身的背景上,而不是会话卡片的填充色;关闭折行时两个轴都在共享文档滚动区滚动,复制条钉在可视宽度内不随横向滚动偏移。 ## 导航 @@ -71,8 +73,8 @@ HTML 在 Blob iframe 中运行,沙箱属性严格为 `sandbox="allow-scripts"` - **预览而非编辑。** 查看器不提供文件编辑或共享搜索接口;目录地址以 `not-regular-file` 失败。未知扩展名使用纯文本读取,仍受其 UTF-8/NUL 检查限制。 -- **文本顺序分页,完整文件受限。** 定位深处源码行需要先加载此前各页;PDF 和 HTML 必须取得 Host `maxFileBytes` 上限内的完整结果。 -- **字节视图不恢复滚动位置。** PDF 与 HTML 的渲染器重新挂载或重新载入时可能回到顶部;HTML iframe 的滚动属于其不透明浏览上下文。 +- **文本顺序分页,完整文件受限。** 定位深处源码行需要先加载此前各页;PDF、HTML 和图片必须取得 Host `maxFileBytes` 上限内的完整结果。 +- **字节视图不恢复滚动位置。** PDF、HTML 与图片的渲染器重新挂载或重新载入时可能回到顶部;图片的横向位置始终不恢复,HTML iframe 的滚动属于其不透明浏览上下文。 - **本地 HTML 依赖集合有限。** 只打包直接引用的经典 `.js` 脚本和 `.css` 样式表。浏览器解析的资源仍受浏览器源与网络规则限制;iframe 不获得运行时文件读取桥接。 - **换行图标为包内自绘。** `IconWrapFill16` 与 `IconNowrapFill16` 住在 `src/client/icons.tsx`,直到共享图标集提供为止;它们的 props 已与共享图标契约一致。 - **滚动写入未节流。** 每次滚动事件都把偏移记进 store;行块已 memo 化,于是由此引发的重渲染交还给 React 的是同一批元素。 diff --git a/packages/client/ui-sidebar-documentpreview/package.json b/packages/client/ui-sidebar-documentpreview/package.json index a008ef19ee..8d592decc0 100644 --- a/packages/client/ui-sidebar-documentpreview/package.json +++ b/packages/client/ui-sidebar-documentpreview/package.json @@ -1,6 +1,6 @@ { "name": "@deepseek-ai/dsh-client-ui-sidebar-documentpreview", - "description": "Extensible document previews for Sidebar files: Markdown, highlighted code, PDF, HTML, and plain text", + "description": "Extensible document previews for Sidebar files: Markdown, highlighted code, images, PDF, HTML, and plain text", "version": "0.1.5-alpha.1", "publishConfig": { "access": "public" diff --git a/packages/client/ui-sidebar-documentpreview/src/client/image/ImageBody.module.css b/packages/client/ui-sidebar-documentpreview/src/client/image/ImageBody.module.css new file mode 100644 index 0000000000..b26bb81a61 --- /dev/null +++ b/packages/client/ui-sidebar-documentpreview/src/client/image/ImageBody.module.css @@ -0,0 +1,40 @@ +.frame { + display: flex; + box-sizing: border-box; + width: max-content; + min-width: 100%; + height: max-content; + min-height: 100%; + font-family: var(--dsw-font, sans-serif); + white-space: normal; +} + +.image { + display: block; + flex: none; + width: auto; + max-width: none; + height: auto; + max-height: none; + margin: auto; + user-select: none; +} + +.image[hidden] { + display: none; +} + +.status { + display: flex; + align-items: center; + justify-content: center; + box-sizing: border-box; + width: 100%; + min-height: 100%; + margin: 0; + padding: 10px; + color: var(--dsw-alias-label-secondary); + font-size: 13px; + line-height: 1.5; + white-space: normal; +} diff --git a/packages/client/ui-sidebar-documentpreview/src/client/image/ImageBody.tsx b/packages/client/ui-sidebar-documentpreview/src/client/image/ImageBody.tsx new file mode 100644 index 0000000000..f01ec88d1c --- /dev/null +++ b/packages/client/ui-sidebar-documentpreview/src/client/image/ImageBody.tsx @@ -0,0 +1,106 @@ +/** Complete image bytes rendered at their intrinsic CSS-pixel dimensions. */ +import { useEffect, useMemo, useState, type ReactNode } from 'react' +import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots' +import { pathPartsOf } from '@deepseek-ai/dsh-util-workspace-path' +import type { DocumentPreviewProps } from '../document/contract.ts' +import { LoadingIndicator } from '../LoadingIndicator.tsx' +import { hostFileOf } from '../rpc.ts' +import type {} from './locales.ts' +import css from './ImageBody.module.css' + +const IMAGE_MEDIA_TYPES = { + png: 'image/png', + jpg: 'image/jpeg', + jpeg: 'image/jpeg', + gif: 'image/gif', + webp: 'image/webp', + bmp: 'image/bmp', + ico: 'image/x-icon', + svg: 'image/svg+xml', +} as const + +type ImageMediaType = typeof IMAGE_MEDIA_TYPES[keyof typeof IMAGE_MEDIA_TYPES] + +/** Standard document props plus the image renderer's dictionary. */ +export type ImageBodyProps = DocumentPreviewProps & PropsLocale<'sidebarImage'> + +type ImageSource = + | { + readonly kind: 'ready' + readonly data: Uint8Array + readonly mediaType: ImageMediaType + readonly url: string + } + | { readonly kind: 'failed'; readonly data: Uint8Array; readonly mediaType: ImageMediaType } + +/** + * Resolve a supported filename to the media type assigned to its Blob. + * @param path - decoded workspace file path. + * @returns the image media type, or undefined for an unregistered suffix. + */ +export function imageMediaType(path: string): ImageMediaType | undefined { + const normalized = path.replaceAll('\\', '/') + const name = normalized.slice(normalized.lastIndexOf('/') + 1).toLowerCase() + const extension = name.slice(name.lastIndexOf('.') + 1) as keyof typeof IMAGE_MEDIA_TYPES + return IMAGE_MEDIA_TYPES[extension] +} + +/** + * Present complete image bytes without fitting or scaling them to the pane. + * @param props - document bytes, resource identity, and locale. + * @returns an intrinsic-size image whose containing document body provides scrolling. + */ +export function ImageBody({ content, resourceAddress, t }: ImageBodyProps): ReactNode { + const path = useMemo(() => hostFileOf(resourceAddress).path, [resourceAddress]) + const mediaType = imageMediaType(path) + const data = content.kind === 'bytes' ? content.data : undefined + const [source, setSource] = useState() + + useEffect(() => { + if (data === undefined || mediaType === undefined) return + let url: string | undefined + try { + url = URL.createObjectURL(new Blob([data], { type: mediaType })) + setSource({ kind: 'ready', data, mediaType, url }) + } catch { + setSource({ kind: 'failed', data, mediaType }) + } + return () => { + if (url !== undefined) URL.revokeObjectURL(url) + } + }, [data, mediaType]) + + if (data === undefined || mediaType === undefined) { + return

{t('unsupported')}

+ } + if (source?.data !== data || source.mediaType !== mediaType) { + return + } + if (source.kind === 'failed') return

{t('failed')}

+ const { name } = pathPartsOf(path) + return +} + +/** SVG stays in the browser's static image mode because its bytes only reach an img Blob URL. */ +function LoadedImage({ url, name, t }: { + readonly url: string + readonly name: string + readonly t: ImageBodyProps['t'] +}): ReactNode { + const [state, setState] = useState<'loading' | 'ready' | 'failed'>('loading') + return
+ {state === 'loading' && } + {state === 'failed' &&

{t('failed')}

} + { setState('ready') }} + onError={() => { setState('failed') }} + /> +
+} diff --git a/packages/client/ui-sidebar-documentpreview/src/client/image/index.ts b/packages/client/ui-sidebar-documentpreview/src/client/image/index.ts new file mode 100644 index 0000000000..28586d1398 --- /dev/null +++ b/packages/client/ui-sidebar-documentpreview/src/client/image/index.ts @@ -0,0 +1,41 @@ +/** Builtin image metadata and keyed document-body registration. */ +import type { Context } from '@deepseek-ai/cordis' +import type {} from '../index.ts' +import type { DocumentPreviewDefinition } from '../document/registry.ts' +import { ImageBody } from './ImageBody.tsx' +import { en, zh } from './locales.ts' + +/** Image implementation identity, shared by metadata and the keyed slot. */ +export const IMAGE_BODY_ID = '@deepseek-ai/dsh-client-ui-sidebar-documentpreview/image' + +/** File suffixes rendered by the builtin image body. */ +export const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'svg'] as const + +/** + * Describe the builtin image renderer independently from its keyed body slot. + * @param title - locale-owned implementation name. + * @returns metadata for complete image files. + */ +export function imageBodyDefinition(title: () => string): DocumentPreviewDefinition { + return { + id: IMAGE_BODY_ID, + extensions: IMAGE_EXTENSIONS, + priority: 'builtin', + title, + loading: 'bytes-complete', + wrap: false, + } +} + +/** + * Register the image dictionary, metadata, and body with reversible effects. + * @param ctx - owning plugin context. + */ +export function apply(ctx: Context): void { + const t = ctx.locale.bind('sidebarImage') + ctx.effect(() => ctx.locale.register('sidebarImage', { zh, en }), 'document-image: dictionaries') + ctx.effect(() => ctx.documentPreviews.register(imageBodyDefinition(() => t('title'))), 'document-image: metadata') + ctx.effect(() => ctx.slots.inject('sidebar.right.tab.document', () => ctx.slots.register( + { name: 'sidebar.right.tab.document', key: IMAGE_BODY_ID, locale: 'sidebarImage' }, ImageBody, + )), 'document-image: body') +} diff --git a/packages/client/ui-sidebar-documentpreview/src/client/image/locales.ts b/packages/client/ui-sidebar-documentpreview/src/client/image/locales.ts new file mode 100644 index 0000000000..9859985ac8 --- /dev/null +++ b/packages/client/ui-sidebar-documentpreview/src/client/image/locales.ts @@ -0,0 +1,27 @@ +/** Locale-owned image renderer labels and status text. */ +export const zh = { + title: '图片', + preview: '图片预览:{name}', + loading: '正在打开图片…', + failed: '无法显示这张图片。', + unsupported: '图片预览需要完整文件内容。', +} satisfies Record + +/** Image renderer dictionary keys. */ +export type ImagePreviewKey = keyof typeof zh + +/** English dictionary with the same keys as the Chinese dictionary. */ +export const en = { + title: 'Image', + preview: 'Image preview: {name}', + loading: 'Opening image…', + failed: 'This image could not be displayed.', + unsupported: 'Image preview requires the complete file contents.', +} satisfies Record + +declare module '@deepseek-ai/dsh-client-ui-slots' { + interface LocaleNamespaceMap { + /** Image preview selection, accessible name, and status text. */ + sidebarImage: ImagePreviewKey + } +} diff --git a/packages/client/ui-sidebar-documentpreview/src/client/index.ts b/packages/client/ui-sidebar-documentpreview/src/client/index.ts index 1e25723c13..ef76084e07 100644 --- a/packages/client/ui-sidebar-documentpreview/src/client/index.ts +++ b/packages/client/ui-sidebar-documentpreview/src/client/index.ts @@ -33,6 +33,7 @@ import { documentTabInfoFactory } from './document/contract.ts' import { apply as registerText } from './text/index.ts' import { apply as registerMarkdown } from './markdown/index.ts' import { apply as registerHtml } from './html/index.ts' +import { apply as registerImage } from './image/index.ts' import { apply as registerPdf } from './pdf/index.ts' import { apply as registerCode } from './code/index.ts' @@ -111,6 +112,7 @@ export function apply(ctx: ClientContext): void { registerText(ctx) registerMarkdown(ctx) registerHtml(ctx) + registerImage(ctx) registerPdf(ctx) registerCode(ctx) } diff --git a/packages/client/ui-sidebar-documentpreview/tests/apply.client.spec.ts b/packages/client/ui-sidebar-documentpreview/tests/apply.client.spec.ts index 649f4ba868..c6a3093b03 100644 --- a/packages/client/ui-sidebar-documentpreview/tests/apply.client.spec.ts +++ b/packages/client/ui-sidebar-documentpreview/tests/apply.client.spec.ts @@ -21,6 +21,8 @@ import { MarkdownBody } from '../src/client/markdown/MarkdownBody.tsx' import { MARKDOWN_BODY_ID } from '../src/client/markdown/index.ts' import { HtmlBody } from '../src/client/html/HtmlBody.tsx' import { HTML_BODY_ID } from '../src/client/html/index.ts' +import { ImageBody } from '../src/client/image/ImageBody.tsx' +import { IMAGE_BODY_ID } from '../src/client/image/index.ts' import { PdfBody } from '../src/client/pdf/PdfBody.tsx' import { PDF_BODY_ID } from '../src/client/pdf/index.ts' import { CodeBody } from '../src/client/code/CodeBody.tsx' @@ -93,6 +95,7 @@ describe('ui-sidebar-documentpreview apply', () => { ['sidebar.right.tab.document', PLAIN_BODY_ID, undefined, TextBody], ['sidebar.right.tab.document', MARKDOWN_BODY_ID, 'documentMarkdown', MarkdownBody], ['sidebar.right.tab.document', HTML_BODY_ID, 'documentHtml', HtmlBody], + ['sidebar.right.tab.document', IMAGE_BODY_ID, 'sidebarImage', ImageBody], ['sidebar.right.tab.document', PDF_BODY_ID, 'sidebarPdf', PdfBody], ['sidebar.right.tab.document', '@deepseek-ai/dsh-client-ui-sidebar-documentpreview/code', 'sidebarCodePreview', CodeBody], ]) diff --git a/packages/client/ui-sidebar-documentpreview/tests/image-body.client.spec.tsx b/packages/client/ui-sidebar-documentpreview/tests/image-body.client.spec.tsx new file mode 100644 index 0000000000..377f93514a --- /dev/null +++ b/packages/client/ui-sidebar-documentpreview/tests/image-body.client.spec.tsx @@ -0,0 +1,111 @@ +// @vitest-environment jsdom +/** Image Blob ownership, media types, intrinsic rendering, and failure states. */ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { cleanup, fireEvent, render, screen } from '@testing-library/react' +import type { SessionId } from '@deepseek-ai/dsh-session/types' +import { ImageBody, imageMediaType, type ImageBodyProps } from '../src/client/image/ImageBody.tsx' +import { en } from '../src/client/image/locales.ts' + +const translations: ReadonlyMap = new Map(Object.entries(en)) +let createDescriptor: PropertyDescriptor | undefined +let revokeDescriptor: PropertyDescriptor | undefined +const create = vi.fn<(blob: Blob) => string>() +const revoke = vi.fn<(url: string) => void>() + +beforeEach(() => { + createDescriptor = Object.getOwnPropertyDescriptor(URL, 'createObjectURL') + revokeDescriptor = Object.getOwnPropertyDescriptor(URL, 'revokeObjectURL') + create.mockReset().mockImplementation(() => `blob:https://preview.invalid/${create.mock.calls.length}`) + revoke.mockReset() + Object.defineProperty(URL, 'createObjectURL', { configurable: true, value: create }) + Object.defineProperty(URL, 'revokeObjectURL', { configurable: true, value: revoke }) +}) + +afterEach(() => { + try { cleanup() } finally { + if (createDescriptor === undefined) Reflect.deleteProperty(URL, 'createObjectURL') + else Object.defineProperty(URL, 'createObjectURL', createDescriptor) + if (revokeDescriptor === undefined) Reflect.deleteProperty(URL, 'revokeObjectURL') + else Object.defineProperty(URL, 'revokeObjectURL', revokeDescriptor) + } +}) + +function props(path = 'asset.png', data: Uint8Array = new Uint8Array([1, 2, 3])): ImageBodyProps { + return { + resourceAddress: `dsh-resource://file/session/image/${path}`, + content: { kind: 'bytes', data }, + wrap: false, + sessionId: 'image' as SessionId, + useTabInfo: () => ({ tab: { signal: new AbortController().signal } }), + useResource: () => ({ value: undefined }), + t: (key, params) => { + const value = translations.get(key) ?? key + return params === undefined ? value : value.replace('{name}', String(params.name)) + }, + } as ImageBodyProps +} + +describe('ImageBody', () => { + it.each([ + ['png', 'image/png'], + ['jpg', 'image/jpeg'], + ['jpeg', 'image/jpeg'], + ['gif', 'image/gif'], + ['webp', 'image/webp'], + ['bmp', 'image/bmp'], + ['ico', 'image/x-icon'], + ['svg', 'image/svg+xml'], + ] as const)('assigns .%s bytes the %s Blob media type', async (extension, mediaType) => { + const view = render() + const image = await screen.findByRole('img', { hidden: true }) + expect(create.mock.calls[0]?.[0].type).toBe(mediaType) + expect(image.getAttribute('src')).toBe('blob:https://preview.invalid/1') + view.unmount() + expect(revoke).toHaveBeenCalledExactlyOnceWith('blob:https://preview.invalid/1') + }) + + it('keeps the image unscaled and non-draggable, then shows it after decoding succeeds', async () => { + render() + const image = await screen.findByRole('img', { hidden: true }) + expect(image.getAttribute('alt')).toBe('Image preview: photo.svg') + expect(image.getAttribute('decoding')).toBe('async') + expect(image.getAttribute('draggable')).toBe('false') + expect(image.getAttribute('referrerpolicy')).toBe('no-referrer') + expect(image.hasAttribute('hidden')).toBe(true) + fireEvent.load(image) + expect(image.hasAttribute('hidden')).toBe(false) + expect(screen.queryByRole('status')).toBeNull() + }) + + it('revokes replaced bytes and reports image decode and Blob creation failures', async () => { + const initial = props() + const view = render() + const first = await screen.findByRole('img', { hidden: true }) + fireEvent.error(first) + expect(screen.getByRole('alert').textContent).toBe(en.failed) + const changed = props('asset.png', new Uint8Array([4, 5, 6])) + view.rerender() + await screen.findByRole('img', { hidden: true }) + expect(revoke).toHaveBeenCalledWith('blob:https://preview.invalid/1') + create.mockImplementationOnce(() => { throw new Error('Blob unavailable') }) + view.rerender() + expect((await screen.findByRole('alert')).textContent).toBe(en.failed) + view.unmount() + expect(revoke).toHaveBeenCalledWith('blob:https://preview.invalid/2') + }) + + it('rejects text delivery and an unregistered suffix without creating a Blob', () => { + const initial = props() + const view = render() + expect(screen.getByRole('alert').textContent).toBe(en.unsupported) + view.rerender() + expect(screen.getByRole('alert').textContent).toBe(en.unsupported) + expect(create).not.toHaveBeenCalled() + }) + + it('matches media types case-insensitively on decoded path suffixes', () => { + expect(imageMediaType('folder/PHOTO.JPEG')).toBe('image/jpeg') + expect(imageMediaType('folder/no-extension')).toBeUndefined() + expect(imageMediaType('folder/photo.avif')).toBeUndefined() + }) +}) diff --git a/packages/client/ui-sidebar-documentpreview/tests/image-registration.client.spec.ts b/packages/client/ui-sidebar-documentpreview/tests/image-registration.client.spec.ts new file mode 100644 index 0000000000..eb7ac01dd1 --- /dev/null +++ b/packages/client/ui-sidebar-documentpreview/tests/image-registration.client.spec.ts @@ -0,0 +1,63 @@ +/** Image metadata, keyed slot, dictionary, and disposal registration. */ +import { Context } from '@deepseek-ai/cordis' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { DocumentPreviewRegistry } from '../src/client/document/registry.ts' +import { ImageBody } from '../src/client/image/ImageBody.tsx' +import { apply, IMAGE_BODY_ID, IMAGE_EXTENSIONS, imageBodyDefinition } from '../src/client/image/index.ts' +import { en, zh } from '../src/client/image/locales.ts' + +let dispose: (() => Promise) | undefined +afterEach(async () => { await dispose?.(); dispose = undefined }) + +describe('image registration', () => { + it('claims common image suffixes as a builtin complete-byte renderer without wrap', () => { + const title = vi.fn(() => 'localized image') + const definition = imageBodyDefinition(title) + expect(definition).toEqual({ + id: IMAGE_BODY_ID, + extensions: IMAGE_EXTENSIONS, + priority: 'builtin', + title, + loading: 'bytes-complete', + wrap: false, + }) + expect(title).not.toHaveBeenCalled() + expect(definition.title()).toBe('localized image') + }) + + it('registers its dictionary and matching keyed body, then removes every contribution', async () => { + const ctx = new Context() + const registry = new DocumentPreviewRegistry() + const dictionaries = new Map() + const bodies = new Map() + const register = vi.fn((options: { key: string }, body: unknown) => { + bodies.set(options.key, body) + return () => { bodies.delete(options.key) } + }) + ctx.provide('documentPreviews', registry) + ctx.provide('slots', { inject: (_key: string, callback: () => () => void) => callback(), register } as never) + ctx.provide('locale', { + bind: () => (key: keyof typeof en) => en[key], + register: (name: string, value: unknown) => { + dictionaries.set(name, value) + return () => { dictionaries.delete(name) } + }, + } as never) + const fiber = ctx.plugin({ apply }) + dispose = async () => { await fiber.dispose() } + await fiber.await() + for (const extension of IMAGE_EXTENSIONS) { + expect(registry.candidates(`ASSET.${extension}`).map(entry => entry.id)).toEqual([IMAGE_BODY_ID]) + } + expect(registry.getSnapshot()[0]?.title()).toBe(en.title) + expect(dictionaries.get('sidebarImage')).toEqual({ zh, en }) + expect(register).toHaveBeenCalledExactlyOnceWith( + { name: 'sidebar.right.tab.document', key: IMAGE_BODY_ID, locale: 'sidebarImage' }, + ImageBody, + ) + await dispose() + expect(registry.getSnapshot()).toEqual([]) + expect(bodies.size).toBe(0) + expect(dictionaries.size).toBe(0) + }) +}) diff --git a/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts b/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts index 0945d530e8..c0299970cf 100644 --- a/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts +++ b/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts @@ -2356,6 +2356,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ occupants: [ 'client-ui-sidebar-documentpreview CodeBody', 'client-ui-sidebar-documentpreview HtmlBody', + 'client-ui-sidebar-documentpreview ImageBody', 'client-ui-sidebar-documentpreview MarkdownBody', 'client-ui-sidebar-documentpreview PdfBody', 'client-ui-sidebar-documentpreview TextBody', From 58956c1a8a3643677fe2820a8a40f3aee5612b39 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Wed, 9 Sep 2026 22:01:10 +0800 Subject: [PATCH 13/32] Revert "feat(web): preview Mermaid, Graphviz, SVG, and HTML code fences" --- ...9-content-sized-diagram-previews.i18n.yaml | 6 - ...26-09-09-content-sized-diagram-previews.md | 25 - ...09-09-content-sized-diagram-previews.zh.md | 25 - ...6-09-09-markdown-static-previews.i18n.yaml | 6 - .../2026-09-09-markdown-static-previews.md | 43 -- .../2026-09-09-markdown-static-previews.zh.md | 43 -- THIRD_PARTY_NOTICES.md | 6 +- .../expected/markdown-mermaid/ui.expected.md | 24 - .../expected/markdown-mermaid/zh.expected.md | 23 - apps/web/tests/markdown-mermaid.e2e.ts | 320 -------- apps/web/tsconfig.json | 1 - apps/web/vite.config.ts | 16 +- packages/client/locale/src/locales/en.ts | 10 - packages/client/locale/src/locales/zh.ts | 10 - packages/client/ui-chat/README.i18n.yaml | 4 +- packages/client/ui-chat/README.md | 8 - packages/client/ui-chat/README.zh.md | 8 - .../ui-chat/src/client/markdown-labels.ts | 13 - .../client/ui-primitives/README.i18n.yaml | 4 +- packages/client/ui-primitives/README.md | 10 - packages/client/ui-primitives/README.zh.md | 10 - .../THIRD_PARTY_PREVIEW_NOTICES.txt | 688 ------------------ packages/client/ui-primitives/package.json | 6 +- .../src/markdown/CodeBlock.module.css | 84 --- .../ui-primitives/src/markdown/CodeBlock.tsx | 53 +- .../src/markdown/SourcePreview.module.css | 35 - .../src/markdown/SourcePreview.tsx | 71 -- .../ui-primitives/src/markdown/graphviz.ts | 37 - .../ui-primitives/src/markdown/mermaid.ts | 97 --- .../src/markdown/preview-document.ts | 44 -- .../src/markdown/preview-theme.ts | 27 - .../ui-primitives/src/markdown/render.tsx | 30 - .../tests/code-block.client.spec.tsx | 2 +- .../tests/fence-previews.client.spec.tsx | 126 ---- .../tests/graphviz-runtime.client.spec.ts | 67 -- .../tests/mermaid-runtime.client.spec.ts | 133 ---- .../tests/source-preview.client.spec.tsx | 162 ----- pnpm-lock.yaml | 14 - scripts/check-workspace-constraints.spec.ts | 14 - scripts/check-workspace-constraints.ts | 2 +- scripts/gen-third-party-notices.spec.ts | 24 - scripts/gen-third-party-notices.ts | 34 - tsconfig.host.json | 1 - 43 files changed, 20 insertions(+), 2346 deletions(-) delete mode 100644 .agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.i18n.yaml delete mode 100644 .agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.md delete mode 100644 .agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.zh.md delete mode 100644 .agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml delete mode 100644 .agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md delete mode 100644 .agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md delete mode 100644 apps/web/tests/expected/markdown-mermaid/ui.expected.md delete mode 100644 apps/web/tests/expected/markdown-mermaid/zh.expected.md delete mode 100644 apps/web/tests/markdown-mermaid.e2e.ts delete mode 100644 packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt delete mode 100644 packages/client/ui-primitives/src/markdown/SourcePreview.module.css delete mode 100644 packages/client/ui-primitives/src/markdown/SourcePreview.tsx delete mode 100644 packages/client/ui-primitives/src/markdown/graphviz.ts delete mode 100644 packages/client/ui-primitives/src/markdown/mermaid.ts delete mode 100644 packages/client/ui-primitives/src/markdown/preview-document.ts delete mode 100644 packages/client/ui-primitives/src/markdown/preview-theme.ts delete mode 100644 packages/client/ui-primitives/tests/fence-previews.client.spec.tsx delete mode 100644 packages/client/ui-primitives/tests/graphviz-runtime.client.spec.ts delete mode 100644 packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts delete mode 100644 packages/client/ui-primitives/tests/source-preview.client.spec.tsx diff --git a/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.i18n.yaml b/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.i18n.yaml deleted file mode 100644 index be4173fd02..0000000000 --- a/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.i18n.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each -# side as of the last confirmed-consistent state. Both languages carry equal authority; -# after editing either side, bring the other along and re-record with: -# pnpm run verify-translation-pairing --write .agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.md -2026-09-09-content-sized-diagram-previews.md: ceb29238eec09f2dde312835dbf376855998a507 -2026-09-09-content-sized-diagram-previews.zh.md: 2689602bfe3469f53e532367877f7e49d52d3d5d diff --git a/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.md b/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.md deleted file mode 100644 index ceb29238ee..0000000000 --- a/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.md +++ /dev/null @@ -1,25 +0,0 @@ -# Agent Note: Content-sized diagram previews - -Status: implemented - -English | [中文](2026-09-09-content-sized-diagram-previews.zh.md) - -## Problem - -Short Graphviz and SVG images leave large empty regions when displayed inside 400px frames. A 59px Graphviz diagram occupies a 400px preview even though its rendered dimensions are already available to the browser. - -## Decision - -Mermaid, Graphviz, and SVG share the inert image canvas in `SourcePreview`. The browser derives its height from the image, preserves aspect ratio when shrinking to the available width, and adds 16px padding. Source switching retains the image and copying reads the original code. Theme changes regenerate Graphviz colors without introducing a separate sizing observer. - -This replaces the diagram-frame choice in [Static Markdown fence previews](../feature/2026-09-09-markdown-static-previews.md); that note continues to own HTML isolation, rendering lifecycle, and license obligations. HTML retains its opaque, script-free, 400px frame. SVG image mode disables scripts, link interaction, and external resource loading without inserting source-controlled markup into the application document. - -## Alternatives considered - -**Set iframe height to auto.** An iframe does not derive its outer height from its inner document. This still reserves an unrelated viewport. - -**Add a frame measurement script or same-origin access.** A diagram already has image dimensions. Extra execution or origin permissions and resize messaging are unnecessary for that content. - -## Consequences - -Short diagrams occupy only their rendered height and canvas padding. The browser geometry regression compares image and container height in light and dark modes, then verifies proportional scaling in a narrow viewport. Browser security checks include SVG scripts, event handlers, nested HTML, and external images; copy and source toggling remain covered. HTML automatic height remains outside this change because arbitrary document layout has different measurement and isolation requirements. diff --git a/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.zh.md b/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.zh.md deleted file mode 100644 index 2689602bfe..0000000000 --- a/.agents/notes/implemented/bug-fix/2026-09-09-content-sized-diagram-previews.zh.md +++ /dev/null @@ -1,25 +0,0 @@ -# Agent Note: 按内容定高的图表预览 - -Status: implemented - -[English](2026-09-09-content-sized-diagram-previews.md) | 中文 - -## Problem - -较矮的 Graphviz 与 SVG 图片显示在 400px iframe 中时,会留下大块空白。浏览器已经知道图片的渲染尺寸,但一张 59px 高的 Graphviz 图表仍占据 400px 的预览区域。 - -## Decision - -Mermaid、Graphviz 与 SVG 共享 `SourcePreview` 的不可执行图片画布。浏览器根据图片决定高度,在可用宽度不足时按比例缩小,并添加 16px 内边距。源码切换保留图片,复制读取原始代码。主题变化重新生成 Graphviz 配色,无需单独的尺寸观察器。 - -这替代了[静态 Markdown fence 预览](../feature/2026-09-09-markdown-static-previews.zh.md)中的图表 iframe 选择;该记录继续维护 HTML 隔离、渲染生命周期与许可证义务。HTML 保留不透明来源、禁用脚本的 400px iframe。SVG 图片模式禁用脚本、链接交互与外部资源加载,无需把源码控制的标记插入应用文档。 - -## Alternatives considered - -**把 iframe 高度设为 auto。** iframe 不会根据内部文档决定外部高度,仍然会保留与内容无关的视口。 - -**添加 iframe 测量脚本或同源访问。** 图表已经具备图片尺寸,不需要额外执行权限、来源权限或尺寸消息协议。 - -## Consequences - -较矮图表只占据渲染高度与画布内边距。浏览器几何回归用例在浅色和深色下比较图片与容器高度,再验证窄视口中的等比例缩放。浏览器安全检查包含 SVG 脚本、事件处理器、嵌套 HTML 与外部图片,并保留复制和源码切换覆盖。HTML 自动高度不属于本次改动,因为任意文档布局具有不同的测量与隔离要求。 diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml deleted file mode 100644 index 8a24afcd59..0000000000 --- a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.i18n.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each -# side as of the last confirmed-consistent state. Both languages carry equal authority; -# after editing either side, bring the other along and re-record with: -# pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md -2026-09-09-markdown-static-previews.md: f3a0363e3d7c4cb19ca67dfc5011e936f7c024cf -2026-09-09-markdown-static-previews.zh.md: 24f87cd73504c1fbd274e1420a3692b3ca55ed5e diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md deleted file mode 100644 index f3a0363e3d..0000000000 --- a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md +++ /dev/null @@ -1,43 +0,0 @@ -# Agent Note: Static Markdown fence previews - -Status: implemented - -English | [中文](2026-09-09-markdown-static-previews.zh.md) - -## Problem - -Readers need to see Mermaid and DOT diagrams, SVG artwork, and HTML examples directly in Assistant replies without interpreting source or copying it to another renderer. These sources are untrusted, and a renderer's npm license field may omit compiled components with separate distribution obligations. - -## Decision - -The shared Markdown renderer enables settled `mermaid`, `graphviz`/`dot`, `svg`, and `html` fences through localized `MarkdownLabels.preview` and the parsed fence language. The [UI primitives package](../../../../packages/client/ui-primitives/README.md) owns `SourcePreview`, which accepts a renderer, source, and labels without Session, file, or Cordis dependencies. Mermaid and Graphviz each supply a `.ts` renderer to that same component. Consumers without preview labels and streaming messages retain code. - -`CodeBlock.preview` owns default visualization, source switching, and verbatim copying. Previews omit the language banner and expose compact icon actions on hover or keyboard focus; devices with any touch input keep actions visible below the diagram. Switching to source hides the mounted preview, preserving completed rendering and pending work. Both views use the same focused toggle button, and copying always reads the source prop. - -`SourcePreview` owns loading, failure, and cancellation of stale result publication. Source replacement and unmounting cancel publication; cancellation before runtime loading completes skips layout. Failures show a localized error and the original source, and replacing invalid source with valid input recovers the preview. - -Mermaid loads on demand. A shared queue serializes theme initialization with diagram work, and each call removes its temporary measurement DOM in `finally`. Strict security, disabled HTML labels, the application palette, and error-rendering policy cannot be overridden by diagram configuration. Generated SVG is displayed as an image without installing links or scripts. Intrinsic dimensions come from the SVG viewBox; large diagrams shrink to fit, and the canvas follows the code-block background. Mounted previews observe document theme attributes and regenerate only when resolved colors change; obsolete renders cannot publish. Graphviz default colors follow the same palette, while authored DOT, SVG, and HTML colors remain intact. - -HTML uses DOMPurify with navigation attributes and document-loading elements forbidden, followed by an opaque `sandbox=""` iframe. A trusted CSP precedes source markup and permits only inline CSS, data images, and data fonts. Scripts, external resources, child frames, form submission, and same-origin access are unavailable. SVG is parsed as XML and displayed with Graphviz output as inert images in a [content-sized canvas](../bug-fix/2026-09-09-content-sized-diagram-previews.md), so SVG scripts and links never become active. HTML frames have a fixed scrollable viewport: measuring their content would require additional origin access or trusted frame scripts. - -Graphviz uses the pinned, unmodified `@viz-js/viz` 3.30.0 WebAssembly distribution with the `dot` layout engine. Its npm MIT declaration covers the wrapper; its build provenance identifies Graphviz 16.0.0 (EPL-2.0), Expat 2.8.4 (MIT), and Emscripten 5.0.7 (MIT/NCSA). Distribution retains these component terms and the exact Graphviz source download under EPL-2.0 section 3.1. [Full preview notices](../../../../packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt) also retain Mermaid's MIT text and select Apache-2.0 for DOMPurify. The UI primitives package ships the notices and the Web build emits the same bytes alongside its assets. License review covers embedded payloads separately from the general permissive npm-metadata policy. - -## Alternatives considered - -**Keep the code banner above diagrams.** A language label and permanent text controls distract from the diagram. Overlay actions retain source access without reserving a title row. - -**Render each streamed chunk.** Incomplete diagrams are frequently invalid, and repeated layout work competes with text streaming. Message settlement provides complete source. - -**Put rendering inside Chat or add a general preview registry.** A shared primitive with plain props satisfies reuse without another registry or feature-plugin dependency. This follows the [shared-control rule](../architecture/2026-09-05-shared-client-control-primitives.md). - -**Execute HTML scripts in a frame.** Static chat examples do not need script execution. An empty sandbox plus sanitization and CSP gives the preview fewer capabilities and avoids introducing a frame messaging protocol. - -**Insert rendered markup into Chat.** The requested preview needs diagram display and source access; HTML styles and executable SVG would share the application document. Iframes isolate layout and origin; SVG image mode additionally disables SVG behavior. - -**Treat Viz.js as MIT-only or use a remote Graphviz service.** The compiled Graphviz license still applies locally; a remote renderer would send conversation content off-device. The bundled renderer retains source availability and legal notices without network rendering. - -## Consequences - -The feature changes presentation without changing persisted messages, provider requests, tools, or Host APIs. Inline HTML styles work, while interactive scripts, external assets, and links do not. Mermaid and Graphviz add lazy browser assets and run layout on the browser thread. Cancellation cannot preempt active layout; Mermaid finishes and releases its measurement DOM even when its result cannot be published. The previews have no editing, export, zoom controls, or interactive diagram links. - -Component tests cover source copying, default preview, delayed completion, stale success and failure, unmounting, fallback, cancellation, runtime loading failure, and recovery. The keyless [browser scenario](../../../../apps/web/tests/markdown-mermaid.e2e.ts) verifies Chinese Mermaid flowcharts, sequence diagrams, malformed source, configuration overrides, opaque frames, real image decoding, source toggling, blocked script/navigation/resource attempts, English/Chinese UI snapshots, and served license text. Notices checks pin the reviewed wrapper and native provenance so upgrades require renewed review. diff --git a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md b/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md deleted file mode 100644 index 24f87cd735..0000000000 --- a/.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md +++ /dev/null @@ -1,43 +0,0 @@ -# Agent Note: 静态 Markdown fence 预览 - -Status: implemented - -[English](2026-09-09-markdown-static-previews.md) | 中文 - -## Problem - -读者需要直接在 Assistant 回复中查看 Mermaid 和 DOT 图表、SVG 图像和 HTML 示例,而不必解读源码或复制到其他渲染器。这些源码不可信,而渲染器的 npm 许可证字段可能遗漏编译组件各自的分发义务。 - -## Decision - -共享 Markdown 渲染器通过本地化的 `MarkdownLabels.preview` 和解析后的 fence 语言启用定稿后的 `mermaid`、`graphviz`/`dot`、`svg` 和 `html` fence。[UI primitives 包](../../../../packages/client/ui-primitives/README.zh.md)拥有 `SourcePreview`,它接收渲染器、源码和文案,不依赖 Session、文件或 Cordis。Mermaid 与 Graphviz 各自向同一组件提供 `.ts` 渲染器。未提供预览文案的调用方与流式消息保留代码显示。 - -`CodeBlock.preview` 负责默认可视化、源码切换与原样复制。预览省略语言横幅,在悬停或键盘聚焦时显示紧凑的图标操作;具有任何触控输入的设备始终在图表下方显示操作。切换到源码会隐藏已挂载的预览,保留完成的渲染和待完成的工作。两种视图使用同一个保持焦点的切换按钮,复制始终读取源码属性。 - -`SourcePreview` 负责加载、失败和取消过期结果发布。替换源码和卸载组件会取消结果发布;在运行时加载完成前取消会跳过布局。失败时显示本地化错误与原始源码,用有效输入替换无效源码后可以恢复预览。 - -Mermaid 按需加载。共享队列将主题初始化与图表渲染一起串行执行,每次调用都在 `finally` 中删除临时测量 DOM。图表配置无法覆盖严格安全模式、禁用 HTML 标签、应用配色和错误渲染策略。生成的 SVG 作为图片显示,不安装链接或脚本。固有尺寸来自 SVG viewBox;大图缩小以适应宽度,画布使用代码块背景。已挂载的预览观察文档主题属性,仅在解析后的配色变化时重新生成;过期渲染不能发布结果。Graphviz 的默认颜色采用同一配色,DOT、SVG 和 HTML 中明确指定的颜色保持原样。 - -HTML 先由 DOMPurify 清理,禁止导航属性与文档加载元素,再进入不透明来源的 `sandbox=""` iframe。可信 CSP 位于源码标记之前,仅允许内联 CSS、data 图片与 data 字体。脚本、外部资源、子 iframe、表单提交与同源访问均不可用。SVG 按 XML 解析后,与 Graphviz 输出一同作为不可执行图片显示在[按内容定高的画布](../bug-fix/2026-09-09-content-sized-diagram-previews.zh.md)中,因此 SVG 脚本与链接不会激活。HTML iframe 使用固定的可滚动视口:测量内容需要额外的来源访问权限或可信 iframe 脚本。 - -Graphviz 使用固定且未修改的 `@viz-js/viz` 3.30.0 WebAssembly 发布包,布局引擎为 `dot`。其 npm MIT 声明覆盖包装层;构建来源记录标明 Graphviz 16.0.0(EPL-2.0)、Expat 2.8.4(MIT)与 Emscripten 5.0.7(MIT/NCSA)。分发保留各组件条款,并按 EPL-2.0 第 3.1 节提供准确的 Graphviz 源码下载地址。[完整预览声明](../../../../packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt)还保留 Mermaid 的 MIT 文本,并为 DOMPurify 选择 Apache-2.0。UI primitives 包携带该声明,Web 构建在资源旁输出相同字节。内嵌产物的许可证检查独立于通用的宽松 npm 元数据策略。 - -## Alternatives considered - -**在图表上方保留代码横幅。** 语言标签和常驻文字控件会分散对图表的注意力。浮层操作保留源码访问,不占用标题行。 - -**渲染每个流式片段。** 未完成的图表通常无效,反复布局会与文本流式输出争用资源。消息定稿可提供完整源码。 - -**在 Chat 内部渲染,或添加通用预览注册表。** 使用普通属性的共享基础组件即可满足复用,无需另加注册表或功能插件依赖。这遵循[共享控件规则](../architecture/2026-09-05-shared-client-control-primitives.zh.md)。 - -**在 iframe 内执行 HTML 脚本。** 静态聊天示例不需要脚本执行。空 sandbox、清理与 CSP 降低预览权限,也避免引入 iframe 消息协议。 - -**把渲染标记插入 Chat。** 所需预览只需显示图表和访问源码;HTML 样式和可执行 SVG 会与应用共享文档。iframe 隔离布局与来源,SVG 图片模式额外禁用 SVG 行为。 - -**将 Viz.js 视为仅使用 MIT,或使用远程 Graphviz 服务。** 本地编译的 Graphviz 仍受其许可证约束;远程渲染会把对话内容发送到设备之外。内置渲染器保留源码可获取性与法律声明,无需网络渲染。 - -## Consequences - -该功能改变呈现,不改变持久化消息、provider 请求、工具或 Host API。HTML 内联样式可用,交互脚本、外部资源和链接不可用。Mermaid 和 Graphviz 增加按需加载的浏览器资源,并在浏览器线程上执行布局。取消无法抢占进行中的布局;即使结果无法发布,Mermaid 仍会完成并释放测量 DOM。预览不提供编辑、导出、缩放控件或交互式图表链接。 - -组件测试覆盖源码复制、默认预览、延迟完成、过期成功与失败、卸载、回退、取消、运行时加载失败与恢复。无密钥[浏览器场景](../../../../apps/web/tests/markdown-mermaid.e2e.ts)验证中文 Mermaid 流程图、时序图、无效源码、配置覆盖、不透明来源 iframe、真实图片解码、源码切换、脚本/导航/资源请求被阻止、中英文 UI 快照和已提供的许可证文本。声明检查固定已审查的包装层与原生构建来源,升级时须重新审查。 diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 2452325d62..31eebdab8d 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -55,7 +55,6 @@ External packages installed for runtime use or distributed inside the prebuilt b | [`@shikijs/langs`](https://github.com/shikijs/shiki) | MIT | | [`@standard-schema/spec`](https://github.com/standard-schema/standard-schema) | MIT | | [`@tanstack/react-virtual`](https://github.com/TanStack/virtual) | MIT | -| [`@viz-js/viz`](https://github.com/mdaines/viz-js) | MIT | | [`@vscode/ripgrep`](https://github.com/microsoft/vscode-ripgrep) | MIT | | [`@xterm/headless`](https://github.com/xtermjs/xterm.js) | MIT | | [`@yarnpkg/parsers`](https://github.com/yarnpkg/berry) | BSD-2-Clause | @@ -67,7 +66,6 @@ External packages installed for runtime use or distributed inside the prebuilt b | [`commander`](https://github.com/tj/commander.js) | MIT | | [`compression`](https://github.com/expressjs/compression) | MIT | | [`diff`](https://github.com/kpdecker/jsdiff) | BSD-3-Clause | -| [`dompurify`](https://github.com/cure53/DOMPurify) | (MPL-2.0 OR Apache-2.0) | | [`e2b`](https://github.com/e2b-dev/e2b) | MIT | | [`electron-updater`](https://github.com/electron-userland/electron-builder) | MIT | | [`eventsource-parser`](https://github.com/rexxars/eventsource-parser) | MIT | @@ -81,7 +79,6 @@ External packages installed for runtime use or distributed inside the prebuilt b | [`mdast-util-from-markdown`](https://github.com/syntax-tree/mdast-util-from-markdown) | MIT | | [`mdast-util-gfm`](https://github.com/syntax-tree/mdast-util-gfm) | MIT | | [`mdast-util-math`](https://github.com/syntax-tree/mdast-util-math) | MIT | -| [`mermaid`](https://github.com/mermaid-js/mermaid) | MIT | | [`micromark-core-commonmark`](https://github.com/micromark/micromark/tree/main/packages/micromark-core-commonmark) | MIT | | [`micromark-extension-gfm`](https://github.com/micromark/micromark-extension-gfm) | MIT | | [`micromark-extension-math`](https://github.com/micromark/micromark-extension-math) | MIT | @@ -115,8 +112,6 @@ External packages installed for runtime use or distributed inside the prebuilt b | [`zod`](https://github.com/colinhacks/zod) | MIT | | [`zustand`](https://github.com/pmndrs/zustand) | MIT | -The Markdown preview distribution also contains Graphviz 16.0.0 (EPL-2.0), Expat 2.8.4 (MIT), and Emscripten 5.0.7 runtime code (MIT/NCSA) inside `@viz-js/viz` 3.30.0. The wrapper's MIT metadata does not relicense these components. [Preview notices](packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt) preserve their full license texts and Graphviz source availability, together with Mermaid's MIT and DOMPurify's selected Apache-2.0 terms. The UI primitives npm package includes this file; the Web build emits it as `preview-third-party-notices.txt`. - pnpm applies local patches to the following packages at install time, so shipped artifacts carry modified copies; each patch file is the complete record of the modification: - `@yao-pkg/pkg@6.21.0` — [`patches/@yao-pkg__pkg@6.21.0.patch`](patches/@yao-pkg__pkg@6.21.0.patch) @@ -194,6 +189,7 @@ External packages **directly declared** for development, tests, types, or toolin | [`jsdom`](https://github.com/jsdom/jsdom) | MIT | | [`lefthook`](https://github.com/evilmartians/lefthook) | MIT | | [`lightningcss`](https://github.com/parcel-bundler/lightningcss) | MPL-2.0 | +| [`mermaid`](https://github.com/mermaid-js/mermaid) | MIT | | [`micromark-util-types`](https://github.com/micromark/micromark/tree/main/packages/micromark-util-types) | MIT | | [`msgpackr`](http://github.com/kriszyp/msgpackr) | MIT | | [`oxlint`](https://github.com/oxc-project/oxc) | MIT | diff --git a/apps/web/tests/expected/markdown-mermaid/ui.expected.md b/apps/web/tests/expected/markdown-mermaid/ui.expected.md deleted file mode 100644 index 985f68fee0..0000000000 --- a/apps/web/tests/expected/markdown-mermaid/ui.expected.md +++ /dev/null @@ -1,24 +0,0 @@ -- heading "Mermaid previews" [level=1] -- button "Source" -- button "Copy" -- tooltip "Copy" -- img "Mermaid diagram" -- button "Source" -- button "Copy" -- img "Mermaid diagram" -- button "Source" -- button "Copy" -- status: Unable to render this diagram. The source is shown below. -- code: flowchart LR A[unfinished -- button "Source" -- button "Copy" -- img "Mermaid diagram" -- button "Source" -- button "Copy" -- img "Graphviz diagram" -- button "Source" -- button "Copy" -- img "SVG preview" -- button "Source" -- button "Copy" -- iframe diff --git a/apps/web/tests/expected/markdown-mermaid/zh.expected.md b/apps/web/tests/expected/markdown-mermaid/zh.expected.md deleted file mode 100644 index 52d7053ded..0000000000 --- a/apps/web/tests/expected/markdown-mermaid/zh.expected.md +++ /dev/null @@ -1,23 +0,0 @@ -- heading "Mermaid previews" [level=1] -- button "源码" -- button "复制" -- img "Mermaid 图表" -- button "源码" -- button "复制" -- img "Mermaid 图表" -- button "源码" -- button "复制" -- status: 无法渲染此图表,源码如下。 -- code: flowchart LR A[unfinished -- button "源码" -- button "复制" -- img "Mermaid 图表" -- button "源码" -- button "复制" -- img "Graphviz 图表" -- button "源码" -- button "复制" -- img "SVG 预览" -- button "源码" -- button "复制" -- iframe diff --git a/apps/web/tests/markdown-mermaid.e2e.ts b/apps/web/tests/markdown-mermaid.e2e.ts deleted file mode 100644 index 95249740bf..0000000000 --- a/apps/web/tests/markdown-mermaid.e2e.ts +++ /dev/null @@ -1,320 +0,0 @@ -import { fileURLToPath } from 'node:url' -import { join } from 'node:path' -import type { Browser, Page } from 'playwright' -import { chromium } from 'playwright' -import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest' -import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm' -import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session' -import type {} from '@deepseek-ai/dsh-session-title' -import { - assertFixtureInventory, captureStableAria, compareOrRefreshGolden, launchWebScaffold, - seedSession, watchConsole, webSnapshotMode, type WebScaffold, -} from './scaffold.ts' -import { newEnglishPage, saveFailureShot } from './support.ts' - -const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/markdown-mermaid', import.meta.url)) -const MODE = webSnapshotMode() -const SEED_ID = 'markdown-mermaid-web-e2e' -const DIAGRAM_MESSAGE = '[class*="markdown"]:has(.md-code-block)' -const FLOW = 'flowchart LR\n A[输入] --> B[共享渲染器] --> C[图形预览]' -const SEQUENCE = 'sequenceDiagram\n participant U as User\n participant R as Renderer\n U->>R: Mermaid source\n R-->>U: Diagram' -const INVALID = 'flowchart LR\n A[unfinished' -const UNTRUSTED = [ - '%%{init: {"securityLevel":"loose","htmlLabels":true,"themeCSS":"body {display:none!important}"}}%%', - 'flowchart LR', - ' A[""] --> B[Safe]', - ' click B "javascript:alert(1)"', -].join('\n') - -const DOT = 'digraph { rankdir=LR; Input -> Preview }' -const SVG = ` -SVG preview - - -
-
` -const HTML = `

Static HTML

- - -Disabled navigation - -` - -function fixture(): string { - const session = Session.create(SessionId('markdown-mermaid-source')) - session.append('turn/start', { turn: 1 }) - const user = session.append('user/message', createUserMessage({ - content: [{ type: 'text', text: 'Preview these Mermaid diagrams.' }], source: { kind: 'user' }, - }), { surfaceOp: 'append' }) - session.append('session/title', { title: 'Mermaid previews', messageSeqs: [user.seq], source: { kind: 'fallback' } }) - session.append('step/start', { turn: 1, step: 1 }) - session.append('assistant/message', { - stream: [], turn: 1, step: 1, - message: createMessage({ - role: 'assistant', - content: [{ type: 'text', text: [ - '# Mermaid previews', - ...[FLOW, SEQUENCE, INVALID, UNTRUSTED].map(code => `\`\`\`mermaid\n${code}\n\`\`\``), - ...[['dot', DOT], ['svg', SVG], ['html', HTML]].map(([lang, code]) => `\`\`\`${lang}\n${code}\n\`\`\``), - ].join('\n\n') }], - source: { kind: 'model', provider: 'fixture', model: 'fixture' }, - }), - }, { surfaceOp: 'append' }) - session.append('step/end', { turn: 1, step: 1 }) - session.append('turn/end', { turn: 1, reason: { kind: 'completed' } }) - const noon = new Date().setHours(12, 0, 0, 0) - return [ - JSON.stringify({ - type: 'session', version: SESSION_FORMAT_VERSION, id: '{{sessionId}}', createdAt: 0, - cwd: '{{cwd}}', isSeeded: false, delegationDepth: 0, - }), - ...session.snapshotEvents().map(event => JSON.stringify({ ...event, time: noon + event.seq * 1000 })), - '', - ].join('\n') -} - -async function openConversation(page: Page, scaffold: WebScaffold): Promise { - await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' }) - await page.getByRole('treeitem').first().click({ timeout: 30_000 }) - await page.getByRole('treeitem').nth(1).click() - await page.getByRole('heading', { name: 'Mermaid previews' }).waitFor() -} - -describe('web e2e: Mermaid chat previews', () => { - let scaffold: WebScaffold - let browser: Browser - beforeAll(async () => { - scaffold = await launchWebScaffold({}) - await seedSession(scaffold, fixture(), SEED_ID) - browser = await chromium.launch() - }, 120_000) - afterAll(async () => { - await browser?.close() - await scaffold?.close() - }) - - it.skipIf(MODE === 'record').each(['light', 'dark'] as const)( - 'tightly wraps short diagram previews in %s mode', async (scheme) => { - const page = await newEnglishPage(browser) - try { - await page.emulateMedia({ colorScheme: scheme }) - await openConversation(page, scaffold) - await expect.poll(() => page.evaluate(() => getComputedStyle(document.documentElement).colorScheme)).toBe(scheme) - - const mermaid = page.getByRole('img', { name: 'Mermaid diagram' }).first() - await mermaid.evaluate(async (node: HTMLImageElement) => { await node.decode() }) - const mermaidHeight = await mermaid.evaluate(node => node.getBoundingClientRect().height) - const canvasHeight = await mermaid.evaluate(node => node.parentElement!.getBoundingClientRect().height) - // Compact diagrams need at most the Mermaid canvas's 16px padding on each side. - expect(canvasHeight - mermaidHeight).toBeLessThanOrEqual(32) - - for (const title of ['Graphviz diagram', 'SVG preview']) { - const image = page.getByRole('img', { name: title, exact: true }) - await image.evaluate(async (node: HTMLImageElement) => { await node.decode() }) - const imageHeight = await image.evaluate(node => node.getBoundingClientRect().height) - const containerHeight = await image.evaluate(node => node.parentElement!.getBoundingClientRect().height) - expect(imageHeight).toBeGreaterThan(0) - expect(containerHeight).toBeGreaterThanOrEqual(imageHeight) - expect.soft(containerHeight - imageHeight, - `${scheme} ${title}: ${containerHeight}px container around ${imageHeight}px content`, - ).toBeLessThanOrEqual(32) - } - await page.setViewportSize({ width: 360, height: 800 }) - const svg = page.getByRole('img', { name: 'SVG preview', exact: true }) - await expect.poll(() => svg.evaluate((node) => { - const { width, height } = node.getBoundingClientRect() - return width > 0 && height > 0 && width < 460 - })).toBe(true) - const compact = await svg.evaluate((node: HTMLImageElement) => ({ - width: node.getBoundingClientRect().width, - height: node.getBoundingClientRect().height, - canvasHeight: node.parentElement!.getBoundingClientRect().height, - ratio: node.naturalWidth / node.naturalHeight, - })) - expect(compact.width / compact.height).toBeCloseTo(compact.ratio, 1) - expect(compact.canvasHeight - compact.height).toBeLessThanOrEqual(32) - } finally { - await page.close() - } - }, - ) - - it.skipIf(MODE === 'record')('updates existing diagrams when the document switches between light and dark', async () => { - const page = await newEnglishPage(browser) - try { - await openConversation(page, scaffold) - const image = page.getByRole('img', { name: 'Mermaid diagram' }).first() - await image.waitFor() - let previous = await image.getAttribute('src') - for (const scheme of ['dark', 'light'] as const) { - await page.evaluate((value) => { - document.documentElement.style.colorScheme = value - document.body.toggleAttribute('data-ds-dark-theme', value === 'dark') - }, scheme) - await expect.poll(() => image.getAttribute('src')).not.toBe(previous) - await expect.poll(() => image.evaluate(node => (node as HTMLImageElement).naturalWidth)).toBeGreaterThan(0) - const colors = await image.evaluate((node) => { - const reference = document.createElement('span') - reference.style.backgroundColor = 'var(--dsw-alias-markdown-code-block)' - document.body.append(reference) - try { - return { - canvas: getComputedStyle(node.parentElement!).backgroundColor, - expected: getComputedStyle(reference).backgroundColor, - } - } finally { - reference.remove() - } - }) - expect(colors.canvas).toBe(colors.expected) - await expect.poll(() => page.getByTitle('HTML preview', { exact: true }).getAttribute('srcdoc')) - .toContain(`color-scheme:${scheme}`) - previous = await image.getAttribute('src') - } - } finally { - await page.close() - } - }) - - it.skipIf(MODE === 'record')('renders diagrams, switches to source, copies source, and contains malformed content', async () => { - const page = await newEnglishPage(browser) - onTestFailed(() => saveFailureShot(page, 'web-e2e-markdown-mermaid')) - const tripwire = watchConsole(page) - const dialogs: string[] = [] - page.on('dialog', (dialog) => { dialogs.push(dialog.message()); void dialog.dismiss() }) - await page.context().grantPermissions(['clipboard-read', 'clipboard-write']) - await openConversation(page, scaffold) - const images = page.getByRole('img', { name: 'Mermaid diagram' }) - await expect.poll(() => images.count(), { timeout: 20_000 }).toBe(3) - await expect.poll(() => images.evaluateAll(nodes => nodes.every(node => (node as HTMLImageElement).naturalWidth > 0))).toBe(true) - expect(await images.evaluateAll(nodes => nodes.every(node => - node.getBoundingClientRect().width <= (node as HTMLImageElement).naturalWidth))).toBe(true) - expect(await page.getByText('Unable to render this diagram. The source is shown below.', { exact: true }).count()).toBe(1) - expect(await page.locator('pre code').allTextContents()).toContain(INVALID) - expect(await images.first().evaluate(node => decodeURIComponent((node as HTMLImageElement).src))).toContain('共享渲染器') - const first = page.locator('.md-code-block').first() - const diagram = await first.getByRole('img').elementHandle() - const controls = first.locator('[class*="bannerWrap"]') - expect(await first.getByText('mermaid', { exact: true }).count()).toBe(0) - await page.mouse.move(0, 0) - expect(await controls.evaluate(node => getComputedStyle(node).opacity)).toBe('0') - await first.hover() - expect(await controls.evaluate(node => getComputedStyle(node).opacity)).toBe('1') - await first.getByRole('button', { name: 'Copy', exact: true }).click() - expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(FLOW) - await page.mouse.move(0, 0) - await first.getByRole('button', { name: 'Source', exact: true }).focus() - expect(await controls.evaluate(node => getComputedStyle(node).opacity)).toBe('1') - await page.keyboard.press('Enter') - expect(await first.getByRole('button', { name: 'Preview', exact: true }) - .evaluate(node => node === document.activeElement)).toBe(true) - expect(await first.locator('pre code').textContent()).toBe(FLOW) - expect(await diagram!.evaluate(node => node.isConnected)).toBe(true) - expect(await diagram!.isVisible()).toBe(false) - await first.getByRole('button', { name: 'Preview', exact: true }).click() - expect(await diagram!.isVisible()).toBe(true) - await first.getByRole('button', { name: 'Copy', exact: true }).waitFor() - expect(await page.locator('body').evaluate(node => getComputedStyle(node).display)).not.toBe('none') - expect(await page.locator('[id^="dsh-mermaid-"]').count()).toBe(0) - expect(dialogs).toEqual([]) - expect(tripwire.pageErrors).toEqual([]) - expect(tripwire.warnings).toEqual([]) - await page.getByRole('heading', { name: 'Mermaid previews' }).click() - await page.mouse.move(0, 0) - const snapshot = await captureStableAria(page, DIAGRAM_MESSAGE, scaffold.workspaceCwd) - await compareOrRefreshGolden(join(SNAPSHOT_DIR, 'ui.expected.md'), snapshot, MODE) - await page.close() - }, 60_000) - - it.skipIf(MODE === 'record')('localizes the preview and failure states in Chinese', async () => { - const page = await browser.newPage({ viewport: { width: 1680, height: 1000 }, locale: 'zh-CN', timezoneId: 'Asia/Shanghai', hasTouch: true }) - await openConversation(page, scaffold) - await expect.poll(() => page.getByRole('img', { name: 'Mermaid 图表' }).count(), { timeout: 20_000 }).toBe(3) - expect(await page.getByRole('button', { name: '源码', exact: true }).count()).toBe(7) - const controls = page.locator('.md-code-block').first().locator('[class*="bannerWrap"]') - expect(await controls.evaluate(node => getComputedStyle(node).opacity)).toBe('1') - expect(await page.getByRole('button', { name: '源码', exact: true }).first() - .evaluate(node => node.getBoundingClientRect().width)).toBe(44) - expect(await page.getByText('无法渲染此图表,源码如下。', { exact: true }).count()).toBe(1) - const firstImage = page.getByRole('img', { name: 'Mermaid 图表' }).first() - await expect.poll(() => firstImage.evaluate(node => (node as HTMLImageElement).naturalWidth)).toBeGreaterThan(0) - expect(await controls.evaluate(node => node.getBoundingClientRect().top)) - .toBeGreaterThanOrEqual(await firstImage.evaluate(node => node.getBoundingClientRect().bottom)) - const snapshot = await captureStableAria(page, DIAGRAM_MESSAGE, scaffold.workspaceCwd) - await compareOrRefreshGolden(join(SNAPSHOT_DIR, 'zh.expected.md'), snapshot, MODE) - await assertFixtureInventory(SNAPSHOT_DIR, ['ui.expected.md', 'zh.expected.md']) - await page.close() - }, 60_000) - - it.skipIf(MODE === 'record')('previews inert DOT and SVG images and isolates static HTML', async () => { - const page = await newEnglishPage(browser) - const requests: string[] = [] - const dialogs: string[] = [] - // Routing observes requests eligible for transport; Chromium also emits 'request' for CSP-blocked URLs. - await page.route('https://preview.invalid/**', async (route) => { - requests.push(route.request().url()) - await route.abort() - }) - page.on('dialog', (dialog) => { dialogs.push(dialog.message()); void dialog.dismiss() }) - await page.context().grantPermissions(['clipboard-read', 'clipboard-write']) - await openConversation(page, scaffold) - for (const [title, code] of [['Graphviz diagram', DOT], ['SVG preview', SVG], ['HTML preview', HTML]] as const) { - const preview = title === 'HTML preview' - ? page.getByTitle(title, { exact: true }) - : page.getByRole('img', { name: title, exact: true, includeHidden: true }) - await preview.waitFor() - if (title === 'HTML preview') { - expect(await preview.getAttribute('sandbox')).toBe('') - const body = preview.contentFrame() - await body.getByRole('heading', { name: 'Static HTML' }).waitFor() - expect(await body.getByRole('heading').evaluate(node => getComputedStyle(node).color)).toBe('rgb(0, 128, 0)') - await body.getByText('Disabled navigation').click() - expect(await preview.evaluate(node => (node as HTMLIFrameElement).contentDocument)).toBeNull() - } else { - await expect.poll(() => preview.evaluate(node => (node as HTMLImageElement).naturalWidth)).toBeGreaterThan(0) - } - const block = page.locator('.md-code-block').filter({ has: preview }) - await block.hover() - await block.getByRole('button', { name: 'Copy', exact: true }).click() - expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(code) - await block.getByRole('button', { name: 'Source', exact: true }).click() - expect(await block.locator('pre code').textContent()).toBe(code) - await block.getByRole('button', { name: 'Preview', exact: true }).click() - expect(await preview.isVisible()).toBe(true) - } - expect(await page.locator('body').getAttribute('data-preview-escaped')).toBeNull() - expect(dialogs).toEqual([]) - expect(requests).toEqual([]) - const notices = await page.request.get(new URL('/preview-third-party-notices.txt', scaffold.authenticatedUrl).href) - expect(notices.ok()).toBe(true) - expect(await notices.text()).toContain('Eclipse Public License - v 2.0') - await page.close() - }) - - it.skipIf(MODE === 'record')('keeps actions visible when a mouse and touchscreen are both available', async () => { - const hybridBrowser = await chromium.launch({ - args: ['--blink-settings=availablePointerTypes=6,primaryPointerType=4,availableHoverTypes=2,primaryHoverType=2'], - }) - try { - const page = await newEnglishPage(hybridBrowser) - expect(await page.evaluate(() => - matchMedia('(hover: hover) and (pointer: fine) and (any-pointer: coarse)').matches)).toBe(true) - await openConversation(page, scaffold) - const first = page.locator('.md-code-block').first() - const diagram = first.getByRole('img', { name: 'Mermaid diagram' }) - await expect.poll(() => diagram.evaluate(node => (node as HTMLImageElement).naturalWidth)).toBeGreaterThan(0) - await page.mouse.move(0, 0) - const controls = first.locator('[class*="bannerWrap"]') - expect(await controls.evaluate(node => getComputedStyle(node).opacity)).toBe('1') - expect(await controls.evaluate(node => getComputedStyle(node).pointerEvents)).toBe('auto') - expect(await first.getByRole('button', { name: 'Source', exact: true }) - .evaluate(node => node.getBoundingClientRect().width)).toBe(44) - expect(await controls.evaluate(node => node.getBoundingClientRect().top)) - .toBeGreaterThanOrEqual(await diagram.evaluate(node => node.getBoundingClientRect().bottom)) - await first.getByRole('button', { name: 'Source', exact: true }).click() - expect(await first.locator('pre code').textContent()).toBe(FLOW) - } finally { - await hybridBrowser.close() - } - }, 60_000) -}) diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index a6e3b24bfd..3b01e3990c 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -79,7 +79,6 @@ "tests/math-rendering.e2e.ts", "tests/markdown-cjk-strong.e2e.ts", "tests/markdown-inline-code-links.e2e.ts", - "tests/markdown-mermaid.e2e.ts", "tests/clickable-links-gallery.e2e.ts", "tests/queue-actions.e2e.ts", "tests/queue-image.e2e.ts", diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts index f6c90861f1..0e15b4f088 100644 --- a/apps/web/vite.config.ts +++ b/apps/web/vite.config.ts @@ -27,20 +27,6 @@ function clientDocumentTitle(): Plugin { } } -/** Preserve preview licenses and Graphviz source availability in every browser distribution. */ -function previewNotices(): Plugin { - return { - name: 'dsh-preview-notices', - async generateBundle() { - this.emitFile({ - type: 'asset', - fileName: 'preview-third-party-notices.txt', - source: await readFile(src('../../packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt'), 'utf8'), - }) - }, - } -} - /** Fail before a Vite dev or preview server can expose the boot-manifest-free shell. */ function rejectStandaloneServe(): Plugin { return { @@ -161,7 +147,7 @@ export default defineConfig({ // Relative asset URLs: preview.html mounts the same output under any base // directory, and the served index resolves identically from the site root. base: './', - plugins: [previewNotices(), rejectStandaloneServe(), clientDocumentTitle(), react(), emitPreviewPage()], + plugins: [rejectStandaloneServe(), clientDocumentTitle(), react(), emitPreviewPage()], build: { // The worker bootstrap holds its page at top-level await; Vite's default // `modules` target (es2020-era) rejects that syntax. diff --git a/packages/client/locale/src/locales/en.ts b/packages/client/locale/src/locales/en.ts index 374de7c7b0..70ce31598c 100644 --- a/packages/client/locale/src/locales/en.ts +++ b/packages/client/locale/src/locales/en.ts @@ -38,16 +38,6 @@ export const en = { 'json.expandNode': 'Expand JSON node', 'json.label': 'JSON', 'markdown.footnotes': 'Footnotes', - 'markdown.preview.graphviz': 'Graphviz diagram', - 'markdown.preview.svg': 'SVG preview', - 'markdown.preview.html': 'HTML preview', - 'markdown.preview.loading': 'Rendering preview…', - 'markdown.preview.error': 'Unable to render this preview. The source is shown below.', - 'markdown.mermaid.diagram': 'Mermaid diagram', - 'markdown.preview.preview': 'Preview', - 'markdown.preview.source': 'Source', - 'markdown.mermaid.loading': 'Rendering diagram…', - 'markdown.mermaid.error': 'Unable to render this diagram. The source is shown below.', 'markdown.truncatedCharacters': '… truncated at {total} characters', 'number.thousand': '{value}K', 'number.million': '{value}M', diff --git a/packages/client/locale/src/locales/zh.ts b/packages/client/locale/src/locales/zh.ts index df1aa1d19e..30cee308d5 100644 --- a/packages/client/locale/src/locales/zh.ts +++ b/packages/client/locale/src/locales/zh.ts @@ -36,16 +36,6 @@ export const zh = { 'json.expandNode': '展开 JSON 节点', 'json.label': 'JSON', 'markdown.footnotes': '脚注', - 'markdown.preview.graphviz': 'Graphviz 图表', - 'markdown.preview.svg': 'SVG 预览', - 'markdown.preview.html': 'HTML 预览', - 'markdown.preview.loading': '正在渲染预览…', - 'markdown.preview.error': '无法渲染此预览,源码如下。', - 'markdown.mermaid.diagram': 'Mermaid 图表', - 'markdown.preview.preview': '预览', - 'markdown.preview.source': '源码', - 'markdown.mermaid.loading': '正在渲染图表…', - 'markdown.mermaid.error': '无法渲染此图表,源码如下。', 'markdown.truncatedCharacters': '… 已截断,共 {total} 字符', 'number.thousand': '{value}K', 'number.million': '{value}M', diff --git a/packages/client/ui-chat/README.i18n.yaml b/packages/client/ui-chat/README.i18n.yaml index 554709bb19..4db27677d0 100644 --- a/packages/client/ui-chat/README.i18n.yaml +++ b/packages/client/ui-chat/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-chat/README.md -README.md: 1bd7f008e46b695899c703c928ebe8bb76fbe4c8 -README.zh.md: 5919622396dde5b0c8cbf51f71999672a11f13ec +README.md: 860dcb9eeb9c92a14d9128d9d8c95c29796726f8 +README.zh.md: 4dd06a16b19b14cacc0ded603cc1cf8869dd1a43 diff --git a/packages/client/ui-chat/README.md b/packages/client/ui-chat/README.md index 1bd7f008e4..860dcb9eeb 100644 --- a/packages/client/ui-chat/README.md +++ b/packages/client/ui-chat/README.md @@ -15,7 +15,6 @@ File-mention providers receive the viewed Session ID with the closing-turn owner ## Table of Contents - [System prompt row](#system-prompt-row) -- [Mermaid previews](#mermaid-previews) - [Turn token usage](#turn-token-usage) - [Turn Process Folding](#turn-process-folding) - [Scroll ownership](#scroll-ownership) @@ -30,13 +29,6 @@ File-mention providers receive the viewed Session ID with the closing-turn owner Each nonempty appended `system/message` owns a collapsed prompt row, including a complete prompt at the start of a headerless window; the same-step header does not duplicate it. Chat also shows a collapsed `System prompt` row for a non-empty initial request, explicit message-series start, or `system/message` surface node replacement whose text differs, reading the last nonempty surviving system node in surface order at the `request/header`; a non-initial request whose preceding header is outside the loaded history window also shows one. A resume repeats the row even when its system text is unchanged, including after pagination supplies the preceding header and system node; same-series config-only or tool-only changes, tool steps, and retries create no repetition, and a `system/message` event is never rendered as a transcript message. The row appears before that request's user messages, matching the provider envelope, and expands to the exact model-visible text with its original line breaks. A request whose system node is empty or outside the loaded window creates no row until the page holding the node arrives. - -## Mermaid previews - -Settled Assistant Markdown shows `mermaid` code fences as diagrams. Diagrams have no language banner. Source/Preview and Copy icon actions appear on hover or keyboard focus and remain visible on touch devices; both views copy the original Mermaid source. Streaming fences remain code until the message settles; invalid diagrams show an error and their source without disrupting other blocks. Chat enables the shared [Mermaid preview primitive](../ui-primitives/README.md) through localized labels. Chat also previews `graphviz`/`dot`, `svg`, and static `html` fences in isolated iframes, with the same default visualization, source switching, and copying. HTML scripts, navigation, and remote resources are disabled. This is a presentation change and adds no model prompt, tool, or Session event. - ------ - ## Turn token usage diff --git a/packages/client/ui-chat/README.zh.md b/packages/client/ui-chat/README.zh.md index 5919622396..4dd06a16b1 100644 --- a/packages/client/ui-chat/README.zh.md +++ b/packages/client/ui-chat/README.zh.md @@ -15,7 +15,6 @@ kind: "package-reference" ## 目录 - [系统提示词行](#system-prompt-row) -- [Mermaid 预览](#mermaid-previews) - [轮次 token 用量](#turn-token-usage) - [轮次过程折叠](#turn-process-folding) - [滚动归属](#scroll-ownership) @@ -32,13 +31,6 @@ kind: "package-reference" ----- - -## Mermaid 预览 - -已定稿的 Assistant Markdown 把 `mermaid` 代码 fence 显示为图表。图表不显示语言标题栏。源码/预览切换与复制图标在悬停或键盘聚焦时出现,触屏上保持可见;两种视图复制的都是原始 Mermaid 源码。流式 fence 在消息定稿前保持代码显示;非法图表显示错误与源码,不影响其他块。Chat 通过本地化 label 启用共享的 [Mermaid 预览原语](../ui-primitives/README.zh.md)。Chat 还在隔离 iframe 中预览 `graphviz`/`dot`、`svg` 和静态 `html` fence,共用默认可视化、源码切换与复制操作。HTML 脚本、导航与远程资源均被禁用。这项展示变更不增加模型提示词、工具或 Session 事件。 - ------ - ## 轮次 token 用量 diff --git a/packages/client/ui-chat/src/client/markdown-labels.ts b/packages/client/ui-chat/src/client/markdown-labels.ts index c77cb8e9e4..6c30b99396 100644 --- a/packages/client/ui-chat/src/client/markdown-labels.ts +++ b/packages/client/ui-chat/src/client/markdown-labels.ts @@ -9,21 +9,8 @@ import type { ChatViewSlotProps } from './contract/slots.ts' * @returns Labels for code fences and footnotes. */ export function markdownLabels(t: ChatViewSlotProps['t']): MarkdownLabels { - const status = { loading: t('markdown.preview.loading'), error: t('markdown.preview.error') } return { code: { copyLabel: t('copy'), copiedLabel: t('copied') }, footnotes: t('markdown.footnotes'), - preview: { - preview: t('markdown.preview.preview'), - source: t('markdown.preview.source'), - mermaid: { - diagram: t('markdown.mermaid.diagram'), - loading: t('markdown.mermaid.loading'), - error: t('markdown.mermaid.error'), - }, - graphviz: { ...status, diagram: t('markdown.preview.graphviz') }, - svg: { ...status, diagram: t('markdown.preview.svg') }, - html: { ...status, diagram: t('markdown.preview.html') }, - }, } } diff --git a/packages/client/ui-primitives/README.i18n.yaml b/packages/client/ui-primitives/README.i18n.yaml index 2c354d584f..5672f45bb3 100644 --- a/packages/client/ui-primitives/README.i18n.yaml +++ b/packages/client/ui-primitives/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-primitives/README.md -README.md: 22f450914078799f2f9da31389670f83cefe66cd -README.zh.md: c9fd355d4b16ae98bd0f194d13d4331a52513044 +README.md: aebb0be860ebaba4543a8fd262599507ead64556 +README.zh.md: a545aff9837036890b6250ab1aa32fb651af0a18 diff --git a/packages/client/ui-primitives/README.md b/packages/client/ui-primitives/README.md index 22f4509140..aebb0be860 100644 --- a/packages/client/ui-primitives/README.md +++ b/packages/client/ui-primitives/README.md @@ -73,15 +73,6 @@ The catalog above lists what each export is for; this section covers the behavio `MarkdownText` renders untrusted GFM and TeX math, blocks unsafe links and images, and can turn resolved file mentions into explicit controls. When the owner passes a `pathImages` vocabulary, image destinations that are local media paths rewrite to displayable URLs on settled renders only (the same streaming gate as file mentions); without a vocabulary, local destinations remain inert alt text. A load or decode failure replaces the image with its authored alt text, or the original destination when alt is empty. Changing the image source permits a fresh load. While a reply streams, it freezes completed blocks, advances a top-level open fence by completed lines, and highlights that fence from saved Shiki grammar state. Completed token lines enter fixed-size React groups, so later chunks reconcile only the growing group; an unchanged fence retains that DOM when the final full parse resolves cross-document syntax. `TerminalBlock`, `ReadBlock`, `DiffBlock`, `SearchBlock`, and `WebBlock` render the matching tool-result intent with copy controls, overflow handling, and ANSI processing where applicable. `JsonTree` and `JsonBlock` inspect JSON values read-only, while `projectUserText` projects sent user text into inline plain runs and reference chips for the message bubble and queue rows. -Supply `MarkdownLabels.preview` to enable settled `mermaid`, `graphviz`/`dot`, `svg`, and `html` fences. Each language supplies localized preview states, and consumers without these labels retain code. Mermaid and Graphviz use the active document palette on the code-block background and update mounted previews when the theme changes. Explicit colors in DOT, SVG, and HTML remain authored content. Rendering loads Mermaid on demand, uses strict security, and exposes the generated SVG as an image with no diagram link handlers. A render failure shows the original source with the supplied error label; replacing the source discards late results from the previous render. The diagram keeps its intrinsic size and shrinks to fit the available width. - -`CodeBlock.preview` supplies an optional headerless body with icon actions for source switching and copying. Actions appear on hover or keyboard focus, and stay visible below the diagram whenever a touchscreen is available, including with a mouse attached. Switching to source keeps the preview mounted, so returning reuses its result; copying always retains the source. - -Each settled fence defaults to visualization and shares the source/copy controls. Graphviz loads `@viz-js/viz` on demand and renders DOT with the `dot` engine. SVG and Graphviz output are inert images in the same content-sized canvas as Mermaid; malformed SVG and DOT retain their source with an error. HTML accepts complete documents or fragments and preserves inline styles, but strips scripts and navigation. HTML frames have no sandbox permissions, and their Content Security Policy blocks external resources, embedded frames, forms, and scripts. Diagram canvases follow the rendered image height with 16px padding and shrink images proportionally to fit the available width. HTML frames use a 400px scrollable viewport. Raw HTML outside a code fence remains ordinary Markdown input. - -Internal render functions accept optional native `MermaidConfig` and Viz.js `RenderOptions` for developer customization. Attribute and theme-variable overrides merge with document defaults; Mermaid preview restrictions and Graphviz SVG output remain fixed. These parameters have no settings UI. - -[Preview license notices](THIRD_PARTY_PREVIEW_NOTICES.txt) ship with this package and the Web frontend. Mermaid is MIT; Viz.js is MIT but embeds Graphviz under EPL-2.0. The notices retain license texts and the exact Graphviz source download. Dependency upgrades require reviewing the embedded payload as well as npm metadata; the [preview decision](../../../.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.md) records the distribution and sandbox choices. ### Localizing copy @@ -150,7 +141,6 @@ None; this package neither assembles nor sends a provider request. These limits define how the atoms behave at the edges; they are current package constraints, not a component roadmap. -- **Diagram rendering runs on the browser thread** — every mounted settled preview starts rendering, including off-screen diagrams. Mermaid serializes layouts; Graphviz performs synchronous WebAssembly layout. Submitted layout work cannot be interrupted. Preview virtualization and worker rendering are not provided. - **Streaming defers cross-boundary reference resolution** — a reference-style link or footnote whose definition sits on the other side of the incremental freeze boundary renders as literal text while the reply streams; the settled full parse at finalize resolves it. - **A long highlighted fence retains its complete token DOM** — streaming avoids re-parsing, re-tokenizing, and reconciling the completed prefix, but it does not discard old colors or virtualize token spans. Final DOM cardinality therefore still follows the fence's token count; nested/container fences and a pathological single long line remain on the general tail path. - **Glyph-level icons are redrawn approximations** — the fish logo and the sparkle mark come from font glyphs whose vector geometry is not exportable from the local design data; hand-authored recreations stand in until an exact export path exists. diff --git a/packages/client/ui-primitives/README.zh.md b/packages/client/ui-primitives/README.zh.md index c9fd355d4b..a545aff983 100644 --- a/packages/client/ui-primitives/README.zh.md +++ b/packages/client/ui-primitives/README.zh.md @@ -73,15 +73,6 @@ kind: "package-library" `MarkdownText` 渲染不可信的 GFM 与 TeX 公式、阻止不安全的链接与图片,并可把已解析的文件提及转换为显式控件。当 owner 传入 `pathImages` 词表时,本地媒体路径的图片目标只在落定渲染阶段重写为可展示 URL(与 file mentions 相同的流式门);不传词表时本地目标保持惰性 alt 文本。加载或解码失败后,图片替换为作者的 alt 文本;alt 为空时显示原始目标路径。图片源变化后可重新加载。回复流式输出时,它冻结已完成的块、按已完成行推进顶层未闭合 fence,并从保存的 Shiki grammar state 为该 fence 增量高亮。已完成的 token 行进入固定大小的 React 分组,后续分片只 reconcile 正在增长的分组;最终全量解析解决跨文档语法时,未变化的 fence 会保留该 DOM。`TerminalBlock`、`ReadBlock`、`DiffBlock`、`SearchBlock` 与 `WebBlock` 把对应的工具结果意图渲染为带复制控件、溢出处理及适用时 ANSI 处理的卡片。`JsonTree` 与 `JsonBlock` 以只读方式检查 JSON 值;`projectUserText` 把已发送的用户文本投影为行内普通文本段与引用 chip,供消息气泡和排队行使用。 -提供 `MarkdownLabels.preview` 可启用定稿后的 `mermaid`、`graphviz`/`dot`、`svg` 和 `html` fence。每种语言提供本地化预览状态,未提供这些文案的调用方保留代码显示。Mermaid 与 Graphviz 在代码块背景上使用当前文档配色,主题切换时同步更新已挂载的预览。DOT、SVG 与 HTML 中明确指定的颜色仍保留原样。渲染按需加载 Mermaid、使用严格安全模式,并把生成的 SVG 显示为图片,不绑定图内链接处理器。渲染失败时显示原始源码与传入的错误文案;替换源码后会丢弃前一次渲染的延迟结果。图表保留固有尺寸,并在可用宽度不足时缩小。 - -`CodeBlock.preview` 提供无标题栏的替代正文,以及切换源码和复制的图标操作。操作在悬停或键盘聚焦时出现;只要设备具备触屏,就在图表下方保持可见,包括同时连接鼠标的情况。切换到源码时保留已挂载的预览,返回时复用其结果;复制始终保留源码。 - -每个定稿 fence 默认显示可视化,并共享源码切换与复制操作。Graphviz 按需加载 `@viz-js/viz`,用 `dot` 引擎渲染 DOT。SVG 与 Graphviz 输出作为不可执行的图片,使用与 Mermaid 相同的按内容定高画布;非法 SVG 与 DOT 显示错误并保留源码。HTML 接受完整文档或片段、保留内联样式,同时移除脚本与导航。HTML iframe 不授予任何 sandbox 权限,Content Security Policy 阻止外部资源、嵌套 iframe、表单与脚本。图表画布随渲染后的图片高度收缩,保留 16px 内边距,并在可用宽度不足时等比例缩小图片。HTML iframe 使用可滚动的 400px 视口。代码 fence 外的原始 HTML 仍按普通 Markdown 输入处理。 - -内部渲染函数接受可选的原生 `MermaidConfig` 与 Viz.js `RenderOptions`,供开发者定制。属性与主题变量覆盖项和文档默认值合并;Mermaid 预览限制与 Graphviz SVG 输出保持固定。这些参数没有设置界面。 - -[预览许可证声明](THIRD_PARTY_PREVIEW_NOTICES.txt)随本包与 Web 前端分发。Mermaid 使用 MIT;Viz.js 使用 MIT,但内嵌 Graphviz 使用 EPL-2.0。声明保留完整许可证文本及准确的 Graphviz 源码下载地址。升级依赖时必须同时检查内嵌产物和 npm 元数据;[预览决策](../../../.agents/notes/implemented/feature/2026-09-09-markdown-static-previews.zh.md)记录分发与 sandbox 选择。 ### 本地化文案 @@ -150,7 +141,6 @@ kind: "package-library" 这些限制说明原子组件在边缘情况下的行为;它们是当前包约束,不是组件路线图。 -- **图表渲染在浏览器线程上执行**:每个已挂载的定稿预览都会开始渲染,包括视口外的图表。Mermaid 串行执行布局;Graphviz 同步执行 WebAssembly 布局。已提交的布局工作无法中断。当前不提供预览虚拟化或 worker 渲染。 - **流式期间跨边界引用解析被推迟**:定义落在增量冻结边界另一侧的引用式链接或脚注,在回复流式输出期间渲染为字面文本;定稿时的全量解析会将其解析。 - **长高亮 fence 会保留完整 token DOM**:流式路径避免重新解析、重新 tokenize 和 reconcile 已完成前缀,但不会丢弃旧颜色或虚拟化 token span。因此最终 DOM 数量仍随 fence 的 token 数增长;嵌套/容器内 fence 与病态的单个超长行仍走通用尾部路径。 - **字形级图标是重新绘制的近似版本**:鱼形标志与闪光标记来自字体字形,而本地设计数据无法导出其矢量几何;在获得精确导出路径前,使用手工重建版本代替。 diff --git a/packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt b/packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt deleted file mode 100644 index 3e1156a536..0000000000 --- a/packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt +++ /dev/null @@ -1,688 +0,0 @@ -Markdown preview third-party notices - -Mermaid 11.16.0: MIT; source https://github.com/mermaid-js/mermaid/tree/mermaid%4011.16.0 -@viz-js/viz 3.30.0: MIT JavaScript wrapper; source and build instructions: -https://github.com/mdaines/viz-js/tree/99da545270e6e7b127a5c7ba65974b8a604a6358 - -The Viz.js WebAssembly payload contains Graphviz 16.0.0 under EPL-2.0, -Expat 2.8.4 under MIT, and Emscripten 5.0.7 runtime code under MIT/NCSA. -Graphviz remains under EPL-2.0; it is not relicensed as MIT by DeepSeek Harness. -Graphviz source code is available under EPL-2.0 at: -https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/16.0.0/graphviz-16.0.0.tar.gz -SHA-256: 36a1de1aaf5a2023b14f95170a5f8f0b12522d1c305b517fc261966597050749 -Viz.js's backend build instructions and additions are available at the commit above. -DeepSeek Harness uses the unmodified upstream Viz.js package. - -Expat source: https://github.com/libexpat/libexpat/tree/R_2_8_4 -Emscripten source: https://github.com/emscripten-core/emscripten/tree/5.0.7 -DOMPurify 3.4.11: Apache-2.0 OR MPL-2.0; this distribution selects Apache-2.0. -Source: https://github.com/cure53/DOMPurify/tree/3.4.11 - -The following license texts and copyright notices apply to their respective components. - - -===== Mermaid ===== - -The MIT License (MIT) - -Copyright (c) 2014 - 2022 Knut Sveidqvist - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - -===== Viz.js ===== - -MIT License - -Copyright (c) Michael Daines - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - -===== Graphviz ===== - -Eclipse Public License - v 2.0 - - THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE - PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION - OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. - -1. DEFINITIONS - -"Contribution" means: - - a) in the case of the initial Contributor, the initial content - Distributed under this Agreement, and - - b) in the case of each subsequent Contributor: - i) changes to the Program, and - ii) additions to the Program; - where such changes and/or additions to the Program originate from - and are Distributed by that particular Contributor. A Contribution - "originates" from a Contributor if it was added to the Program by - such Contributor itself or anyone acting on such Contributor's behalf. - Contributions do not include changes or additions to the Program that - are not Modified Works. - -"Contributor" means any person or entity that Distributes the Program. - -"Licensed Patents" mean patent claims licensable by a Contributor which -are necessarily infringed by the use or sale of its Contribution alone -or when combined with the Program. - -"Program" means the Contributions Distributed in accordance with this -Agreement. - -"Recipient" means anyone who receives the Program under this Agreement -or any Secondary License (as applicable), including Contributors. - -"Derivative Works" shall mean any work, whether in Source Code or other -form, that is based on (or derived from) the Program and for which the -editorial revisions, annotations, elaborations, or other modifications -represent, as a whole, an original work of authorship. - -"Modified Works" shall mean any work in Source Code or other form that -results from an addition to, deletion from, or modification of the -contents of the Program, including, for purposes of clarity any new file -in Source Code form that contains any contents of the Program. Modified -Works shall not include works that contain only declarations, -interfaces, types, classes, structures, or files of the Program solely -in each case in order to link to, bind by name, or subclass the Program -or Modified Works thereof. - -"Distribute" means the acts of a) distributing or b) making available -in any manner that enables the transfer of a copy. - -"Source Code" means the form of a Program preferred for making -modifications, including but not limited to software source code, -documentation source, and configuration files. - -"Secondary License" means either the GNU General Public License, -Version 2.0, or any later versions of that license, including any -exceptions or additional permissions as identified by the initial -Contributor. - -2. GRANT OF RIGHTS - - a) Subject to the terms of this Agreement, each Contributor hereby - grants Recipient a non-exclusive, worldwide, royalty-free copyright - license to reproduce, prepare Derivative Works of, publicly display, - publicly perform, Distribute and sublicense the Contribution of such - Contributor, if any, and such Derivative Works. - - b) Subject to the terms of this Agreement, each Contributor hereby - grants Recipient a non-exclusive, worldwide, royalty-free patent - license under Licensed Patents to make, use, sell, offer to sell, - import and otherwise transfer the Contribution of such Contributor, - if any, in Source Code or other form. This patent license shall - apply to the combination of the Contribution and the Program if, at - the time the Contribution is added by the Contributor, such addition - of the Contribution causes such combination to be covered by the - Licensed Patents. The patent license shall not apply to any other - combinations which include the Contribution. No hardware per se is - licensed hereunder. - - c) Recipient understands that although each Contributor grants the - licenses to its Contributions set forth herein, no assurances are - provided by any Contributor that the Program does not infringe the - patent or other intellectual property rights of any other entity. - Each Contributor disclaims any liability to Recipient for claims - brought by any other entity based on infringement of intellectual - property rights or otherwise. As a condition to exercising the - rights and licenses granted hereunder, each Recipient hereby - assumes sole responsibility to secure any other intellectual - property rights needed, if any. For example, if a third party - patent license is required to allow Recipient to Distribute the - Program, it is Recipient's responsibility to acquire that license - before distributing the Program. - - d) Each Contributor represents that to its knowledge it has - sufficient copyright rights in its Contribution, if any, to grant - the copyright license set forth in this Agreement. - - e) Notwithstanding the terms of any Secondary License, no - Contributor makes additional grants to any Recipient (other than - those set forth in this Agreement) as a result of such Recipient's - receipt of the Program under the terms of a Secondary License - (if permitted under the terms of Section 3). - -3. REQUIREMENTS - -3.1 If a Contributor Distributes the Program in any form, then: - - a) the Program must also be made available as Source Code, in - accordance with section 3.2, and the Contributor must accompany - the Program with a statement that the Source Code for the Program - is available under this Agreement, and informs Recipients how to - obtain it in a reasonable manner on or through a medium customarily - used for software exchange; and - - b) the Contributor may Distribute the Program under a license - different than this Agreement, provided that such license: - i) effectively disclaims on behalf of all other Contributors all - warranties and conditions, express and implied, including - warranties or conditions of title and non-infringement, and - implied warranties or conditions of merchantability and fitness - for a particular purpose; - - ii) effectively excludes on behalf of all other Contributors all - liability for damages, including direct, indirect, special, - incidental and consequential damages, such as lost profits; - - iii) does not attempt to limit or alter the recipients' rights - in the Source Code under section 3.2; and - - iv) requires any subsequent distribution of the Program by any - party to be under a license that satisfies the requirements - of this section 3. - -3.2 When the Program is Distributed as Source Code: - - a) it must be made available under this Agreement, or if the - Program (i) is combined with other material in a separate file or - files made available under a Secondary License, and (ii) the initial - Contributor attached to the Source Code the notice described in - Exhibit A of this Agreement, then the Program may be made available - under the terms of such Secondary Licenses, and - - b) a copy of this Agreement must be included with each copy of - the Program. - -3.3 Contributors may not remove or alter any copyright, patent, -trademark, attribution notices, disclaimers of warranty, or limitations -of liability ("notices") contained within the Program from any copy of -the Program which they Distribute, provided that Contributors may add -their own appropriate notices. - -4. COMMERCIAL DISTRIBUTION - -Commercial distributors of software may accept certain responsibilities -with respect to end users, business partners and the like. While this -license is intended to facilitate the commercial use of the Program, -the Contributor who includes the Program in a commercial product -offering should do so in a manner which does not create potential -liability for other Contributors. Therefore, if a Contributor includes -the Program in a commercial product offering, such Contributor -("Commercial Contributor") hereby agrees to defend and indemnify every -other Contributor ("Indemnified Contributor") against any losses, -damages and costs (collectively "Losses") arising from claims, lawsuits -and other legal actions brought by a third party against the Indemnified -Contributor to the extent caused by the acts or omissions of such -Commercial Contributor in connection with its distribution of the Program -in a commercial product offering. The obligations in this section do not -apply to any claims or Losses relating to any actual or alleged -intellectual property infringement. In order to qualify, an Indemnified -Contributor must: a) promptly notify the Commercial Contributor in -writing of such claim, and b) allow the Commercial Contributor to control, -and cooperate with the Commercial Contributor in, the defense and any -related settlement negotiations. The Indemnified Contributor may -participate in any such claim at its own expense. - -For example, a Contributor might include the Program in a commercial -product offering, Product X. That Contributor is then a Commercial -Contributor. If that Commercial Contributor then makes performance -claims, or offers warranties related to Product X, those performance -claims and warranties are such Commercial Contributor's responsibility -alone. Under this section, the Commercial Contributor would have to -defend claims against the other Contributors related to those performance -claims and warranties, and if a court requires any other Contributor to -pay any damages as a result, the Commercial Contributor must pay -those damages. - -5. NO WARRANTY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT -PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" -BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR -IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF -TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR -PURPOSE. Each Recipient is solely responsible for determining the -appropriateness of using and distributing the Program and assumes all -risks associated with its exercise of rights under this Agreement, -including but not limited to the risks and costs of program errors, -compliance with applicable laws, damage to or loss of data, programs -or equipment, and unavailability or interruption of operations. - -6. DISCLAIMER OF LIABILITY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT -PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS -SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST -PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE -EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - -7. GENERAL - -If any provision of this Agreement is invalid or unenforceable under -applicable law, it shall not affect the validity or enforceability of -the remainder of the terms of this Agreement, and without further -action by the parties hereto, such provision shall be reformed to the -minimum extent necessary to make such provision valid and enforceable. - -If Recipient institutes patent litigation against any entity -(including a cross-claim or counterclaim in a lawsuit) alleging that the -Program itself (excluding combinations of the Program with other software -or hardware) infringes such Recipient's patent(s), then such Recipient's -rights granted under Section 2(b) shall terminate as of the date such -litigation is filed. - -All Recipient's rights under this Agreement shall terminate if it -fails to comply with any of the material terms or conditions of this -Agreement and does not cure such failure in a reasonable period of -time after becoming aware of such noncompliance. If all Recipient's -rights under this Agreement terminate, Recipient agrees to cease use -and distribution of the Program as soon as reasonably practicable. -However, Recipient's obligations under this Agreement and any licenses -granted by Recipient relating to the Program shall continue and survive. - -Everyone is permitted to copy and distribute copies of this Agreement, -but in order to avoid inconsistency the Agreement is copyrighted and -may only be modified in the following manner. The Agreement Steward -reserves the right to publish new versions (including revisions) of -this Agreement from time to time. No one other than the Agreement -Steward has the right to modify this Agreement. The Eclipse Foundation -is the initial Agreement Steward. The Eclipse Foundation may assign the -responsibility to serve as the Agreement Steward to a suitable separate -entity. Each new version of the Agreement will be given a distinguishing -version number. The Program (including Contributions) may always be -Distributed subject to the version of the Agreement under which it was -received. In addition, after a new version of the Agreement is published, -Contributor may elect to Distribute the Program (including its -Contributions) under the new version. - -Except as expressly stated in Sections 2(a) and 2(b) above, Recipient -receives no rights or licenses to the intellectual property of any -Contributor under this Agreement, whether expressly, by implication, -estoppel or otherwise. All rights in the Program not expressly granted -under this Agreement are reserved. Nothing in this Agreement is intended -to be enforceable by any entity that is not a Contributor or Recipient. -No third-party beneficiary rights are created under this Agreement. - -Exhibit A - Form of Secondary Licenses Notice - -"This Source Code may also be made available under the following -Secondary Licenses when the conditions for such availability set forth -in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), -version(s), and exceptions or additional permissions here}." - - Simply including a copy of this Agreement, including this Exhibit A - is not sufficient to license the Source Code under Secondary Licenses. - - If it is not possible or desirable to put the notice in a particular - file, then You may include the notice in a location (such as a LICENSE - file in a relevant directory) where a recipient would be likely to - look for such a notice. - - You may add additional accurate notices of copyright ownership. - - -===== Expat ===== - -Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper -Copyright (c) 2001-2025 Expat maintainers - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -===== Emscripten ===== - -Emscripten is available under 2 licenses, the MIT license and the -University of Illinois/NCSA Open Source License. - -Both are permissive open source licenses, with little if any -practical difference between them. - -The reason for offering both is that (1) the MIT license is -well-known, while (2) the University of Illinois/NCSA Open Source -License allows Emscripten's code to be integrated upstream into -LLVM, which uses that license, should the opportunity arise. - -The full text of both licenses follows. - -============================================================================== - -Copyright (c) 2010-2014 Emscripten authors, see AUTHORS file. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -============================================================================== - -Copyright (c) 2010-2014 Emscripten authors, see AUTHORS file. -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal with the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimers. - - Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following disclaimers - in the documentation and/or other materials provided with the - distribution. - - Neither the names of Mozilla, - nor the names of its contributors may be used to endorse - or promote products derived from this Software without specific prior - written permission. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. - -============================================================================== - -This program uses portions of Node.js source code located in src/library_path.js, -in accordance with the terms of the MIT license. Node's license follows: - - """ - Copyright Joyent, Inc. and other Node contributors. All rights reserved. - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to - deal in the Software without restriction, including without limitation the - rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - IN THE SOFTWARE. - """ - -The musl libc project is bundled in this repo, and it has the MIT license, see -system/lib/libc/musl/COPYRIGHT - -The third_party/ subdirectory contains code with other licenses. None of it is -used by default, but certain options use it (e.g., the optional closure compiler -flag will run closure compiler from third_party/). - - -===== DOMPurify ===== - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/packages/client/ui-primitives/package.json b/packages/client/ui-primitives/package.json index 587cd95ee6..2613c3aa98 100644 --- a/packages/client/ui-primitives/package.json +++ b/packages/client/ui-primitives/package.json @@ -45,15 +45,11 @@ "mdast-util-gfm": "^3.1.0", "mdast-util-math": "^3.0.0", "micromark-extension-gfm": "^3.0.0", - "micromark-util-sanitize-uri": "^2.0.1", - "mermaid": "11.16.0", - "@viz-js/viz": "3.30.0", - "dompurify": "3.4.11" + "micromark-util-sanitize-uri": "^2.0.1" }, "files": [ "lib/index.js", "lib/**/*.css", - "THIRD_PARTY_PREVIEW_NOTICES.txt", "lib/types/**/*.d.ts" ], "peerDependencies": { diff --git a/packages/client/ui-primitives/src/markdown/CodeBlock.module.css b/packages/client/ui-primitives/src/markdown/CodeBlock.module.css index a443ff1e07..a6e25ba39f 100644 --- a/packages/client/ui-primitives/src/markdown/CodeBlock.module.css +++ b/packages/client/ui-primitives/src/markdown/CodeBlock.module.css @@ -57,7 +57,6 @@ display: flex; align-items: center; flex-shrink: 0; - gap: 12px; } .copyButton { @@ -99,89 +98,6 @@ color: var(--dsw-alias-label-primary); } -/* Alternate content is a figure; its actions overlay instead of taking a title row. */ -.preview.showingPreview { - background: transparent; -} - -.preview .bannerWrap { - position: absolute; - top: 8px; - right: 8px; - z-index: 1; - background: transparent; -} - -.preview .banner { - padding: 2px; - background: var(--dsw-alias-bg-base); - border: 0; - border-radius: 8px; - box-shadow: var(--dsw-elevation-panel); -} - -.preview .action { - gap: 2px; -} - -.iconButton { - display: inline-flex; - align-items: center; - justify-content: center; - width: 32px; - height: 32px; - border-radius: 6px; - color: var(--dsw-alias-label-secondary); -} - -.iconButton span { - display: flex; -} - -.iconButton:hover { - color: var(--dsw-alias-label-primary); - background: var(--dsw-alias-interactive-bg-hover); -} - -.preview:not(.showingPreview) :where(pre) { - padding-top: 48px; -} - -@media (hover: hover) and (pointer: fine) { - .preview .bannerWrap { - opacity: 0; - pointer-events: none; - } - - .preview:hover .bannerWrap, - .preview:focus-within .bannerWrap { - opacity: 1; - pointer-events: auto; - } -} - -@media (any-pointer: coarse) { - .preview { - padding-bottom: 56px; - } - - .preview .bannerWrap { - top: auto; - bottom: 8px; - opacity: 1; - pointer-events: auto; - } - - .preview .iconButton { - width: 44px; - height: 44px; - } - - .preview:not(.showingPreview) :where(pre) { - padding-top: 16px; - } -} - .numbered :where(pre) code { display: block; counter-reset: source-line; diff --git a/packages/client/ui-primitives/src/markdown/CodeBlock.tsx b/packages/client/ui-primitives/src/markdown/CodeBlock.tsx index 367ae5febe..02cdbe683a 100644 --- a/packages/client/ui-primitives/src/markdown/CodeBlock.tsx +++ b/packages/client/ui-primitives/src/markdown/CodeBlock.tsx @@ -2,8 +2,6 @@ import { Fragment, useCallback, useMemo, useRef, useState, useSyncExternalStore import type { CSSProperties, ReactNode } from 'react' import clsx from 'clsx' import { writeClipboard } from '../clipboard.ts' -import { Tooltip } from '../Tooltip.tsx' -import { IconCheckOutline16, IconCodeOutline16, IconCopyOutline16 } from '../icons/index.tsx' import { StreamingHighlightSession, grammarLoadCount, highlightToHtml, subscribeGrammarLoaded, } from './highlight.ts' @@ -33,8 +31,6 @@ export interface CodeBlockProps { copyLabel: string /** Copy-button label during the post-copy confirmation window. */ copiedLabel: string - /** Headerless settled preview with hover/focus actions; copying always retains the source text. */ - preview?: { content: ReactNode; previewLabel: string; sourceLabel: string } | undefined } /** @@ -63,7 +59,7 @@ function renderLine(line: readonly HighlightSpan[], index: number): ReactNode { ) } -export function CodeBlock({ code, lang, streaming, className, lineNumbers = false, copyLabel, copiedLabel, preview }: CodeBlockProps) { +export function CodeBlock({ code, lang, streaming, className, lineNumbers = false, copyLabel, copiedLabel }: CodeBlockProps) { const trimmed = code.endsWith('\n') ? code.slice(0, -1) : code const sourceLines = lineNumbers ? trimmed.split('\n') : undefined const rootRef = useRef(null) @@ -147,13 +143,13 @@ export function CodeBlock({ code, lang, streaming, className, lineNumbers = fals [streaming, highlighting, streamedBody, trimmed, lang, loaded], ) const [copied, setCopied] = useState(false) - const [showSource, setShowSource] = useState(false) - const previewAvailable = preview !== undefined && streaming !== true - const showingPreview = previewAvailable && !showSource const onCopy = useCallback(() => { if (copied) return - void writeClipboard(trimmed).then((ok) => { + /* v8 ignore next -- both arms always mount a
; trimmed is the
+       typed fallback if the DOM shape ever diverges. */
+    const text = rootRef.current?.querySelector('pre')?.textContent ?? trimmed
+    void writeClipboard(text).then((ok) => {
       if (!ok) return
       setCopied(true)
       window.setTimeout(() => { setCopied(false) }, 1000)
@@ -175,22 +171,8 @@ export function CodeBlock({ code, lang, streaming, className, lineNumbers = fals
         
) - const copyActionLabel = copied ? copiedLabel : copyLabel - const copyAction = ( - - ) - return ( -
{/* The attribute carries no style here; owner stylesheets use it to pin the banner (sidebar code preview, horizontal scroll). */}
- {!previewAvailable &&
{lang ?? ''}
} +
{lang ?? ''}
- {previewAvailable && ( - - - - )} - {previewAvailable - ? {copyAction} - : copyAction} +
- {previewAvailable && } - {!showingPreview && body} + {body}
) } diff --git a/packages/client/ui-primitives/src/markdown/SourcePreview.module.css b/packages/client/ui-primitives/src/markdown/SourcePreview.module.css deleted file mode 100644 index 46a674ed0a..0000000000 --- a/packages/client/ui-primitives/src/markdown/SourcePreview.module.css +++ /dev/null @@ -1,35 +0,0 @@ -.canvas { - overflow: auto; - padding: 16px; - background: var(--dsw-alias-markdown-code-block); - border-radius: 12px; -} - -.diagram { - display: block; - max-width: 100%; - height: auto; - margin: 0 auto; -} - -.status { - padding: 16px; - color: var(--dsw-alias-label-secondary); -} - -.staging { - position: fixed; - top: 0; - left: -100000px; - visibility: hidden; - pointer-events: none; -} - -.frame { - display: block; - width: 100%; - height: 400px; - border: 0; - border-radius: 12px; - background: var(--dsw-alias-markdown-code-block); -} diff --git a/packages/client/ui-primitives/src/markdown/SourcePreview.tsx b/packages/client/ui-primitives/src/markdown/SourcePreview.tsx deleted file mode 100644 index 3ce07fb34d..0000000000 --- a/packages/client/ui-primitives/src/markdown/SourcePreview.tsx +++ /dev/null @@ -1,71 +0,0 @@ -/** Read-only diagram preview with source fallback and per-source async ownership. */ - -import { useEffect, useState } from 'react' -import css from './SourcePreview.module.css' -import { readPreviewTheme } from './preview-theme.ts' - -/** Localized preview states; the diagram source remains verbatim. */ -export interface PreviewLabels { - diagram: string - loading: string - error: string -} - -type Result = { kind: 'ok'; code: string; src: string } | { kind: 'error'; code: string } - -/* v8 ignore next 3 -- closed-union backstop; only reached if a result is forged */ -function assertNever(value: never): never { - throw new Error(`unreachable preview result: ${String(value)}`) -} - -/** - * Display a complete document or diagram, retaining the source when rendering fails. - * @param props - Source and complete localized labels. Source and document theme changes cancel obsolete renders. - * @returns A loading status, an inert image or sandboxed document, or an error with the original source. - */ -export function SourcePreview({ code, labels, render, document: isDocument = false }: { - code: string - labels: PreviewLabels - render: (code: string, signal: AbortSignal) => string | Promise - document?: boolean -}) { - const [result, setResult] = useState(null) - useEffect(() => { - let controller: AbortController | undefined - let palette: string | undefined - const update = () => { - const next = JSON.stringify(readPreviewTheme()) - if (next === palette) return - palette = next - controller?.abort() - const current = new AbortController() - controller = current - void (async () => await render(code, current.signal))().then( - (src) => { if (!current.signal.aborted) setResult({ kind: 'ok', code, src }) }, - () => { if (!current.signal.aborted) setResult({ kind: 'error', code }) }, - ) - } - // Isolated image/frame documents cannot inherit the host's CSS variables. - const observer = new MutationObserver(update) - observer.observe(document.documentElement, { attributes: true, attributeFilter: ['style'] }) - observer.observe(document.body, { attributes: true, attributeFilter: ['style', 'data-ds-dark-theme'] }) - update() - return () => { observer.disconnect(); controller?.abort() } - }, [code, render]) - - if (result?.code !== code) return
{labels.loading}
- switch (result.kind) { - case 'ok': - if (isDocument) return -
`, new AbortController().signal) - const parsed = new DOMParser().parseFromString(doc, 'text/html') - expect(parsed.querySelector('h1')?.textContent).toBe('Example') - expect(parsed.querySelector('style')?.textContent).toBe('h1 { color: green }') - expect(parsed.querySelector('script, iframe, base, [href], [action], [formaction], [onload]')).toBeNull() - expect(parsed.querySelectorAll('meta[http-equiv]').length).toBe(1) - expect(parsed.querySelector('meta[http-equiv]')?.getAttribute('content')).toContain("default-src 'none'") - }) - - it('encodes SVG as an image rather than executable document markup', () => { - const code = '' - const url = renderSvg(code, new AbortController().signal) - expect(url).toMatch(/^data:image\/svg\+xml;charset=utf-8,/) - expect(decodeURIComponent(url.slice(url.indexOf(',') + 1))).toBe(code) - }) - - it.each(['', '', ''])('rejects non-SVG or malformed XML: %s', (code) => { - expect(() => renderSvg(code, new AbortController().signal)).toThrow('Invalid SVG document') - }) - - it.each([renderHtml, renderSvg])('does not prepare a cancelled document', (renderDocument) => { - const controller = new AbortController() - controller.abort() - expect(() => renderDocument(svg, controller.signal)).toThrow(controller.signal.reason) - }) -}) diff --git a/packages/client/ui-primitives/tests/graphviz-runtime.client.spec.ts b/packages/client/ui-primitives/tests/graphviz-runtime.client.spec.ts deleted file mode 100644 index 1a7b170516..0000000000 --- a/packages/client/ui-primitives/tests/graphviz-runtime.client.spec.ts +++ /dev/null @@ -1,67 +0,0 @@ -// @vitest-environment jsdom - -import { afterEach, beforeEach, expect, it, vi } from 'vitest' - -const instance = vi.fn() -beforeEach(() => { - vi.resetModules() - instance.mockReset() - vi.doMock('@viz-js/viz', () => ({ instance })) -}) -afterEach(() => { vi.doUnmock('@viz-js/viz') }) - -it('retries failed initialization and reuses the loaded runtime', async () => { - const renderString = vi.fn().mockReturnValue('') - instance.mockRejectedValueOnce(new Error('WASM unavailable')).mockResolvedValue({ renderString }) - const { renderGraphviz } = await import('../src/markdown/graphviz.ts') - await expect(renderGraphviz('digraph {}', new AbortController().signal)).rejects.toThrow('WASM unavailable') - await expect(renderGraphviz('digraph {}', new AbortController().signal)).resolves.toContain('data:image/svg+xml') - await renderGraphviz('digraph {}', new AbortController().signal) - expect(instance).toHaveBeenCalledTimes(2) -}) - -it('skips layout after cancellation during runtime loading', async () => { - const pending = Promise.withResolvers<{ renderString: ReturnType }>() - instance.mockReturnValue(pending.promise) - const { renderGraphviz } = await import('../src/markdown/graphviz.ts') - const controller = new AbortController() - const result = renderGraphviz('digraph {}', controller.signal) - const rejection = expect(result).rejects.toMatchObject({ name: 'AbortError' }) - controller.abort() - const renderString = vi.fn() - pending.resolve({ renderString }) - await rejection - expect(renderString).not.toHaveBeenCalled() -}) - -it('uses theme defaults without rewriting authored DOT attributes', async () => { - const previous = document.body.getAttribute('style') - try { - document.body.style.setProperty('--dsw-alias-label-primary', 'rgb(230, 231, 232)') - document.body.style.setProperty('--dsw-alias-label-secondary', '#aabbcc') - document.body.style.setProperty('--dsw-alias-label-tertiary', '#8899aa') - document.body.style.setProperty('--dsw-alias-bg-layer-2', '#222222') - const renderString = vi.fn().mockReturnValue('') - instance.mockResolvedValue({ renderString }) - const { renderGraphviz } = await import('../src/markdown/graphviz.ts') - const code = 'digraph { a [color="red"]; a -> b }' - await renderGraphviz(code, new AbortController().signal) - expect(renderString).toHaveBeenCalledWith(code, expect.objectContaining({ - nodeAttributes: { color: '#8899aa', fontcolor: '#e6e7e8', fillcolor: '#222222', style: 'filled' }, - edgeAttributes: { color: '#aabbcc', fontcolor: '#e6e7e8' }, - })) - await renderGraphviz(code, new AbortController().signal, { - engine: 'neato', format: 'plain', yInvert: true, - graphAttributes: { ranksep: 1 }, nodeAttributes: { shape: 'box' }, edgeAttributes: { color: 'red' }, - }) - expect(renderString).toHaveBeenLastCalledWith(code, { - engine: 'neato', format: 'svg', yInvert: true, - graphAttributes: { bgcolor: 'transparent', fontcolor: '#e6e7e8', ranksep: 1 }, - nodeAttributes: { color: '#8899aa', fontcolor: '#e6e7e8', fillcolor: '#222222', style: 'filled', shape: 'box' }, - edgeAttributes: { color: 'red', fontcolor: '#e6e7e8' }, - }) - } finally { - if (previous === null) document.body.removeAttribute('style') - else document.body.setAttribute('style', previous) - } -}) diff --git a/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts b/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts deleted file mode 100644 index c5a4ccd6d3..0000000000 --- a/packages/client/ui-primitives/tests/mermaid-runtime.client.spec.ts +++ /dev/null @@ -1,133 +0,0 @@ -// @vitest-environment jsdom - -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' - -const initialize = vi.fn() -const renderDiagram = vi.fn() - -beforeEach(() => { - vi.resetModules() - vi.resetAllMocks() - vi.doMock('mermaid', () => ({ default: { initialize, render: renderDiagram } })) -}) -afterEach(() => { vi.doUnmock('mermaid') }) - -describe('Mermaid runtime', () => { - it('allows another attempt after the runtime import fails', async () => { - vi.doMock('mermaid', () => { throw new Error('runtime unavailable') }) - const { renderMermaid } = await import('../src/markdown/mermaid.ts') - await expect(renderMermaid('first', new AbortController().signal)).rejects.toThrow() - expect(initialize).not.toHaveBeenCalled() - vi.doMock('mermaid', () => ({ default: { initialize, render: renderDiagram } })) - renderDiagram.mockResolvedValue({ svg: '' }) - await expect(renderMermaid('retry', new AbortController().signal)).resolves.toContain('data:image/svg+xml') - expect(renderDiagram).toHaveBeenCalledOnce() - }) - - it('accepts native configuration without weakening preview restrictions', async () => { - const { renderMermaid } = await import('../src/markdown/mermaid.ts') - renderDiagram.mockResolvedValue({ svg: '' }) - await renderMermaid('flowchart LR', new AbortController().signal, { - // oxlint-disable-next-line typescript/no-deprecated - layout: 'dagre', flowchart: { nodeSpacing: 40, htmlLabels: true }, - themeVariables: { primaryColor: '#123456' }, - securityLevel: 'loose', startOnLoad: true, suppressErrorRendering: false, htmlLabels: true, secure: [], - }) - expect(initialize.mock.calls[0]![0]).toMatchObject({ - layout: 'dagre', flowchart: { nodeSpacing: 40, htmlLabels: false }, - themeVariables: { primaryColor: '#123456', darkMode: false }, - securityLevel: 'strict', startOnLoad: false, suppressErrorRendering: true, htmlLabels: false, - }) - expect(initialize.mock.calls[0]![0]).toHaveProperty('secure', expect.arrayContaining(['securityLevel'])) - }) - - it('reuses the runtime and removes each measurement container after rendering', async () => { - const { renderMermaid } = await import('../src/markdown/mermaid.ts') - expect(initialize).not.toHaveBeenCalled() - const stages: HTMLElement[] = [] - const ids: string[] = [] - renderDiagram.mockImplementation(async (id: string, code: string, stage: HTMLElement) => { - expect(stage.isConnected).toBe(true) - expect(stage.getAttribute('aria-hidden')).toBe('true') - stages.push(stage) - ids.push(id) - return { svg: `${code}` } - }) - const results = await Promise.all([ - renderMermaid('中文', new AbortController().signal), - renderMermaid('second', new AbortController().signal), - ]) - expect(initialize).toHaveBeenCalledTimes(2) - expect(initialize).toHaveBeenCalledWith(expect.objectContaining({ - startOnLoad: false, securityLevel: 'strict', suppressErrorRendering: true, htmlLabels: false, - secure: [ - 'secure', 'securityLevel', 'startOnLoad', 'maxTextSize', 'maxEdges', - 'suppressErrorRendering', 'theme', 'themeVariables', 'themeCSS', 'htmlLabels', 'flowchart', - ], - })) - expect(results.map(url => decodeURIComponent(url.split(',')[1]!))).toEqual(['中文', 'second']) - expect(new Set(ids).size).toBe(2) - expect(stages.every(stage => !stage.isConnected)).toBe(true) - }) - - it('keeps theme initialization with its render and recovers the queue after failure', async () => { - const { renderMermaid } = await import('../src/markdown/mermaid.ts') - const first = Promise.withResolvers<{ svg: string }>() - renderDiagram.mockReturnValueOnce(first.promise).mockResolvedValue({ svg: '' }) - const light = renderMermaid('first', new AbortController().signal) - const failure = expect(light).rejects.toThrow('invalid') - await vi.waitFor(() => { expect(renderDiagram).toHaveBeenCalledOnce() }) - const previous = document.documentElement.style.colorScheme - try { - document.documentElement.style.colorScheme = 'dark' - const dark = renderMermaid('second', new AbortController().signal) - await Promise.resolve() - expect(initialize).toHaveBeenCalledOnce() - first.reject(new Error('invalid')) - await failure - await dark - expect(initialize.mock.calls[1]![0]).toMatchObject({ themeVariables: { darkMode: true } }) - } finally { - document.documentElement.style.colorScheme = previous - } - }) - - it('removes measurement DOM even when Mermaid rejects', async () => { - const { renderMermaid } = await import('../src/markdown/mermaid.ts') - let stage: HTMLElement | undefined - const error = new Error('bad diagram') - renderDiagram.mockImplementation(async (_id: string, _code: string, target: HTMLElement) => { - stage = target - target.innerHTML = 'partial render' - throw error - }) - await expect(renderMermaid('bad', new AbortController().signal)).rejects.toBe(error) - expect(stage?.isConnected).toBe(false) - }) - - it('preserves intrinsic diagram size instead of stretching percentage-width SVG images', async () => { - const { renderMermaid } = await import('../src/markdown/mermaid.ts') - renderDiagram.mockResolvedValue({ svg: '' }) - const url = await renderMermaid('flowchart LR', new AbortController().signal) - const svg = new DOMParser().parseFromString(decodeURIComponent(url.split(',')[1]!), 'image/svg+xml').documentElement - expect(svg.getAttribute('width')).toBe('420') - expect(svg.getAttribute('height')).toBe('180') - }) - - it('does not start cancelled work after loading the runtime', async () => { - const { renderMermaid } = await import('../src/markdown/mermaid.ts') - const controller = new AbortController() - controller.abort() - await expect(renderMermaid('unused', controller.signal)).rejects.toMatchObject({ name: 'AbortError' }) - expect(renderDiagram).not.toHaveBeenCalled() - }) - - it('allows another attempt after runtime initialization fails', async () => { - const { renderMermaid } = await import('../src/markdown/mermaid.ts') - initialize.mockImplementationOnce(() => { throw new Error('initialization failed') }) - await expect(renderMermaid('first', new AbortController().signal)).rejects.toThrow('initialization failed') - renderDiagram.mockResolvedValue({ svg: '' }) - await expect(renderMermaid('retry', new AbortController().signal)).resolves.toContain('data:image/svg+xml') - expect(initialize).toHaveBeenCalledTimes(2) - }) -}) diff --git a/packages/client/ui-primitives/tests/source-preview.client.spec.tsx b/packages/client/ui-primitives/tests/source-preview.client.spec.tsx deleted file mode 100644 index 7e63f06929..0000000000 --- a/packages/client/ui-primitives/tests/source-preview.client.spec.tsx +++ /dev/null @@ -1,162 +0,0 @@ -// @vitest-environment jsdom - -import { act, cleanup, fireEvent, render, screen } from '@testing-library/react' -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { SourcePreview } from '../src/markdown/SourcePreview.tsx' -import { CodeBlock } from '../src/markdown/CodeBlock.tsx' -import { renderMermaid } from '../src/markdown/mermaid.ts' -import { MarkdownText } from '../src/markdown/MarkdownText.tsx' -import { markdownLabels } from './labels.client.ts' - -vi.mock('../src/markdown/mermaid.ts', () => ({ renderMermaid: vi.fn() })) - -const labels = { - diagram: 'Mermaid diagram', loading: 'Rendering diagram…', error: 'Unable to render this diagram.', - preview: 'Preview', source: 'Source', -} -const preview = { - preview: labels.preview, source: labels.source, - mermaid: labels, graphviz: labels, svg: labels, html: labels, -} -const source = 'flowchart LR\n A[Input] --> B[Preview]' -const imageUrl = 'data:image/svg+xml;charset=utf-8,%3Csvg%2F%3E' - -afterEach(() => { cleanup(); vi.unstubAllGlobals() }) -beforeEach(() => { vi.resetAllMocks() }) - -describe('SourcePreview', () => { - it('updates mounted previews on theme changes and ignores obsolete completions', async () => { - const previous = document.documentElement.style.colorScheme - const old = Promise.withResolvers() - vi.mocked(renderMermaid).mockReturnValueOnce(old.promise).mockResolvedValue(imageUrl) - const view = render() - try { - const oldSignal = vi.mocked(renderMermaid).mock.calls[0]![1] - await act(async () => { document.documentElement.style.colorScheme = 'dark' }) - expect(oldSignal.aborted).toBe(true) - const image = await screen.findByRole('img') - await act(async () => { old.resolve('obsolete') }) - expect(image.getAttribute('src')).toBe(imageUrl) - await act(async () => { document.body.style.setProperty('--unrelated', '1') }) - expect(renderMermaid).toHaveBeenCalledTimes(2) - await act(async () => { document.documentElement.style.colorScheme = 'light' }) - expect(renderMermaid).toHaveBeenCalledTimes(3) - view.unmount() - await act(async () => { document.documentElement.style.colorScheme = 'dark' }) - expect(renderMermaid).toHaveBeenCalledTimes(3) - } finally { - view.unmount() - document.documentElement.style.colorScheme = previous - document.body.style.removeProperty('--unrelated') - } - }) - it('shows loading until rendering completes, then displays an image without inserting SVG', async () => { - const pending = Promise.withResolvers() - vi.mocked(renderMermaid).mockReturnValue(pending.promise) - const view = render() - expect(screen.getByRole('status').textContent).toBe(labels.loading) - expect(screen.queryByRole('img')).toBeNull() - await act(async () => { pending.resolve(imageUrl) }) - expect(screen.getByRole('img', { name: labels.diagram }).getAttribute('src')).toBe(imageUrl) - expect(view.container.querySelector('svg')).toBeNull() - expect(screen.queryByRole('status')).toBeNull() - }) - - it('retains invalid source and recovers when the source changes', async () => { - vi.mocked(renderMermaid).mockRejectedValueOnce(new Error('Parse error')) - const view = render() - expect((await screen.findByText(labels.error)).getAttribute('role')).toBe('status') - expect(view.container.querySelector('pre code')?.textContent).toBe('invalid') - const next = Promise.withResolvers() - vi.mocked(renderMermaid).mockReturnValue(next.promise) - view.rerender() - expect(screen.getByRole('status').textContent).toBe(labels.loading) - expect(view.container.querySelector('pre')).toBeNull() - await act(async () => { next.resolve(imageUrl) }) - expect(screen.getByRole('img').getAttribute('src')).toBe(imageUrl) - }) - - it.each(['resolve', 'reject'] as const)('ignores a stale %s after a newer source finishes', async (outcome) => { - const old = Promise.withResolvers() - const next = Promise.withResolvers() - vi.mocked(renderMermaid).mockReturnValueOnce(old.promise).mockReturnValueOnce(next.promise) - const view = render() - const oldSignal = vi.mocked(renderMermaid).mock.calls[0]![1] - view.rerender() - expect(oldSignal.aborted).toBe(true) - await act(async () => { next.resolve(imageUrl) }) - await act(async () => { - if (outcome === 'resolve') old.resolve('obsolete-image') - else old.reject(new Error('obsolete-error')) - }) - expect(screen.getByRole('img').getAttribute('src')).toBe(imageUrl) - expect(screen.queryByRole('status')).toBeNull() - }) - - it('cancels the owner when unmounted while loading', async () => { - const pending = Promise.withResolvers() - vi.mocked(renderMermaid).mockReturnValue(pending.promise) - const view = render() - const signal = vi.mocked(renderMermaid).mock.calls[0]![1] - view.unmount() - expect(signal.aborted).toBe(true) - await act(async () => { pending.reject(new Error('cancelled')) }) - expect(screen.queryByRole('img')).toBeNull() - }) -}) - -describe('Markdown Mermaid fences', () => { - it('retains a preview when switching to numbered source', async () => { - vi.mocked(renderMermaid).mockResolvedValue(imageUrl) - const view = render(, - previewLabel: labels.preview, sourceLabel: labels.source, - }} />) - const diagram = await screen.findByRole('img', { name: labels.diagram }) - expect(view.container.querySelector('[data-line-numbers]')).not.toBeNull() - fireEvent.click(screen.getByRole('button', { name: labels.source })) - expect([...view.container.querySelectorAll('code > .line')].map(line => line.textContent)).toEqual(source.split('\n')) - expect(diagram.isConnected).toBe(true) - expect(screen.queryByRole('img')).toBeNull() - fireEvent.click(screen.getByRole('button', { name: labels.preview })) - expect(screen.getByRole('img', { name: labels.diagram })).toBe(diagram) - expect(renderMermaid).toHaveBeenCalledOnce() - }) - - it('keeps streaming source literal, then offers preview, source and source copying', async () => { - const writeText = vi.fn().mockResolvedValue(undefined) - vi.stubGlobal('navigator', Object.create(navigator, { clipboard: { value: { writeText } } })) - vi.mocked(renderMermaid).mockResolvedValue(imageUrl) - const props = { text: `\`\`\`mermaid\n${source}\n\`\`\``, labels: { ...markdownLabels, preview } } - const view = render() - expect(view.container.querySelector('pre code')?.textContent).toBe(source) - expect(renderMermaid).not.toHaveBeenCalled() - expect(screen.queryByRole('button', { name: labels.source })).toBeNull() - view.rerender() - const diagram = await screen.findByRole('img', { name: labels.diagram }) - expect(screen.queryByText('mermaid')).toBeNull() - expect(screen.getByRole('button', { name: labels.source }).textContent).toBe('') - expect(screen.getByRole('button', { name: markdownLabels.code.copyLabel }).textContent).toBe('') - fireEvent.click(screen.getByRole('button', { name: markdownLabels.code.copyLabel })) - await screen.findByRole('button', { name: markdownLabels.code.copiedLabel }) - expect(writeText).toHaveBeenCalledWith(source) - fireEvent.click(screen.getByRole('button', { name: labels.source })) - expect(view.container.querySelector('pre code')?.textContent).toBe(source) - expect(screen.queryByRole('img')).toBeNull() - expect(diagram.isConnected).toBe(true) - expect(screen.queryByText('mermaid')).toBeNull() - fireEvent.click(screen.getByRole('button', { name: labels.preview })) - expect(screen.getByRole('img', { name: labels.diagram })).toBe(diagram) - expect(screen.queryByRole('status')).toBeNull() - expect(renderMermaid).toHaveBeenCalledOnce() - }) - - it('leaves other languages and consumers without preview labels as code', () => { - const view = render() - expect(view.container.querySelector('pre code')?.textContent).toBe(source) - view.rerender() - expect(view.container.querySelector('pre code')?.textContent).toBe('flowchart LR') - expect(renderMermaid).not.toHaveBeenCalled() - }) -}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 90df336c0a..04b7a7e33a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3327,18 +3327,12 @@ importers: '@types/react-dom': specifier: ~18.3.0 version: 18.3.7(@types/react@18.3.31) - '@viz-js/viz': - specifier: 3.30.0 - version: 3.30.0 anser: specifier: ^2.3.5 version: 2.3.5 clsx: specifier: ^2.0.0 version: 2.1.1 - dompurify: - specifier: 3.4.11 - version: 3.4.11 katex: specifier: ^0.16.47 version: 0.16.47 @@ -3351,9 +3345,6 @@ importers: mdast-util-math: specifier: ^3.0.0 version: 3.0.0 - mermaid: - specifier: 11.16.0 - version: 11.16.0 micromark-core-commonmark: specifier: ^2.0.3 version: 2.0.3 @@ -14295,9 +14286,6 @@ packages: '@vitest/utils@4.1.8': resolution: {integrity: sha512-uOJamYALNhfJ6iolExyQM40yIQwDqYnkKtQ5VCiSe17E33H0aQ/u+1GlRuz4LZBk6Mm3sg90G9hEbmEt37C1Zg==} - '@viz-js/viz@3.30.0': - resolution: {integrity: sha512-2zmcP55QY44uQfZ+GvgNHmGd8S6KUD+2eMur9AbYybSzrOd/m8nMUg0ZircJNiJRKGgVBKAE8kh0hAwpUFUFQQ==} - '@vscode/ripgrep-darwin-arm64@1.18.0': resolution: {integrity: sha512-r3ktHSvbFycQNF6sl7sNDPocpsI7J+mEzh1IaZFkY0spm3k2Z9t8hPAeOK7+p0l6p6/swkQC14XWX01low+94Q==} cpu: [arm64] @@ -20907,8 +20895,6 @@ snapshots: convert-source-map: 2.0.0 tinyrainbow: 3.1.0 - '@viz-js/viz@3.30.0': {} - '@vscode/ripgrep-darwin-arm64@1.18.0': optional: true diff --git a/scripts/check-workspace-constraints.spec.ts b/scripts/check-workspace-constraints.spec.ts index 7d0177eb45..2042754128 100644 --- a/scripts/check-workspace-constraints.spec.ts +++ b/scripts/check-workspace-constraints.spec.ts @@ -3,7 +3,6 @@ import { describe, expect, it } from 'vitest' import { checkDshFamilyVersion, - checkWorkspaceManifest, checkExperimentalDependencyIsolation, checkExperimentalManifest, expectedDshPackageFiles, @@ -144,16 +143,3 @@ describe('package payload constraints', () => { ]) }) }) - -it('requires preview license notices in the published UI primitives payload', () => { - const name = '@deepseek-ai/dsh-client-ui-primitives' - const files = expectedDshPackageFiles({ name }) - expect(files).toContain('THIRD_PARTY_PREVIEW_NOTICES.txt') - const check = (entries: readonly string[]) => checkWorkspaceManifest({ - dir: 'packages/client/ui-primitives', manifest: { name, files: [...entries] }, - }).filter(message => message.includes('package.json files')) - expect(check(files)).toEqual([]) - expect(check(files.filter(file => file !== 'THIRD_PARTY_PREVIEW_NOTICES.txt'))).toEqual([ - expect.stringContaining('package.json files must be'), - ]) -}) diff --git a/scripts/check-workspace-constraints.ts b/scripts/check-workspace-constraints.ts index 744b5be9ca..95a8835eeb 100644 --- a/scripts/check-workspace-constraints.ts +++ b/scripts/check-workspace-constraints.ts @@ -155,7 +155,7 @@ const packageFileExtras: Readonly> = { // them through its own CSS pipeline, so the sheets are published artifacts. // The glob covers whichever sheets a package emits; sourcemaps stay // unpublished, as everywhere else in the repository. - '@deepseek-ai/dsh-client-ui-primitives': ['lib/**/*.css', 'THIRD_PARTY_PREVIEW_NOTICES.txt'], + '@deepseek-ai/dsh-client-ui-primitives': ['lib/**/*.css'], '@deepseek-ai/dsh-client-ui-dockkit': ['lib/**/*.css'], '@deepseek-ai/dsh-client-web': ['lib/**/*.css'], '@deepseek-ai/dsh-client-ui-theme': ['lib/styles'], diff --git a/scripts/gen-third-party-notices.spec.ts b/scripts/gen-third-party-notices.spec.ts index 46b1b35d11..fabce6e8c9 100644 --- a/scripts/gen-third-party-notices.spec.ts +++ b/scripts/gen-third-party-notices.spec.ts @@ -4,7 +4,6 @@ import { tmpdir } from 'node:os' import { describe, expect, it } from 'vitest' import { CLAUDE_AGENT_SDK_PACKAGE, - assertPreviewDistribution, assertRuntimeLicenses, claudeDistributionFromManifest, collectPythonDependencies, @@ -396,26 +395,3 @@ describe('manifestPatterns', () => { ]) }) }) - -describe('preview distribution licenses', () => { - const dependencies = { mermaid: '11.16.0', '@viz-js/viz': '3.30.0', dompurify: '3.4.11' } - const sources = [ - 'pkg:docker/emscripten/emsdk@5.0.7?platform=linux%2Famd64', - 'https://github.com/libexpat/libexpat/releases/download/R_2_8_4/expat-2.8.4.tar.gz', - 'https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/16.0.0/graphviz-16.0.0.tar.gz', - ] - it('accepts the reviewed wrapper and native sources', () => { - expect(() => { assertPreviewDistribution(dependencies, sources) }).not.toThrow() - const notices = readFileSync(resolve(root, 'packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt'), 'utf8') - expect(notices).toContain('Eclipse Public License - v 2.0') - expect(notices).toContain(sources[2]) - expect(notices).toContain(readFileSync(resolve(root, 'packages/client/ui-primitives/node_modules/mermaid/LICENSE'), 'utf8').trim()) - expect(notices).toContain(readFileSync(resolve(root, 'packages/client/ui-primitives/node_modules/dompurify/LICENSE'), 'utf8').trim()) - }) - it.each(Object.keys(dependencies))('rejects an unreviewed %s upgrade', (name) => { - expect(() => { assertPreviewDistribution({ ...dependencies, [name]: '99.0.0' }, sources) }).toThrow('preview notices: review') - }) - it.each([sources.slice(1), [...sources, 'https://example.com/new-library'], [...sources.slice(0, 2), 'graphviz-next']])('rejects changed embedded sources', (...uris) => { - expect(() => { assertPreviewDistribution(dependencies, uris) }).toThrow('native sources') - }) -}) diff --git a/scripts/gen-third-party-notices.ts b/scripts/gen-third-party-notices.ts index 2130723202..9e83956e5e 100644 --- a/scripts/gen-third-party-notices.ts +++ b/scripts/gen-third-party-notices.ts @@ -685,28 +685,6 @@ ${rows.join('\n')} ` } -/** - * Require renewed license review when a preview dependency or embedded source changes. - * @param dependencies - UI primitives' browser build dependencies. - * @param sources - Native source URIs from the installed Viz.js build provenance. - * @returns Nothing; throws when a version or native source differs from the reviewed distribution. - */ -export function assertPreviewDistribution(dependencies: Record, sources: readonly string[]): void { - for (const [name, version] of Object.entries({ mermaid: '11.16.0', '@viz-js/viz': '3.30.0', dompurify: '3.4.11' })) { - if (dependencies[name] !== version) { - throw new Error(`preview notices: review ${name} ${String(dependencies[name])} licenses and update THIRD_PARTY_PREVIEW_NOTICES.txt`) - } - } - const expected = [ - 'pkg:docker/emscripten/emsdk@5.0.7?platform=linux%2Famd64', - 'https://github.com/libexpat/libexpat/releases/download/R_2_8_4/expat-2.8.4.tar.gz', - 'https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/16.0.0/graphviz-16.0.0.tar.gz', - ] - if (sources.length !== expected.length || expected.some(uri => !sources.includes(uri))) { - throw new Error('preview notices: review the changed Viz.js native sources and their distribution licenses') - } -} - /** * Render the complete notices document. * @returns The exact bytes THIRD_PARTY_NOTICES.md must hold after resolving browser inputs. @@ -717,16 +695,6 @@ export async function render(): Promise { // the manifests map it was resolved from; render() owns that single load. workspaceLinkedManifestCache.clear() const { manifests, names } = loadWorkspaceManifests() - const previewPackage = 'packages/client/ui-primitives' - const provenance = JSON.parse(readFileSync(resolve(root, previewPackage, 'node_modules/@viz-js/viz/lib/provenance.json'), 'utf8')) as { - predicate: { buildDefinition: { resolvedDependencies: { uri: string }[] } } - } - const previewDependencies = manifests.get(`${previewPackage}/package.json`)?.devDependencies - if (previewDependencies === undefined) throw new Error('preview notices: missing UI primitives browser dependencies') - assertPreviewDistribution( - previewDependencies, - provenance.predicate.buildDefinition.resolvedDependencies.map(source => source.uri), - ) const npm = collectNpmDeps(manifests, names, browser) const runtimeDeps = npm.filter(dep => dep.runtime) const devDeps = npm.filter(dep => !dep.runtime) @@ -767,8 +735,6 @@ External packages installed for runtime use or distributed inside the prebuilt b ${renderNpmTable(runtimeDeps)} -The Markdown preview distribution also contains Graphviz 16.0.0 (EPL-2.0), Expat 2.8.4 (MIT), and Emscripten 5.0.7 runtime code (MIT/NCSA) inside \`@viz-js/viz\` 3.30.0. The wrapper's MIT metadata does not relicense these components. [Preview notices](packages/client/ui-primitives/THIRD_PARTY_PREVIEW_NOTICES.txt) preserve their full license texts and Graphviz source availability, together with Mermaid's MIT and DOMPurify's selected Apache-2.0 terms. The UI primitives npm package includes this file; the Web build emits it as \`preview-third-party-notices.txt\`. - pnpm applies local patches to the following packages at install time, so shipped artifacts carry modified copies; each patch file is the complete record of the modification: ${patchedLines.join('\n')} diff --git a/tsconfig.host.json b/tsconfig.host.json index e7abea1600..c5a3f118b3 100644 --- a/tsconfig.host.json +++ b/tsconfig.host.json @@ -67,7 +67,6 @@ "apps/web/tests/math-rendering.e2e.ts", "apps/web/tests/markdown-cjk-strong.e2e.ts", "apps/web/tests/markdown-inline-code-links.e2e.ts", - "apps/web/tests/markdown-mermaid.e2e.ts", "apps/web/tests/clickable-links-gallery.e2e.ts", "apps/web/tests/queue-actions.e2e.ts", "apps/web/tests/queue-image.e2e.ts", From dd393c18202b25f9734d51cb61aac8fa8b2c5ecf Mon Sep 17 00:00:00 2001 From: imccyu <276526105+imccyu@users.noreply.github.com> Date: Wed, 9 Sep 2026 20:18:50 +0800 Subject: [PATCH 14/32] release(dsh): 0.1.5-alpha.2 --- apps/cli/package.json | 2 +- apps/desktop-host/package.json | 2 +- apps/desktop/package.json | 2 +- apps/web/package.json | 2 +- package.json | 2 +- packages/acp/acp/package.json | 2 +- packages/api/gateway/package.json | 2 +- packages/api/remotes/package.json | 2 +- packages/api/session-controller/package.json | 2 +- packages/api/settings-controller/package.json | 2 +- packages/api/workspace-controller/package.json | 2 +- packages/api/workspace-files/package.json | 2 +- packages/attachment/attachment-local/package.json | 2 +- packages/attachment/attachment/package.json | 2 +- packages/boot/app-boot/package.json | 2 +- packages/boot/cmdline/package.json | 2 +- packages/bundle/acp-app/package.json | 2 +- packages/bundle/base/package.json | 2 +- packages/bundle/headless/package.json | 2 +- packages/bundle/sdk-app/package.json | 2 +- packages/bundle/sdk-minimal/package.json | 2 +- packages/bundle/web-app/package.json | 2 +- packages/client/connection/package.json | 2 +- packages/client/file-upload/package.json | 2 +- packages/client/hmr/package.json | 2 +- packages/client/locale/package.json | 2 +- packages/client/modules/package.json | 2 +- packages/client/resources/package.json | 2 +- packages/client/store/package.json | 2 +- packages/client/ui-agent-preset/package.json | 2 +- packages/client/ui-approval/package.json | 2 +- packages/client/ui-attachment/package.json | 2 +- packages/client/ui-brand-official/package.json | 2 +- packages/client/ui-chat/package.json | 2 +- packages/client/ui-commands/package.json | 2 +- packages/client/ui-conversation/package.json | 2 +- packages/client/ui-deliverables/package.json | 2 +- packages/client/ui-directory-picker-browse/package.json | 2 +- packages/client/ui-directory-picker-native/package.json | 2 +- packages/client/ui-dockkit/package.json | 2 +- packages/client/ui-goal/package.json | 2 +- packages/client/ui-input-trigger/package.json | 2 +- packages/client/ui-jobs/package.json | 2 +- packages/client/ui-layout/package.json | 2 +- packages/client/ui-message-feedback/package.json | 2 +- packages/client/ui-model-selection/package.json | 2 +- packages/client/ui-open-in-app/package.json | 2 +- packages/client/ui-permission-presets/package.json | 2 +- packages/client/ui-plan/package.json | 2 +- packages/client/ui-primitives/package.json | 2 +- packages/client/ui-reference/package.json | 2 +- packages/client/ui-renderer/package.json | 2 +- packages/client/ui-schedule/package.json | 2 +- packages/client/ui-session/package.json | 2 +- packages/client/ui-settings-general/package.json | 2 +- packages/client/ui-settings-models/package.json | 2 +- packages/client/ui-settings-plugin-inventory/package.json | 2 +- packages/client/ui-settings-plugins/package.json | 2 +- packages/client/ui-settings/package.json | 2 +- packages/client/ui-sidebar-documentpreview/package.json | 2 +- packages/client/ui-sidebar-files/package.json | 2 +- packages/client/ui-sidebar-right/package.json | 2 +- packages/client/ui-sidebar/package.json | 2 +- packages/client/ui-skill/package.json | 2 +- packages/client/ui-slots/package.json | 2 +- packages/client/ui-subagent/package.json | 2 +- packages/client/ui-theme/package.json | 2 +- packages/client/ui-tool/package.json | 2 +- packages/client/ui-trajectory/package.json | 2 +- packages/client/ui-user-questions/package.json | 2 +- packages/client/ui-workflow-run/package.json | 2 +- packages/client/ui-workspace/package.json | 2 +- packages/client/web/package.json | 2 +- packages/code-runtime/code-runtime-worker-thread/package.json | 2 +- packages/code-runtime/code-runtime/package.json | 2 +- packages/compaction/command-compact/package.json | 2 +- packages/compaction/compaction-basic/package.json | 2 +- packages/compaction/compaction-tool-result-pruner/package.json | 2 +- packages/compaction/compaction/package.json | 2 +- packages/context/agent-instructions/package.json | 2 +- packages/context/file-reference-local/package.json | 2 +- packages/context/file-reference/package.json | 2 +- packages/context/session-reference/package.json | 2 +- packages/context/time-context/package.json | 2 +- packages/context/tmux-context/package.json | 2 +- packages/core/agent-default-model/package.json | 2 +- packages/core/agent-loop/package.json | 2 +- packages/core/agent-tool-presentation/package.json | 2 +- packages/core/agent/package.json | 2 +- packages/core/scope/package.json | 2 +- packages/core/session/package.json | 2 +- packages/core/system-prompt/package.json | 2 +- packages/core/tools/package.json | 2 +- packages/credentials/authorization/package.json | 2 +- packages/credentials/credentials-local/package.json | 2 +- packages/credentials/credentials/package.json | 2 +- packages/e2b/e2b/package.json | 2 +- packages/e2b/fs-e2b/package.json | 2 +- packages/e2b/subprocess-e2b/package.json | 2 +- packages/experimental/agent-team-profile/package.json | 2 +- packages/experimental/agent-team-web-profile/package.json | 2 +- packages/experimental/agent-team/package.json | 2 +- packages/experimental/client-ui-agent-team/package.json | 2 +- packages/experimental/code-runtime-python/package.json | 2 +- packages/experimental/inspector/package.json | 2 +- packages/experimental/tool-agent-team/package.json | 2 +- packages/experimental/webworker-packer/package.json | 2 +- packages/experimental/webworker-runtime/package.json | 2 +- packages/extensions/cordis-client-runner/package.json | 2 +- packages/extensions/cordis-host-runner/package.json | 2 +- packages/extensions/tool-cordis/package.json | 2 +- packages/extensions/ui-cordis/package.json | 2 +- packages/feedback/command-feedback/package.json | 2 +- packages/feedback/message-feedback/package.json | 2 +- packages/fs/fs-local/package.json | 2 +- packages/fs/fs-observation-policy/package.json | 2 +- packages/fs/fs-sandbox/package.json | 2 +- packages/fs/fs/package.json | 2 +- packages/fs/tool-fs-search/package.json | 2 +- packages/fs/tool-fs/package.json | 2 +- packages/fs/tool-present/package.json | 2 +- packages/fs/tool-str-replace-editor/package.json | 2 +- packages/goal/command-goal/package.json | 2 +- packages/goal/goal-round-driver/package.json | 2 +- packages/goal/goal/package.json | 2 +- packages/goal/tool-goal/package.json | 2 +- packages/guard/repeat-tool-reminder/package.json | 2 +- packages/guard/timeout-policy/package.json | 2 +- packages/hooks/hook-protocol/package.json | 2 +- packages/hooks/hooks-claude-code/package.json | 2 +- packages/hooks/hooks-codex/package.json | 2 +- packages/host/directory-picker-auto/package.json | 2 +- packages/host/directory-picker-browse/package.json | 2 +- packages/host/directory-picker-native/package.json | 2 +- packages/host/directory-picker/package.json | 2 +- packages/host/frontend-static/package.json | 2 +- packages/host/open-in-app/package.json | 2 +- packages/host/plugin-inventory/package.json | 2 +- packages/host/webserver/package.json | 2 +- packages/identity/anonymous-user-id/package.json | 2 +- packages/interaction/commands/package.json | 2 +- packages/interaction/permission-presets/package.json | 2 +- packages/interaction/tool-ask-user/package.json | 2 +- packages/interaction/user-approval/package.json | 2 +- packages/interaction/user-questions/package.json | 2 +- packages/jobs/jobs-local/package.json | 2 +- packages/jobs/jobs/package.json | 2 +- packages/jobs/tool-jobs/package.json | 2 +- packages/llm/deepseek-llm-api-extensions/package.json | 2 +- packages/llm/llm-deepseek/package.json | 2 +- packages/llm/llm-pi-ai/package.json | 2 +- packages/llm/llm-retry/package.json | 2 +- packages/llm/llm/package.json | 2 +- packages/llm/plugin-package-inventory-deepseek/package.json | 2 +- packages/llm/token-meter/package.json | 2 +- packages/lsp/lsp-stdio/package.json | 2 +- packages/lsp/lsp/package.json | 2 +- packages/lsp/tool-lsp/package.json | 2 +- packages/mcp/mcp-client/package.json | 2 +- packages/plan/plan-mode/package.json | 2 +- packages/preset/agent-presets/package.json | 2 +- packages/preset/persona/package.json | 2 +- packages/runtime-diagnostics/invariants/package.json | 2 +- packages/sandbox/sandbox-local/package.json | 2 +- packages/sandbox/sandbox-policy/package.json | 2 +- packages/sandbox/sandbox-windows-acl/package.json | 2 +- packages/sandbox/sandbox/package.json | 2 +- packages/schedule/schedule/package.json | 2 +- packages/sdk/client/package.json | 2 +- packages/sdk/protocol/package.json | 2 +- packages/sdk/server/package.json | 2 +- packages/session-query/session-log-export/package.json | 2 +- packages/session-query/session-query-sqlite/package.json | 2 +- packages/session-query/session-query/package.json | 2 +- packages/session-query/tool-session-query/package.json | 2 +- packages/session/session-checkpoint-policy/package.json | 2 +- packages/session/session-format-catalog/package.json | 2 +- packages/session/session-format-v0-to-v1/package.json | 2 +- packages/session/session-format-v1-to-v2/package.json | 2 +- packages/session/session-format-v2-to-v3/package.json | 2 +- packages/session/session-format/package.json | 2 +- packages/session/session-log-deepseek/package.json | 2 +- packages/session/session-persistence-jsonl/package.json | 2 +- packages/session/session-persistence/package.json | 2 +- packages/session/session-projection-cache/package.json | 2 +- packages/session/session-projection/package.json | 2 +- packages/session/session-stats/package.json | 2 +- packages/session/session-telemetry-otel/package.json | 2 +- packages/session/session-telemetry/package.json | 2 +- packages/session/session-title-all-prompts-llm/package.json | 2 +- packages/session/session-title-first-prompt-llm/package.json | 2 +- packages/session/session-title-llm/package.json | 2 +- packages/session/session-title/package.json | 2 +- packages/session/session-turn-outline/package.json | 2 +- packages/settings/settings-file/package.json | 2 +- packages/settings/settings/package.json | 2 +- packages/shell/bash-local/package.json | 2 +- packages/shell/bash-sandbox/package.json | 2 +- packages/shell/pwsh-local/package.json | 2 +- packages/shell/pwsh-sandbox/package.json | 2 +- packages/shell/shell-env/package.json | 2 +- packages/shell/shell/package.json | 2 +- packages/shell/tool-bash-persistent/package.json | 2 +- packages/shell/tool-bash/package.json | 2 +- packages/shell/tool-pwsh-persistent/package.json | 2 +- packages/shell/tool-pwsh/package.json | 2 +- packages/skill/skill-badge/package.json | 2 +- packages/skill/skill-filesystem/package.json | 2 +- packages/skill/skill/package.json | 2 +- packages/skill/tool-skill/package.json | 2 +- packages/spill/spill-local/package.json | 2 +- packages/spill/spill-policy/package.json | 2 +- packages/spill/spill/package.json | 2 +- packages/storage/storage-domain/package.json | 2 +- packages/storage/storage-json/package.json | 2 +- packages/storage/storage-sqlite/package.json | 2 +- packages/storage/storage/package.json | 2 +- packages/subagent/subagent-acp/package.json | 2 +- packages/subagent/subagent-claude-code/package.json | 2 +- packages/subagent/subagent-codex/package.json | 2 +- packages/subagent/subagent-dsh-sdk/package.json | 2 +- packages/subagent/subagent-fork-in-process/package.json | 2 +- packages/subagent/subagent-in-process-driver/package.json | 2 +- packages/subagent/subagent-spawn-in-process/package.json | 2 +- packages/subagent/subagent/package.json | 2 +- packages/subagent/tool-subagent-control/package.json | 2 +- packages/subagent/tool-subagent/package.json | 2 +- packages/subprocess/subprocess-local/package.json | 2 +- packages/subprocess/subprocess/package.json | 2 +- packages/subprocess/win32-process/package.json | 2 +- packages/terminal/terminal-bash/package.json | 2 +- packages/terminal/terminal/package.json | 2 +- packages/terminal/tool-terminal/package.json | 2 +- packages/test-support/agent-loop-testkit/package.json | 2 +- packages/test-support/client-runtime/package.json | 2 +- packages/test-support/llm-mock-server/package.json | 2 +- packages/test-support/llm-replay/package.json | 2 +- packages/test-support/loader-smoke/package.json | 2 +- packages/test-support/session-snapshot/package.json | 2 +- packages/todo/tool-todo/package.json | 2 +- packages/typert/generator/package.json | 2 +- packages/typert/loader/package.json | 2 +- packages/typert/protocol/package.json | 2 +- packages/typert/registry/package.json | 2 +- packages/util/atomic-write/package.json | 2 +- packages/util/brand/package.json | 2 +- packages/util/chunked-list/package.json | 2 +- packages/util/crypto/package.json | 2 +- packages/util/deque/package.json | 2 +- packages/util/home-paths/package.json | 2 +- packages/util/http-proxy/package.json | 2 +- packages/util/launch-environment/package.json | 2 +- packages/util/native-command/package.json | 2 +- packages/util/output-retention/package.json | 2 +- packages/util/package-manifest/package.json | 2 +- packages/util/time/package.json | 2 +- packages/util/timeout/package.json | 2 +- packages/util/values/package.json | 2 +- packages/util/workspace-path/package.json | 2 +- packages/web/tool-web/package.json | 2 +- packages/web/web-fetch-http/package.json | 2 +- packages/web/web-search-deepseek/package.json | 2 +- packages/web/web-search-exa/package.json | 2 +- packages/web/web-search-perplexity/package.json | 2 +- packages/web/web/package.json | 2 +- packages/webhook/webhook-github/package.json | 2 +- packages/webhook/webhook/package.json | 2 +- packages/workflow/tool-ralph/package.json | 2 +- packages/workflow/tool-workflow/package.json | 2 +- packages/workflow/workflow-worker-thread/package.json | 2 +- packages/workflow/workflow/package.json | 2 +- packages/workspace/workspace/package.json | 2 +- 272 files changed, 272 insertions(+), 272 deletions(-) diff --git a/apps/cli/package.json b/apps/cli/package.json index 57084f2ac5..430451a4d4 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh", "description": "dsh CLI: profile boot, plugin management, and the browser UI alias", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/apps/desktop-host/package.json b/apps/desktop-host/package.json index fc44413c3d..68996a4894 100644 --- a/apps/desktop-host/package.json +++ b/apps/desktop-host/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-desktop-host", "description": "Private upstream-Node host process for the Electron desktop application", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "private": true, "license": "MIT", "type": "module", diff --git a/apps/desktop/package.json b/apps/desktop/package.json index d4a8146a1c..b428a0550c 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-desktop", "description": "Electron desktop shell for an isolated pnpm-installed dsh runtime", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "private": true, "license": "MIT", "type": "module", diff --git a/apps/web/package.json b/apps/web/package.json index 6c6dbc31aa..439036b0db 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-web-frontend", "description": "Web application entry: vite build over the @deepseek-ai/dsh-client-web shell library; dist/ served by apps/cli's dsh web", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/package.json b/package.json index a09fa3f997..09627ea0d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@deepseek-ai/dsh-root", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "license": "MIT", "private": true, "type": "module", diff --git a/packages/acp/acp/package.json b/packages/acp/acp/package.json index c7a821c5d5..a5cf5a2d64 100644 --- a/packages/acp/acp/package.json +++ b/packages/acp/acp/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-acp", "description": "Automation-only Agent Client Protocol server for driving DeepSeek Harness agents over JSON-RPC stdio", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/api/gateway/package.json b/packages/api/gateway/package.json index 8530dfd990..8228fefce4 100644 --- a/packages/api/gateway/package.json +++ b/packages/api/gateway/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-api-gateway", "description": "Typert Remote Host dispatcher and Client API endpoint", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/api/remotes/package.json b/packages/api/remotes/package.json index 0d7280d631..fafd62f2e3 100644 --- a/packages/api/remotes/package.json +++ b/packages/api/remotes/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-api-remotes", "description": "Remote BFF assembly for application-selected Host capabilities", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/api/session-controller/package.json b/packages/api/session-controller/package.json index 3603490bf4..0376282f77 100644 --- a/packages/api/session-controller/package.json +++ b/packages/api/session-controller/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-api-session-controller", "description": "Session Remote commands, cold reads, and live control transport", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/api/settings-controller/package.json b/packages/api/settings-controller/package.json index 2cfeb1e89a..91da932736 100644 --- a/packages/api/settings-controller/package.json +++ b/packages/api/settings-controller/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-api-settings-controller", "description": "Remote owner for the configuration surfaces over the settings-domain seams", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/api/workspace-controller/package.json b/packages/api/workspace-controller/package.json index fcfd014594..ffdc9e2080 100644 --- a/packages/api/workspace-controller/package.json +++ b/packages/api/workspace-controller/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-api-workspace-controller", "description": "Workspace Remote commands and reconnect-safe state transport", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/api/workspace-files/package.json b/packages/api/workspace-files/package.json index f867c86a1e..5ee4f54e67 100644 --- a/packages/api/workspace-files/package.json +++ b/packages/api/workspace-files/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-api-workspace-files", "description": "Workspace file service and Client resource provider: bounded reads, directory listing, and live metadata over the workspaceFiles Remote namespace", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/attachment/attachment-local/package.json b/packages/attachment/attachment-local/package.json index 71034eb684..afa52d914f 100644 --- a/packages/attachment/attachment-local/package.json +++ b/packages/attachment/attachment-local/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-attachment-local", "description": "Private content-addressed DSH_HOME attachment storage", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/attachment/attachment/package.json b/packages/attachment/attachment/package.json index 48cde83037..d98db07b61 100644 --- a/packages/attachment/attachment/package.json +++ b/packages/attachment/attachment/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-attachment", "description": "Durable immutable attachment storage seam for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/boot/app-boot/package.json b/packages/boot/app-boot/package.json index 2e49da08de..64eedc7ae1 100644 --- a/packages/boot/app-boot/package.json +++ b/packages/boot/app-boot/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-app-boot", "description": "Shared boot glue for the app bins: .env loading, fail-loud Loader guards, snapshot-aware config resolution, and the Loader boot sequence", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/boot/cmdline/package.json b/packages/boot/cmdline/package.json index 6a4a9679d9..ea10cc6960 100644 --- a/packages/boot/cmdline/package.json +++ b/packages/boot/cmdline/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-cmdline", "description": "Immutable command-line handoff from a dsh launcher to any app plugin that injects cmdlineArgs", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/bundle/acp-app/package.json b/packages/bundle/acp-app/package.json index 3fb7dfaa3b..085b7341e5 100644 --- a/packages/bundle/acp-app/package.json +++ b/packages/bundle/acp-app/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-acp-app", "description": "The dsh ACP profile bundle: automation-only JSON-RPC stdio and process lifecycle over dsh-base", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/bundle/base/package.json b/packages/bundle/base/package.json index 4f3407903a..64e33f55b1 100644 --- a/packages/bundle/base/package.json +++ b/packages/bundle/base/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-base", "description": "The shared dsh core as a profile bundle: the first patch layer of base-backed profiles, inserting core rows over the empty profile root", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/bundle/headless/package.json b/packages/bundle/headless/package.json index b8f809ebf3..1b9e611457 100644 --- a/packages/bundle/headless/package.json +++ b/packages/bundle/headless/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-headless", "description": "The dsh one-shot bundle: a direct core Agent/Session runner over dsh-base with no Host, HTTP, or browser layer", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/bundle/sdk-app/package.json b/packages/bundle/sdk-app/package.json index 1f39ae000b..4fc726caa8 100644 --- a/packages/bundle/sdk-app/package.json +++ b/packages/bundle/sdk-app/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-sdk-app", "description": "The dsh SDK profile bundle: stdio JSON-RPC serving and process lifecycle over dsh-base", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/bundle/sdk-minimal/package.json b/packages/bundle/sdk-minimal/package.json index d95375faed..630f448daf 100644 --- a/packages/bundle/sdk-minimal/package.json +++ b/packages/bundle/sdk-minimal/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-sdk-minimal", "description": "The standalone minimal SDK profile bundle: JSON-RPC, one DeepSeek adapter, persistent shell, and JSONL sessions", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/bundle/web-app/package.json b/packages/bundle/web-app/package.json index 692a6be952..6782a6e444 100644 --- a/packages/bundle/web-app/package.json +++ b/packages/bundle/web-app/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-web-app", "description": "The dsh browser-surface bundle: the web patch layer over dsh-base plus the runtime glue plugin (frontend dist serving, web-surface prompt, bash runtime variables, URL line)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/connection/package.json b/packages/client/connection/package.json index 9c999a025b..16dceff71f 100644 --- a/packages/client/connection/package.json +++ b/packages/client/connection/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-connection", "description": "Authenticated RPC transport, generation lifecycle, and browser fixture", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/file-upload/package.json b/packages/client/file-upload/package.json index 015a125351..fce7fd086d 100644 --- a/packages/client/file-upload/package.json +++ b/packages/client/file-upload/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-file-upload", "description": "Agent-scoped browser file upload, streaming intake, and staged receipt service", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/hmr/package.json b/packages/client/hmr/package.json index 6295fa479f..a3df146d0f 100644 --- a/packages/client/hmr/package.json +++ b/packages/client/hmr/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-hmr", "description": "Dev-only hot-reload driver for script-loaded client entries: SSE rebuilt frames → invalidate/prefetch → fiber swap through the vendored Loader entry", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/locale/package.json b/packages/client/locale/package.json index 10177f91e2..49928c9321 100644 --- a/packages/client/locale/package.json +++ b/packages/client/locale/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-locale", "description": "Locale plugin: Host-backed preference, extensible language catalog, browser fallback, and typed built-in dictionaries", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/modules/package.json b/packages/client/modules/package.json index 1c09baf8a6..fadb06d13e 100644 --- a/packages/client/modules/package.json +++ b/packages/client/modules/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-modules", "description": "Client module system, dual-face: node half composes the __DSH_BOOT__ entry graph (incremental dsh.client scan, bundle route, index tap, webPlugins service); browser half is the lazy-CJS module table the vendored cordis Loader consumes as its internal seam", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/resources/package.json b/packages/client/resources/package.json index cdcd4eed2d..21a47b7544 100644 --- a/packages/client/resources/package.json +++ b/packages/client/resources/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-resources", "description": "Unified client resource model: protocol-registered providers turn URL addresses into live values, consumed through the useResource global standard hook", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/store/package.json b/packages/client/store/package.json index 6bb0c0a212..fe71ce96ce 100644 --- a/packages/client/store/package.json +++ b/packages/client/store/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-store", "description": "React-free observable and snapshot-store contracts with the shared Zustand/Immer engine", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-agent-preset/package.json b/packages/client/ui-agent-preset/package.json index 9984d47613..857bc9c906 100644 --- a/packages/client/ui-agent-preset/package.json +++ b/packages/client/ui-agent-preset/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-agent-preset", "description": "Agent-preset surfaces: the default for later sessions, this session's seat, and the composition editor", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-approval/package.json b/packages/client/ui-approval/package.json index b4cecaa31d..00138c179e 100644 --- a/packages/client/ui-approval/package.json +++ b/packages/client/ui-approval/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-approval", "description": "Approval composer takeover over the scoped Remote Event waterfall", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-attachment/package.json b/packages/client/ui-attachment/package.json index 9adf41af13..429f1955b3 100644 --- a/packages/client/ui-attachment/package.json +++ b/packages/client/ui-attachment/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-attachment", "description": "Dynamic attachment presentation plugin for conversation input, message-image, and trajectory image slots", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-brand-official/package.json b/packages/client/ui-brand-official/package.json index 0db54ad4f0..62ddf9c91e 100644 --- a/packages/client/ui-brand-official/package.json +++ b/packages/client/ui-brand-official/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-brand-official", "description": "Official DeepSeek Harness brand occupants for the Web client's sidebar slots", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-chat/package.json b/packages/client/ui-chat/package.json index 7a5cb18771..ea9e994e91 100644 --- a/packages/client/ui-chat/package.json +++ b/packages/client/ui-chat/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-chat", "description": "Chat Conversation target, node definitions, renderers, and details surface", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-commands/package.json b/packages/client/ui-commands/package.json index 40ce5a3bff..4dc37a8261 100644 --- a/packages/client/ui-commands/package.json +++ b/packages/client/ui-commands/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-commands", "description": "Client command surface: global directory cache, '/' source, three command UI kinds, popupSelect registry", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-conversation/package.json b/packages/client/ui-conversation/package.json index 987aa9574f..c1e62e4100 100644 --- a/packages/client/ui-conversation/package.json +++ b/packages/client/ui-conversation/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-conversation", "description": "Target-neutral Conversation assembly, shell, composer, queue, and view navigation", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-deliverables/package.json b/packages/client/ui-deliverables/package.json index 16534d6f8d..dcac6ce807 100644 --- a/packages/client/ui-deliverables/package.json +++ b/packages/client/ui-deliverables/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-deliverables", "description": "Produced-files turn tail and clickable final-response file references for Web", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-directory-picker-browse/package.json b/packages/client/ui-directory-picker-browse/package.json index ec0a9d8ed0..f6544117ae 100644 --- a/packages/client/ui-directory-picker-browse/package.json +++ b/packages/client/ui-directory-picker-browse/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-directory-picker-browse", "description": "In-app directory browsing surface: the workspace directory-flow owner rendering the host's listing and creation primitives", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-directory-picker-native/package.json b/packages/client/ui-directory-picker-native/package.json index 9b370e32bb..1b81a714a8 100644 --- a/packages/client/ui-directory-picker-native/package.json +++ b/packages/client/ui-directory-picker-native/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-directory-picker-native", "description": "Native directory-picker surface: the renderless workspace directory-flow occupant driving the host's OS chooser", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-dockkit/package.json b/packages/client/ui-dockkit/package.json index d4ce40915b..df264e82f8 100644 --- a/packages/client/ui-dockkit/package.json +++ b/packages/client/ui-dockkit/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-dockkit", "description": "Docking layout kit: split-tree engine with invertible operations, and the React components that render and drive it (zero cordis)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-goal/package.json b/packages/client/ui-goal/package.json index 5d516249f9..49f1105462 100644 --- a/packages/client/ui-goal/package.json +++ b/packages/client/ui-goal/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-goal", "description": "Session goal surface: GoalBar docked above the composer, read from the goal session projection", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-input-trigger/package.json b/packages/client/ui-input-trigger/package.json index 65e30abb16..d6f3bd7fb6 100644 --- a/packages/client/ui-input-trigger/package.json +++ b/packages/client/ui-input-trigger/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-input-trigger", "description": "Input trigger pipeline: '/' and '@' detection, candidate menu, pick routing to registered sources", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-jobs/package.json b/packages/client/ui-jobs/package.json index cd0ea7ebe9..196567bb7a 100644 --- a/packages/client/ui-jobs/package.json +++ b/packages/client/ui-jobs/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-jobs", "description": "Session-header background-job list: live registry state mirrored from session/jobs frames", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "type": "module", "main": "lib/index.js", "types": "lib/types/index.d.ts", diff --git a/packages/client/ui-layout/package.json b/packages/client/ui-layout/package.json index a2c025f39d..1beae6f3b0 100644 --- a/packages/client/ui-layout/package.json +++ b/packages/client/ui-layout/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-layout", "description": "Shell plugin: three-column AppFrame with drag handles, ctx.layout viewing-state service (navigation + panels)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-message-feedback/package.json b/packages/client/ui-message-feedback/package.json index d5fd7aed7e..343f289faa 100644 --- a/packages/client/ui-message-feedback/package.json +++ b/packages/client/ui-message-feedback/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-message-feedback", "description": "The Web feedback surface: per-message Like/Dislike in the assistant-message action strip and the feedback dialog behind Dislike and /feedback, backed by the messageFeedback and sessionFeedback Host Remotes", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-model-selection/package.json b/packages/client/ui-model-selection/package.json index d3c89480e8..d0951c3d7c 100644 --- a/packages/client/ui-model-selection/package.json +++ b/packages/client/ui-model-selection/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-model-selection", "description": "Model selection over the shared model catalog, Session projection, and session.selectModel", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-open-in-app/package.json b/packages/client/ui-open-in-app/package.json index 3b39d1e5d8..97c063097d 100644 --- a/packages/client/ui-open-in-app/package.json +++ b/packages/client/ui-open-in-app/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-open-in-app", "description": "Web Session-header \"Open In...\" split button opening the session workspace directory in a locally installed application", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-permission-presets/package.json b/packages/client/ui-permission-presets/package.json index e065186bcd..708f3fba3f 100644 --- a/packages/client/ui-permission-presets/package.json +++ b/packages/client/ui-permission-presets/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-permission-presets", "description": "Permission surfaces: a new-session default in General settings and a current-session /permission popup over the permissions projection", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-plan/package.json b/packages/client/ui-plan/package.json index 7080b89644..6fa0ddcc2f 100644 --- a/packages/client/ui-plan/package.json +++ b/packages/client/ui-plan/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-plan", "description": "Plan-mode composer control: the conversation.input.plan seat over the plan projection and the /plan command channel", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-primitives/package.json b/packages/client/ui-primitives/package.json index 2613c3aa98..ca37e9b16f 100644 --- a/packages/client/ui-primitives/package.json +++ b/packages/client/ui-primitives/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-primitives", "description": "Pure React atoms for the dsh web UI: controls, icons, markdown, and JSON inspectors (zero cordis)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-reference/package.json b/packages/client/ui-reference/package.json index 2e57deca88..7bfe165621 100644 --- a/packages/client/ui-reference/package.json +++ b/packages/client/ui-reference/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-reference", "description": "Unified Web @file and @session reference source", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-renderer/package.json b/packages/client/ui-renderer/package.json index 2aefdb4b1e..f1f6d4721d 100644 --- a/packages/client/ui-renderer/package.json +++ b/packages/client/ui-renderer/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-renderer", "description": "Browser UI renderer: React slot bindings, ctx.uiRenderer, and the assembled application root", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-schedule/package.json b/packages/client/ui-schedule/package.json index e47d9ad54a..a2a6536d3d 100644 --- a/packages/client/ui-schedule/package.json +++ b/packages/client/ui-schedule/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-schedule", "description": "Read-only active Schedule catalog in the Web Session header", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "type": "module", "main": "lib/index.js", "types": "lib/types/index.d.ts", diff --git a/packages/client/ui-session/package.json b/packages/client/ui-session/package.json index 9996019293..3e09735e19 100644 --- a/packages/client/ui-session/package.json +++ b/packages/client/ui-session/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-session", "description": "Session Controller adapter for React and session-scoped slots", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-settings-general/package.json b/packages/client/ui-settings-general/package.json index 2d33e995f4..8327d2ca1e 100644 --- a/packages/client/ui-settings-general/package.json +++ b/packages/client/ui-settings-general/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-settings-general", "description": "Settings ownerless-copy and product onboarding plugin: the General section, shell trigger/header chrome content, settings dictionaries, and the versioned welcome notice", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-settings-models/package.json b/packages/client/ui-settings-models/package.json index da707bee60..a3d882b2e8 100644 --- a/packages/client/ui-settings-models/package.json +++ b/packages/client/ui-settings-models/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-settings-models", "description": "Models settings and shared product-onboarding dialogs over existing settings and credential joins", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-settings-plugin-inventory/package.json b/packages/client/ui-settings-plugin-inventory/package.json index 84d0b26e40..0755e07977 100644 --- a/packages/client/ui-settings-plugin-inventory/package.json +++ b/packages/client/ui-settings-plugin-inventory/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-settings-plugin-inventory", "description": "Read-only Cordis Loader inventory tab in Web Plugins settings", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-settings-plugins/package.json b/packages/client/ui-settings-plugins/package.json index c4b27fae88..acc7a836dd 100644 --- a/packages/client/ui-settings-plugins/package.json +++ b/packages/client/ui-settings-plugins/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-settings-plugins", "description": "Plugins settings section with feature-owned tabs and configurable host-plane plugin cards", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-settings/package.json b/packages/client/ui-settings/package.json index 305ecef2fa..dffc545328 100644 --- a/packages/client/ui-settings/package.json +++ b/packages/client/ui-settings/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-settings", "description": "Settings domain base plugin: the settings-namespace scope service and the canonical settings slot-type contract", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-sidebar-documentpreview/package.json b/packages/client/ui-sidebar-documentpreview/package.json index 8d592decc0..af3d91613f 100644 --- a/packages/client/ui-sidebar-documentpreview/package.json +++ b/packages/client/ui-sidebar-documentpreview/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-sidebar-documentpreview", "description": "Extensible document previews for Sidebar files: Markdown, highlighted code, images, PDF, HTML, and plain text", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-sidebar-files/package.json b/packages/client/ui-sidebar-files/package.json index ce97ee1ffc..619884d036 100644 --- a/packages/client/ui-sidebar-files/package.json +++ b/packages/client/ui-sidebar-files/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-sidebar-files", "description": "Workspace file tree tab type for the right Sidebar: lazy directory listing over the workspaceFiles Remote namespace, opening files into the Sidebar", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-sidebar-right/package.json b/packages/client/ui-sidebar-right/package.json index c8fad0215c..31b8055429 100644 --- a/packages/client/ui-sidebar-right/package.json +++ b/packages/client/ui-sidebar-right/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-sidebar-right", "description": "Right Sidebar: the docking surface's session-bound state, its panel and header expand control, and the navigation service over it", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-sidebar/package.json b/packages/client/ui-sidebar/package.json index 3fb78453b2..6fda5a97db 100644 --- a/packages/client/ui-sidebar/package.json +++ b/packages/client/ui-sidebar/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-sidebar", "description": "Sidebar plugin: session multi-level tree, search, grouping, state dots", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-skill/package.json b/packages/client/ui-skill/package.json index cefa0086f2..9db4e24efd 100644 --- a/packages/client/ui-skill/package.json +++ b/packages/client/ui-skill/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-skill", "description": "Web skill references and the dedicated skill tool row", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-slots/package.json b/packages/client/ui-slots/package.json index fce80c249e..f01270278e 100644 --- a/packages/client/ui-slots/package.json +++ b/packages/client/ui-slots/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-slots", "description": "Slot registry pure core: SlotMap declaration merging, single register composition API, four-share props types, store-seat types, renderer install seam", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-subagent/package.json b/packages/client/ui-subagent/package.json index fe75323062..1835c7f7a2 100644 --- a/packages/client/ui-subagent/package.json +++ b/packages/client/ui-subagent/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-subagent", "description": "Subagent conversation catalog, continuation routing UI, and '@' reference source", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-theme/package.json b/packages/client/ui-theme/package.json index 5f9dd4940c..610bd399ab 100644 --- a/packages/client/ui-theme/package.json +++ b/packages/client/ui-theme/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-theme", "description": "Theme plugin: Host bootstrap for the pre-plugin palette; DOM-free ThemeRuntime for light/dark/system state; --dsw-* token styles and Appearance settings row", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-tool/package.json b/packages/client/ui-tool/package.json index 3a3722d64d..14030de47a 100644 --- a/packages/client/ui-tool/package.json +++ b/packages/client/ui-tool/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-tool", "description": "Client Tool call-tree renderer and keyed per-tool presentation slot", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-trajectory/package.json b/packages/client/ui-trajectory/package.json index 7f9752a6a8..417c8a47e3 100644 --- a/packages/client/ui-trajectory/package.json +++ b/packages/client/ui-trajectory/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-trajectory", "description": "Trajectory event ledger with an interactive timing overview: pure-consumer plugin registering into the conversation ViewMap (no service)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-user-questions/package.json b/packages/client/ui-user-questions/package.json index b32352c522..16883d3686 100644 --- a/packages/client/ui-user-questions/package.json +++ b/packages/client/ui-user-questions/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-user-questions", "description": "Web ask_user_question composer takeover and plan-review presentation UI", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-workflow-run/package.json b/packages/client/ui-workflow-run/package.json index 15ca5a0d2d..a44c93a427 100644 --- a/packages/client/ui-workflow-run/package.json +++ b/packages/client/ui-workflow-run/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-workflow-run", "description": "Durable workflow-run Conversation Node and nested member disclosure for dsh web", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/ui-workspace/package.json b/packages/client/ui-workspace/package.json index 3a35cae4d4..72b3b8ff33 100644 --- a/packages/client/ui-workspace/package.json +++ b/packages/client/ui-workspace/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-workspace", "description": "Workspace picker plugin: one WorkspacePicker registered into the sidebar and empty-state workspace slots", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/client/web/package.json b/packages/client/web/package.json index 64b36efc5c..6a9a8364c0 100644 --- a/packages/client/web/package.json +++ b/packages/client/web/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-web", "description": "Web boot kernel: static module table, Cordis loader, framework-free boot page, and UI-renderer handoff", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/code-runtime/code-runtime-worker-thread/package.json b/packages/code-runtime/code-runtime-worker-thread/package.json index e69ccc2f52..a31e670376 100644 --- a/packages/code-runtime/code-runtime-worker-thread/package.json +++ b/packages/code-runtime/code-runtime-worker-thread/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-code-runtime-worker-thread", "description": "Worker-thread implementation of the DeepSeek Harness code-execution seam", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/code-runtime/code-runtime/package.json b/packages/code-runtime/code-runtime/package.json index a49f2cf0a9..4321c52d38 100644 --- a/packages/code-runtime/code-runtime/package.json +++ b/packages/code-runtime/code-runtime/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-code-runtime", "description": "Abstract code-execution seam (ctx.codeRuntime) for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/compaction/command-compact/package.json b/packages/compaction/command-compact/package.json index faffbe4943..a18140fa85 100644 --- a/packages/compaction/command-compact/package.json +++ b/packages/compaction/command-compact/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-command-compact", "description": "Human-facing slash command for explicit session compaction", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/compaction/compaction-basic/package.json b/packages/compaction/compaction-basic/package.json index 69de3038dd..8de83e4f12 100644 --- a/packages/compaction/compaction-basic/package.json +++ b/packages/compaction/compaction-basic/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-compaction-basic", "description": "Token-meter-driven compaction policy and LLM summarization backend for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/compaction/compaction-tool-result-pruner/package.json b/packages/compaction/compaction-tool-result-pruner/package.json index 3cf8b5d169..57dd414347 100644 --- a/packages/compaction/compaction-tool-result-pruner/package.json +++ b/packages/compaction/compaction-tool-result-pruner/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-compaction-tool-result-pruner", "description": "Replay-safe model-free head/middle/tail pruning for tool-result surface nodes", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/compaction/compaction/package.json b/packages/compaction/compaction/package.json index 54ad37fdd1..110298ffbf 100644 --- a/packages/compaction/compaction/package.json +++ b/packages/compaction/compaction/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-compaction", "description": "Abstract compaction service seam (ctx.compaction) for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/context/agent-instructions/package.json b/packages/context/agent-instructions/package.json index 6c94153e57..a9b57dc9c0 100644 --- a/packages/context/agent-instructions/package.json +++ b/packages/context/agent-instructions/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-agent-instructions", "description": "Workspace context loader for AGENTS.md/CLAUDE.md instruction files", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/context/file-reference-local/package.json b/packages/context/file-reference-local/package.json index 8f419495dd..cb46191bc6 100644 --- a/packages/context/file-reference-local/package.json +++ b/packages/context/file-reference-local/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-file-reference-local", "description": "Local-filesystem ctx.fileReferences provider with bounded fuzzy indexes", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/context/file-reference/package.json b/packages/context/file-reference/package.json index c33a4cfece..890676082d 100644 --- a/packages/context/file-reference/package.json +++ b/packages/context/file-reference/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-file-reference", "description": "File-reference discovery contract and shared @file grammar", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/context/session-reference/package.json b/packages/context/session-reference/package.json index 444f4f5d7e..c5899f1094 100644 --- a/packages/context/session-reference/package.json +++ b/packages/context/session-reference/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-reference", "description": "Cross-session snapshot references and durable untrusted model context (ctx.sessionReferenceResolver)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/context/time-context/package.json b/packages/context/time-context/package.json index 1d6e5a374c..634bfc2058 100644 --- a/packages/context/time-context/package.json +++ b/packages/context/time-context/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-time-context", "description": "Opt-in durable per-step context with the current time and elapsed time", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/context/tmux-context/package.json b/packages/context/tmux-context/package.json index 113aa345c3..9a3696c994 100644 --- a/packages/context/tmux-context/package.json +++ b/packages/context/tmux-context/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tmux-context", "description": "Opt-in durable per-step context with this agent's tmux pane and window location", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/core/agent-default-model/package.json b/packages/core/agent-default-model/package.json index 409b297f35..02f25d90b0 100644 --- a/packages/core/agent-default-model/package.json +++ b/packages/core/agent-default-model/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-agent-default-model", "description": "Default model selection shared by Agent entry points", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/core/agent-loop/package.json b/packages/core/agent-loop/package.json index d73c8085ea..627c46ff44 100644 --- a/packages/core/agent-loop/package.json +++ b/packages/core/agent-loop/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-agent-loop", "description": "The concrete agent loop plugin for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/core/agent-tool-presentation/package.json b/packages/core/agent-tool-presentation/package.json index 55f24b532e..b1069260d4 100644 --- a/packages/core/agent-tool-presentation/package.json +++ b/packages/core/agent-tool-presentation/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-agent-tool-presentation", "description": "Agent-plane presentation selector: composes one agent's tools as PTC mode, native, or both", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/core/agent/package.json b/packages/core/agent/package.json index 2df9571f97..e654ac0d2f 100644 --- a/packages/core/agent/package.json +++ b/packages/core/agent/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-agent", "description": "Agent interface, registry, initiator scope, and event vocabulary for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/core/scope/package.json b/packages/core/scope/package.json index 2922794f45..bb0d51aa0e 100644 --- a/packages/core/scope/package.json +++ b/packages/core/scope/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-scope", "description": "Scoped-context registration primitive (scope tags, scope-filtered event dispatch) for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/core/session/package.json b/packages/core/session/package.json index 65db598136..7b7858cb3d 100644 --- a/packages/core/session/package.json +++ b/packages/core/session/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session", "description": "Event-sourced session store for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/core/system-prompt/package.json b/packages/core/system-prompt/package.json index 7ca95e44c7..cb431d3fbd 100644 --- a/packages/core/system-prompt/package.json +++ b/packages/core/system-prompt/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-system-prompt", "description": "System prompt assembly registry for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/core/tools/package.json b/packages/core/tools/package.json index ebb966cb43..174d6f6902 100644 --- a/packages/core/tools/package.json +++ b/packages/core/tools/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tools", "description": "Tool registry and execution pipeline for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/credentials/authorization/package.json b/packages/credentials/authorization/package.json index 728f091539..2bfb81078c 100644 --- a/packages/credentials/authorization/package.json +++ b/packages/credentials/authorization/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-authorization", "description": "Authorization seam (ctx.authorization): plugin-owned flows that obtain a credential through a conversation with the human", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/credentials/credentials-local/package.json b/packages/credentials/credentials-local/package.json index 4bd2a9daa0..5e0a6ce461 100644 --- a/packages/credentials/credentials-local/package.json +++ b/packages/credentials/credentials-local/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-credentials-local", "description": "File-backed credentials provider ($DSH_HOME/.env under the live process environment) for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/credentials/credentials/package.json b/packages/credentials/credentials/package.json index 0ccc71df24..d41f37d3ec 100644 --- a/packages/credentials/credentials/package.json +++ b/packages/credentials/credentials/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-credentials", "description": "Abstract credential seam (ctx.credentials): settings carry references to secrets, providers own the values", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/e2b/e2b/package.json b/packages/e2b/e2b/package.json index efcaa3d50c..373e619db7 100644 --- a/packages/e2b/e2b/package.json +++ b/packages/e2b/e2b/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-e2b", "description": "Shared E2B sandbox lifecycle for DeepSeek Harness provider adapters", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/e2b/fs-e2b/package.json b/packages/e2b/fs-e2b/package.json index c646180f50..e63f687f60 100644 --- a/packages/e2b/fs-e2b/package.json +++ b/packages/e2b/fs-e2b/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-fs-e2b", "description": "E2B filesystem implementation for DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/e2b/subprocess-e2b/package.json b/packages/e2b/subprocess-e2b/package.json index e75003e983..a5f999e7d5 100644 --- a/packages/e2b/subprocess-e2b/package.json +++ b/packages/e2b/subprocess-e2b/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-subprocess-e2b", "description": "E2B subprocess implementation for DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/experimental/agent-team-profile/package.json b/packages/experimental/agent-team-profile/package.json index 699ebc29ec..219b268ddd 100644 --- a/packages/experimental/agent-team-profile/package.json +++ b/packages/experimental/agent-team-profile/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-experimental-agent-team-profile", "description": "Experimental profile bundle enabling Agent Teams over dsh-base", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/experimental/agent-team-web-profile/package.json b/packages/experimental/agent-team-web-profile/package.json index 4ca780b18c..48ea6d71ba 100644 --- a/packages/experimental/agent-team-web-profile/package.json +++ b/packages/experimental/agent-team-web-profile/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-experimental-agent-team-web-profile", "description": "Experimental Web profile layer for Agent Teams Remote and UI plugins", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/experimental/agent-team/package.json b/packages/experimental/agent-team/package.json index dee4fc8756..5f04d02601 100644 --- a/packages/experimental/agent-team/package.json +++ b/packages/experimental/agent-team/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-experimental-agent-team", "description": "Implicit-root Agent Teams roster, durable peer mailbox, and shared task DAG", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/experimental/client-ui-agent-team/package.json b/packages/experimental/client-ui-agent-team/package.json index 12fa3b7275..3584f6493c 100644 --- a/packages/experimental/client-ui-agent-team/package.json +++ b/packages/experimental/client-ui-agent-team/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-experimental-client-ui-agent-team", "description": "Web Agent Teams roster, task board, and teammate navigation", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/experimental/code-runtime-python/package.json b/packages/experimental/code-runtime-python/package.json index b179c1a16b..7db8fe5dfe 100644 --- a/packages/experimental/code-runtime-python/package.json +++ b/packages/experimental/code-runtime-python/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-experimental-code-runtime-python", "description": "CPython subprocess implementation of the DeepSeek Harness code-execution seam", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "repository": { "type": "git", "url": "git+https://github.com/deepseek-ai/deepseek-harness.git", diff --git a/packages/experimental/inspector/package.json b/packages/experimental/inspector/package.json index e195c6f09a..a9c1e10725 100644 --- a/packages/experimental/inspector/package.json +++ b/packages/experimental/inspector/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-experimental-inspector", "description": "Experimental cross-realm CDP hub for Host debugging and Client Runtime inspection", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "private": true, "repository": { "type": "git", diff --git a/packages/experimental/tool-agent-team/package.json b/packages/experimental/tool-agent-team/package.json index eb41e65d5f..fb5779f90c 100644 --- a/packages/experimental/tool-agent-team/package.json +++ b/packages/experimental/tool-agent-team/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-experimental-tool-agent-team", "description": "Scoped model-facing Agent Teams tools over ctx.agentTeams", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/experimental/webworker-packer/package.json b/packages/experimental/webworker-packer/package.json index ba52e9e94e..264e8edea7 100644 --- a/packages/experimental/webworker-packer/package.json +++ b/packages/experimental/webworker-packer/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-experimental-webworker-packer", "description": "Build-time packer for the browser runtime's base VFS image and ordered data-overlay archives", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "private": true, "repository": { "type": "git", diff --git a/packages/experimental/webworker-runtime/package.json b/packages/experimental/webworker-runtime/package.json index a1a54e1e0f..a0d088ce71 100644 --- a/packages/experimental/webworker-runtime/package.json +++ b/packages/experimental/webworker-runtime/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-experimental-webworker-runtime", "description": "Browser-only harness runtime: in-memory VFS, module transform and loader, postMessage tunnel, and the dedicated Web Worker assembly, with the Node-compatibility layer that lets the host tree run unchanged", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "private": true, "repository": { "type": "git", diff --git a/packages/extensions/cordis-client-runner/package.json b/packages/extensions/cordis-client-runner/package.json index b6b0e3c9ac..c57e78e8ab 100644 --- a/packages/extensions/cordis-client-runner/package.json +++ b/packages/extensions/cordis-client-runner/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-cordis-client-runner", "description": "Browser half of dynamic dual-half plugin packages: event subscription, closure evaluation, guard facade, and loader entries", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/extensions/cordis-host-runner/package.json b/packages/extensions/cordis-host-runner/package.json index c673c2faaf..53e27100c2 100644 --- a/packages/extensions/cordis-host-runner/package.json +++ b/packages/extensions/cordis-host-runner/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-cordis-host-runner", "description": "Dynamic package definition registry, host-half sandbox lifecycle, and invoke handler table for model-mounted dual-half packages", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/extensions/tool-cordis/package.json b/packages/extensions/tool-cordis/package.json index 1499e1db10..da941bf469 100644 --- a/packages/extensions/tool-cordis/package.json +++ b/packages/extensions/tool-cordis/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-cordis", "description": "Self-referential cordis toolset: inspect the live runtime, mount and dispose model-written plugins", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/extensions/ui-cordis/package.json b/packages/extensions/ui-cordis/package.json index 20b473f2f6..07b34e3d7b 100644 --- a/packages/extensions/ui-cordis/package.json +++ b/packages/extensions/ui-cordis/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-ui-cordis", "description": "Cordis dynamic-plugin definition card: the keyed cordis_define tool row with its run/stop switch", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/feedback/command-feedback/package.json b/packages/feedback/command-feedback/package.json index 39e700ddae..357e06639c 100644 --- a/packages/feedback/command-feedback/package.json +++ b/packages/feedback/command-feedback/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-command-feedback", "description": "Log-only session feedback: the record event, the sessionFeedback Host Remote, and the human-facing slash command", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/feedback/message-feedback/package.json b/packages/feedback/message-feedback/package.json index 456800ba92..7b0031ab1f 100644 --- a/packages/feedback/message-feedback/package.json +++ b/packages/feedback/message-feedback/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-message-feedback", "description": "Canonical Session-log ratings and notes for finalized assistant messages", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/fs/fs-local/package.json b/packages/fs/fs-local/package.json index ea0ba6695b..3b7492c05b 100644 --- a/packages/fs/fs-local/package.json +++ b/packages/fs/fs-local/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-fs-local", "description": "Local-filesystem implementation of the DeepSeek Harness filesystem seam (ctx.fs)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/fs/fs-observation-policy/package.json b/packages/fs/fs-observation-policy/package.json index 4e59ada1ac..bb2f3d986f 100644 --- a/packages/fs/fs-observation-policy/package.json +++ b/packages/fs/fs-observation-policy/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-fs-observation-policy", "description": "File-context policy plugin for the DeepSeek Harness — observed-state, read-before-edit, and version-guarded write/edit added over the ctx.fs provider seam through the fs/* event gate (no service API)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/fs/fs-sandbox/package.json b/packages/fs/fs-sandbox/package.json index 841e8ca041..f1eda99e86 100644 --- a/packages/fs/fs-sandbox/package.json +++ b/packages/fs/fs-sandbox/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-fs-sandbox", "description": "Sandbox-enforcing implementation of the DeepSeek Harness filesystem seam: fences write/edit by the per-call sandbox mode (read-only denies mutation, workspace-write contains it to the workspace + temp roots) while reads pass through", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/fs/fs/package.json b/packages/fs/fs/package.json index 6d4a55441d..4944f3f7db 100644 --- a/packages/fs/fs/package.json +++ b/packages/fs/fs/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-fs", "description": "Abstract filesystem capability seam (ctx.fs) for the DeepSeek Harness — vocabulary types, the FileSystem service (text IO + optional version-guarded atomic mutations), and the fs/* policy event vocabulary", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/fs/tool-fs-search/package.json b/packages/fs/tool-fs-search/package.json index 5d9842a174..db3715b502 100644 --- a/packages/fs/tool-fs-search/package.json +++ b/packages/fs/tool-fs-search/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-fs-search", "description": "Model-facing filesystem discovery tools (glob, grep) backed by the packaged ripgrep binary (@vscode/ripgrep)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/fs/tool-fs/package.json b/packages/fs/tool-fs/package.json index e44c7a7f07..062a553050 100644 --- a/packages/fs/tool-fs/package.json +++ b/packages/fs/tool-fs/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-fs", "description": "Model-facing filesystem tools (read, write, edit) over the DeepSeek Harness filesystem seam (ctx.fs)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/fs/tool-present/package.json b/packages/fs/tool-present/package.json index d1847ded9d..0baffa2345 100644 --- a/packages/fs/tool-present/package.json +++ b/packages/fs/tool-present/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-present", "description": "Explicit workspace file delivery declarations for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/fs/tool-str-replace-editor/package.json b/packages/fs/tool-str-replace-editor/package.json index 9eb68b3a95..669f8da8a5 100644 --- a/packages/fs/tool-str-replace-editor/package.json +++ b/packages/fs/tool-str-replace-editor/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-str-replace-editor", "description": "Model-facing view, create, literal replace, and line insert tool over the Harness filesystem service", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/goal/command-goal/package.json b/packages/goal/command-goal/package.json index 238a65e732..c279129914 100644 --- a/packages/goal/command-goal/package.json +++ b/packages/goal/command-goal/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-command-goal", "description": "Human-facing slash command for persisted same-session goals", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/goal/goal-round-driver/package.json b/packages/goal/goal-round-driver/package.json index 7fe8fb72ff..43704663e2 100644 --- a/packages/goal/goal-round-driver/package.json +++ b/packages/goal/goal-round-driver/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-goal-round-driver", "description": "Race-fenced same-session goal-round driver", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/goal/goal/package.json b/packages/goal/goal/package.json index 4558efc896..013acc8c31 100644 --- a/packages/goal/goal/package.json +++ b/packages/goal/goal/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-goal", "description": "Event-sourced same-session goal state and lifecycle service for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/goal/tool-goal/package.json b/packages/goal/tool-goal/package.json index 1204bbee09..c6836cf722 100644 --- a/packages/goal/tool-goal/package.json +++ b/packages/goal/tool-goal/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-goal", "description": "Model-facing same-session goal tools with execution-time authority checks", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/guard/repeat-tool-reminder/package.json b/packages/guard/repeat-tool-reminder/package.json index 9f4876b47c..76a61f7a6d 100644 --- a/packages/guard/repeat-tool-reminder/package.json +++ b/packages/guard/repeat-tool-reminder/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-repeat-tool-reminder", "description": "Repeat-tool-call guard plugin: advisory reminders when an agent loops on identical tool calls", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/guard/timeout-policy/package.json b/packages/guard/timeout-policy/package.json index 59f19a67ad..50c9064807 100644 --- a/packages/guard/timeout-policy/package.json +++ b/packages/guard/timeout-policy/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-call-timeout-policy", "description": "Tool-call timeout policy: a tools/execute wrapper that arms a per-tool deadline on exec.signal and returns TOOL_TIMEOUT when it wins", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/hooks/hook-protocol/package.json b/packages/hooks/hook-protocol/package.json index 90fa06db8d..953ff92fce 100644 --- a/packages/hooks/hook-protocol/package.json +++ b/packages/hooks/hook-protocol/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-hook-protocol", "description": "Shared Claude Code / Codex hook wire protocol: matcher engine, stdin/exit-code/stdout codec, multi-hook merge, and hook/* session events", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/hooks/hooks-claude-code/package.json b/packages/hooks/hooks-claude-code/package.json index 6b7cd0594b..8e77285198 100644 --- a/packages/hooks/hooks-claude-code/package.json +++ b/packages/hooks/hooks-claude-code/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-hooks-claude-code", "description": "Bridge plugin: run a Claude Code hooks.json / settings hook config on the DeepSeek Harness interception seams", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/hooks/hooks-codex/package.json b/packages/hooks/hooks-codex/package.json index 4da41ec1da..846f035e97 100644 --- a/packages/hooks/hooks-codex/package.json +++ b/packages/hooks/hooks-codex/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-hooks-codex", "description": "Bridge plugin: run a Codex hooks.json hook config on the DeepSeek Harness interception seams", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/host/directory-picker-auto/package.json b/packages/host/directory-picker-auto/package.json index 68d31835d3..32278ecaba 100644 --- a/packages/host/directory-picker-auto/package.json +++ b/packages/host/directory-picker-auto/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-host-directory-picker-auto", "description": "Adaptive chooser of the directory-picker seam: resolves the host situation at boot and mounts the native or browse backend for the DeepSeek Harness web GUI host", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/host/directory-picker-browse/package.json b/packages/host/directory-picker-browse/package.json index 66198388ae..8ea96e6341 100644 --- a/packages/host/directory-picker-browse/package.json +++ b/packages/host/directory-picker-browse/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-host-directory-picker-browse", "description": "In-app browsing backend of the directory-picker seam (listing/creation primitives over the host filesystem)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/host/directory-picker-native/package.json b/packages/host/directory-picker-native/package.json index 9e1547073c..b6bb6d9110 100644 --- a/packages/host/directory-picker-native/package.json +++ b/packages/host/directory-picker-native/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-host-directory-picker-native", "description": "Native-OS-chooser backend of the directory-picker seam for the DeepSeek Harness web GUI host", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/host/directory-picker/package.json b/packages/host/directory-picker/package.json index 10d3b4e2a0..ef0e68372d 100644 --- a/packages/host/directory-picker/package.json +++ b/packages/host/directory-picker/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-host-directory-picker", "description": "Abstract workspace-directory picking seam (ctx.directoryPicker) for the DeepSeek Harness web GUI host", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/host/frontend-static/package.json b/packages/host/frontend-static/package.json index f1413302a0..e348e08d2a 100644 --- a/packages/host/frontend-static/package.json +++ b/packages/host/frontend-static/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-host-frontend-static", "description": "SPA dist server for the Web shell: owns the webserver fallback seat, serving explicit index entries and static assets with traversal rejection and 404 misses", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/host/open-in-app/package.json b/packages/host/open-in-app/package.json index ceb0c74b33..c88582a6fd 100644 --- a/packages/host/open-in-app/package.json +++ b/packages/host/open-in-app/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-host-open-in-app", "description": "Host half of open-in-app: resolved application catalog, icons, and the launch endpoint as three webServer routes", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/host/plugin-inventory/package.json b/packages/host/plugin-inventory/package.json index a3bdbe1e8f..65ed93c1d9 100644 --- a/packages/host/plugin-inventory/package.json +++ b/packages/host/plugin-inventory/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-host-plugin-inventory", "description": "Read-only Remote projection of current Cordis Loader plugin state", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/host/webserver/package.json b/packages/host/webserver/package.json index 01c1dd58aa..96ab1c4704 100644 --- a/packages/host/webserver/package.json +++ b/packages/host/webserver/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-host-webserver", "description": "Web route-registration plugin: HTTP and upgrade routes, index transform taps, and static dist fallback; knows no harness concepts", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/identity/anonymous-user-id/package.json b/packages/identity/anonymous-user-id/package.json index 1873a8dbb7..2d9d2d82b4 100644 --- a/packages/identity/anonymous-user-id/package.json +++ b/packages/identity/anonymous-user-id/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-anonymous-user-id", "description": "Shared anonymous user identity for DeepSeek Harness telemetry and feedback correlation", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/interaction/commands/package.json b/packages/interaction/commands/package.json index c29b99c7f0..1fe03def46 100644 --- a/packages/interaction/commands/package.json +++ b/packages/interaction/commands/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-commands", "description": "Plugin-owned human command registry for DeepSeek Harness UIs", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/interaction/permission-presets/package.json b/packages/interaction/permission-presets/package.json index fb5c7cd1aa..ef46950a5b 100644 --- a/packages/interaction/permission-presets/package.json +++ b/packages/interaction/permission-presets/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-permission-presets", "description": "User-facing permission presets (ctx.permissionPresets) for the DeepSeek Harness: one product-level Permissions select bundling the sandbox-mode and approval-policy knobs, written through to their own session events", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/interaction/tool-ask-user/package.json b/packages/interaction/tool-ask-user/package.json index bcc4d7c002..91b43a476d 100644 --- a/packages/interaction/tool-ask-user/package.json +++ b/packages/interaction/tool-ask-user/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-ask-user", "description": "Model-facing ask_user_question tool over the ctx.userQuestions seam", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/interaction/user-approval/package.json b/packages/interaction/user-approval/package.json index 786ac6f456..30ac058e29 100644 --- a/packages/interaction/user-approval/package.json +++ b/packages/interaction/user-approval/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-user-approval", "description": "User-approval seam (ctx.approval) for the DeepSeek Harness: one-shot permission decisions dispatched to composed answerers over the approval/request waterfall, fail-closed by default", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/interaction/user-questions/package.json b/packages/interaction/user-questions/package.json index c65c17c91d..c9936649b9 100644 --- a/packages/interaction/user-questions/package.json +++ b/packages/interaction/user-questions/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-user-questions", "description": "Abstract user-questions seam (ctx.userQuestions) for asking the human during agent runs", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/jobs/jobs-local/package.json b/packages/jobs/jobs-local/package.json index 208bb4f66e..5a262665d7 100644 --- a/packages/jobs/jobs-local/package.json +++ b/packages/jobs/jobs-local/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-jobs-local", "description": "Process-local implementation of the DeepSeek Harness background job registry seam", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/jobs/jobs/package.json b/packages/jobs/jobs/package.json index 94744c6a2a..b567121e03 100644 --- a/packages/jobs/jobs/package.json +++ b/packages/jobs/jobs/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-jobs", "description": "Background job registry (ctx.jobs) for the DeepSeek Harness — shared ids, owner isolation, polling, cancellation, and completion listeners for long-running tool work", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/jobs/tool-jobs/package.json b/packages/jobs/tool-jobs/package.json index d908add0a6..03615aea99 100644 --- a/packages/jobs/tool-jobs/package.json +++ b/packages/jobs/tool-jobs/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-jobs", "description": "Model-facing background job control tools (job_output, job_list, job_kill) over the ctx.jobs registry", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/llm/deepseek-llm-api-extensions/package.json b/packages/llm/deepseek-llm-api-extensions/package.json index 24804f96db..411cd64bba 100644 --- a/packages/llm/deepseek-llm-api-extensions/package.json +++ b/packages/llm/deepseek-llm-api-extensions/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-deepseek-llm-api-extensions", "description": "Additive request-field registry for the official DeepSeek LLM API adapter", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/llm/llm-deepseek/package.json b/packages/llm/llm-deepseek/package.json index b10ec1ff14..f9a8d5c09a 100644 --- a/packages/llm/llm-deepseek/package.json +++ b/packages/llm/llm-deepseek/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-llm-deepseek", "description": "DeepSeek chat-completions adapter for the DeepSeek Harness LLM seam", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/llm/llm-pi-ai/package.json b/packages/llm/llm-pi-ai/package.json index 28652bf860..2c7d5ca5c6 100644 --- a/packages/llm/llm-pi-ai/package.json +++ b/packages/llm/llm-pi-ai/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-llm-pi-ai", "description": "pi-ai-backed DeepSeek adapter for the DeepSeek Harness LLM seam (design-verification twin of dsh-llm-deepseek)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/llm/llm-retry/package.json b/packages/llm/llm-retry/package.json index 5e3fef8315..b0033c09a7 100644 --- a/packages/llm/llm-retry/package.json +++ b/packages/llm/llm-retry/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-llm-retry", "description": "Provider-routed LLM request retry policy for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/llm/llm/package.json b/packages/llm/llm/package.json index 73235b3521..9e4a322e0b 100644 --- a/packages/llm/llm/package.json +++ b/packages/llm/llm/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-llm", "description": "Provider-neutral LLM service interface for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/llm/plugin-package-inventory-deepseek/package.json b/packages/llm/plugin-package-inventory-deepseek/package.json index 16cd26163a..46193fec94 100644 --- a/packages/llm/plugin-package-inventory-deepseek/package.json +++ b/packages/llm/plugin-package-inventory-deepseek/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-plugin-package-inventory-deepseek", "description": "Active Loader-backed plugin package inventory for official DeepSeek LLM API requests", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/llm/token-meter/package.json b/packages/llm/token-meter/package.json index 5a19084762..983f61a42f 100644 --- a/packages/llm/token-meter/package.json +++ b/packages/llm/token-meter/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-token-meter", "description": "Replay-aware token measurement service (ctx.tokenMeter) for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/lsp/lsp-stdio/package.json b/packages/lsp/lsp-stdio/package.json index 99f8f79231..5ede6bd195 100644 --- a/packages/lsp/lsp-stdio/package.json +++ b/packages/lsp/lsp-stdio/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-lsp-stdio", "description": "Generic stdio language-server provider for the DeepSeek Harness LSP capability seam (ctx.lsp) — spawns configured servers, translates JSON-RPC, and serves transient-open goToDefinition/findReferences/goToImplementation/hover queries in the host filesystem namespace", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/lsp/lsp/package.json b/packages/lsp/lsp/package.json index 175508a801..71a7be6754 100644 --- a/packages/lsp/lsp/package.json +++ b/packages/lsp/lsp/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-lsp", "description": "Abstract LSP capability seam (ctx.lsp) for the DeepSeek Harness — language-server provider registry keyed by branded id and extension mapping, order-independent per-query selection, normalized definition/references/implementation/hover requests and results, and the LspError taxonomy", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/lsp/tool-lsp/package.json b/packages/lsp/tool-lsp/package.json index aef7b01bc8..2cb4805bc0 100644 --- a/packages/lsp/tool-lsp/package.json +++ b/packages/lsp/tool-lsp/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-lsp", "description": "Model-facing lsp tool over the DeepSeek Harness LSP capability seam (ctx.lsp) — one read-only tool with goToDefinition/findReferences/goToImplementation/hover operations, one-based UTF-16 cursor coordinates, bounded location rendering, and hover normalization", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/mcp/mcp-client/package.json b/packages/mcp/mcp-client/package.json index 3cc384ca25..b4d921a813 100644 --- a/packages/mcp/mcp-client/package.json +++ b/packages/mcp/mcp-client/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-mcp-client", "description": "MCP client bridge: connects to MCP servers and registers their tools on ctx.tools", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/plan/plan-mode/package.json b/packages/plan/plan-mode/package.json index cab618dccd..759f290dda 100644 --- a/packages/plan/plan-mode/package.json +++ b/packages/plan/plan-mode/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-plan-mode", "description": "Logged per-agent plan mode with deployment guidance, a direct slash command, and a user-reviewed exit", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/preset/agent-presets/package.json b/packages/preset/agent-presets/package.json index a632b21ee0..e6a026225a 100644 --- a/packages/preset/agent-presets/package.json +++ b/packages/preset/agent-presets/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-agent-presets", "description": "Per-session agent composition from preset cordis.yml files for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/preset/persona/package.json b/packages/preset/persona/package.json index ec81978b55..ac69830a75 100644 --- a/packages/preset/persona/package.json +++ b/packages/preset/persona/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-persona", "description": "Composition-authored deployment persona section for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/runtime-diagnostics/invariants/package.json b/packages/runtime-diagnostics/invariants/package.json index 4666c078d5..6dcf6f5517 100644 --- a/packages/runtime-diagnostics/invariants/package.json +++ b/packages/runtime-diagnostics/invariants/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-invariants", "description": "Registry service for package-owned DeepSeek Harness runtime invariants", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/sandbox/sandbox-local/package.json b/packages/sandbox/sandbox-local/package.json index c9a5618507..02200c0e13 100644 --- a/packages/sandbox/sandbox-local/package.json +++ b/packages/sandbox/sandbox-local/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-sandbox-local", "description": "Local process-sandbox backends for the DeepSeek Harness sandbox seam: bwrap, the npm-distributed landlock-run launcher, macOS Seatbelt, or the Windows ACL restricted-token runner — functionally probed, fail-closed", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/sandbox/sandbox-policy/package.json b/packages/sandbox/sandbox-policy/package.json index 7a21457c90..3f59b340c6 100644 --- a/packages/sandbox/sandbox-policy/package.json +++ b/packages/sandbox/sandbox-policy/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-sandbox-policy", "description": "Per-call sandbox policy resolver and current model context: deployment fallbacks plus each session's mode and workspace root, shared by every enforcing capability family", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/sandbox/sandbox-windows-acl/package.json b/packages/sandbox/sandbox-windows-acl/package.json index 27ca514db8..5de9c52edf 100644 --- a/packages/sandbox/sandbox-windows-acl/package.json +++ b/packages/sandbox/sandbox-windows-acl/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-sandbox-windows-acl", "description": "Windows ACL write-restriction sandbox backend (restricted-token spawn with capability-SID write allowlist) for the DeepSeek Harness sandbox seam", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/sandbox/sandbox/package.json b/packages/sandbox/sandbox/package.json index 02c4e0eee8..f817a85049 100644 --- a/packages/sandbox/sandbox/package.json +++ b/packages/sandbox/sandbox/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-sandbox", "description": "Abstract process-sandbox seam (ctx.sandbox) for the DeepSeek Harness: same-world confinement vocabulary and the SandboxProvider contract", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/schedule/schedule/package.json b/packages/schedule/schedule/package.json index 78fac782ec..37fa4589c9 100644 --- a/packages/schedule/schedule/package.json +++ b/packages/schedule/schedule/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-schedule", "description": "Agent-scoped durable after, at, and fixed-rate reminders over the session event log", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/sdk/client/package.json b/packages/sdk/client/package.json index 5534f7028e..f3f9321ca3 100644 --- a/packages/sdk/client/package.json +++ b/packages/sdk/client/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-sdk-client", "description": "TypeScript client SDK for driving a DeepSeek Harness runtime subprocess over stdio JSON-RPC: the DeepSeekHarness high-level turns API and the lower-level HarnessClient", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/sdk/protocol/package.json b/packages/sdk/protocol/package.json index 145a79d7a7..753fa4ac1e 100644 --- a/packages/sdk/protocol/package.json +++ b/packages/sdk/protocol/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-sdk-protocol", "description": "Shared wire protocol for the DeepSeek Harness SDK runtime: the newline-delimited JSON-RPC stdio transport and the named request, result, and notification types spoken between the runtime server and SDK clients", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/sdk/server/package.json b/packages/sdk/server/package.json index 58920ce23b..aaf98612ea 100644 --- a/packages/sdk/server/package.json +++ b/packages/sdk/server/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-sdk-jsonrpc-server", "description": "Stdio JSON-RPC server plugin for out-of-process DeepSeek Harness SDK clients", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session-query/session-log-export/package.json b/packages/session-query/session-log-export/package.json index e107281710..91966f3773 100644 --- a/packages/session-query/session-log-export/package.json +++ b/packages/session-query/session-log-export/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-log-export", "description": "Web Session-log export command and shared download dialog", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session-query/session-query-sqlite/package.json b/packages/session-query/session-query-sqlite/package.json index 560e1056cf..01d3178e31 100644 --- a/packages/session-query/session-query-sqlite/package.json +++ b/packages/session-query/session-query-sqlite/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-query-sqlite", "description": "Concrete ctx.sessionQuery backend with SQLite FTS5 search", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session-query/session-query/package.json b/packages/session-query/session-query/package.json index 80e928341b..6141578ea4 100644 --- a/packages/session-query/session-query/package.json +++ b/packages/session-query/session-query/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-query", "description": "Combined session query service contract with concrete reads, traces, and filters", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session-query/tool-session-query/package.json b/packages/session-query/tool-session-query/package.json index b54d4eae26..e3244c2e76 100644 --- a/packages/session-query/tool-session-query/package.json +++ b/packages/session-query/tool-session-query/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-session-query", "description": "Workspace-authorized model-facing session history search, trace, and event read tools", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-checkpoint-policy/package.json b/packages/session/session-checkpoint-policy/package.json index f59985e5b3..796e177b29 100644 --- a/packages/session/session-checkpoint-policy/package.json +++ b/packages/session/session-checkpoint-policy/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-checkpoint-policy", "description": "Semantic session durability checkpoints before model requests and tool side effects", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-format-catalog/package.json b/packages/session/session-format-catalog/package.json index b2f197c13c..56406e219b 100644 --- a/packages/session/session-format-catalog/package.json +++ b/packages/session/session-format-catalog/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-format-catalog", "description": "Build-static first-party Session format codec and migration catalog", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-format-v0-to-v1/package.json b/packages/session/session-format-v0-to-v1/package.json index 58e4b3f677..42f7f1c4a9 100644 --- a/packages/session/session-format-v0-to-v1/package.json +++ b/packages/session/session-format-v0-to-v1/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-format-v0-to-v1", "description": "Frozen released-v0 Session codec and identity migration to v1", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-format-v1-to-v2/package.json b/packages/session/session-format-v1-to-v2/package.json index b44f957bfd..11955848ea 100644 --- a/packages/session/session-format-v1-to-v2/package.json +++ b/packages/session/session-format-v1-to-v2/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-format-v1-to-v2", "description": "Frozen released-v1 Session codec and assistant-stream migration to v2", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-format-v2-to-v3/package.json b/packages/session/session-format-v2-to-v3/package.json index 99b1ca46d8..4c0c17815e 100644 --- a/packages/session/session-format-v2-to-v3/package.json +++ b/packages/session/session-format-v2-to-v3/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-format-v2-to-v3", "description": "Streaming system-prompt, canonical-envelope and PTC migration into V3", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-format/package.json b/packages/session/session-format/package.json index 069a8c2e95..cc55b09ce3 100644 --- a/packages/session/session-format/package.json +++ b/packages/session/session-format/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-format", "description": "Streaming adjacent Session format migration machinery", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-log-deepseek/package.json b/packages/session/session-log-deepseek/package.json index 9dfdf7e6dd..3c7f0e65fc 100644 --- a/packages/session/session-log-deepseek/package.json +++ b/packages/session/session-log-deepseek/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-log-deepseek", "description": "Incremental lossless session-log request extension for the official DeepSeek LLM API", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-persistence-jsonl/package.json b/packages/session/session-persistence-jsonl/package.json index 0233f1c4e5..11f50ba97a 100644 --- a/packages/session/session-persistence-jsonl/package.json +++ b/packages/session/session-persistence-jsonl/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-persistence-jsonl", "description": "JSONL durable session persistence backend for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-persistence/package.json b/packages/session/session-persistence/package.json index 00c06bd87b..36f7009ebd 100644 --- a/packages/session/session-persistence/package.json +++ b/packages/session/session-persistence/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-persistence", "description": "Abstract durable session persistence seam (ctx.sessionPersistence) for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-projection-cache/package.json b/packages/session/session-projection-cache/package.json index 4572668791..7d9cd2587e 100644 --- a/packages/session/session-projection-cache/package.json +++ b/packages/session/session-projection-cache/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-projection-cache", "description": "Persisted projection cache (ctx.sessionProjectionCache): durable per-session checkpoint records on the session_projcache storage domain (per-record layout), throttled write-behind, and the cached listing read", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-projection/package.json b/packages/session/session-projection/package.json index 0820666165..e36e2dc4a8 100644 --- a/packages/session/session-projection/package.json +++ b/packages/session/session-projection/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-projection", "description": "Session-projection seam: the merge-extensible projection type table, the provider contract, and the ctx.sessionProjections registry serving whole current values of log-derived per-session state", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-stats/package.json b/packages/session/session-stats/package.json index 507f87a96b..cfaf57382b 100644 --- a/packages/session/session-stats/package.json +++ b/packages/session/session-stats/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-stats", "description": "Whole-log conversation counts and wall times projection (sessionStats) for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-telemetry-otel/package.json b/packages/session/session-telemetry-otel/package.json index 707e536ad4..51bb035943 100644 --- a/packages/session/session-telemetry-otel/package.json +++ b/packages/session/session-telemetry-otel/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-telemetry-otel", "description": "OpenTelemetry backend for the DeepSeek Harness telemetry seam: hands captured session records to the OTel JS SDK's log pipeline", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-telemetry/package.json b/packages/session/session-telemetry/package.json index a7e1b7c31a..7927c46409 100644 --- a/packages/session/session-telemetry/package.json +++ b/packages/session/session-telemetry/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-telemetry", "description": "SessionTelemetryBackend seam for the DeepSeek Harness: session-event capture, projection, redaction, and handoff to a reporting backend", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-title-all-prompts-llm/package.json b/packages/session/session-title-all-prompts-llm/package.json index 730c1d46de..c51f74eed9 100644 --- a/packages/session/session-title-all-prompts-llm/package.json +++ b/packages/session/session-title-all-prompts-llm/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-title-all-prompts-llm", "description": "All-user-messages LLM provider plugin for DeepSeek Harness session titles", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-title-first-prompt-llm/package.json b/packages/session/session-title-first-prompt-llm/package.json index 14343665f7..3a3717fcc7 100644 --- a/packages/session/session-title-first-prompt-llm/package.json +++ b/packages/session/session-title-first-prompt-llm/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-title-first-prompt-llm", "description": "First-message LLM provider plugin for DeepSeek Harness session titles", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-title-llm/package.json b/packages/session/session-title-llm/package.json index 2a13d395ca..89cd217004 100644 --- a/packages/session/session-title-llm/package.json +++ b/packages/session/session-title-llm/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-title-llm", "description": "Shared LLM generation policy for DeepSeek Harness session-title providers", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-title/package.json b/packages/session/session-title/package.json index 4f244531e9..79170df18d 100644 --- a/packages/session/session-title/package.json +++ b/packages/session/session-title/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-title", "description": "Log-backed session title service and provider registry for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/session/session-turn-outline/package.json b/packages/session/session-turn-outline/package.json index 711e009430..892bd66c9b 100644 --- a/packages/session/session-turn-outline/package.json +++ b/packages/session/session-turn-outline/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-turn-outline", "description": "Whole-log turn outline projection (turnOutline) for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/settings/settings-file/package.json b/packages/settings/settings-file/package.json index f0eb2ddb46..5a91ea8a02 100644 --- a/packages/settings/settings-file/package.json +++ b/packages/settings/settings-file/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-settings-file", "description": "File-backed settings provider (settings.yaml) for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/settings/settings/package.json b/packages/settings/settings/package.json index c7a2fbec40..55343abb6c 100644 --- a/packages/settings/settings/package.json +++ b/packages/settings/settings/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-settings", "description": "Abstract user-settings seam (ctx.settings) for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/shell/bash-local/package.json b/packages/shell/bash-local/package.json index 9359c2de1b..0f1b558a61 100644 --- a/packages/shell/bash-local/package.json +++ b/packages/shell/bash-local/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-bash-local", "description": "Local-subprocess implementation of the DeepSeek Harness bash executor seam", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/shell/bash-sandbox/package.json b/packages/shell/bash-sandbox/package.json index 7ea041a1a5..d7405f3cc4 100644 --- a/packages/shell/bash-sandbox/package.json +++ b/packages/shell/bash-sandbox/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-bash-sandbox", "description": "Sandbox-consuming implementation of the DeepSeek Harness bash executor seam (confines every command via ctx.sandbox, reports denial/enforcement result facts)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/shell/pwsh-local/package.json b/packages/shell/pwsh-local/package.json index ebea606ae7..7b102e4c30 100644 --- a/packages/shell/pwsh-local/package.json +++ b/packages/shell/pwsh-local/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-pwsh-local", "description": "Local PowerShell implementation of the DeepSeek Harness bash executor seam", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/shell/pwsh-sandbox/package.json b/packages/shell/pwsh-sandbox/package.json index bc911347ea..6d5185ef9b 100644 --- a/packages/shell/pwsh-sandbox/package.json +++ b/packages/shell/pwsh-sandbox/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-pwsh-sandbox", "description": "Sandbox-consuming implementation of the DeepSeek Harness PowerShell executor seam (confines every command via ctx.sandbox, reports denial/enforcement result facts)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/shell/shell-env/package.json b/packages/shell/shell-env/package.json index 3558307a0c..e0b4fb2368 100644 --- a/packages/shell/shell-env/package.json +++ b/packages/shell/shell-env/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-shell-env", "description": "Tool-independent managed DSH_* shell environment registry", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/shell/shell/package.json b/packages/shell/shell/package.json index 6fce0fb257..88503f4385 100644 --- a/packages/shell/shell/package.json +++ b/packages/shell/shell/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-shell", "description": "Abstract bash executor seam (ctx.shell) for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/shell/tool-bash-persistent/package.json b/packages/shell/tool-bash-persistent/package.json index 7b817703b5..a8c99b3c5c 100644 --- a/packages/shell/tool-bash-persistent/package.json +++ b/packages/shell/tool-bash-persistent/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-bash-persistent", "description": "Model-facing owner-scoped persistent Bash tool backed by the Harness PTY service", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/shell/tool-bash/package.json b/packages/shell/tool-bash/package.json index 3ed1a01a9f..c8648afd57 100644 --- a/packages/shell/tool-bash/package.json +++ b/packages/shell/tool-bash/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-bash", "description": "Model-facing bash tool with optional generic background-job and sandbox-escalation support", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/shell/tool-pwsh-persistent/package.json b/packages/shell/tool-pwsh-persistent/package.json index 780948e7a0..c42a4bde52 100644 --- a/packages/shell/tool-pwsh-persistent/package.json +++ b/packages/shell/tool-pwsh-persistent/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-pwsh-persistent", "description": "Model-facing owner-scoped persistent PowerShell tool backed by the Harness PTY service", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/shell/tool-pwsh/package.json b/packages/shell/tool-pwsh/package.json index 7c003409c2..b01b2e3cd9 100644 --- a/packages/shell/tool-pwsh/package.json +++ b/packages/shell/tool-pwsh/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-pwsh", "description": "Model-facing pwsh tool over the bash executor seam", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/skill/skill-badge/package.json b/packages/skill/skill-badge/package.json index c5db5bbec3..1fd637dabb 100644 --- a/packages/skill/skill-badge/package.json +++ b/packages/skill/skill-badge/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-skill-badge", "description": "Bundled dsh badge skill provider for DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/skill/skill-filesystem/package.json b/packages/skill/skill-filesystem/package.json index 09dc51f2dd..484c7ea0e1 100644 --- a/packages/skill/skill-filesystem/package.json +++ b/packages/skill/skill-filesystem/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-skill-filesystem", "description": "Local filesystem skill provider for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/skill/skill/package.json b/packages/skill/skill/package.json index 8705f3481f..56154b531d 100644 --- a/packages/skill/skill/package.json +++ b/packages/skill/skill/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-skill", "description": "Agent skill provider registry for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/skill/tool-skill/package.json b/packages/skill/tool-skill/package.json index 633473717e..120876880c 100644 --- a/packages/skill/tool-skill/package.json +++ b/packages/skill/tool-skill/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-skill", "description": "Model-facing skill loading tool for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/spill/spill-local/package.json b/packages/spill/spill-local/package.json index 7cc5eda514..089535ff13 100644 --- a/packages/spill/spill-local/package.json +++ b/packages/spill/spill-local/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-spill-local", "description": "Local-filesystem implementation of the DeepSeek Harness spill storage seam (private session-scoped files)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/spill/spill-policy/package.json b/packages/spill/spill-policy/package.json index 9990cdf288..d3a0ed5eb6 100644 --- a/packages/spill/spill-policy/package.json +++ b/packages/spill/spill-policy/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-spill-policy", "description": "Tool-result spill policy for the DeepSeek Harness — replaces oversized plain-text tool results with a retained preview plus a spill-file path (no service API)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/spill/spill/package.json b/packages/spill/spill/package.json index eeedb76373..651531bf82 100644 --- a/packages/spill/spill/package.json +++ b/packages/spill/spill/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-spill", "description": "Abstract spill storage seam (ctx.spillStore) for the DeepSeek Harness — save oversized tool text and return a retrieval locator", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/storage/storage-domain/package.json b/packages/storage/storage-domain/package.json index ab2bc8c205..dbbd79571c 100644 --- a/packages/storage/storage-domain/package.json +++ b/packages/storage/storage-domain/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-storage-domain", "description": "Domain data form (ctx.storage.domain): schema-validated, event-emitting KV domains over storage backends for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/storage/storage-json/package.json b/packages/storage/storage-json/package.json index f35b45d72f..4e79b26fc0 100644 --- a/packages/storage/storage-json/package.json +++ b/packages/storage/storage-json/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-storage-json", "description": "JSON file KV storage backend for the DeepSeek Harness storage hub", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/storage/storage-sqlite/package.json b/packages/storage/storage-sqlite/package.json index 00797f7c07..638ad2e283 100644 --- a/packages/storage/storage-sqlite/package.json +++ b/packages/storage/storage-sqlite/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-storage-sqlite", "description": "SQLite storage backend (kv facet) for the DeepSeek Harness storage hub", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/storage/storage/package.json b/packages/storage/storage/package.json index 471ac26288..c45cc74a11 100644 --- a/packages/storage/storage/package.json +++ b/packages/storage/storage/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-storage", "description": "Storage hub (ctx.storage): named backend registry plus mounted data-form facilities for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/subagent/subagent-acp/package.json b/packages/subagent/subagent-acp/package.json index 4c6faca8b0..6e42076bc3 100644 --- a/packages/subagent/subagent-acp/package.json +++ b/packages/subagent/subagent-acp/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-subagent-acp", "description": "Out-of-process ACP subagent backend: drives a child agent in a spawned subprocess over the Agent Client Protocol", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/subagent/subagent-claude-code/package.json b/packages/subagent/subagent-claude-code/package.json index f4f1daea88..b4e328eff0 100644 --- a/packages/subagent/subagent-claude-code/package.json +++ b/packages/subagent/subagent-claude-code/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-subagent-claude-code", "description": "One-shot Claude Code subagent provider over the official Agent SDK", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/subagent/subagent-codex/package.json b/packages/subagent/subagent-codex/package.json index e25cfd69f8..79bda26eec 100644 --- a/packages/subagent/subagent-codex/package.json +++ b/packages/subagent/subagent-codex/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-subagent-codex", "description": "One-shot Codex subagent provider over the official app-server protocol", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/subagent/subagent-dsh-sdk/package.json b/packages/subagent/subagent-dsh-sdk/package.json index 43fbea39e5..505ee00c38 100644 --- a/packages/subagent/subagent-dsh-sdk/package.json +++ b/packages/subagent/subagent-dsh-sdk/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-subagent-dsh-sdk", "description": "Out-of-process SDK subagent backend: drives a child DeepSeek Harness runtime subprocess over stdio JSON-RPC through the TypeScript SDK client", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/subagent/subagent-fork-in-process/package.json b/packages/subagent/subagent-fork-in-process/package.json index 6c4c040b9b..2deb14834d 100644 --- a/packages/subagent/subagent-fork-in-process/package.json +++ b/packages/subagent/subagent-fork-in-process/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-subagent-fork-in-process", "description": "In-process fork subagent backend: runs a child agent seeded with a prefix of the parent's log", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/subagent/subagent-in-process-driver/package.json b/packages/subagent/subagent-in-process-driver/package.json index 51c6b2240b..ee7d0febc4 100644 --- a/packages/subagent/subagent-in-process-driver/package.json +++ b/packages/subagent/subagent-in-process-driver/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-subagent-in-process-driver", "description": "Shared in-process subagent run driver: drives a child agent on ctx.agents (used by the spawn and fork backends)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/subagent/subagent-spawn-in-process/package.json b/packages/subagent/subagent-spawn-in-process/package.json index 7f0b7f2dba..73fd12c1fc 100644 --- a/packages/subagent/subagent-spawn-in-process/package.json +++ b/packages/subagent/subagent-spawn-in-process/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-subagent-spawn-in-process", "description": "In-process spawn subagent backend: runs a fresh child agent on ctx.agents", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/subagent/subagent/package.json b/packages/subagent/subagent/package.json index 22e000973f..319d9ecbe5 100644 --- a/packages/subagent/subagent/package.json +++ b/packages/subagent/subagent/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-subagent", "description": "Abstract subagent seam (ctx.subagents): named-provider registry for delegating to child agents", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/subagent/tool-subagent-control/package.json b/packages/subagent/tool-subagent-control/package.json index 71d256c372..667f86351b 100644 --- a/packages/subagent/tool-subagent-control/package.json +++ b/packages/subagent/tool-subagent-control/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-subagent-control", "description": "Globally named send_message, interrupt_agent, and list_agents tools over ctx.subagents continuations", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/subagent/tool-subagent/package.json b/packages/subagent/tool-subagent/package.json index 119d39ad1b..284c093f12 100644 --- a/packages/subagent/tool-subagent/package.json +++ b/packages/subagent/tool-subagent/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-subagent", "description": "Model-facing subagent delegation tool over the ctx.subagents seam", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/subprocess/subprocess-local/package.json b/packages/subprocess/subprocess-local/package.json index 5b19229c75..7465d787f9 100644 --- a/packages/subprocess/subprocess-local/package.json +++ b/packages/subprocess/subprocess-local/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-subprocess-local", "description": "Local-subprocess implementation of the DeepSeek Harness subprocess seam", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/subprocess/subprocess/package.json b/packages/subprocess/subprocess/package.json index 627077a52a..2f20d3a6f9 100644 --- a/packages/subprocess/subprocess/package.json +++ b/packages/subprocess/subprocess/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-subprocess", "description": "Subprocess seam (ctx.subprocess) for the DeepSeek Harness — managed process groups, bounded spill-backed output, and escalated kills behind one abstract service", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/subprocess/win32-process/package.json b/packages/subprocess/win32-process/package.json index a7b3a2fbb1..28fc6c2685 100644 --- a/packages/subprocess/win32-process/package.json +++ b/packages/subprocess/win32-process/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-win32-process", "description": "Shared low-level Win32 process, stdio, and Job Object primitives", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/terminal/terminal-bash/package.json b/packages/terminal/terminal-bash/package.json index 92f346a595..c433ad9375 100644 --- a/packages/terminal/terminal-bash/package.json +++ b/packages/terminal/terminal-bash/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-terminal-bash", "description": "Persistent shell PTY backend over the DeepSeek Harness subprocess terminal primitive", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/terminal/terminal/package.json b/packages/terminal/terminal/package.json index 4a65ed9e29..ec2fc7c719 100644 --- a/packages/terminal/terminal/package.json +++ b/packages/terminal/terminal/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-terminal", "description": "Persistent PTY session seam for the DeepSeek Harness — owner-scoped ids, backend registry, interactive sends, reads, signals, and awaited cleanup", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/terminal/tool-terminal/package.json b/packages/terminal/tool-terminal/package.json index c0e1707fc6..bfcbeddef1 100644 --- a/packages/terminal/tool-terminal/package.json +++ b/packages/terminal/tool-terminal/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-terminal", "description": "Six model-facing persistent PTY tools with owner isolation and generic background-job integration", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/test-support/agent-loop-testkit/package.json b/packages/test-support/agent-loop-testkit/package.json index 7bc3890fec..1e2eb18ee4 100644 --- a/packages/test-support/agent-loop-testkit/package.json +++ b/packages/test-support/agent-loop-testkit/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-agent-loop-testkit", "description": "Prerequisite mounting, production AgentLoop drivers, and Inbox stubs for tests", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/test-support/client-runtime/package.json b/packages/test-support/client-runtime/package.json index 88298cd72b..326a78083a 100644 --- a/packages/test-support/client-runtime/package.json +++ b/packages/test-support/client-runtime/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-client-test-runtime", "description": "jsdom slot test runtime: real Cordis Context + SlotRegistry + UI renderer with test-owned session/workspace doubles for feature specs", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/test-support/llm-mock-server/package.json b/packages/test-support/llm-mock-server/package.json index 09076a4f03..70538bbbad 100644 --- a/packages/test-support/llm-mock-server/package.json +++ b/packages/test-support/llm-mock-server/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-llm-mock-server", "description": "Scriptable OpenAI-compatible HTTP/SSE fault server for LLM recovery tests", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/test-support/llm-replay/package.json b/packages/test-support/llm-replay/package.json index f5281eb4f5..54e9d293b0 100644 --- a/packages/test-support/llm-replay/package.json +++ b/packages/test-support/llm-replay/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-llm-replay", "description": "Replay LLM plugin: short-circuits llm/stream with model chunks reconstructed from a recorded session JSONL (keyless snapshot tests)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/test-support/loader-smoke/package.json b/packages/test-support/loader-smoke/package.json index f158d852c0..2d435c9d9e 100644 --- a/packages/test-support/loader-smoke/package.json +++ b/packages/test-support/loader-smoke/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-loader-smoke", "description": "Shared subprocess and direct-agent harness for keyless real-Loader example smoke tests", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/test-support/session-snapshot/package.json b/packages/test-support/session-snapshot/package.json index 8bf4945353..1b4576dccc 100644 --- a/packages/test-support/session-snapshot/package.json +++ b/packages/test-support/session-snapshot/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-session-snapshot", "description": "Session-log snapshot core with an ACP protocol adapter, expected-output normalization, and fixture invariants", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/todo/tool-todo/package.json b/packages/todo/tool-todo/package.json index d539bfd420..863345c42a 100644 --- a/packages/todo/tool-todo/package.json +++ b/packages/todo/tool-todo/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-todo", "description": "Model-facing todo_write tool over the DeepSeek Harness event-sourced session log", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/typert/generator/package.json b/packages/typert/generator/package.json index 8f4052432c..8ef779b90c 100644 --- a/packages/typert/generator/package.json +++ b/packages/typert/generator/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-typert-generator", "description": "TypeScript project analyzer and model-driven Typert artifact generator", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/typert/loader/package.json b/packages/typert/loader/package.json index 99873e3c8c..1e58aa5723 100644 --- a/packages/typert/loader/package.json +++ b/packages/typert/loader/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-typert-loader", "description": "Loader integration for generated Typert package contributions", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/typert/protocol/package.json b/packages/typert/protocol/package.json index 128a91015b..67b30c4377 100644 --- a/packages/typert/protocol/package.json +++ b/packages/typert/protocol/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-typert-protocol", "description": "Compiler-independent Remote metadata and Typert provider protocols", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/typert/registry/package.json b/packages/typert/registry/package.json index 57cc0269b7..2392b2f0c4 100644 --- a/packages/typert/registry/package.json +++ b/packages/typert/registry/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-typert-registry", "description": "Runtime registry for generated package reflection and Zod schemas", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/atomic-write/package.json b/packages/util/atomic-write/package.json index debc1821e2..c18e75ac26 100644 --- a/packages/util/atomic-write/package.json +++ b/packages/util/atomic-write/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-atomic-write", "description": "Zero-dependency atomic file replacement: exclusive-create random-suffix temp + rename carrying the caller-stated permissions (writeFileAtomic)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/brand/package.json b/packages/util/brand/package.json index eb8f05ad2b..a7c8974297 100644 --- a/packages/util/brand/package.json +++ b/packages/util/brand/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-brand", "description": "Stateless branded primitive types for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/chunked-list/package.json b/packages/util/chunked-list/package.json index 2a3fc316da..f27dee18f1 100644 --- a/packages/util/chunked-list/package.json +++ b/packages/util/chunked-list/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-chunked-list", "description": "Persistent append-only chunked lists with bounded copying and JSON checkpoint validation", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/crypto/package.json b/packages/util/crypto/package.json index 29c97db176..3e54890d57 100644 --- a/packages/util/crypto/package.json +++ b/packages/util/crypto/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-util-crypto", "description": "Zero-dependency browser-safe UUID and byte-encoding helpers", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/deque/package.json b/packages/util/deque/package.json index 9e770c6ebc..bdea147fb7 100644 --- a/packages/util/deque/package.json +++ b/packages/util/deque/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-deque", "description": "Zero-dependency circular deque with amortized constant-time end operations and bounded vacant storage", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/home-paths/package.json b/packages/util/home-paths/package.json index e2248ef6d4..34291f69ba 100644 --- a/packages/util/home-paths/package.json +++ b/packages/util/home-paths/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-home-paths", "description": "Shared filesystem path helpers for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/http-proxy/package.json b/packages/util/http-proxy/package.json index 557ff05008..4091676849 100644 --- a/packages/util/http-proxy/package.json +++ b/packages/util/http-proxy/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-http-proxy", "description": "Process-wide outbound HTTP proxy policy for DeepSeek Harness: resolve it from the launch environment and install it as undici's global dispatcher", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/launch-environment/package.json b/packages/util/launch-environment/package.json index 05721e99de..69c88ef587 100644 --- a/packages/util/launch-environment/package.json +++ b/packages/util/launch-environment/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-launch-environment", "description": "Immutable DeepSeek Harness launch environment that records which layer supplied each value", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/native-command/package.json b/packages/util/native-command/package.json index ff25cef7b4..32b2562fd5 100644 --- a/packages/util/native-command/package.json +++ b/packages/util/native-command/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-native-command", "description": "Host-native command and path-opening utilities with shell-free execution, cancellation, desktop detection, and WSL handoff", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/output-retention/package.json b/packages/util/output-retention/package.json index 60f35e488c..ab3f8c5143 100644 --- a/packages/util/output-retention/package.json +++ b/packages/util/output-retention/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-output-retention", "description": "Zero-dependency bounded-retention primitive: ItemRetainer/TextRetainer + neutral notice helpers (what did we keep, what did we omit)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/package-manifest/package.json b/packages/util/package-manifest/package.json index d5ac0e87bc..57e6beceda 100644 --- a/packages/util/package-manifest/package.json +++ b/packages/util/package-manifest/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-package-manifest", "description": "Shared type declarations for package.json.dsh configuration fields", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/time/package.json b/packages/util/time/package.json index 396b587e04..20b7468982 100644 --- a/packages/util/time/package.json +++ b/packages/util/time/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-util-time", "description": "Zero-dependency time vocabulary shared by wire boundaries: canonicalClientTimeZone (IANA zone validation and canonicalization only, no formatting)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/timeout/package.json b/packages/util/timeout/package.json index 52601ba8e9..35500070eb 100644 --- a/packages/util/timeout/package.json +++ b/packages/util/timeout/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-timeout", "description": "Zero-dependency timeout/deadline primitive: clampTimeout, deadline, timeoutOf, TimeoutReason (timing + classification only, no termination)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/values/package.json b/packages/util/values/package.json index 0caecde0da..8b08968d19 100644 --- a/packages/util/values/package.json +++ b/packages/util/values/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-util-values", "description": "Duplicate-install-safe value primitives for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/util/workspace-path/package.json b/packages/util/workspace-path/package.json index 52831afa03..2d9f7d4cb7 100644 --- a/packages/util/workspace-path/package.json +++ b/packages/util/workspace-path/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-util-workspace-path", "description": "Browser-safe Workspace path and display helpers", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/web/tool-web/package.json b/packages/web/tool-web/package.json index 00029269e1..463248c787 100644 --- a/packages/web/tool-web/package.json +++ b/packages/web/tool-web/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-web", "description": "Model-facing web tools (web_search, web_fetch) over the DeepSeek Harness web capability seam (ctx.web)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/web/web-fetch-http/package.json b/packages/web/web-fetch-http/package.json index 69deb08084..2c52a4b0f7 100644 --- a/packages/web/web-fetch-http/package.json +++ b/packages/web/web-fetch-http/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-web-fetch-http", "description": "Anonymous public HTTP(S) fetch provider for the DeepSeek Harness web capability seam (ctx.web)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/web/web-search-deepseek/package.json b/packages/web/web-search-deepseek/package.json index 01ac736fcc..6e7ef73ca2 100644 --- a/packages/web/web-search-deepseek/package.json +++ b/packages/web/web-search-deepseek/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-web-search-deepseek", "description": "DeepSeek-backed search provider (native web_search via the Anthropic-compatible API) for the DeepSeek Harness web capability seam (ctx.web)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/web/web-search-exa/package.json b/packages/web/web-search-exa/package.json index e50850670a..daefc8d2d3 100644 --- a/packages/web/web-search-exa/package.json +++ b/packages/web/web-search-exa/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-web-search-exa", "description": "Exa-backed search provider for the DeepSeek Harness web capability seam (ctx.web)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/web/web-search-perplexity/package.json b/packages/web/web-search-perplexity/package.json index 8d58b9d76c..819966ac3a 100644 --- a/packages/web/web-search-perplexity/package.json +++ b/packages/web/web-search-perplexity/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-web-search-perplexity", "description": "Perplexity-backed search provider for the DeepSeek Harness web capability seam (ctx.web)", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/web/web/package.json b/packages/web/web/package.json index 7afab4d2bb..75b51cae79 100644 --- a/packages/web/web/package.json +++ b/packages/web/web/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-web", "description": "Abstract web access capability seam (ctx.web) for the DeepSeek Harness — search/fetch provider registry, registration-order-independent selection, request/result vocabulary, and the WebError taxonomy", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/webhook/webhook-github/package.json b/packages/webhook/webhook-github/package.json index 8ad3788e28..81b8c9cdeb 100644 --- a/packages/webhook/webhook-github/package.json +++ b/packages/webhook/webhook-github/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-webhook-github", "description": "Signed GitHub HTTP webhook adapter for the DeepSeek Harness webhook runtime", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/webhook/webhook/package.json b/packages/webhook/webhook/package.json index 27baa443ce..ee8416fe68 100644 --- a/packages/webhook/webhook/package.json +++ b/packages/webhook/webhook/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-webhook", "description": "Fire-and-forget webhook rule runtime that creates Workspace-backed DeepSeek Harness Sessions", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/workflow/tool-ralph/package.json b/packages/workflow/tool-ralph/package.json index 23921d85c6..a1b6609049 100644 --- a/packages/workflow/tool-ralph/package.json +++ b/packages/workflow/tool-ralph/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-ralph", "description": "Model-facing fresh-agent Ralph loop over the workflow and subagent seams", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/workflow/tool-workflow/package.json b/packages/workflow/tool-workflow/package.json index 71f9830317..06cb66d839 100644 --- a/packages/workflow/tool-workflow/package.json +++ b/packages/workflow/tool-workflow/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-tool-workflow", "description": "Model-facing workflow tool: run a JavaScript orchestration script over ctx.workflowEngine", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/workflow/workflow-worker-thread/package.json b/packages/workflow/workflow-worker-thread/package.json index 030baacd98..2a91e2d2dc 100644 --- a/packages/workflow/workflow-worker-thread/package.json +++ b/packages/workflow/workflow-worker-thread/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-workflow-worker-thread", "description": "worker-thread workflow engine: executes model-written orchestration scripts off the host event loop, bridging agent() calls back to ctx.subagents", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/workflow/workflow/package.json b/packages/workflow/workflow/package.json index c5f414941c..8e03f25a7c 100644 --- a/packages/workflow/workflow/package.json +++ b/packages/workflow/workflow/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-workflow", "description": "Workflow capability seam: ctx.workflowEngine service, run vocabulary, and workflow/* events", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, diff --git a/packages/workspace/workspace/package.json b/packages/workspace/workspace/package.json index 4a30eea728..bf1ad56f88 100644 --- a/packages/workspace/workspace/package.json +++ b/packages/workspace/workspace/package.json @@ -1,7 +1,7 @@ { "name": "@deepseek-ai/dsh-workspace", "description": "Workspace entity registry (ctx.workspaceRegistry): durable workspace records with validated session attachment over the domain data form for the DeepSeek Harness", - "version": "0.1.5-alpha.1", + "version": "0.1.5-alpha.2", "publishConfig": { "access": "public" }, From 8e8fb2fc6216c8acbadd83d20a99ff305c59775b Mon Sep 17 00:00:00 2001 From: j-xiang Date: Thu, 10 Sep 2026 00:21:32 +0800 Subject: [PATCH 15/32] docs(i18n): proofread bilingual README corpus --- apps/cli/README.i18n.yaml | 2 +- apps/cli/README.zh.md | 16 +++---- apps/cli/reference/README.i18n.yaml | 4 +- apps/cli/reference/README.md | 6 +-- apps/cli/reference/README.zh.md | 20 ++++---- apps/desktop/README.i18n.yaml | 2 +- apps/desktop/README.zh.md | 42 ++++++++-------- apps/web/tests/README.i18n.yaml | 4 +- apps/web/tests/README.md | 34 ++----------- apps/web/tests/README.zh.md | 26 ++-------- .../active-stream-reconnect/README.i18n.yaml | 2 +- .../active-stream-reconnect/README.zh.md | 4 +- .../agent-continuation/README.i18n.yaml | 2 +- benchmarks/agent-continuation/README.zh.md | 12 ++--- .../long-session-browser/README.i18n.yaml | 2 +- benchmarks/long-session-browser/README.zh.md | 8 ++-- docs/i18n/README.i18n.yaml | 2 +- docs/i18n/README.zh.md | 2 +- docs/subsystems/README.i18n.yaml | 2 +- docs/subsystems/README.zh.md | 26 +++++----- native/system/README.i18n.yaml | 2 +- native/system/README.zh.md | 10 ++-- .../packages/darwin-x64/README.i18n.yaml | 2 +- .../system/packages/darwin-x64/README.zh.md | 2 +- native/system/packages/entry/README.i18n.yaml | 2 +- native/system/packages/entry/README.zh.md | 4 +- .../packages/linux-arm64/README.i18n.yaml | 2 +- .../system/packages/linux-arm64/README.zh.md | 4 +- .../packages/linux-x64/README.i18n.yaml | 2 +- native/system/packages/linux-x64/README.zh.md | 4 +- packages/README.i18n.yaml | 2 +- packages/README.zh.md | 32 ++++++------- packages/acp/README.i18n.yaml | 2 +- packages/acp/README.zh.md | 8 ++-- packages/acp/acp/README.i18n.yaml | 4 +- packages/acp/acp/README.md | 6 +-- packages/acp/acp/README.zh.md | 22 ++++----- packages/api/README.i18n.yaml | 2 +- packages/api/README.zh.md | 12 ++--- packages/api/gateway/README.i18n.yaml | 2 +- packages/api/gateway/README.zh.md | 24 +++++----- packages/api/remotes/README.i18n.yaml | 4 +- packages/api/remotes/README.md | 4 +- packages/api/remotes/README.zh.md | 18 +++---- .../api/session-controller/README.i18n.yaml | 2 +- packages/api/session-controller/README.zh.md | 20 ++++---- .../api/settings-controller/README.i18n.yaml | 2 +- packages/api/settings-controller/README.zh.md | 12 ++--- .../api/workspace-controller/README.i18n.yaml | 2 +- .../api/workspace-controller/README.zh.md | 12 ++--- packages/api/workspace-files/README.i18n.yaml | 2 +- packages/api/workspace-files/README.zh.md | 8 ++-- packages/attachment/README.i18n.yaml | 4 +- packages/attachment/README.md | 2 +- packages/attachment/README.zh.md | 2 +- .../attachment-local/README.i18n.yaml | 4 +- .../attachment/attachment-local/README.md | 2 +- .../attachment/attachment-local/README.zh.md | 18 +++---- .../attachment/attachment/README.i18n.yaml | 4 +- packages/attachment/attachment/README.md | 4 +- packages/attachment/attachment/README.zh.md | 16 +++---- packages/boot/README.i18n.yaml | 2 +- packages/boot/README.zh.md | 2 +- packages/boot/app-boot/README.i18n.yaml | 2 +- packages/boot/app-boot/README.zh.md | 20 ++++---- packages/boot/cmdline/README.i18n.yaml | 2 +- packages/boot/cmdline/README.zh.md | 16 +++---- packages/bundle/README.i18n.yaml | 2 +- packages/bundle/README.zh.md | 14 +++--- packages/bundle/acp-app/README.i18n.yaml | 2 +- packages/bundle/acp-app/README.zh.md | 12 ++--- packages/bundle/base/README.i18n.yaml | 2 +- packages/bundle/base/README.zh.md | 14 +++--- packages/bundle/headless/README.i18n.yaml | 2 +- packages/bundle/headless/README.zh.md | 28 +++++------ packages/bundle/sdk-app/README.i18n.yaml | 2 +- packages/bundle/sdk-app/README.zh.md | 8 ++-- packages/bundle/sdk-minimal/README.i18n.yaml | 2 +- packages/bundle/sdk-minimal/README.zh.md | 16 +++---- packages/bundle/web-app/README.i18n.yaml | 2 +- packages/bundle/web-app/README.zh.md | 24 +++++----- packages/client/README.i18n.yaml | 2 +- packages/client/README.zh.md | 18 +++---- packages/client/connection/README.i18n.yaml | 2 +- packages/client/connection/README.zh.md | 14 +++--- packages/client/hmr/README.i18n.yaml | 4 +- packages/client/hmr/README.md | 4 +- packages/client/hmr/README.zh.md | 18 +++---- packages/client/locale/README.i18n.yaml | 2 +- packages/client/locale/README.zh.md | 34 ++++++------- packages/client/modules/README.i18n.yaml | 4 +- packages/client/modules/README.md | 6 +-- packages/client/modules/README.zh.md | 22 ++++----- packages/client/resources/README.i18n.yaml | 2 +- packages/client/resources/README.zh.md | 16 +++---- packages/client/store/README.i18n.yaml | 2 +- packages/client/store/README.zh.md | 12 ++--- .../client/ui-agent-preset/README.i18n.yaml | 2 +- packages/client/ui-agent-preset/README.zh.md | 20 ++++---- packages/client/ui-approval/README.i18n.yaml | 2 +- packages/client/ui-approval/README.zh.md | 2 +- .../client/ui-attachment/README.i18n.yaml | 4 +- packages/client/ui-attachment/README.md | 2 +- packages/client/ui-attachment/README.zh.md | 20 ++++---- .../client/ui-brand-official/README.i18n.yaml | 2 +- .../client/ui-brand-official/README.zh.md | 14 +++--- packages/client/ui-chat/README.i18n.yaml | 2 +- packages/client/ui-chat/README.zh.md | 20 ++++---- packages/client/ui-commands/README.i18n.yaml | 4 +- packages/client/ui-commands/README.md | 6 +-- packages/client/ui-commands/README.zh.md | 16 +++---- .../client/ui-conversation/README.i18n.yaml | 2 +- packages/client/ui-conversation/README.zh.md | 28 +++++------ .../client/ui-deliverables/README.i18n.yaml | 2 +- packages/client/ui-deliverables/README.zh.md | 26 +++++----- .../README.i18n.yaml | 2 +- .../ui-directory-picker-browse/README.zh.md | 4 +- .../README.i18n.yaml | 4 +- .../ui-directory-picker-native/README.md | 4 +- .../ui-directory-picker-native/README.zh.md | 24 +++++----- packages/client/ui-dockkit/README.i18n.yaml | 2 +- packages/client/ui-dockkit/README.zh.md | 20 ++++---- packages/client/ui-goal/README.i18n.yaml | 4 +- packages/client/ui-goal/README.md | 2 +- packages/client/ui-goal/README.zh.md | 16 +++---- .../client/ui-input-trigger/README.i18n.yaml | 2 +- packages/client/ui-input-trigger/README.zh.md | 18 +++---- packages/client/ui-jobs/README.i18n.yaml | 4 +- packages/client/ui-jobs/README.md | 4 +- packages/client/ui-jobs/README.zh.md | 22 ++++----- packages/client/ui-layout/README.i18n.yaml | 4 +- packages/client/ui-layout/README.md | 2 +- packages/client/ui-layout/README.zh.md | 18 +++---- .../ui-message-feedback/README.i18n.yaml | 2 +- .../client/ui-message-feedback/README.zh.md | 2 +- .../ui-model-selection/README.i18n.yaml | 4 +- packages/client/ui-model-selection/README.md | 4 +- .../client/ui-model-selection/README.zh.md | 18 +++---- .../client/ui-open-in-app/README.i18n.yaml | 2 +- packages/client/ui-open-in-app/README.zh.md | 12 ++--- .../ui-permission-presets/README.i18n.yaml | 4 +- .../client/ui-permission-presets/README.md | 6 +-- .../client/ui-permission-presets/README.zh.md | 18 +++---- packages/client/ui-plan/README.i18n.yaml | 2 +- packages/client/ui-plan/README.zh.md | 12 ++--- .../client/ui-primitives/README.i18n.yaml | 4 +- packages/client/ui-primitives/README.md | 4 +- packages/client/ui-primitives/README.zh.md | 26 +++++----- packages/client/ui-renderer/README.i18n.yaml | 2 +- packages/client/ui-renderer/README.zh.md | 10 ++-- packages/client/ui-schedule/README.i18n.yaml | 2 +- packages/client/ui-schedule/README.zh.md | 26 +++++----- packages/client/ui-session/README.i18n.yaml | 2 +- packages/client/ui-session/README.zh.md | 6 +-- .../ui-settings-general/README.i18n.yaml | 2 +- .../client/ui-settings-general/README.zh.md | 2 +- .../ui-settings-models/README.i18n.yaml | 2 +- .../client/ui-settings-models/README.zh.md | 2 +- .../README.i18n.yaml | 2 +- .../ui-settings-plugin-inventory/README.zh.md | 8 ++-- .../ui-settings-plugins/README.i18n.yaml | 2 +- .../client/ui-settings-plugins/README.zh.md | 10 ++-- .../README.i18n.yaml | 2 +- .../ui-sidebar-documentpreview/README.zh.md | 10 ++-- .../client/ui-sidebar-files/README.i18n.yaml | 2 +- packages/client/ui-sidebar-files/README.zh.md | 12 ++--- .../client/ui-sidebar-right/README.i18n.yaml | 2 +- packages/client/ui-sidebar-right/README.zh.md | 16 +++---- packages/client/ui-sidebar/README.i18n.yaml | 2 +- packages/client/ui-sidebar/README.zh.md | 10 ++-- packages/client/ui-skill/README.i18n.yaml | 4 +- packages/client/ui-skill/README.md | 2 +- packages/client/ui-skill/README.zh.md | 10 ++-- packages/client/ui-slots/README.i18n.yaml | 4 +- packages/client/ui-slots/README.md | 2 +- packages/client/ui-slots/README.zh.md | 14 +++--- packages/client/ui-subagent/README.i18n.yaml | 4 +- packages/client/ui-subagent/README.md | 4 +- packages/client/ui-subagent/README.zh.md | 4 +- packages/client/ui-theme/README.i18n.yaml | 2 +- packages/client/ui-theme/README.zh.md | 14 +++--- packages/client/ui-tool/README.i18n.yaml | 2 +- packages/client/ui-tool/README.zh.md | 16 +++---- .../client/ui-trajectory/README.i18n.yaml | 4 +- packages/client/ui-trajectory/README.md | 2 +- packages/client/ui-trajectory/README.zh.md | 14 +++--- .../client/ui-user-questions/README.i18n.yaml | 2 +- .../client/ui-user-questions/README.zh.md | 14 +++--- .../client/ui-workflow-run/README.i18n.yaml | 2 +- packages/client/ui-workflow-run/README.zh.md | 16 +++---- packages/client/ui-workspace/README.i18n.yaml | 4 +- packages/client/ui-workspace/README.md | 2 +- packages/client/ui-workspace/README.zh.md | 14 +++--- packages/client/web/README.i18n.yaml | 4 +- packages/client/web/README.md | 2 +- packages/client/web/README.zh.md | 12 ++--- packages/code-runtime/README.i18n.yaml | 4 +- packages/code-runtime/README.md | 2 +- packages/code-runtime/README.zh.md | 6 +-- .../README.i18n.yaml | 2 +- .../code-runtime-worker-thread/README.zh.md | 20 ++++---- .../code-runtime/README.i18n.yaml | 2 +- .../code-runtime/code-runtime/README.zh.md | 2 +- packages/compaction/README.i18n.yaml | 2 +- packages/compaction/README.zh.md | 4 +- .../command-compact/README.i18n.yaml | 2 +- .../compaction/command-compact/README.zh.md | 10 ++-- .../compaction-basic/README.i18n.yaml | 4 +- .../compaction/compaction-basic/README.md | 4 +- .../compaction/compaction-basic/README.zh.md | 14 +++--- .../README.i18n.yaml | 2 +- .../README.zh.md | 16 +++---- .../compaction/compaction/README.i18n.yaml | 4 +- packages/compaction/compaction/README.md | 8 ++-- packages/compaction/compaction/README.zh.md | 16 +++---- packages/context/README.i18n.yaml | 2 +- packages/context/README.zh.md | 16 +++---- .../agent-instructions/README.i18n.yaml | 4 +- packages/context/agent-instructions/README.md | 4 +- .../context/agent-instructions/README.zh.md | 16 +++---- .../file-reference-local/README.i18n.yaml | 2 +- .../context/file-reference-local/README.zh.md | 12 ++--- .../context/file-reference/README.i18n.yaml | 2 +- packages/context/file-reference/README.zh.md | 12 ++--- .../session-reference/README.i18n.yaml | 2 +- .../context/session-reference/README.zh.md | 26 +++++----- .../context/time-context/README.i18n.yaml | 4 +- packages/context/time-context/README.md | 4 +- packages/context/time-context/README.zh.md | 4 +- .../context/tmux-context/README.i18n.yaml | 4 +- packages/context/tmux-context/README.md | 6 +-- packages/context/tmux-context/README.zh.md | 16 +++---- packages/core/README.i18n.yaml | 2 +- packages/core/README.zh.md | 12 ++--- .../core/agent-default-model/README.i18n.yaml | 2 +- .../core/agent-default-model/README.zh.md | 12 ++--- packages/core/agent-loop/README.i18n.yaml | 4 +- packages/core/agent-loop/README.md | 4 +- packages/core/agent-loop/README.zh.md | 22 ++++----- .../agent-tool-presentation/README.i18n.yaml | 4 +- .../core/agent-tool-presentation/README.md | 2 +- .../core/agent-tool-presentation/README.zh.md | 8 ++-- packages/core/agent/README.i18n.yaml | 2 +- packages/core/agent/README.zh.md | 16 +++---- packages/core/scope/README.i18n.yaml | 2 +- packages/core/scope/README.zh.md | 10 ++-- packages/core/session/README.i18n.yaml | 4 +- packages/core/session/README.md | 4 +- packages/core/session/README.zh.md | 26 +++++----- packages/core/system-prompt/README.i18n.yaml | 2 +- packages/core/system-prompt/README.zh.md | 32 ++++++------- packages/core/tools/README.i18n.yaml | 4 +- packages/core/tools/README.md | 6 +-- packages/core/tools/README.zh.md | 6 +-- packages/credentials/README.i18n.yaml | 4 +- packages/credentials/README.md | 2 +- packages/credentials/README.zh.md | 6 +-- .../authorization/README.i18n.yaml | 2 +- .../credentials/authorization/README.zh.md | 14 +++--- .../credentials-local/README.i18n.yaml | 4 +- .../credentials/credentials-local/README.md | 4 +- .../credentials-local/README.zh.md | 16 +++---- .../credentials/credentials/README.i18n.yaml | 4 +- packages/credentials/credentials/README.md | 2 +- packages/credentials/credentials/README.zh.md | 16 +++---- packages/e2b/README.i18n.yaml | 2 +- packages/e2b/README.zh.md | 8 ++-- packages/e2b/e2b/README.i18n.yaml | 2 +- packages/e2b/e2b/README.zh.md | 16 +++---- packages/e2b/fs-e2b/README.i18n.yaml | 4 +- packages/e2b/fs-e2b/README.md | 2 +- packages/e2b/fs-e2b/README.zh.md | 16 +++---- packages/e2b/subprocess-e2b/README.i18n.yaml | 4 +- packages/e2b/subprocess-e2b/README.md | 2 +- packages/e2b/subprocess-e2b/README.zh.md | 10 ++-- packages/experimental/README.i18n.yaml | 2 +- packages/experimental/README.zh.md | 4 +- .../agent-team-profile/README.i18n.yaml | 2 +- .../agent-team-profile/README.zh.md | 12 ++--- .../agent-team-web-profile/README.i18n.yaml | 2 +- .../agent-team-web-profile/README.zh.md | 2 +- .../experimental/agent-team/README.i18n.yaml | 2 +- packages/experimental/agent-team/README.zh.md | 24 +++++----- .../client-ui-agent-team/README.i18n.yaml | 2 +- .../client-ui-agent-team/README.zh.md | 16 +++---- .../code-runtime-python/README.i18n.yaml | 2 +- .../code-runtime-python/README.zh.md | 11 +++-- .../experimental/inspector/README.i18n.yaml | 2 +- packages/experimental/inspector/README.zh.md | 38 +++++++-------- .../tool-agent-team/README.i18n.yaml | 2 +- .../experimental/tool-agent-team/README.zh.md | 22 ++++----- .../webworker-packer/README.i18n.yaml | 2 +- .../webworker-packer/README.zh.md | 22 ++++----- .../webworker-runtime/README.i18n.yaml | 2 +- .../webworker-runtime/README.zh.md | 10 ++-- packages/extensions/README.i18n.yaml | 4 +- packages/extensions/README.md | 2 +- packages/extensions/README.zh.md | 8 ++-- .../cordis-client-runner/README.i18n.yaml | 2 +- .../cordis-client-runner/README.zh.md | 4 +- .../cordis-host-runner/README.i18n.yaml | 2 +- .../cordis-host-runner/README.zh.md | 18 +++---- .../extensions/tool-cordis/README.i18n.yaml | 4 +- packages/extensions/tool-cordis/README.md | 2 +- packages/extensions/tool-cordis/README.zh.md | 22 ++++----- .../extensions/ui-cordis/README.i18n.yaml | 2 +- packages/extensions/ui-cordis/README.zh.md | 16 +++---- packages/feedback/README.i18n.yaml | 2 +- packages/feedback/README.zh.md | 8 ++-- .../command-feedback/README.i18n.yaml | 2 +- .../feedback/command-feedback/README.zh.md | 12 ++--- .../message-feedback/README.i18n.yaml | 4 +- packages/feedback/message-feedback/README.md | 4 +- .../feedback/message-feedback/README.zh.md | 20 ++++---- packages/fs/README.i18n.yaml | 2 +- packages/fs/README.zh.md | 4 +- packages/fs/fs-local/README.i18n.yaml | 4 +- packages/fs/fs-local/README.md | 4 +- packages/fs/fs-local/README.zh.md | 10 ++-- .../fs/fs-observation-policy/README.i18n.yaml | 4 +- packages/fs/fs-observation-policy/README.md | 6 +-- .../fs/fs-observation-policy/README.zh.md | 14 +++--- packages/fs/fs-sandbox/README.i18n.yaml | 4 +- packages/fs/fs-sandbox/README.md | 2 +- packages/fs/fs-sandbox/README.zh.md | 4 +- packages/fs/tool-fs-search/README.i18n.yaml | 2 +- packages/fs/tool-fs-search/README.zh.md | 8 ++-- packages/fs/tool-present/README.i18n.yaml | 2 +- packages/fs/tool-present/README.zh.md | 4 +- .../tool-str-replace-editor/README.i18n.yaml | 2 +- .../fs/tool-str-replace-editor/README.zh.md | 6 +-- packages/goal/README.i18n.yaml | 4 +- packages/goal/README.md | 4 +- packages/goal/README.zh.md | 14 +++--- packages/goal/command-goal/README.i18n.yaml | 2 +- packages/goal/command-goal/README.zh.md | 4 +- .../goal/goal-round-driver/README.i18n.yaml | 2 +- packages/goal/goal-round-driver/README.zh.md | 4 +- packages/goal/goal/README.i18n.yaml | 2 +- packages/goal/goal/README.zh.md | 14 +++--- packages/goal/tool-goal/README.i18n.yaml | 2 +- packages/goal/tool-goal/README.zh.md | 8 ++-- packages/guard/README.i18n.yaml | 4 +- packages/guard/README.md | 2 +- packages/guard/README.zh.md | 4 +- .../repeat-tool-reminder/README.i18n.yaml | 2 +- .../guard/repeat-tool-reminder/README.zh.md | 10 ++-- .../guard/timeout-policy/README.i18n.yaml | 4 +- packages/guard/timeout-policy/README.md | 2 +- packages/guard/timeout-policy/README.zh.md | 8 ++-- packages/hooks/README.i18n.yaml | 2 +- packages/hooks/README.zh.md | 6 +-- packages/hooks/hook-protocol/README.i18n.yaml | 2 +- packages/hooks/hook-protocol/README.zh.md | 10 ++-- .../hooks/hooks-claude-code/README.i18n.yaml | 4 +- packages/hooks/hooks-claude-code/README.md | 4 +- packages/hooks/hooks-claude-code/README.zh.md | 12 ++--- packages/hooks/hooks-codex/README.i18n.yaml | 2 +- packages/hooks/hooks-codex/README.zh.md | 4 +- packages/host/README.i18n.yaml | 4 +- packages/host/README.md | 2 +- packages/host/README.zh.md | 2 +- .../directory-picker-auto/README.i18n.yaml | 4 +- packages/host/directory-picker-auto/README.md | 2 +- .../host/directory-picker-auto/README.zh.md | 4 +- .../directory-picker-browse/README.i18n.yaml | 2 +- .../host/directory-picker-browse/README.zh.md | 10 ++-- .../directory-picker-native/README.i18n.yaml | 2 +- .../host/directory-picker-native/README.zh.md | 14 +++--- .../host/directory-picker/README.i18n.yaml | 4 +- packages/host/directory-picker/README.md | 2 +- packages/host/directory-picker/README.zh.md | 10 ++-- .../host/frontend-static/README.i18n.yaml | 2 +- packages/host/frontend-static/README.zh.md | 8 ++-- packages/host/open-in-app/README.i18n.yaml | 2 +- packages/host/open-in-app/README.zh.md | 12 ++--- .../host/plugin-inventory/README.i18n.yaml | 2 +- packages/host/plugin-inventory/README.zh.md | 14 +++--- packages/host/webserver/README.i18n.yaml | 2 +- packages/host/webserver/README.zh.md | 8 ++-- packages/identity/README.i18n.yaml | 2 +- packages/identity/README.zh.md | 4 +- .../anonymous-user-id/README.i18n.yaml | 4 +- packages/identity/anonymous-user-id/README.md | 6 +-- .../identity/anonymous-user-id/README.zh.md | 20 ++++---- packages/interaction/README.i18n.yaml | 4 +- packages/interaction/README.md | 2 +- packages/interaction/README.zh.md | 12 ++--- .../interaction/commands/README.i18n.yaml | 4 +- packages/interaction/commands/README.md | 2 +- packages/interaction/commands/README.zh.md | 20 ++++---- .../permission-presets/README.i18n.yaml | 2 +- .../permission-presets/README.zh.md | 10 ++-- .../tool-ask-user/README.i18n.yaml | 4 +- packages/interaction/tool-ask-user/README.md | 2 +- .../interaction/tool-ask-user/README.zh.md | 8 ++-- .../user-approval/README.i18n.yaml | 4 +- packages/interaction/user-approval/README.md | 2 +- .../interaction/user-approval/README.zh.md | 20 ++++---- .../user-questions/README.i18n.yaml | 4 +- packages/interaction/user-questions/README.md | 2 +- .../interaction/user-questions/README.zh.md | 4 +- packages/jobs/README.i18n.yaml | 2 +- packages/jobs/README.zh.md | 2 +- packages/jobs/jobs-local/README.i18n.yaml | 4 +- packages/jobs/jobs-local/README.md | 2 +- packages/jobs/jobs-local/README.zh.md | 6 +-- packages/jobs/jobs/README.i18n.yaml | 4 +- packages/jobs/jobs/README.md | 4 +- packages/jobs/jobs/README.zh.md | 14 +++--- packages/jobs/tool-jobs/README.i18n.yaml | 4 +- packages/jobs/tool-jobs/README.md | 4 +- packages/jobs/tool-jobs/README.zh.md | 16 +++---- packages/llm/README.i18n.yaml | 4 +- packages/llm/README.md | 2 +- packages/llm/README.zh.md | 8 ++-- .../README.i18n.yaml | 2 +- .../deepseek-llm-api-extensions/README.zh.md | 6 +-- packages/llm/llm-deepseek/README.i18n.yaml | 2 +- packages/llm/llm-deepseek/README.zh.md | 16 +++---- packages/llm/llm-pi-ai/README.i18n.yaml | 2 +- packages/llm/llm-pi-ai/README.zh.md | 18 +++---- packages/llm/llm-retry/README.i18n.yaml | 2 +- packages/llm/llm-retry/README.zh.md | 14 +++--- packages/llm/llm/README.i18n.yaml | 2 +- packages/llm/llm/README.zh.md | 16 +++---- .../README.i18n.yaml | 2 +- .../README.zh.md | 4 +- packages/llm/token-meter/README.i18n.yaml | 4 +- packages/llm/token-meter/README.md | 4 +- packages/llm/token-meter/README.zh.md | 16 +++---- packages/lsp/README.i18n.yaml | 2 +- packages/lsp/README.zh.md | 4 +- packages/lsp/lsp-stdio/README.i18n.yaml | 2 +- packages/lsp/lsp-stdio/README.zh.md | 6 +-- packages/lsp/lsp/README.i18n.yaml | 2 +- packages/lsp/lsp/README.zh.md | 6 +-- packages/lsp/tool-lsp/README.i18n.yaml | 2 +- packages/lsp/tool-lsp/README.zh.md | 10 ++-- packages/mcp/README.i18n.yaml | 2 +- packages/mcp/README.zh.md | 4 +- packages/mcp/mcp-client/README.i18n.yaml | 2 +- packages/mcp/mcp-client/README.zh.md | 22 ++++----- packages/plan/README.i18n.yaml | 2 +- packages/plan/README.zh.md | 8 ++-- packages/plan/plan-mode/README.i18n.yaml | 2 +- packages/plan/plan-mode/README.zh.md | 18 +++---- packages/preset/README.i18n.yaml | 2 +- packages/preset/README.zh.md | 6 +-- .../preset/agent-presets/README.i18n.yaml | 4 +- packages/preset/agent-presets/README.md | 2 +- packages/preset/agent-presets/README.zh.md | 12 ++--- packages/preset/persona/README.i18n.yaml | 2 +- packages/preset/persona/README.zh.md | 2 +- packages/runtime-diagnostics/README.i18n.yaml | 2 +- packages/runtime-diagnostics/README.zh.md | 6 +-- .../invariants/README.i18n.yaml | 2 +- .../invariants/README.zh.md | 24 +++++----- packages/sandbox/README.i18n.yaml | 2 +- packages/sandbox/README.zh.md | 8 ++-- .../sandbox/sandbox-local/README.i18n.yaml | 2 +- packages/sandbox/sandbox-local/README.zh.md | 8 ++-- .../sandbox/sandbox-policy/README.i18n.yaml | 2 +- packages/sandbox/sandbox-policy/README.zh.md | 16 +++---- .../sandbox-windows-acl/README.i18n.yaml | 2 +- .../sandbox/sandbox-windows-acl/README.zh.md | 6 +-- packages/sandbox/sandbox/README.i18n.yaml | 4 +- packages/sandbox/sandbox/README.md | 2 +- packages/sandbox/sandbox/README.zh.md | 16 +++---- packages/schedule/README.i18n.yaml | 2 +- packages/schedule/README.zh.md | 4 +- packages/schedule/schedule/README.i18n.yaml | 2 +- packages/schedule/schedule/README.zh.md | 14 +++--- packages/sdk/README.i18n.yaml | 2 +- packages/sdk/README.zh.md | 14 +++--- packages/sdk/client/README.i18n.yaml | 2 +- packages/sdk/client/README.zh.md | 14 +++--- packages/sdk/protocol/README.i18n.yaml | 2 +- packages/sdk/protocol/README.zh.md | 14 +++--- packages/sdk/server/README.i18n.yaml | 4 +- packages/sdk/server/README.md | 2 +- packages/sdk/server/README.zh.md | 16 +++---- packages/session-query/README.i18n.yaml | 2 +- packages/session-query/README.zh.md | 4 +- .../session-log-export/README.i18n.yaml | 2 +- .../session-log-export/README.zh.md | 24 +++++----- .../session-query-sqlite/README.i18n.yaml | 2 +- .../session-query-sqlite/README.zh.md | 8 ++-- .../session-query/README.i18n.yaml | 4 +- .../session-query/session-query/README.md | 2 +- .../session-query/session-query/README.zh.md | 16 +++---- .../tool-session-query/README.i18n.yaml | 2 +- .../tool-session-query/README.zh.md | 10 ++-- packages/session/README.i18n.yaml | 2 +- packages/session/README.zh.md | 8 ++-- .../README.i18n.yaml | 4 +- .../session-checkpoint-policy/README.md | 2 +- .../session-checkpoint-policy/README.zh.md | 6 +-- .../session-format-catalog/README.i18n.yaml | 2 +- .../session-format-catalog/README.zh.md | 8 ++-- .../session-format-v0-to-v1/README.i18n.yaml | 2 +- .../session-format-v0-to-v1/README.zh.md | 14 +++--- .../session-format-v2-to-v3/README.i18n.yaml | 2 +- .../session-format-v2-to-v3/README.zh.md | 16 +++---- .../session/session-format/README.i18n.yaml | 2 +- packages/session/session-format/README.zh.md | 14 +++--- .../session-log-deepseek/README.i18n.yaml | 2 +- .../session/session-log-deepseek/README.zh.md | 14 +++--- .../README.i18n.yaml | 2 +- .../session-persistence-jsonl/README.zh.md | 12 ++--- .../session-persistence/README.i18n.yaml | 2 +- .../session/session-persistence/README.zh.md | 30 ++++++------ .../session-projection-cache/README.i18n.yaml | 4 +- .../session-projection-cache/README.md | 4 +- .../session-projection-cache/README.zh.md | 16 +++---- .../session-projection/README.i18n.yaml | 2 +- .../session/session-projection/README.zh.md | 4 +- .../session/session-stats/README.i18n.yaml | 2 +- packages/session/session-stats/README.zh.md | 2 +- .../session-telemetry-otel/README.i18n.yaml | 2 +- .../session-telemetry-otel/README.zh.md | 6 +-- .../session-telemetry/README.i18n.yaml | 2 +- .../session/session-telemetry/README.zh.md | 10 ++-- .../README.i18n.yaml | 2 +- .../README.zh.md | 8 ++-- .../README.i18n.yaml | 2 +- .../README.zh.md | 8 ++-- .../session/session-title/README.i18n.yaml | 2 +- packages/session/session-title/README.zh.md | 8 ++-- .../session-turn-outline/README.i18n.yaml | 2 +- .../session/session-turn-outline/README.zh.md | 10 ++-- packages/settings/README.i18n.yaml | 4 +- packages/settings/README.md | 4 +- packages/settings/README.zh.md | 4 +- .../settings/settings-file/README.i18n.yaml | 2 +- packages/settings/settings-file/README.zh.md | 6 +-- packages/settings/settings/README.i18n.yaml | 2 +- packages/settings/settings/README.zh.md | 6 +-- packages/shell/README.i18n.yaml | 4 +- packages/shell/README.md | 4 +- packages/shell/README.zh.md | 6 +-- packages/shell/bash-local/README.i18n.yaml | 2 +- packages/shell/bash-local/README.zh.md | 16 +++---- packages/shell/bash-sandbox/README.i18n.yaml | 4 +- packages/shell/bash-sandbox/README.md | 2 +- packages/shell/bash-sandbox/README.zh.md | 14 +++--- packages/shell/pwsh-local/README.i18n.yaml | 2 +- packages/shell/pwsh-local/README.zh.md | 14 +++--- packages/shell/pwsh-sandbox/README.i18n.yaml | 4 +- packages/shell/pwsh-sandbox/README.md | 2 +- packages/shell/pwsh-sandbox/README.zh.md | 20 ++++---- packages/shell/shell-env/README.i18n.yaml | 2 +- packages/shell/shell-env/README.zh.md | 12 ++--- packages/shell/shell/README.i18n.yaml | 4 +- packages/shell/shell/README.md | 2 +- packages/shell/shell/README.zh.md | 12 ++--- .../tool-bash-persistent/README.i18n.yaml | 4 +- packages/shell/tool-bash-persistent/README.md | 6 +-- .../shell/tool-bash-persistent/README.zh.md | 12 ++--- packages/shell/tool-bash/README.i18n.yaml | 2 +- packages/shell/tool-bash/README.zh.md | 18 +++---- .../tool-pwsh-persistent/README.i18n.yaml | 2 +- .../shell/tool-pwsh-persistent/README.zh.md | 14 +++--- packages/shell/tool-pwsh/README.i18n.yaml | 2 +- packages/shell/tool-pwsh/README.zh.md | 16 +++---- packages/skill/README.i18n.yaml | 2 +- packages/skill/README.zh.md | 6 +-- packages/skill/skill-badge/README.i18n.yaml | 4 +- packages/skill/skill-badge/README.md | 4 +- packages/skill/skill-badge/README.zh.md | 10 ++-- .../skill/skill-filesystem/README.i18n.yaml | 2 +- packages/skill/skill-filesystem/README.zh.md | 12 ++--- packages/skill/skill/README.i18n.yaml | 4 +- packages/skill/skill/README.md | 2 +- packages/skill/skill/README.zh.md | 8 ++-- packages/skill/tool-skill/README.i18n.yaml | 4 +- packages/skill/tool-skill/README.md | 4 +- packages/skill/tool-skill/README.zh.md | 10 ++-- packages/spill/README.i18n.yaml | 2 +- packages/spill/README.zh.md | 4 +- packages/spill/spill-local/README.i18n.yaml | 2 +- packages/spill/spill-local/README.zh.md | 8 ++-- packages/spill/spill-policy/README.i18n.yaml | 2 +- packages/spill/spill-policy/README.zh.md | 2 +- packages/spill/spill/README.i18n.yaml | 2 +- packages/spill/spill/README.zh.md | 18 +++---- .../storage/storage-domain/README.i18n.yaml | 4 +- packages/storage/storage-domain/README.md | 6 +-- packages/storage/storage-domain/README.zh.md | 14 +++--- .../storage/storage-json/README.i18n.yaml | 2 +- packages/storage/storage-json/README.zh.md | 4 +- .../storage/storage-sqlite/README.i18n.yaml | 2 +- packages/storage/storage-sqlite/README.zh.md | 8 ++-- packages/storage/storage/README.i18n.yaml | 2 +- packages/storage/storage/README.zh.md | 6 +-- packages/subagent/README.i18n.yaml | 4 +- packages/subagent/README.md | 2 +- packages/subagent/README.zh.md | 6 +-- .../subagent/subagent-acp/README.i18n.yaml | 2 +- packages/subagent/subagent-acp/README.zh.md | 12 ++--- .../subagent-claude-code/README.i18n.yaml | 4 +- .../subagent/subagent-claude-code/README.md | 6 +-- .../subagent-claude-code/README.zh.md | 18 +++---- .../subagent/subagent-codex/README.i18n.yaml | 2 +- packages/subagent/subagent-codex/README.zh.md | 6 +-- .../subagent-dsh-sdk/README.i18n.yaml | 4 +- packages/subagent/subagent-dsh-sdk/README.md | 4 +- .../subagent/subagent-dsh-sdk/README.zh.md | 24 +++++----- .../subagent-fork-in-process/README.i18n.yaml | 2 +- .../subagent-fork-in-process/README.zh.md | 16 +++---- .../README.i18n.yaml | 4 +- .../subagent-in-process-driver/README.md | 2 +- .../subagent-in-process-driver/README.zh.md | 10 ++-- .../README.i18n.yaml | 2 +- .../subagent-spawn-in-process/README.zh.md | 14 +++--- packages/subagent/subagent/README.i18n.yaml | 2 +- packages/subagent/subagent/README.zh.md | 22 ++++----- .../tool-subagent-control/README.i18n.yaml | 2 +- .../tool-subagent-control/README.zh.md | 24 +++++----- .../subagent/tool-subagent/README.i18n.yaml | 2 +- packages/subagent/tool-subagent/README.zh.md | 2 +- packages/subprocess/README.i18n.yaml | 4 +- packages/subprocess/README.md | 2 +- packages/subprocess/README.zh.md | 2 +- .../subprocess-local/README.i18n.yaml | 2 +- .../subprocess/subprocess-local/README.zh.md | 16 +++---- .../subprocess/subprocess/README.i18n.yaml | 4 +- packages/subprocess/subprocess/README.md | 6 +-- packages/subprocess/subprocess/README.zh.md | 16 +++---- .../subprocess/win32-process/README.i18n.yaml | 2 +- .../subprocess/win32-process/README.zh.md | 42 ++++++++-------- packages/terminal/README.i18n.yaml | 2 +- packages/terminal/README.zh.md | 2 +- .../terminal/terminal-bash/README.i18n.yaml | 2 +- packages/terminal/terminal-bash/README.zh.md | 14 +++--- packages/terminal/terminal/README.i18n.yaml | 2 +- packages/terminal/terminal/README.zh.md | 10 ++-- .../terminal/tool-terminal/README.i18n.yaml | 2 +- packages/terminal/tool-terminal/README.zh.md | 10 ++-- packages/test-support/README.i18n.yaml | 4 +- packages/test-support/README.md | 2 +- packages/test-support/README.zh.md | 10 ++-- .../agent-loop-testkit/README.i18n.yaml | 2 +- .../agent-loop-testkit/README.zh.md | 8 ++-- .../client-runtime/README.i18n.yaml | 2 +- .../test-support/client-runtime/README.zh.md | 24 +++++----- .../llm-mock-server/README.i18n.yaml | 2 +- .../test-support/llm-mock-server/README.zh.md | 16 +++---- .../test-support/llm-replay/README.i18n.yaml | 2 +- packages/test-support/llm-replay/README.zh.md | 10 ++-- .../loader-smoke/README.i18n.yaml | 2 +- .../test-support/loader-smoke/README.zh.md | 18 +++---- .../session-snapshot/README.i18n.yaml | 2 +- .../session-snapshot/README.zh.md | 14 +++--- packages/todo/README.i18n.yaml | 2 +- packages/todo/README.zh.md | 2 +- packages/todo/tool-todo/README.i18n.yaml | 2 +- packages/todo/tool-todo/README.zh.md | 18 +++---- packages/typert/README.i18n.yaml | 4 +- packages/typert/README.md | 4 +- packages/typert/README.zh.md | 8 ++-- packages/typert/generator/README.i18n.yaml | 4 +- packages/typert/generator/README.md | 4 +- packages/typert/generator/README.zh.md | 16 +++---- packages/typert/loader/README.i18n.yaml | 4 +- packages/typert/loader/README.md | 2 +- packages/typert/loader/README.zh.md | 16 +++---- packages/typert/protocol/README.i18n.yaml | 2 +- packages/typert/protocol/README.zh.md | 6 +-- packages/util/README.i18n.yaml | 2 +- packages/util/README.zh.md | 6 +-- packages/util/atomic-write/README.i18n.yaml | 2 +- packages/util/atomic-write/README.zh.md | 14 +++--- packages/util/brand/README.i18n.yaml | 2 +- packages/util/brand/README.zh.md | 8 ++-- packages/util/chunked-list/README.i18n.yaml | 2 +- packages/util/chunked-list/README.zh.md | 10 ++-- packages/util/crypto/README.i18n.yaml | 2 +- packages/util/crypto/README.zh.md | 10 ++-- packages/util/deque/README.i18n.yaml | 2 +- packages/util/deque/README.zh.md | 6 +-- packages/util/home-paths/README.i18n.yaml | 4 +- packages/util/home-paths/README.md | 2 +- packages/util/home-paths/README.zh.md | 2 +- packages/util/http-proxy/README.i18n.yaml | 2 +- packages/util/http-proxy/README.zh.md | 20 ++++---- .../util/launch-environment/README.i18n.yaml | 2 +- packages/util/launch-environment/README.zh.md | 4 +- packages/util/native-command/README.i18n.yaml | 4 +- packages/util/native-command/README.md | 2 +- packages/util/native-command/README.zh.md | 4 +- .../util/output-retention/README.i18n.yaml | 2 +- packages/util/output-retention/README.zh.md | 2 +- packages/util/time/README.i18n.yaml | 2 +- packages/util/time/README.zh.md | 14 +++--- packages/util/timeout/README.i18n.yaml | 2 +- packages/util/timeout/README.zh.md | 8 ++-- packages/util/values/README.i18n.yaml | 2 +- packages/util/values/README.zh.md | 6 +-- packages/web/README.i18n.yaml | 2 +- packages/web/README.zh.md | 10 ++-- packages/web/tool-web/README.i18n.yaml | 2 +- packages/web/tool-web/README.zh.md | 6 +-- packages/web/web-fetch-http/README.i18n.yaml | 2 +- packages/web/web-fetch-http/README.zh.md | 8 ++-- .../web/web-search-deepseek/README.i18n.yaml | 4 +- packages/web/web-search-deepseek/README.md | 2 +- packages/web/web-search-deepseek/README.zh.md | 6 +-- packages/web/web-search-exa/README.i18n.yaml | 2 +- packages/web/web-search-exa/README.zh.md | 8 ++-- .../web-search-perplexity/README.i18n.yaml | 2 +- .../web/web-search-perplexity/README.zh.md | 6 +-- packages/web/web/README.i18n.yaml | 2 +- packages/web/web/README.zh.md | 6 +-- packages/webhook/README.i18n.yaml | 2 +- packages/webhook/README.zh.md | 12 ++--- .../webhook/webhook-github/README.i18n.yaml | 2 +- packages/webhook/webhook-github/README.zh.md | 28 +++++------ packages/webhook/webhook/README.i18n.yaml | 2 +- packages/webhook/webhook/README.zh.md | 48 +++++++++---------- packages/workflow/README.i18n.yaml | 2 +- packages/workflow/README.zh.md | 2 +- packages/workflow/tool-ralph/README.i18n.yaml | 4 +- packages/workflow/tool-ralph/README.md | 2 +- packages/workflow/tool-ralph/README.zh.md | 14 +++--- .../workflow/tool-workflow/README.i18n.yaml | 2 +- packages/workflow/tool-workflow/README.zh.md | 18 +++---- .../workflow-worker-thread/README.i18n.yaml | 2 +- .../workflow-worker-thread/README.zh.md | 14 +++--- packages/workflow/workflow/README.i18n.yaml | 4 +- packages/workflow/workflow/README.md | 4 +- packages/workflow/workflow/README.zh.md | 10 ++-- packages/workspace/README.i18n.yaml | 2 +- packages/workspace/README.zh.md | 6 +-- packages/workspace/workspace/README.i18n.yaml | 2 +- packages/workspace/workspace/README.zh.md | 12 ++--- python/README.i18n.yaml | 2 +- python/README.zh.md | 4 +- python/sdk-runtime/README.i18n.yaml | 2 +- python/sdk-runtime/README.zh.md | 16 +++---- python/sdk/README.i18n.yaml | 2 +- python/sdk/README.zh.md | 20 ++++---- python/sdk/examples/README.i18n.yaml | 2 +- python/sdk/examples/README.zh.md | 16 +++---- 744 files changed, 2592 insertions(+), 2631 deletions(-) diff --git a/apps/cli/README.i18n.yaml b/apps/cli/README.i18n.yaml index aa5c385a7e..cfded686cf 100644 --- a/apps/cli/README.i18n.yaml +++ b/apps/cli/README.i18n.yaml @@ -3,4 +3,4 @@ # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write apps/cli/README.md README.md: 2e74ef68cf0b8487083a2e2af0f5175c78ec5212 -README.zh.md: 85a75f4c025e1bfe1461b9ffdaca533d308318ba +README.zh.md: 553f28f3af78b18658701449678de80b086dbb15 diff --git a/apps/cli/README.zh.md b/apps/cli/README.zh.md index 85a75f4c02..553f28f3af 100644 --- a/apps/cli/README.zh.md +++ b/apps/cli/README.zh.md @@ -2,7 +2,7 @@ [English](README.md) | 中文 -`dsh` 是唯一受支持的 Node 应用启动器;profile 由多个插件组合包 patch 层按顺序叠加而成,其上再应用用户自己的覆盖配置。SDK 与 ACP 都是 profile,而不是独立的公开 bin。Python 运行时 wheel 会打包同一个命令;SDK 默认使用 `sdk`,极简示例选择 `sdk-minimal`。[`src/args.ts`](src/args.ts) 负责命令语法,[`src/bin.ts`](src/bin.ts) 只加载选中的运行器。无效命令、来自其他模式的选项、配置错误和启动失败都会以非零状态退出。 +`dsh` 是唯一受支持的 Node 应用启动器;profile 由多个插件组合包 patch 层按顺序叠加而成,其上再应用用户自己的覆盖配置。SDK 与 ACP(Agent Client Protocol)都是 profile,而不是独立的公开可执行命令。Python 运行时 wheel 包中也包含同一个命令;SDK 默认使用 `sdk`,极简示例选择 `sdk-minimal`。[`src/args.ts`](src/args.ts) 负责命令语法,[`src/bin.ts`](src/bin.ts) 只加载选中的运行器。无效命令、来自其他模式的选项、配置错误和启动失败都会以非零状态退出。 ## 入口模式 @@ -10,14 +10,14 @@ |---|---| | `dsh --profile ` | 启动位于 `$DSH_HOME/profiles/` 的指定 profile。 | | `dsh --profile --from-default-profile