优化: L2统一状态机完整(ConvState持久化+事件暴露+前端status联合)
1a PerConvState.conv_state持久化(入口/reset/drop写收敛,CONV_STATE_ENABLED门控) 1b AiChatEvent加AiConvStateChanged变体,guard持app_handle在迁移点emit 1c 前端convStates真相源+停止按钮三态(status union)+MaxRoundsCard读conv_state 双轨过渡:enum视图与generating bool并行,off降级可回退
This commit is contained in:
@@ -287,6 +287,21 @@ export interface ModelConfig {
|
||||
*/
|
||||
export type AiErrorType = 'auth' | 'network' | 'timeout' | 'provider_config' | 'unknown'
|
||||
|
||||
/**
|
||||
* L2 统一状态机 — 对话生命周期状态字面量(对齐后端 ConvState serde rename_all=snake_case,
|
||||
* crates/df-ai/.../agentic/conv_state.rs)。5 态:
|
||||
* - idle:空闲,可接新请求
|
||||
* - generating:生成中(含审批挂起期,审批是 loop 内暂停点非独立态)
|
||||
* - stopping:停中(用户已点停止,loop 收尾中,瞬态)
|
||||
* - error:出错(用户可重试回 generating)
|
||||
* - compressed:压缩中(Generating/Idle 期间瞬态派生,压缩完成回原态)
|
||||
*
|
||||
* 后端开关 CONV_STATE_ENABLED 门控:on 时 GeneratingGuard set/reset 同步迁移并发
|
||||
* AiConvStateChanged 事件;off 时纯旧 generating bool 行为(可回退)。前端 conv_state 为
|
||||
* 新增派生源,旧 streaming/generating bool 双轨过渡保留,不强制全替(防回归)。
|
||||
*/
|
||||
export type ConvState = 'idle' | 'generating' | 'stopping' | 'error' | 'compressed'
|
||||
|
||||
/** AI 聊天事件(后端 emit 的结构,conversation_id 用于多对话流式路由) */
|
||||
export type AiChatEvent = ({
|
||||
type: 'AiTextDelta'; delta: string
|
||||
@@ -333,6 +348,13 @@ export type AiChatEvent = ({
|
||||
// 前端渲染求助卡显 reason + options 按钮供用户选,与 AiApprovalRequired(工具执行前审批)/
|
||||
// AiMaxRoundsReached(达 max 被动截断)语义区分——求助=AI 主动「我搞不定」。
|
||||
type: 'AiHelpRequired'; reason: string; context: string; options: string[]
|
||||
} | {
|
||||
// L2 统一状态机(批2 1b/1c):ConvState 经 AiChatEvent 推前端,供 status union 消费。
|
||||
// conv_state 值为 idle|generating|stopping|error|compressed(snake_case,对齐后端 ConvState serde)。
|
||||
// 后端在 conv_state 变化时(入口→generating / reset·drop→idle)emit;conversation_id 标识
|
||||
// 哪个会话的状态变了(F-09 多会话并发下前端按 convId 路由)。CONV_STATE_ENABLED 门控:off 时
|
||||
// 后端不 emit,前端 conv_state 收不到 → 消费方须回退旧 streaming/generating bool 判断(双轨过渡)。
|
||||
type: 'AiConvStateChanged'; conv_state: ConvState
|
||||
} | {
|
||||
// F-260616-07: 流式调用自动重试提示(前端可在错误气泡内显示「重试 n/m」)
|
||||
type: 'AiStreamRetry'; attempt: number; max_attempts: number
|
||||
|
||||
Reference in New Issue
Block a user