新增: 多会话并发前端 UI 阶段3/4(F-09 收尾)
后端 per-conv 并发已就绪(d899c58 + CR-03~07),前端呈现层收尾:
阶段3 多会话生成态:
- stores/ai.ts generatingConvId 单值 → generatingConvs:Set + add/remove/isGenerating helper
- useAiEvents 5 处迁移(Completed/Error/路由标记改 per-conv Set 操作,
AiError 精确清出错会话非全局清空,修原 = null 误清其他会话)
- ConversationSidebar 多会话并行生成脉冲指示(isGenerating 各会话独立)
阶段4 独立窗口多会话:
- useAiWindow label ai-detached → ai-detached-{convId}(per-conv 独立窗口)
- localStorage 单 key → per-conv key(防多会话串扰,读路径兼容旧 key 回退)
vue-tsc EXIT 0 + generatingConvId 零代码残留(仅注释)
This commit is contained in:
@@ -63,8 +63,11 @@ export const state = reactive({
|
||||
streaming: false,
|
||||
currentText: '',
|
||||
pendingApprovals: [] as AiToolCallInfo[],
|
||||
// 正在生成的对话 id:生成中切走时用于路由,后台事件不污染当前视图
|
||||
generatingConvId: null as string | null,
|
||||
// 正在生成的会话集合(F-09 多会话并发):后端 per-conv 已支持多会话同时生成,
|
||||
// 前端用 Set 表达"多会话同时生成"态。生成中切走时用于路由,后台事件不污染当前视图。
|
||||
// isGenerating(convId)/addGenerating/removeGenerating helper 经 useAiStore 暴露。
|
||||
// 单会话场景行为不变(Set 含 0 或 1 元素)。
|
||||
generatingConvs: new Set<string>(),
|
||||
providers: [] as AiProviderConfig[],
|
||||
activeProvider: null as string | null,
|
||||
panelOpen: true,
|
||||
@@ -185,6 +188,23 @@ const filteredConversations = computed<AiConversationSummary[] | null>(() => {
|
||||
.sort((a, b) => (b.updated_at > a.updated_at ? 1 : b.updated_at < a.updated_at ? -1 : 0))
|
||||
})
|
||||
|
||||
/**
|
||||
* F-09 多会话并发:生成态 Set helper。
|
||||
*
|
||||
* Vue 3 reactive 对 Set 的 has/add/delete 均有 proxy 跟踪,在 computed/template
|
||||
* 内调用 isGenerating(convId) 会建立响应式依赖,Set 变更时自动触发更新。
|
||||
* 单会话场景:Set 含 0 或 1 元素,行为与原单值 generatingConvId 等价。
|
||||
*/
|
||||
function addGenerating(convId: string): void {
|
||||
state.generatingConvs.add(convId)
|
||||
}
|
||||
function removeGenerating(convId: string): void {
|
||||
state.generatingConvs.delete(convId)
|
||||
}
|
||||
function isGenerating(convId: string | null | undefined): boolean {
|
||||
return !!convId && state.generatingConvs.has(convId)
|
||||
}
|
||||
|
||||
/**
|
||||
* AI Store 统一入口 — 返回单例 state + 全部方法。
|
||||
*
|
||||
@@ -197,6 +217,10 @@ export function useAiStore() {
|
||||
return {
|
||||
state,
|
||||
filteredConversations,
|
||||
// F-09: 生成态 Set helper(替代单值 generatingConvId 的读写)
|
||||
addGenerating,
|
||||
removeGenerating,
|
||||
isGenerating,
|
||||
...useAiEvents(),
|
||||
...useAiStream(),
|
||||
...useAiSend(),
|
||||
|
||||
Reference in New Issue
Block a user