优化: F-09生成中新建对话不中断(决策e)
去中断弹窗+去generatingConvs.clear(对齐switchConversation真并发)+死key清理;vue-tsc✅
This commit is contained in:
@@ -238,15 +238,14 @@ async function confirmClearChat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新建对话(UX-08 §3.4):生成中点新建 → 弹 ConfirmDialog「当前正在生成,确定中断并新建?」,
|
* 新建对话(UX-08 §3.4 / F-09 决策e):新建 = createConversation + 切 active,
|
||||||
* 确认走原软复位流程(B-260615-10 store.newConversation,中断 + 新建);取消不动(保持生成)。
|
* 旧 conv 后台 loop 继续(后端 ai_conversation_create 决策e 不杀旧 loop),与 switchConversation
|
||||||
* 非生成中直接走原新建流程(零行为变化)。仅「当前视图正在生成」才弹确认 ——
|
* 同属真并发语义——不弹「中断并新建」确认(与并行矛盾)。对齐 switchConversation:89-91
|
||||||
* 切走后台生成时(streaming && !isGenerating(activeConversationId))不算中断当前视图。
|
* 「允许生成中切换:后台继续生成,事件按 conversation_id 路由」。
|
||||||
|
*
|
||||||
|
* 历史:B-260615-10 单 loop 软复位弹中断确认,F-09 决策e 上线后已废弃(A 路线遗留)。
|
||||||
*/
|
*/
|
||||||
async function confirmNewConversation() {
|
async function confirmNewConversation() {
|
||||||
if (isViewingGenerating.value) {
|
|
||||||
if (!await confirmDialog(t('aiChat.confirmNewConvWhileGenerating'))) return
|
|
||||||
}
|
|
||||||
await store.newConversation()
|
await store.newConversation()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,13 +274,6 @@ const convSidebarRef = ref<InstanceType<typeof ConversationSidebar> | null>(null
|
|||||||
// cycleProvider/providerBarVisible/showProviderSwitched 已迁移至 ai/TopBar.vue
|
// cycleProvider/providerBarVisible/showProviderSwitched 已迁移至 ai/TopBar.vue
|
||||||
// (顶部工具栏 + provider/model 选择逻辑,零行为变更,store 单例共享 modelOverride)。
|
// (顶部工具栏 + provider/model 选择逻辑,零行为变更,store 单例共享 modelOverride)。
|
||||||
|
|
||||||
// 当前视图是否正在生成(切走后台生成时光标不显示)
|
|
||||||
// F-09: 多会话并发 — 用 isGenerating(activeConversationId) 替代单值比对,
|
|
||||||
// 当前会话在生成 Set 中即算"视图正在生成"(其他会话后台生成不影响本视图判定)
|
|
||||||
const isViewingGenerating = computed(() =>
|
|
||||||
store.state.streaming && store.isGenerating(store.state.activeConversationId)
|
|
||||||
)
|
|
||||||
|
|
||||||
/** UX-09:进入编辑态 — 置 editingMsgId(透传 ChatInput prop)+ 委托 ChatInput.startEditFocus 回填/聚焦。 */
|
/** UX-09:进入编辑态 — 置 editingMsgId(透传 ChatInput prop)+ 委托 ChatInput.startEditFocus 回填/聚焦。 */
|
||||||
function startEdit(msg: AiMessage): void {
|
function startEdit(msg: AiMessage): void {
|
||||||
editingMsgId.value = msg.id
|
editingMsgId.value = msg.id
|
||||||
|
|||||||
@@ -223,7 +223,7 @@
|
|||||||
* - `confirm-delete`(id):删除需弹 ConfirmDialog,而 ConfirmDialog 由父渲染 +
|
* - `confirm-delete`(id):删除需弹 ConfirmDialog,而 ConfirmDialog 由父渲染 +
|
||||||
* confirmDialog 实例归父所有(useConfirm 每次调用返回独立 ref,非全局单例),
|
* confirmDialog 实例归父所有(useConfirm 每次调用返回独立 ref,非全局单例),
|
||||||
* 故删除确认交父处理。父调原 confirmDeleteConversation(id)。
|
* 故删除确认交父处理。父调原 confirmDeleteConversation(id)。
|
||||||
* - `confirm-new-conversation`:新建对话(生成中走确认弹层),交父 confirmNewConversation。
|
* - `confirm-new-conversation`:新建对话(F-09 决策e 直接新建,旧后台继续不中断),交父 confirmNewConversation。
|
||||||
* - 父 Ctrl+K 全局快捷键聚焦搜索框:经 defineExpose({ focusSearch }) 供父调,
|
* - 父 Ctrl+K 全局快捷键聚焦搜索框:经 defineExpose({ focusSearch }) 供父调,
|
||||||
* 父侧 ref 替代原 searchInputRef(零行为变更)。
|
* 父侧 ref 替代原 searchInputRef(零行为变更)。
|
||||||
*
|
*
|
||||||
@@ -239,7 +239,7 @@ import type { AiConversationSummary } from '../../api/types'
|
|||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
/** 删除对话(需二次确认),父调 confirmDeleteConversation(id) */
|
/** 删除对话(需二次确认),父调 confirmDeleteConversation(id) */
|
||||||
(e: 'confirm-delete', id: string): void
|
(e: 'confirm-delete', id: string): void
|
||||||
/** 新建对话(生成中需二次确认),父调 confirmNewConversation() */
|
/** 新建对话(F-09 决策e 直接新建,旧后台继续不中断),父调 confirmNewConversation() */
|
||||||
(e: 'confirm-new-conversation'): void
|
(e: 'confirm-new-conversation'): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ defineProps<{
|
|||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
/** 折叠/展开会话侧栏(store.toggleSidebar,父转发保持 store 单一调用源) */
|
/** 折叠/展开会话侧栏(store.toggleSidebar,父转发保持 store 单一调用源) */
|
||||||
(e: 'toggle-sidebar'): void
|
(e: 'toggle-sidebar'): void
|
||||||
/** 新建会话(父 confirmNewConversation 带二次确认) */
|
/** 新建会话(父 confirmNewConversation,F-09 决策e 直接新建无中断确认) */
|
||||||
(e: 'new-conversation'): void
|
(e: 'new-conversation'): void
|
||||||
/** 清空上下文(归档保留;父 handleClearContext) */
|
/** 清空上下文(归档保留;父 handleClearContext) */
|
||||||
(e: 'clear-context'): void
|
(e: 'clear-context'): void
|
||||||
|
|||||||
@@ -71,11 +71,13 @@ async function newConversation() {
|
|||||||
state.currentText = ''
|
state.currentText = ''
|
||||||
state.pendingApprovals = []
|
state.pendingApprovals = []
|
||||||
state.streaming = false
|
state.streaming = false
|
||||||
// F-260616-09(A 路线):补漏清字段维持单例软隔离,解「新建会话上下文残留」。
|
// F-09 决策e(真并发):newConversation 对齐 switchConversation 并行语义——旧 conv 后台 loop 继续,
|
||||||
// queue 清空防旧会话排队消息被带进新会话 drain;generatingConvs 清空防后台事件
|
// 不清 generatingConvs(保留旧 conv 生成态跟踪,侧栏显双会话生成,AiCompleted/AiError 按
|
||||||
// 错误路由;agentRound 复位 0;searchQuery 清空防新会话侧栏被旧搜索过滤。
|
// conversation_id 正确收尾旧 conv)。原 state.generatingConvs.clear() 是 A 路线 F-260616-09
|
||||||
|
// 单 loop 软隔离遗留,真并发下致后台生成前端丢失跟踪,废弃。
|
||||||
|
// queue 清空防旧会话排队消息带进新会话 drain;agentRound 复位 0;searchQuery 清空防新会话
|
||||||
|
// 侧栏被旧搜索过滤。此三项均为新 conv 本地视图复位(非跨 conv 跟踪),保留。
|
||||||
state.queue = []
|
state.queue = []
|
||||||
state.generatingConvs.clear()
|
|
||||||
state.agentRound = 0
|
state.agentRound = 0
|
||||||
state.searchQuery = ''
|
state.searchQuery = ''
|
||||||
await loadConversations()
|
await loadConversations()
|
||||||
|
|||||||
@@ -115,8 +115,6 @@ export default {
|
|||||||
confirmDeleteActiveConversation: '"{title}" is the chat you are currently viewing. Deleting it will clear the current view and cannot be undone. Continue?',
|
confirmDeleteActiveConversation: '"{title}" is the chat you are currently viewing. Deleting it will clear the current view and cannot be undone. Continue?',
|
||||||
clearChat: 'Clear',
|
clearChat: 'Clear',
|
||||||
confirmClearChat: 'Are you sure you want to clear all messages in this chat? This cannot be undone.',
|
confirmClearChat: 'Are you sure you want to clear all messages in this chat? This cannot be undone.',
|
||||||
// UX-08 §3.4: generate-in-progress confirm when starting a new chat (only when generating, otherwise no behavior change)
|
|
||||||
confirmNewConvWhileGenerating: 'Generation is in progress. Interrupt it and start a new chat?',
|
|
||||||
toastSendFail: 'Send failed: {msg}',
|
toastSendFail: 'Send failed: {msg}',
|
||||||
|
|
||||||
// ── Message copy (F-260615-13) ──
|
// ── Message copy (F-260615-13) ──
|
||||||
|
|||||||
@@ -116,8 +116,6 @@ export default {
|
|||||||
confirmDeleteActiveConversation: '「{title}」是当前正在查看的对话,删除后将清空当前视图且不可恢复,确定继续?',
|
confirmDeleteActiveConversation: '「{title}」是当前正在查看的对话,删除后将清空当前视图且不可恢复,确定继续?',
|
||||||
clearChat: '清空',
|
clearChat: '清空',
|
||||||
confirmClearChat: '确定清空当前对话的所有消息?此操作不可恢复。',
|
confirmClearChat: '确定清空当前对话的所有消息?此操作不可恢复。',
|
||||||
// UX-08 §3.4:生成中点新建对话确认弹窗(仅生成中触发,非生成中零行为变化)
|
|
||||||
confirmNewConvWhileGenerating: '当前正在生成,确定中断并新建对话?',
|
|
||||||
toastSendFail: '发送失败:{msg}',
|
toastSendFail: '发送失败:{msg}',
|
||||||
|
|
||||||
// ── 消息拷贝(F-260615-13) ──
|
// ── 消息拷贝(F-260615-13) ──
|
||||||
|
|||||||
Reference in New Issue
Block a user