diff --git a/packages/experimental/README.i18n.yaml b/packages/experimental/README.i18n.yaml index 03eb8666d6..4a78e26afb 100644 --- a/packages/experimental/README.i18n.yaml +++ b/packages/experimental/README.i18n.yaml @@ -18,8 +18,8 @@ en: 55d9e37b0a8dd4d8 zh: 3acb6415f92698fb /packages-experimental/packages: - en: a72419fc7d4ceffc - zh: dbc5db0c563c79da + en: b49292fa525d6e3e + zh: 486516e9073f5055 /packages-experimental/related-documentation: en: 40797d4849455966 zh: bb91a68dd995887c diff --git a/packages/experimental/README.md b/packages/experimental/README.md index 493dcabf99..cac02170c0 100644 --- a/packages/experimental/README.md +++ b/packages/experimental/README.md @@ -36,7 +36,7 @@ Promotion requires a named product role, documented public behavior and limitati | Package | Role | ctx key | |---|---|---| -| [`action-cards`](action-cards/README.md) | Optional action cards below answers: the proposal tool, card state, user actions and status notices | `ctx.actionCards` | +| [`action-cards`](action-cards/README.md) | Optional action cards below answers: `action-card` blocks, card state, user actions and status notices | `ctx.actionCards` | | [`client-ui-action-cards`](client-ui-action-cards/README.md) | Card frame below completed answers, kind bodies and the layer that hides card blocks | — | | [`creation-recommendations`](creation-recommendations/README.md) | Explicit-need creation of persistent removable interface plugins | — | | [`client-ui-creation-recommendations`](client-ui-creation-recommendations/README.md) | Personalized page card body with location selection and undo | — | diff --git a/packages/experimental/README.zh.md b/packages/experimental/README.zh.md index 767bd16cdb..68130aeb7c 100644 --- a/packages/experimental/README.zh.md +++ b/packages/experimental/README.zh.md @@ -36,7 +36,7 @@ kind: "package-group" | 包 | 职责 | ctx 键 | |---|---|---| -| [`action-cards`](action-cards/README.zh.md) | 回答下方的可选操作卡片:提议工具、卡片状态、用户操作与状态通知 | `ctx.actionCards` | +| [`action-cards`](action-cards/README.zh.md) | 回答下方的可选操作卡片:`action-card` 代码块、卡片状态、用户操作与状态通知 | `ctx.actionCards` | | [`client-ui-action-cards`](client-ui-action-cards/README.zh.md) | 已完成回答下方的卡片框架、种类正文,以及隐藏卡片代码块的层 | — | | [`creation-recommendations`](creation-recommendations/README.zh.md) | 针对明确需求创建持续可用、可移除的界面插件 | — | | [`client-ui-creation-recommendations`](client-ui-creation-recommendations/README.zh.md) | 个性化页面卡片正文、位置选择和撤销 | — | diff --git a/packages/experimental/action-cards/README.i18n.yaml b/packages/experimental/action-cards/README.i18n.yaml index d37c73a28d..3a8a4ee2e5 100644 --- a/packages/experimental/action-cards/README.i18n.yaml +++ b/packages/experimental/action-cards/README.i18n.yaml @@ -21,11 +21,11 @@ en: ec2c7e23b17e2d3e zh: f6e104e7ce68c3ac /deepseek-ai-dsh-action-cards/use-this-package/card-rules: - en: 0f1c4042adfac06f - zh: 153e8bf627a4b08f + en: 1720908663123d8e + zh: abc24f2874f21e59 /deepseek-ai-dsh-action-cards/understand-the-implementation: - en: ff7c2e2a2bea9024 - zh: 87e339ce742a33a5 + en: 2553967d926b491d + zh: 8d7edff4d39aff5e /deepseek-ai-dsh-action-cards/further-exploration: en: b5d6fde7329f67a7 zh: db2839d22fc577c4 @@ -60,8 +60,8 @@ en: 58785543e2428dba zh: 4b082f77b3b2f482 /deepseek-ai-dsh-action-cards/known-limitations-and-deferred-work: - en: e7e2c528f27690b2 - zh: 898bcdec6b4165bf + en: a59763d767870671 + zh: a5fce29a79e17d0f /deepseek-ai-dsh-action-cards/known-limitations-and-deferred-work/dev-note: en: e67f633dc6fe7773 zh: bd8a8936229e035e diff --git a/packages/experimental/action-cards/README.md b/packages/experimental/action-cards/README.md index d9e68c8184..cc4afeca09 100644 --- a/packages/experimental/action-cards/README.md +++ b/packages/experimental/action-cards/README.md @@ -33,7 +33,7 @@ A kind package injects `actionCards` and calls `ctx.actionCards.register(kind)` ### Card rules -- A card is a fenced block whose language is `action-card` and whose content is one JSON object with `action`, `title`, `brief` and an object `details`. Only top-level blocks count: a block inside a list item, block quote or another block offers no card. The first such block of a turn that parses becomes the card, named by the id of the assistant message that holds it. Later blocks of that turn, blocks in reasoning, blocks in an interrupted answer, blocks with a blank title or brief, and every block of a subagent Session create no card, and nothing reports this to the model. +- A card is a fenced block whose language is `action-card` and whose content is one JSON object with `action`, `title`, `brief` and an object `details`. A block counts when its fence follows at most three spaces, or at most three spaces and a list item marker; a block in a block quote, one indented four or more spaces and one inside another fenced block offer no card. The first such block of a turn that parses becomes the card, named by the id of the assistant message that holds it. Later blocks of that turn, blocks in reasoning, blocks in an interrupted answer, blocks with a blank title or brief, and every block of a subagent Session create no card, and nothing reports this to the model. - Admission does not check the kind: a card whose action no kind registered, or whose `details` fail the kind schema, still appears, replaces every unstarted earlier card, and refuses every action except Not now as unavailable. - A newer card of any kind replaces every unstarted earlier card. Replacement is derived from the log and never recorded. - Events a forked Session inherits create no cards. @@ -48,7 +48,7 @@ A kind package injects `actionCards` and calls `ctx.actionCards.register(kind)`
Implementation internals — click to expand -The package default-exports the `actionCards` Remote service and registers no tool. The logged answer is the durable proposal: the `actionCards` Session projection (state version 3) reads the text blocks of each `assistant/message` with [`src/fence.ts`](src/fence.ts), which finds top-level fenced blocks by the CommonMark rules and matches their language the way the Chat client dispatches fences, and admits the first valid block of the turn. It also records decisions from `plugin:action-cards/decision`, and keeps unreported decisions until a status notice whose `through` covers them enters the log. The header's `origin` marks a subagent Session, whose projection admits nothing. Its Client view `{ proposals, decisions }` is excluded from Session summaries. +The package default-exports the `actionCards` Remote service and registers no tool. The logged answer is the durable proposal: the `actionCards` Session projection (state version 3) reads the text blocks of each `assistant/message` with [`src/fence.ts`](src/fence.ts), which finds fenced blocks at the top level and in list items by the CommonMark fence rules and matches their language the way the Chat client dispatches fences, and admits the first valid block of the turn. It also records decisions from `plugin:action-cards/decision`, and keeps unreported decisions until a status notice whose `through` covers them enters the log. The header's `origin` marks a subagent Session, whose projection admits nothing. Its Client view `{ proposals, decisions }` is excluded from Session summaries. The Remote `act(sessionId, cardId, verb, payload?)` checks the owner, the live root and the card; Not now continues without a registered kind, while other verbs need the kind, the verb and Remote access. It then shares one operation per card. The kind's `reconcile` runs first and the live root is checked again; a dismissed or replaced card then settles unchanged, Not now is recorded, a writing verb is refused in a read-only Session, and every other verb goes to the kind handler under the Agent's initiator. `record()` also accepts an action whose kind has unregistered, because Cordis disposes a plugin's effects concurrently and an unloading kind still records the outcome of work it started. An `agent/pre-step` listener adds the status notice after later listeners prepared the step. @@ -114,7 +114,7 @@ The notice is appended after the request's other new context and never rewrites - The model learns nothing about a block that creates no card: a malformed block, a second block of the turn or a subagent's block shows nothing, while the answer may already invite the user to the card. -- The Host reads only top-level blocks whose language is literally `action-card`, while the Chat client hides every `action-card` block it renders. A block in a list item or block quote, or one whose language is written with an escape or a character reference, is hidden and offers no card; a block inside an HTML block or a `$$` or `\[ … \]` math block offers a card while its text stays visible. The skills ask for one top-level block at the end of the answer. +- The Host finds blocks line by line and reads only the literal language `action-card`, while the Chat client hides every `action-card` block it renders. A block in a block quote, one indented four or more spaces in a nested list item, or one whose language is written with an escape or a character reference, is hidden and offers no card; a block inside an HTML block or a `$$` or `\[ … \]` math block offers a card while its text stays visible. The skills ask for one top-level block at the end of the answer. - Sessions recorded with the removed `propose_action` tool show no card for those calls, and decision records that name a card `callId` are skipped. - A card that fails its kind schema or names no registered kind still replaces an unstarted earlier card, which then offers no action. - Cards are offered in the main conversation only. A subagent Session, including a Creator child's, admits no card, because only a live root can act on one. diff --git a/packages/experimental/action-cards/README.zh.md b/packages/experimental/action-cards/README.zh.md index a81723edc3..6074c46855 100644 --- a/packages/experimental/action-cards/README.zh.md +++ b/packages/experimental/action-cards/README.zh.md @@ -33,7 +33,7 @@ kind: "package-reference" ### 卡片规则 -- 卡片是语言为 `action-card` 的围栏代码块,内容是一个 JSON 对象,包含 `action`、`title`、`brief` 和对象类型的 `details`。只有最外层的代码块算数:列表项、引用块或其他块里的代码块不提供卡片。一轮中第一个能解析的这种代码块成为卡片,以所在助手消息的 id 作为卡片 id。同一轮之后的代码块、思考内容里的代码块、被打断的回答里的代码块、标题或说明为空的代码块,以及 subagent 会话里的所有代码块都不会产生卡片,也不会告知模型。 +- 卡片是语言为 `action-card` 的围栏代码块,内容是一个 JSON 对象,包含 `action`、`title`、`brief` 和对象类型的 `details`。围栏前最多有 3 个空格,或最多 3 个空格加一个列表项标记的代码块才算数;引用块里的、缩进 4 格及以上的,以及其他围栏代码块里的代码块不提供卡片。一轮中第一个能解析的这种代码块成为卡片,以所在助手消息的 id 作为卡片 id。同一轮之后的代码块、思考内容里的代码块、被打断的回答里的代码块、标题或说明为空的代码块,以及 subagent 会话里的所有代码块都不会产生卡片,也不会告知模型。 - 收下卡片时不检查种类:动作没有种类注册、或 `details` 未通过种类校验的卡片照样出现,并替换此前所有尚未开始的卡片,除“暂不需要”外的操作一律以 unavailable 拒绝。 - 任何种类的新卡片都会替换此前所有尚未开始的卡片。替换从日志推导,从不单独记录。 - fork 出的会话从父会话继承的事件不会产生卡片。 @@ -48,7 +48,7 @@ kind: "package-reference"
实现细节——点击展开 -本包默认导出 `actionCards` Remote 服务,不注册任何工具。日志里的回答就是持久的提议:`actionCards` 会话投影(状态版本 3)用 [`src/fence.ts`](src/fence.ts) 读取每条 `assistant/message` 的文字块,按 CommonMark 规则找出顶层围栏代码块,并按 Chat 客户端分派代码块的方式匹配语言,收下本轮第一个合格的代码块。投影还从 `plugin:action-cards/decision` 读取决定,并保留尚未报告的决定,直到 `through` 覆盖它们的状态通知写入日志。会话头的 `origin` 标出 subagent 会话,其投影不收任何卡片。投影的客户端视图 `{ proposals, decisions }` 不进入会话摘要。 +本包默认导出 `actionCards` Remote 服务,不注册任何工具。日志里的回答就是持久的提议:`actionCards` 会话投影(状态版本 3)用 [`src/fence.ts`](src/fence.ts) 读取每条 `assistant/message` 的文字块,按 CommonMark 的围栏规则找出顶层和列表项里的围栏代码块,并按 Chat 客户端分派代码块的方式匹配语言,收下本轮第一个合格的代码块。投影还从 `plugin:action-cards/decision` 读取决定,并保留尚未报告的决定,直到 `through` 覆盖它们的状态通知写入日志。会话头的 `origin` 标出 subagent 会话,其投影不收任何卡片。投影的客户端视图 `{ proposals, decisions }` 不进入会话摘要。 Remote `act(sessionId, cardId, verb, payload?)` 先检查服务所有者、在线根 Agent 和卡片;“暂不需要”在种类未注册时也继续处理,其他操作还需要种类、操作和 Remote 权限。然后同一张卡片共用一次处理。种类的 `reconcile` 先运行,之后再次检查在线根 Agent;已忽略或已替换的卡片原样返回,“暂不需要”被记录,写入类操作在只读会话中被拒绝,其余操作在该 Agent 的发起方作用域内交给种类处理器。`record()` 也接受种类已注销的动作,因为 Cordis 并发释放插件的各个 effect,卸载中的种类仍要记录已开始工作的结果。一个 `agent/pre-step` 监听器在后续监听器准备好本步之后追加状态通知。 @@ -114,7 +114,7 @@ Latest status of action cards from user actions and background work. These are s - 代码块没有产生卡片时模型不会知道:格式错误的代码块、同一轮的第二个代码块或 subagent 的代码块都不显示任何东西,而回答里可能已经邀请用户点卡片。 -- Host 只读取语言字面上就是 `action-card` 的顶层代码块,而 Chat 客户端会隐藏它渲染出的每一个 `action-card` 代码块。列表项或引用块里的代码块、语言用转义或字符引用写成的代码块会被隐藏,但不提供卡片;HTML 块或 `$$`、`\[ … \]` 数学块里的代码块会提供卡片,但其文字仍然可见。各 Skill 要求在回答末尾写一个顶层代码块。 +- Host 逐行查找代码块,只认字面上就是 `action-card` 的语言,而 Chat 客户端会隐藏它渲染出的每一个 `action-card` 代码块。引用块里的代码块、嵌套列表项里缩进 4 格及以上的代码块、语言用转义或字符引用写成的代码块会被隐藏,但不提供卡片;HTML 块或 `$$`、`\[ … \]` 数学块里的代码块会提供卡片,但其文字仍然可见。各 Skill 要求在回答末尾写一个顶层代码块。 - 用已移除的 `propose_action` 工具录下的会话,这些调用不再显示卡片;用 `callId` 指代卡片的决定记录会被跳过。 - 未通过种类校验或动作没有注册的卡片仍会替换此前尚未开始的卡片,被替换的卡片不再提供任何操作。 - 卡片只在主对话中提供。subagent 会话(包括 Creator 子 Agent 的会话)不收任何卡片,因为只有在线的根 Agent 才能对卡片进行操作。 diff --git a/packages/experimental/action-cards/src/fence.ts b/packages/experimental/action-cards/src/fence.ts index cd0ad1168c..d53525e381 100644 --- a/packages/experimental/action-cards/src/fence.ts +++ b/packages/experimental/action-cards/src/fence.ts @@ -4,7 +4,8 @@ import type { ActionCardFence } from './types.ts' /** Language of a block that offers a card, matched after lowercasing, as the Chat client dispatches fences. */ export const ACTION_CARD_FENCE: ActionCardFence = 'action-card' -const OPENING = /^( {0,3})(`{3,}|~{3,})(.*)$/u +/** Up to three spaces, optionally the marker of the list item the fence starts, then the fence and its info string. */ +const OPENING = /^( {0,3})((?:[-+*]|\d{1,9}[.)]) {1,4})?(`{3,}|~{3,})(.*)$/u /** An open fence: its closing line, its content indentation and, for a card block, the content read so far. */ interface OpenFence { @@ -23,21 +24,27 @@ function opened(line: string): OpenFence | undefined { const opening = OPENING.exec(line) if (opening === null) return undefined const indent = String(opening[1]) - const marker = String(opening[2]) - const info = String(opening[3]) + const item: string | undefined = opening[2] + const marker = String(opening[3]) + const info = String(opening[4]) if (marker.startsWith('`') && info.includes('`')) return undefined + // In a list item, content lines and the closing line are indented from the item's content column. + const width = indent.length + (item?.length ?? 0) + const closingIndent = (item === undefined ? 0 : width) + 3 return { - closing: new RegExp(`^ {0,3}${marker.charAt(0)}{${String(marker.length)},}[ \\t]*$`, 'u'), - outdent: new RegExp(`^ {0,${String(indent.length)}}`, 'u'), + closing: new RegExp(`^ {0,${String(closingIndent)}}${marker.charAt(0)}{${String(marker.length)},}[ \\t]*$`, 'u'), + outdent: new RegExp(`^ {0,${String(width)}}`, 'u'), content: languageOf(info) === ACTION_CARD_FENCE ? [] : undefined, } } /** - * Contents of the top-level fenced code blocks whose language is {@link ACTION_CARD_FENCE}, in text order. - * A fence opens with at least three backticks or tildes indented by at most three spaces, and closes at a line of the - * same character at least as long, or at the end of the text; content lines lose up to the opening's indentation. - * Fences inside lists or block quotes are not read. + * Contents of the fenced code blocks whose language is {@link ACTION_CARD_FENCE}, in text order. + * A fence opens with at least three backticks or tildes after at most three spaces, optionally followed by the marker of + * the list item it starts. It closes at a line of the same character at least as long, indented at most three spaces + * past the list item's content column or, outside a list item, the line start; an unclosed fence runs to the end of the + * text. Content lines lose up to the opening's indentation, marker included. Fences in block quotes or indented four or + * more spaces are not read. * @param text - one text block of an assistant message. * @returns the blocks' contents. */ diff --git a/packages/experimental/action-cards/tests/fence.spec.ts b/packages/experimental/action-cards/tests/fence.spec.ts index 139121d6a6..7382df8d71 100644 --- a/packages/experimental/action-cards/tests/fence.spec.ts +++ b/packages/experimental/action-cards/tests/fence.spec.ts @@ -15,12 +15,21 @@ it('removes the opening indentation from content and runs an unclosed fence to t expect(actionCardFences('````action-card\n{"a":1}\n```\n````')).toEqual(['{"a":1}\n```']) }) -it('skips other languages, fences nested in another fence, indented code and backtick info strings', () => { +it('reads fences in list items, closing them by the item content column so a later card still counts', () => { + expect(actionCardFences('- ```json\n {"a":1}\n ```\n\nText.\n\n```action-card\n{"b":2}\n```')).toEqual(['{"b":2}']) + expect(actionCardFences('10. ```action-card\n {"c":3}\n ```\nafter')).toEqual(['{"c":3}']) + expect(actionCardFences('- ```action-card\n {"d":4}\n ```\n ```')).toEqual(['{"d":4}\n ```']) + expect(actionCardFences('1. Step\n ```action-card\n {"e":5}\n ```')).toEqual(['{"e":5}']) +}) + +it('skips other languages, fences nested in another fence or a block quote, deeper indentation and backtick info strings', () => { expect(actionCardFences('No card here.')).toEqual([]) expect(actionCardFences('action-card mentioned in prose only')).toEqual([]) expect(actionCardFences('```json\n{"action-card":true}\n```')).toEqual([]) expect(actionCardFences('```action-cards\n{}\n```')).toEqual([]) expect(actionCardFences('````md\n```action-card\n{"e":5}\n```\n````')).toEqual([]) expect(actionCardFences(' ```action-card\n {"f":6}\n ```')).toEqual([]) + expect(actionCardFences('- Item\n - Nested\n ```action-card\n {"f":6}\n ```')).toEqual([]) + expect(actionCardFences('> ```action-card\n> {"h":8}\n> ```')).toEqual([]) expect(actionCardFences('```action-card `x`\n{"g":7}\n```')).toEqual([]) }) diff --git a/packages/experimental/client-ui-action-cards/README.i18n.yaml b/packages/experimental/client-ui-action-cards/README.i18n.yaml index 2dfc8699a8..6fe8a12d5c 100644 --- a/packages/experimental/client-ui-action-cards/README.i18n.yaml +++ b/packages/experimental/client-ui-action-cards/README.i18n.yaml @@ -9,8 +9,8 @@ en: c36a554629f96f79 zh: 0ea837da87938e52 /deepseek-ai-dsh-client-ui-action-cards/summary: - en: 3215a474eb349563 - zh: db3ee020eb9742ea + en: ce345186f5858586 + zh: 282cb5d7c46b1726 /deepseek-ai-dsh-client-ui-action-cards/table-of-contents: en: d152484eb41ac6b4 zh: b00dddf4c88f0a45 @@ -18,11 +18,11 @@ en: 717a53d2170d253b zh: 4e52852690601371 /deepseek-ai-dsh-client-ui-action-cards/use-this-package/register-a-card-body: - en: 9ec9f9f8f3165d3e - zh: 2d8154ec2fe0c9ab + en: f46356cea53e8c72 + zh: 76f7ee328445a5d4 /deepseek-ai-dsh-client-ui-action-cards/understand-the-implementation: en: 180ee8add4b750a4 - zh: ace4d6220de0bde1 + zh: 8ad116b65ccd532a /deepseek-ai-dsh-client-ui-action-cards/further-exploration: en: 1a18353340275de1 zh: ffd5667919fe45ff diff --git a/packages/experimental/client-ui-action-cards/README.md b/packages/experimental/client-ui-action-cards/README.md index bfff9e52da..95a992a982 100644 --- a/packages/experimental/client-ui-action-cards/README.md +++ b/packages/experimental/client-ui-action-cards/README.md @@ -9,7 +9,7 @@ English | [中文](README.zh.md) ## Summary -Users see an optional action card below a completed answer: its title, a brief that folds when long, and the controls of the experiment that proposed it. The answer's `action-card` block that offers the card is never shown. A card whose experiment provides no controls in this browser offers only Not now. Showing, expanding and folding cards make no model request. +Users see an optional action card below a completed answer: its title, a brief that folds when long, and the controls of the experiment that proposed it. The answer's `action-card` block that offers the card is never shown. A card whose experiment provides no controls in this browser, or whose fields those controls cannot read, offers only Not now. Showing, expanding and folding cards make no model request. ## Table of Contents @@ -29,7 +29,7 @@ Enable the [Personalized recommendations](../personalized-recommendations/README ### Register a card body -A kind's browser plugin injects `actionCards` and registers its body inside its own `ctx.effect`: `ctx.actionCards.register({ action, locale, Body })` returns the disposer. The frame renders `Body` for cards of that action with the card, its recorded or derived decision, the Session id, the frame's title and folded brief as `summary`, the frame's fold component as `Folded`, an `act(verb, payload?)` bound to the card, and a translator `t` for the body's own locale namespace. The body places `summary` in its own layout and owns its header, controls, status and footer. A second body for the same action is a registration error. +A kind's browser plugin injects `actionCards` and registers its body inside its own `ctx.effect`: `ctx.actionCards.register({ action, locale, Body })` returns the disposer. The frame renders `Body` for cards of that action with the card, its recorded or derived decision, the Session id, the frame's title and folded brief as `summary`, the frame's dismiss-only content as `fallback`, the frame's fold component as `Folded`, an `act(verb, payload?)` bound to the card, and a translator `t` for the body's own locale namespace. The body places `summary` in its own layout, renders `fallback` instead when its schema rejects the card's `details`, and owns its header, controls, status and footer. A second body for the same action is a registration error. ----- diff --git a/packages/experimental/client-ui-action-cards/README.zh.md b/packages/experimental/client-ui-action-cards/README.zh.md index 6626b8a308..c7274c97fa 100644 --- a/packages/experimental/client-ui-action-cards/README.zh.md +++ b/packages/experimental/client-ui-action-cards/README.zh.md @@ -9,7 +9,7 @@ kind: "package-reference" ## 概述 -用户在已完成的回答下方看到一张可选操作卡片:标题、过长时会折叠的说明,以及提议该卡片的实验所提供的控件。回答里提供卡片的 `action-card` 代码块从不显示。如果实验在当前浏览器中没有提供控件,卡片只提供“暂不需要”。展示、展开和折叠卡片都不会发起模型请求。 +用户在已完成的回答下方看到一张可选操作卡片:标题、过长时会折叠的说明,以及提议该卡片的实验所提供的控件。回答里提供卡片的 `action-card` 代码块从不显示。如果实验在当前浏览器中没有提供控件,或者控件读不了卡片的字段,卡片只提供“暂不需要”。展示、展开和折叠卡片都不会发起模型请求。 ## 目录 @@ -29,7 +29,7 @@ kind: "package-reference" ### 注册卡片正文 -种类的浏览器插件注入 `actionCards`,并在自己的 `ctx.effect` 中注册正文:`ctx.actionCards.register({ action, locale, Body })` 返回注销函数。框架为该动作的卡片渲染 `Body`,并传入:卡片、已记录或推导出的决定、会话 id、框架渲染的标题与折叠说明 `summary`、框架的折叠组件 `Folded`、绑定到该卡片的 `act(verb, payload?)`,以及正文自己语言命名空间的翻译函数 `t`。正文把 `summary` 放进自己的布局,并负责自己的标题栏、控件、状态和底部操作。为同一动作注册第二个正文属于注册错误。 +种类的浏览器插件注入 `actionCards`,并在自己的 `ctx.effect` 中注册正文:`ctx.actionCards.register({ action, locale, Body })` 返回注销函数。框架为该动作的卡片渲染 `Body`,并传入:卡片、已记录或推导出的决定、会话 id、框架渲染的标题与折叠说明 `summary`、只提供“暂不需要”的后备内容 `fallback`、框架的折叠组件 `Folded`、绑定到该卡片的 `act(verb, payload?)`,以及正文自己语言命名空间的翻译函数 `t`。正文把 `summary` 放进自己的布局,卡片的 `details` 未通过自己的校验时改为渲染 `fallback`,并负责自己的标题栏、控件、状态和底部操作。为同一动作注册第二个正文属于注册错误。 ----- @@ -46,9 +46,9 @@ kind: "package-reference" | 源码 | 内容 | |---|---| | [`src/client/mount.ts`](src/client/mount.ts) | 注册表、Remote、词典与插槽条目 | -| [`src/client/Card.tsx`](src/client/Card.tsx) | 轮次尾部、框架、折叠、兜底正文与代码块显示层 | +| [`src/client/Card.tsx`](src/client/Card.tsx) | 轮次尾部、框架、折叠、后备正文与代码块显示层 | | [`src/client/registry.ts`](src/client/registry.ts) | 正文注册表与正文属性 | -| [`tests/`](tests/) | 位置、框架、兜底、代码块与注册测试 | +| [`tests/`](tests/) | 位置、框架、后备正文、代码块与注册测试 |
diff --git a/packages/experimental/client-ui-action-cards/src/client/Card.tsx b/packages/experimental/client-ui-action-cards/src/client/Card.tsx index 42ec0164dc..29c9d3d09e 100644 --- a/packages/experimental/client-ui-action-cards/src/client/Card.tsx +++ b/packages/experimental/client-ui-action-cards/src/client/Card.tsx @@ -116,10 +116,11 @@ export function ActionCard({ proposal, decision, sessionId, act, bind, useBodies {proposal.title} + const fallback = // The frame re-renders on a locale change and hands the body a new summary, so the body re-renders with it. const content = body === undefined - ? - : body.render({ proposal, decision, sessionId, summary, Folded: FoldedText, act: send }, bind(body.locale)) + ? fallback + : body.render({ proposal, decision, sessionId, summary, fallback, Folded: FoldedText, act: send }, bind(body.locale)) return
{content}
@@ -128,7 +129,7 @@ export function ActionCard({ proposal, decision, sessionId, act, bind, useBodies /** Phases the fallback can name; other kind phases leave only the summary. */ const NAMED_PHASES: Readonly> = { dismissed: 'dismissed', replaced: 'replaced' } -/** Title, brief and Not now for a card whose kind registered no body in this browser. */ +/** Title, brief and Not now for a card whose kind registered no body in this browser or whose body rejects its `details`. */ function FallbackBody({ summary, decision, act, t }: { summary: ReactNode decision: ActionCardDecision | undefined diff --git a/packages/experimental/client-ui-action-cards/src/client/registry.ts b/packages/experimental/client-ui-action-cards/src/client/registry.ts index 4933ee8dbb..554753e4de 100644 --- a/packages/experimental/client-ui-action-cards/src/client/registry.ts +++ b/packages/experimental/client-ui-action-cards/src/client/registry.ts @@ -23,6 +23,8 @@ export interface ActionCardBodyProps /** diff --git a/packages/experimental/client-ui-action-cards/tests/browser-plugin.client.spec.ts b/packages/experimental/client-ui-action-cards/tests/browser-plugin.client.spec.ts index 748cfca652..39dfe04161 100644 --- a/packages/experimental/client-ui-action-cards/tests/browser-plugin.client.spec.ts +++ b/packages/experimental/client-ui-action-cards/tests/browser-plugin.client.spec.ts @@ -52,7 +52,7 @@ it('binds actions to the displayed session, serves registered bodies and removes const translate = (key: string) => key const element = bound.hooks.bodies.getSnapshot().get('test_action')!.render({ proposal: { cardId: brandString('card'), turn: 1, action: 'test_action', title: 'Counter', brief: 'Keep count.', details: {} }, decision: undefined, - sessionId: brandString('session-one'), summary: null, Folded: Body, act: vi.fn() }, translate) + sessionId: brandString('session-one'), summary: null, fallback: null, Folded: Body, act: vi.fn() }, translate) expect(isValidElement(element) && element.type === Body && (element.props as { t: unknown }).t === translate).toBe(true) expect(() => ctx.actionCards.register({ action: 'test_action', locale: 'actionCards', Body })).toThrow('a body for "test_action" is already registered') await kind.dispose() diff --git a/packages/experimental/client-ui-action-cards/tests/card.client.spec.tsx b/packages/experimental/client-ui-action-cards/tests/card.client.spec.tsx index 8a2ba65e8a..7ae6ea4617 100644 --- a/packages/experimental/client-ui-action-cards/tests/card.client.spec.tsx +++ b/packages/experimental/client-ui-action-cards/tests/card.client.spec.tsx @@ -78,6 +78,16 @@ it('renders a registered body with the frame summary, the fold, its own translat expect(value.act).toHaveBeenCalledWith(cardId, 'start', { value: 'x' }) }) +it('hands a registered body the fallback, which offers only Not now for a card the body cannot read', async () => { + const value = props(new Map([['test_action', { locale: 'testCard', render: frame => frame.fallback }]])) + render() + expect(screen.getByRole('region', { name: 'Counter' }).textContent).toContain('Keep my task count visible.') + const dismiss = screen.getByRole('button', { name: en.dismiss }) + fireEvent.click(dismiss) + expect(value.act).toHaveBeenCalledWith(cardId, 'dismiss', undefined) + await vi.waitFor(() => { expect(dismiss.hasAttribute('disabled')).toBe(false) }) +}) + it('offers only Not now for a card whose kind registered no body, and reports refusals and lost replies', async () => { const value = props(new Map(), undefined, true) const pending = Promise.withResolvers() diff --git a/packages/experimental/client-ui-creation-recommendations/README.i18n.yaml b/packages/experimental/client-ui-creation-recommendations/README.i18n.yaml index 5cc62170da..4268a9fa00 100644 --- a/packages/experimental/client-ui-creation-recommendations/README.i18n.yaml +++ b/packages/experimental/client-ui-creation-recommendations/README.i18n.yaml @@ -21,8 +21,8 @@ en: e6ce5b7dca9ededf zh: 8f41b6d59c913283 /deepseek-ai-dsh-client-ui-creation-recommendations/understand-the-implementation: - en: d493c9dccc11c3a0 - zh: d2a8d39089dcb4d1 + en: 1a4a2d4a287b7724 + zh: c284e45b94e601ab /deepseek-ai-dsh-client-ui-creation-recommendations/further-exploration: en: 6543c44016da2cdf zh: fb0d365a5e411b04 diff --git a/packages/experimental/client-ui-creation-recommendations/README.md b/packages/experimental/client-ui-creation-recommendations/README.md index fb7dc6e92e..16554826ff 100644 --- a/packages/experimental/client-ui-creation-recommendations/README.md +++ b/packages/experimental/client-ui-creation-recommendations/README.md @@ -45,7 +45,7 @@ Plan disclosure depends on omitted text, not rendered height. Long previews coll
Implementation internals — click to expand -The plugin registers its body with the shared card frame, which places the card after its Turn and supplies the title, the folded brief, the fold component and card-bound actions. The body validates the card's details and recorded data, then renders the header with the cost notice toggle, the location picker, written placement, folded initial content, progress, Undo and Restore. The cost notice preference is a browser-local store owned by the plugin. The shared Menu handles portal positioning, keyboard selection and dismissal. The body registration and its dictionaries share one plugin lifetime. +The plugin registers its body with the shared card frame, which places the card after its Turn and supplies the title, the folded brief, the fold component and card-bound actions. The body validates the card's details and recorded data, then renders the header with the cost notice toggle, the location picker, written placement, folded initial content, progress, Undo and Restore. A card whose details fail validation shows the frame's fallback, which offers only Not now. The cost notice preference is a browser-local store owned by the plugin. The shared Menu handles portal positioning, keyboard selection and dismissal. The body registration and its dictionaries share one plugin lifetime. - [Source](src/client/Card.tsx) - [Tests](tests/) diff --git a/packages/experimental/client-ui-creation-recommendations/README.zh.md b/packages/experimental/client-ui-creation-recommendations/README.zh.md index f9294f3394..7fa3461c30 100644 --- a/packages/experimental/client-ui-creation-recommendations/README.zh.md +++ b/packages/experimental/client-ui-creation-recommendations/README.zh.md @@ -45,7 +45,7 @@ kind: "package-reference"
实现细节 — 点击展开 -插件把正文注册到共享卡片框架,由框架把卡片放在所属回合之后,并提供标题、折叠后的说明、折叠组件和绑定到卡片的操作。正文先校验卡片的 details 和已记录的数据,再渲染带消耗说明开关的标题栏、位置选择、手写位置、折叠的预填内容、进度,以及撤销和恢复。消耗说明的偏好是插件自有的浏览器本地存储。共享 Menu 处理浮层定位、键盘选择和关闭。正文注册和语言字典使用同一插件生命周期。 +插件把正文注册到共享卡片框架,由框架把卡片放在所属回合之后,并提供标题、折叠后的说明、折叠组件和绑定到卡片的操作。正文先校验卡片的 details 和已记录的数据,再渲染带消耗说明开关的标题栏、位置选择、手写位置、折叠的预填内容、进度,以及撤销和恢复。details 未通过校验的卡片改为显示框架的后备内容,只提供“暂不需要”。消耗说明的偏好是插件自有的浏览器本地存储。共享 Menu 处理浮层定位、键盘选择和关闭。正文注册和语言字典使用同一插件生命周期。 - [源码](src/client/Card.tsx) - [测试](tests/) diff --git a/packages/experimental/client-ui-creation-recommendations/src/client/Card.tsx b/packages/experimental/client-ui-creation-recommendations/src/client/Card.tsx index 18150edce0..10ce39c9f2 100644 --- a/packages/experimental/client-ui-creation-recommendations/src/client/Card.tsx +++ b/packages/experimental/client-ui-creation-recommendations/src/client/Card.tsx @@ -61,11 +61,12 @@ function LocationPicker({ value, disabled, onChange, t }: { } /** - * Display creation, persistent installation, reversible removal and restoration below the frame's summary. + * Display creation, persistent installation, reversible removal and restoration below the frame's summary; a card whose + * fields fail the page schema shows the frame's fallback. * @param props - card, state, actions, folded-text component and notice preference. * @returns the card body. */ -export function PageCardBody({ proposal, decision, summary, Folded, act, infoDismissed, t }: PageCardProps) { +export function PageCardBody({ proposal, decision, summary, fallback, Folded, act, infoDismissed, t }: PageCardProps) { const details = detailsSchema.safeParse(proposal.details) const parsed = decision === undefined ? undefined : dataSchema.safeParse(decision.data) const data = parsed?.success === true ? parsed.data : undefined @@ -79,7 +80,7 @@ export function PageCardBody({ proposal, decision, summary, Folded, act, infoDis const customId = useId() const [pending, setPending] = useState() const [error, setError] = useState() - if (!details.success) return
{summary}
+ if (!details.success) return fallback const busy = pending !== undefined const slot = selected !== undefined && selected !== 'custom' ? selected : data?.slot ?? details.data.slot const location = selected ?? (data?.customLocation === undefined ? slot : 'custom') diff --git a/packages/experimental/client-ui-creation-recommendations/tests/card.client.spec.tsx b/packages/experimental/client-ui-creation-recommendations/tests/card.client.spec.tsx index 826590a34b..4ca032bb87 100644 --- a/packages/experimental/client-ui-creation-recommendations/tests/card.client.spec.tsx +++ b/packages/experimental/client-ui-creation-recommendations/tests/card.client.spec.tsx @@ -19,8 +19,8 @@ type Act = (verb: string, payload?: ActionCardFields) => Promise> } { const proposal = { cardId, turn: 1, action: ACTION, title: 'Counter', brief: 'Keep my task count visible.', details } return { proposal, decision: decision === undefined ? undefined : { cardId, action: ACTION, ...decision }, - sessionId: brandString('session-1'), summary: <>{proposal.title}

{proposal.brief}

, Folded: FoldedText, - act: vi.fn(async () => ({ status: 'accepted' })), infoDismissed: createSnapshotStore(true), + sessionId: brandString('session-1'), summary: <>{proposal.title}

{proposal.brief}

, + fallback:

frame fallback

, Folded: FoldedText, act: vi.fn(async () => ({ status: 'accepted' })), infoDismissed: createSnapshotStore(true), t: makeTranslate(chinese ? zh : en) } } @@ -255,9 +255,10 @@ it('shows supplied initial content as folded data below the plan and omits it ot expect(screen.getByRole('button', { name: '收起内容' }).getAttribute('aria-expanded')).toBe('true') }) -it('falls back to the summary for invalid fields and ignores unknown phases and invalid data', () => { +it('shows only the frame fallback for invalid fields and ignores unknown phases and invalid data', () => { const invalid = render() - expect(screen.getByText('Counter')).toBeTruthy() + expect(screen.getByText('frame fallback')).toBeTruthy() + expect(screen.queryByText('Counter')).toBeNull() expect(screen.queryByRole('button')).toBeNull() invalid.unmount() render() diff --git a/packages/experimental/client-ui-creation-recommendations/tests/mount.client.spec.tsx b/packages/experimental/client-ui-creation-recommendations/tests/mount.client.spec.tsx index 6bfbb88ecb..61d3a9678f 100644 --- a/packages/experimental/client-ui-creation-recommendations/tests/mount.client.spec.tsx +++ b/packages/experimental/client-ui-creation-recommendations/tests/mount.client.spec.tsx @@ -30,7 +30,7 @@ it('registers the page body and its copy for the plugin lifetime', async () => { expect(locale.bind('creationRecommendations')('heading')).toBe('Personalized pages') const t = locale.bind('creationRecommendations') render(('card'), turn: 1, action: 'create_personalized_page', title: 'Counter', brief: 'Keep count.', - details: { slot: 'page' } }} decision={undefined} sessionId={brandString('session')} summary={null} Folded={FoldedText} act={vi.fn()} t={t} />) + details: { slot: 'page' } }} decision={undefined} sessionId={brandString('session')} summary={null} fallback={null} Folded={FoldedText} act={vi.fn()} t={t} />) expect(screen.getByRole('note').textContent).toContain(en.creationCost) await fiber.dispose() expect(unregister).toHaveBeenCalledOnce() diff --git a/packages/experimental/client-ui-plugin-recommendations/README.i18n.yaml b/packages/experimental/client-ui-plugin-recommendations/README.i18n.yaml index 7031c695aa..42d8bb2117 100644 --- a/packages/experimental/client-ui-plugin-recommendations/README.i18n.yaml +++ b/packages/experimental/client-ui-plugin-recommendations/README.i18n.yaml @@ -18,8 +18,8 @@ en: 10c47fd420b1f232 zh: 7094c3b465978372 /deepseek-ai-dsh-client-ui-plugin-recommendations/understand-the-implementation: - en: 1b20e5e631381ab1 - zh: a3f0bbc3dc14001d + en: 875746574bf16367 + zh: 946587badfc6ca14 /deepseek-ai-dsh-client-ui-plugin-recommendations/further-exploration: en: 6c262b6cd246b4b5 zh: f9d44765797b5d91 diff --git a/packages/experimental/client-ui-plugin-recommendations/README.md b/packages/experimental/client-ui-plugin-recommendations/README.md index e5a9cb216b..6e83dadc2a 100644 --- a/packages/experimental/client-ui-plugin-recommendations/README.md +++ b/packages/experimental/client-ui-plugin-recommendations/README.md @@ -35,7 +35,7 @@ Enable the [Personalized recommendations bundle](../personalized-recommendations
Implementation internals — click to expand -The plugin mounts its catalog-text Remote, then registers its body with the shared card frame, which places the card after its Turn and supplies the card, its recorded decision and card-bound actions. The body asks the Host for the plugin's current catalog text and selection and renders the header with the Official badge, the details target, status, and Enable and Not now through the frame's action. The details target is named View details with the plugin title, and the catalog description remains its accessible description. A refused lookup shows its reason and a lost reply says the details could not be loaded; both offer Not now and Try again, which repeats the lookup, but no Enable. A recorded outcome stays as recorded even after its plugin leaves the catalog. While an action runs, only its own button reads Working, and both stay disabled. The plugin keeps returned catalog text by plugin name for its lifetime, so a revisited card renders it at once while its own lookup refreshes the selection. Until a plugin's first lookup returns, the card shows the proposed title, a placeholder description line and the disabled actions, so its layout holds. The Remote, the body registration and its dictionaries share one plugin lifetime. +The plugin mounts its catalog-text Remote, then registers its body with the shared card frame, which places the card after its Turn and supplies the card, its recorded decision and card-bound actions. The body asks the Host for the plugin's current catalog text and selection and renders the header with the Official badge, the details target, status, and Enable and Not now through the frame's action. The details target is named View details with the plugin title, and the catalog description remains its accessible description. A refused lookup shows its reason and a lost reply says the details could not be loaded; both offer Not now and Try again, which repeats the lookup, but no Enable. A card that names no plugin shows the frame's fallback, which offers only Not now. A recorded outcome stays as recorded even after its plugin leaves the catalog. While an action runs, only its own button reads Working, and both stay disabled. The plugin keeps returned catalog text by plugin name for its lifetime, so a revisited card renders it at once while its own lookup refreshes the selection. Until a plugin's first lookup returns, the card shows the proposed title, a placeholder description line and the disabled actions, so its layout holds. The Remote, the body registration and its dictionaries share one plugin lifetime. Cards use the application font, a distinct title and compact body scale, and a separate action footer. The built entry supplies generated Remote descriptors to the source-tested mount lifecycle. diff --git a/packages/experimental/client-ui-plugin-recommendations/README.zh.md b/packages/experimental/client-ui-plugin-recommendations/README.zh.md index df33e7901c..b278756bfc 100644 --- a/packages/experimental/client-ui-plugin-recommendations/README.zh.md +++ b/packages/experimental/client-ui-plugin-recommendations/README.zh.md @@ -35,7 +35,7 @@ kind: "package-reference"
实现细节 — 点击展开 -插件先挂载读取目录文本的 Remote,再向共享的卡片框架注册正文;框架把卡片放在所在回合之后,并提供卡片、已记录的决定和绑定到卡片的操作。正文向 Host 读取插件当前的目录文本和启用状态,渲染带「官方」标记的标题栏、详情点击区域、状态,以及通过框架操作发出的启用和暂不需要。详情点击区域的无障碍名称是「查看详情」加插件标题,目录描述仍作为它的无障碍描述。查询被拒绝时显示原因,回复丢失时说明无法读取插件信息;两种情况都提供「暂不需要」和重新查询的「重试」,不提供启用。已记录的结果保持不变,插件之后离开目录也一样。操作进行中只有被点击的按钮显示「正在处理…」,两个按钮都禁用。插件在自身生命周期内按插件名记住读到的目录文本,再次进入会话时卡片立即显示,同时卡片自己的查询会刷新启用状态。某个插件的第一次查询返回前,卡片显示提议的标题、一行描述占位和禁用的按钮,布局不跳动。Remote、正文注册和词典共用同一个插件生命周期。 +插件先挂载读取目录文本的 Remote,再向共享的卡片框架注册正文;框架把卡片放在所在回合之后,并提供卡片、已记录的决定和绑定到卡片的操作。正文向 Host 读取插件当前的目录文本和启用状态,渲染带「官方」标记的标题栏、详情点击区域、状态,以及通过框架操作发出的启用和暂不需要。详情点击区域的无障碍名称是「查看详情」加插件标题,目录描述仍作为它的无障碍描述。查询被拒绝时显示原因,回复丢失时说明无法读取插件信息;两种情况都提供「暂不需要」和重新查询的「重试」,不提供启用。卡片没有写插件名时显示框架的后备内容,只提供「暂不需要」。已记录的结果保持不变,插件之后离开目录也一样。操作进行中只有被点击的按钮显示「正在处理…」,两个按钮都禁用。插件在自身生命周期内按插件名记住读到的目录文本,再次进入会话时卡片立即显示,同时卡片自己的查询会刷新启用状态。某个插件的第一次查询返回前,卡片显示提议的标题、一行描述占位和禁用的按钮,布局不跳动。Remote、正文注册和词典共用同一个插件生命周期。 卡片沿用应用字体,通过标题、正文和独立操作区区分信息层级。构建入口将生成的 Remote 描述传给可直接从源码测试的挂载流程。 diff --git a/packages/experimental/client-ui-plugin-recommendations/src/client/Card.tsx b/packages/experimental/client-ui-plugin-recommendations/src/client/Card.tsx index 1d88ad17cc..ec619e0e85 100644 --- a/packages/experimental/client-ui-plugin-recommendations/src/client/Card.tsx +++ b/packages/experimental/client-ui-plugin-recommendations/src/client/Card.tsx @@ -62,12 +62,13 @@ function statusKey(phase: string, data: CardData): RecommendationKey | undefined /** * Display one plugin card: its current catalog title and description, the user's choice and its outcome. * Until the plugin's first catalog lookup returns, a placeholder line and the disabled actions hold the final layout. - * A refused or lost lookup leaves Not now and a retry of the lookup, but not Enable. + * A refused or lost lookup leaves Not now and a retry of the lookup, but not Enable. A card that names no plugin shows + * the frame's fallback. * @param props - card, state, actions and plugin-lifetime services. * @returns the card body. */ export function PluginCardBody({ - proposal, decision, sessionId, summary, act, catalog, describe, openDetails, resolveText, t, + proposal, decision, sessionId, fallback, act, catalog, describe, openDetails, resolveText, t, }: PluginCardProps) { const details = detailsSchema.safeParse(proposal.details) const name = details.success ? details.data.name : undefined @@ -96,7 +97,7 @@ export function PluginCardBody({ ) return () => { current = false } }, [catalog, describe, sessionId, proposal.cardId, name, phase, attempt]) - if (name === undefined) return
{summary}
+ if (name === undefined) return fallback // Remembered text shows at once; this card's own refusal or lost reply still decides what it offers. const current = lookup === null || lookup?.status === 'refused' ? lookup : cached ?? lookup const loading = current === undefined diff --git a/packages/experimental/client-ui-plugin-recommendations/tests/browser-plugin.client.spec.tsx b/packages/experimental/client-ui-plugin-recommendations/tests/browser-plugin.client.spec.tsx index a77dd0aaaa..4ce5ec9527 100644 --- a/packages/experimental/client-ui-plugin-recommendations/tests/browser-plugin.client.spec.tsx +++ b/packages/experimental/client-ui-plugin-recommendations/tests/browser-plugin.client.spec.tsx @@ -38,7 +38,7 @@ it('registers the plugin body, its copy and Remote for the plugin lifetime and s const proposal = { cardId: brandString('card'), turn: 1, action: 'enable_official_plugin', title: 'Search', brief: 'Find old sessions.', details: { name: 'official-search' } } const card = () => ('session-one')} summary={null} - Folded={FoldedText} act={vi.fn()} t={locale.bind('pluginRecommendations')} /> + fallback={null} Folded={FoldedText} act={vi.fn()} t={locale.bind('pluginRecommendations')} /> render(card()) await act(async () => {}) expect(describe).toHaveBeenCalledWith('session-one', 'card') diff --git a/packages/experimental/client-ui-plugin-recommendations/tests/card.client.spec.tsx b/packages/experimental/client-ui-plugin-recommendations/tests/card.client.spec.tsx index 3e37984b2d..37eba53f6d 100644 --- a/packages/experimental/client-ui-plugin-recommendations/tests/card.client.spec.tsx +++ b/packages/experimental/client-ui-plugin-recommendations/tests/card.client.spec.tsx @@ -30,8 +30,8 @@ function catalog() { function props(decision?: { phase: string; data?: ActionCardFields }, details: RecommendationDetails = available, store = catalog()) { return { proposal, decision: decision === undefined ? undefined : { cardId, action: ACTION, ...decision }, - sessionId: brandString('session-1'), summary: {proposal.title}, Folded: FoldedText, - act: vi.fn(async () => ({ status: 'settled', decision: { cardId, action: ACTION, phase: 'enabled' } })), + sessionId: brandString('session-1'), summary: {proposal.title}, fallback:

frame fallback

, + Folded: FoldedText, act: vi.fn(async () => ({ status: 'settled', decision: { cardId, action: ACTION, phase: 'enabled' } })), catalog: store, describe: vi.fn(async () => details), openDetails: vi.fn<(name: string) => void>(), resolveText: (text: LocalizedText) => typeof text === 'string' ? text : text.zh ?? text.en, t: makeTranslate(zh), @@ -213,10 +213,11 @@ it('renders a remembered plugin at once on a later card while refusals and lost expect(screen.queryByRole('button', { name: '启用' })).toBeNull() }) -it('renders only the frame summary when the card names no plugin', () => { +it('shows only the frame fallback when the card names no plugin', () => { const value = { ...props(), proposal: { ...proposal, details: {} } } render() - expect(screen.getByText('搜索旧会话')).toBeTruthy() + expect(screen.getByText('frame fallback')).toBeTruthy() + expect(screen.queryByText('搜索旧会话')).toBeNull() expect(screen.queryByRole('button')).toBeNull() expect(value.describe).not.toHaveBeenCalled() })