优化: 工具失败视觉区分(UX-01)+旧卡自动收起增强(UX-03)
This commit is contained in:
@@ -64,6 +64,11 @@ const emit = defineEmits<{
|
||||
const rootEl = ref<HTMLElement>()
|
||||
// 卡片级折叠(整卡 body 显隐,区别于 read_file 内容级)
|
||||
const expandedCards = ref(new Set<string>())
|
||||
// UX-260616-03:用户主动展开的卡片(记忆态,不被自动收起清除)。
|
||||
// 与 expandedCards 区分:expandedCards 是"展开"语义的当前态(含默认首卡),
|
||||
// userExpandedCards 是"用户明确点开"的持久标记,collapseInactive 跳过这些卡。
|
||||
// 语义:用户读过的卡不强制折叠,符合"跟随阅读位置"的增强目标。
|
||||
const userExpandedCards = ref(new Set<string>())
|
||||
// 内容级展开(read_file "展开全部")
|
||||
const expandedTools = ref(new Set<string>())
|
||||
// 分组折叠状态(按分组索引);多卡片分组默认收起
|
||||
@@ -166,10 +171,14 @@ function toggleAllGroups(): void {
|
||||
* - 分组未折叠 → 用户手动 expandedCards 或首卡默认展开
|
||||
* - 分组已折叠 → false(整组隐藏)
|
||||
* - 多卡片分组 + 未手动操作过 → 仅首卡(ci===0)展开
|
||||
* - UX-260616-03:userExpandedCards(用户主动展开记忆)优先,即使父级 collapseInactive
|
||||
* 清了 expandedCards,记忆态仍保持展开(用户读过的卡不强制折叠)。
|
||||
*/
|
||||
function isCardExpanded(tc: AiToolCallInfo, gi: number, ci: number): boolean {
|
||||
if (isGroupCollapsed(gi)) return false
|
||||
// 用户手动切换过该卡
|
||||
// UX-260616-03:用户主动展开的卡片记忆态优先(不被自动收起影响)
|
||||
if (userExpandedCards.value.has(tc.id)) return true
|
||||
// 用户手动切换过该卡(当前态)
|
||||
if (expandedCards.value.has(tc.id)) return true
|
||||
// 多卡片分组:仅首卡默认展开
|
||||
if (groupedToolCalls.value[gi]?.calls.length >= 2) return ci === 0
|
||||
@@ -178,8 +187,15 @@ function isCardExpanded(tc: AiToolCallInfo, gi: number, ci: number): boolean {
|
||||
}
|
||||
|
||||
function toggleCardExpand(id: string) {
|
||||
if (expandedCards.value.has(id)) expandedCards.value.delete(id)
|
||||
else expandedCards.value.add(id)
|
||||
if (expandedCards.value.has(id)) {
|
||||
expandedCards.value.delete(id)
|
||||
// 收起时同步清记忆(下次自动收起可作用于它)
|
||||
userExpandedCards.value.delete(id)
|
||||
} else {
|
||||
expandedCards.value.add(id)
|
||||
// UX-260616-03:展开即记忆(用户主动展开,后续不被自动收起)
|
||||
userExpandedCards.value.add(id)
|
||||
}
|
||||
}
|
||||
|
||||
function toggleExpand(id: string) {
|
||||
@@ -187,7 +203,12 @@ function toggleExpand(id: string) {
|
||||
else expandedTools.value.add(id)
|
||||
}
|
||||
|
||||
/** 收起不在 activeIds 中的已完成/已拒绝卡片(供父组件 auto-collapse watch 调用) */
|
||||
/**
|
||||
* 收起不在 activeIds 中的已完成/已拒绝卡片(供父组件 auto-collapse watch 调用)。
|
||||
* UX-260616-03:userExpandedCards(用户主动展开记忆)不被清除——用户读过的卡
|
||||
* 即使不再 active(running/pending/write_file)也保持展开,避免"我刚才在看,突然被收起"。
|
||||
* 仅清 expandedCards(默认态/首卡)与 expandedTools(内容级展开,跟随卡片折叠)。
|
||||
*/
|
||||
function collapseInactive(activeIds: Set<string>): void {
|
||||
// CR-260615-31:对称过滤 expandedTools(原只清 expandedCards,expandedTools 残留致折叠后内容展开态)
|
||||
if (expandedCards.value.size > 0) {
|
||||
@@ -196,6 +217,7 @@ function collapseInactive(activeIds: Set<string>): void {
|
||||
if (expandedTools.value.size > 0) {
|
||||
expandedTools.value = new Set([...expandedTools.value].filter(id => activeIds.has(id)))
|
||||
}
|
||||
// UX-260616-03:不清 userExpandedCards(记忆态),isCardExpanded 优先读它保持展开。
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user