Parcourir la source

fix(ui-chat): preserve prompt cards on resumed requests

A resume header starts a visible request series even when the system node text is unchanged. Include resume in the request-prompt visibility predicate so full history and an older-page prepend retain the restart card. Keep startsSeries handling and existing regression assertions unchanged; align the local JSDoc and README pair.
Tianyi Cui il y a 1 mois
Parent
commit
77b6b10c21

+ 2 - 2
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: 25acf9753ad73efd7ef576552bb4879867419036
-README.zh.md: f575924feaacb294d5353bbce73464eade566ee0
+README.md: c5ca444762245786048867f074210d35dad2ac25
+README.zh.md: 6252237a3b220511fe9489ef84495c5950053c4f

+ 1 - 1
packages/client/ui-chat/README.md

@@ -25,7 +25,7 @@ The browser Chat target for Conversation assembly. It registers Chat event defin
 <a id="system-prompt-row"></a>
 ## System prompt row
 
-Chat 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 text from the latest `system/message` node before the `request/header`; a non-initial request whose preceding header is outside the loaded history window also shows one. Once that predecessor is available, an unchanged resume does not repeat the row; same-series config-only or tool-only changes, tool steps, and retries also 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.
+Chat 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 text from the latest `system/message` node before 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.
 
 <a id="turn-token-usage"></a>
 ## Turn token usage

+ 1 - 1
packages/client/ui-chat/README.zh.md

@@ -25,7 +25,7 @@ Conversation 组装的浏览器 Chat target。本包注册 Chat event definition
 <a id="system-prompt-row"></a>
 ## 系统提示词行
 
-Chat 会为非空的初始请求、显式消息序列起点、文本发生变化的 `system/message` surface 节点替换(文本读取自 `request/header` 之前最近的 `system/message` 节点),或前序 header 尚未进入已加载历史窗口的非初始请求显示一行默认折叠的`系统提示词`。前序 header 到达后,内容未变的 resume 不会重复该行;同一序列内仅配置或仅工具变化、工具步骤与重试也不会重复,且 `system/message` 事件绝不会渲染为对话消息。该行位于请求的用户消息之前,与提供方 envelope 顺序一致;展开后显示保留原始换行的精确模型可见文本。系统节点为空或位于已加载窗口之外的请求不创建该行,直到包含该节点的分页到达。
+Chat 会为非空的初始请求、显式消息序列起点、文本发生变化的 `system/message` surface 节点替换(文本读取自 `request/header` 之前最近的 `system/message` 节点),或前序 header 尚未进入已加载历史窗口的非初始请求显示一行默认折叠的`系统提示词`。即使系统文本未变,resume 也会重复该行,包括分页补齐前序 header 和系统节点后;同一序列内仅配置或仅工具变化、工具步骤与重试不会重复,且 `system/message` 事件绝不会渲染为对话消息。该行位于请求的用户消息之前,与提供方 envelope 顺序一致;展开后显示保留原始换行的精确模型可见文本。系统节点为空或位于已加载窗口之外的请求不创建该行,直到包含该节点的分页到达。
 
 -----
 

+ 3 - 1
packages/client/ui-chat/src/client/conversation-nodes/request-prompt.ts

@@ -78,7 +78,8 @@ export const systemMessageDefinition: ConversationNodeDefinition<SystemPromptNod
 }
 
 /**
- * Request-header prompt Definition for the Chat target.
+ * Request-header prompt Definition for the Chat target. Resume and explicit
+ * series starts retain a prompt card even when the system text is unchanged.
  * @param inspect - the shared prompt interpretation, supplied by the
  * uiConversation service (a client bundle cannot value-import it).
  * @returns the Chat request-prompt Definition.
@@ -109,6 +110,7 @@ export function requestPromptDefinition(inspect: RequestPromptInspector): Conver
           match.event.data.reason === 'initial',
         ),
         showsPrompt: previous === undefined
+          || match.event.data.reason === 'resume'
           || match.event.data.reason === 'series'
           || match.event.data.startsSeries === true
           || change === 'system'