feat: per-turn file change summary button - #1851
Open
ArrogHie wants to merge 1 commit into
Open
Conversation
Add a TurnFilesSummary component that shows a centered button with file count and line changes for the last completed turn only. Clicking the button expands a popover listing all files modified in that turn, each openable in a diff editor. - Only renders on the last round of the last turn after streaming ends - Disappears when a new turn starts (isLastTurn becomes false) - Uses get_turn_files Rust command for per-turn file scoping - Add getTurnFiles to SnapshotAPI with dedup - Add isLastTurn and turnBackendIndex to VirtualItem model-round - Add i18n keys for en-US, zh-CN, zh-TW
ArrogHie
force-pushed
the
feature/turn-files-summary
branch
from
July 30, 2026 01:12
64f7201 to
43436b2
Compare
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.
概述
新增
TurnFilesSummary组件,在最后一轮对话完成后,于会话下方渲染一个居中且醒目的按钮。按钮显示该轮对话中修改的文件个数以及总增删行数。点击按钮展开浮层,列出所有被修改的文件;点击文件可打开 diff 编辑器查看具体改动。现有的
SessionFilesBadge位于聊天头部,显示整个会话中修改的所有文件。本功能提供按轮次粒度的改动展示,仅在轮次完全结束(包括打字机动画)后出现,并在新一轮对话开始时自动消失。核心行为
isLastRound且isLastTurn)!isVisuallyStreaming)isLastTurn变为false)get_turn_filesRust 命令按轮次范围获取文件(非全会话)变更文件
TurnFilesSummary.tsxTurnFilesSummary.scssModelRoundItem.tsxSnapshotAPI.tsmodernFlowChatStore.tsVirtualItemRenderer.tsxen-US/flow-chat.jsonzh-CN/flow-chat.jsonzh-TW/flow-chat.json数据流
实现细节
TurnFilesSummary.tsx(新增,465 行)自包含组件:通过
getTurnFiles加载该轮文件,以 60 秒 TTL 缓存和并发上限 3 获取每个文件的 diff 统计,渲染居中按钮和浮层。点击文件通过createDiffEditorTab打开 diff 编辑器。TurnFilesSummary.scss(新增,261 行)全宽 flex 容器,按钮居中。按钮:28px 高度,sm 字号,柔和背景色,细边框。浮层:通过
left:50% + translateX(-50%)居中,动画关键帧保留translateX避免位置跳变。ModelRoundItem.tsx(+13 −3)新增
isLastTurnprop。TurnFilesSummary渲染在 footer div 外部(独立视觉区块)。渲染条件:isTurnComplete && isLastRound && isLastTurn && !isVisuallyStreaming。memo 比较函数加入isLastTurn。SnapshotAPI.ts(+20)新增
getTurnFiles(sessionId, turnIndex, workspacePath?)方法,封装已有的 Rustget_turn_files命令,带请求去重。modernFlowChatStore.ts(+5)在
model-roundVirtualItem 类型中新增isLastTurn和turnBackendIndex字段。分别从turnIndex === dialogTurns.length - 1和turn.backendTurnIndex赋值。国际化(3 个语言文件共 +15)
新增
turnFilesSummary命名空间,包含filesCount、expandCue、clickToViewDiff三个键,覆盖 en-US、zh-CN、zh-TW。开发中解决的问题
1. "Rendered more hooks than during the previous render"
toggleHint的useMemo放在了提前return null之后。将所有 hooks 移到任何条件返回之前,确保 hook 数量在每次渲染中恒定。2. 浮层弹出时位置跳变
动画关键帧仅包含
translateY,丢失了translateX(-50%)居中偏移。在from和to关键帧中均加入translateX(-50%),使动画全程保持居中。3. Agent 输出时屏闪
TurnFilesSummary在流式输出期间提前出现,导致虚拟列表高度变化引起重排。通过增加!isVisuallyStreaming条件和容器min-height:0修复。验证
pnpm run type-check:web(tsc --noEmit)pnpm run i18n:contract:test(37 项测试)