fix(web): surface max-tokens turn ends as a localized truncation notice

A turn the provider ends at its per-request output cap previously produced
no visible sign in the Web chat flow: only error-kind turn/end events built
a conversation node, so the truncated answer read as a normal completion.

Add a turn-max-tokens conversation node Definition over the durable
turn/end event, a warning-styled localized notice row distinct from
turn-error, a fixture max-tokens sample turn, and an assembled keyless
snapshot pinning the dot state, title, and hint.

Closes #1522
This commit is contained in:
creatixchu
2026-08-12 15:36:27 +08:00
parent 3784607f3d
commit e4ca03cb85
22 changed files with 356 additions and 17 deletions

View File

@@ -77,7 +77,8 @@ export type {
CommandNode, CompactionSummaryNode, ComposerPhase,
ContextMessageNode, ConversationNode, ConversationSnapshot, ModelRetryNode, QueuedMessage,
LegacyConversationSlice, PartialAssistant, RunningToolCall,
SteeringMessageNode, TodoItem, ToolCallBlock, ToolResultNode, TurnErrorNode, UnknownSurfaceNode, UserMessageNode,
SteeringMessageNode, TodoItem, ToolCallBlock, ToolResultNode, TurnErrorNode, TurnMaxTokensNode,
UnknownSurfaceNode, UserMessageNode,
} from './sessions/conversation.ts'
export {
EMPTY_CHAT_SNAPSHOT, EMPTY_CONVERSATION_VIEWS, toAssistantBlock, toAssistantBlocks,

View File

@@ -163,6 +163,17 @@ export interface TurnErrorNode {
code?: string
}
/** Durable notice for a turn ended by the per-request output-token cap. */
export interface TurnMaxTokensNode {
kind: 'turn-max-tokens'
/** Seq of the owning turn/end event. */
seq: number
/** Unix epoch ms from the turn/end event. */
time: number
turn: number
step: number
}
/** A tool result paired (when in-window) with its call head. */
export interface ToolResultNode {
kind: 'tool-result'
@@ -268,6 +279,7 @@ export type ConversationNode =
| ContextMessageNode
| ModelRetryNode
| TurnErrorNode
| TurnMaxTokensNode
| ToolResultNode
| CommandNode
| CompactionSummaryNode