Repository navigation
fix(chat): 会话离开时清掉 turnCollapse 折叠分桶,并给分桶个数加上限 - #831
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
#818、#819 评审的 follow-up。
stores/turnCollapse.ts的折叠记录(轮次 + 工具行)只在删会话时清理。coworker 被解雇、btw 被关闭、task 子代理收进历史后,分桶都留在 localStorage 里成了孤儿。每个会话最多 400 条,但分桶个数没有上限。What changed
sessions/index.ts:新增forgetCollapsedIfGone,在会话确实离开投影之后调用,挂在四个出口:coworkerdismissed回流、task 子代理停留 8 秒后收进历史、dismissCoworkerFromUI的死 tab 兜底、disposeBtwConversation。task 在停留期间被复活的,不清。turnCollapse.ts:分桶个数上限TURN_COLLAPSE_CONVERSATION_LIMIT = 100,轮次和工具行按会话 id 合计。持久化里加recent(最近写入的在末尾),超出时按最久未用整桶淘汰。旧数据里不在recent中的会话,视为最旧。Tradeoffs
Scope
不改:关掉「自动折叠」后,以前收起过的轮次展开后收不回去(#818 低优先级)。根因:
UserMeta、TurnCollapseFooter、turnSpans/Esc 都要求autoCollapseTurns开启才会出现,现有测试也锁定了「关掉开关就没有收起入口」。建议的修法:轮次 id 在 override 里(包括false)时仍给出收起入口。这会牵涉三处 UI 和一条现有约定,所以另开处理。Verification
expected { a: true } to be undefined);修复后相关 5 个文件 64 条全部通过。pnpm typecheck通过;pnpm lint无 error;pnpm test:changed:247 files / 2069 tests passed。