任务结束后,把该任务涉及的文件改动汇总到任务标题和任务条目下方,同时保留后续接入回滚功能需要的轮次信息。
Agent runtime 的文件写入继续只记录原始 fileChanges
packages/services/src/session/fileChangeTracker.tsbeforeContent / afterContent 记到 session file change tracker任务摘要在读取任务列表时动态聚合
packages/services/src/session/taskChangeSummary.tspackages/services/src/session/zcodeTaskService.tsZCodeTaskMeta.changeSummaryUI 只消费摘要,不直接扫描完整快照
packages/ui/src/lib/taskChangeSummary.tspackages/ui/src/TaskList.tsxpackages/ui/src/App.tsxfileCount: 任务涉及的唯一文件数added / removed: 按任务最终结果聚合后的总行数files[]
pathadded / removedwriteCountlastTurnIndexfileChangeschangeSummary.files[].lastTurnIndex 只是 UI 快速定位入口v4 conversation 不复用旧 session/previewFileRewind / session/applyFileRewind 入口;每轮文件摘要和撤销要走 v4 投影与命令/查询边界。产品语义固定为“只撤销工作区文件修改”:撤销成功后不删除、不截断、不改写聊天历史,只把对应轮次的文件状态标记为已撤销。
Write/Edit 等文件工具
-> core 写入 workspace checkpoint artifact
-> SessionEvent.CheckpointCreated(snapshotRef/diffRef/messageId/targetMessageId/toolMessageId)
-> 同步写入既有 session_entry(runtime/workspace_checkpoint),冷恢复时重建 checkpoint event
-> v4 ProductProjection 按 stable messageId/turnId 归属到 turnHeader
-> TurnHeader.fileChanges = { files, additions, deletions }
-> UI 在该轮尾部显示文件摘要
用户点击撤销文件
-> previewFileRewind(turn/message target)
-> core previewWorkspaceFileRewind 做 hash 安全检查
-> UI 弹窗展示 safe / unsafe / ignored 文件
-> applyFileRewind
-> core applyWorkspaceFileRewind 写回或删除文件
-> SessionEvent.RewindTriggered(scope=workspace, reason=file_summary_rewind)
-> 同步写入既有 session_entry(runtime/workspace_file_rewind),冷恢复时重建撤销事件
-> v4 ProductProjection 标记该轮文件已撤销,不触发 row.removed
turnHeader.fileChanges 只承载轻量摘要:文件数、总新增行、总删除行,以及后续需要的撤销状态;不要把完整 patch 或 before/after content 放进 replayable snapshot。CheckpointCreated 的 event store 是运行时内存账本;checkpoint payload 还必须写入既有
session_entry,child/main runtime 冷恢复时先重建事件再执行 preview/apply。该持久化复用现有表,
不新增数据库表或 migration;artifact 仍是 before/after 内容的唯一大对象来源。RewindTriggered 同样写入既有 session_entry;否则关闭详情或重启后会把已撤销
turn 重新投影成 active。detached child cold resume 产生新的 raw event epoch 时,以
SessionResumed 重设 gateway raw cursor,但 transport sequence 继续单调递增。messageId / turnId / checkpoint id;turnIndex 只能作为旧数据兼容 fallback,不能作为新协议的主要定位。CheckpointCreated(scope=workspace|both) 可以贡献文件摘要;shell/bash checkpoint 如果 core 判为 ignored,撤销 preview 只展示 ignored,不作为可安全写回文件。availability.rewindFiles 表达,行上的 canRewindFiles 只表达该轮是否可撤销。canRewindFiles 与 availability.rewindFiles 门禁;父 task 是否仍在运行不新增
父级 guard。父任务或外部进程对同一文件的修改继续由现有 hash preview 判为 unsafe。childSessionId 为命令 session。desktop-continuous 通过 live delta 更新摘要和撤销状态;手机 /remote 的 web-remote-replayable 通过同一 host projection/snapshot 恢复,不在 relay 或 main 进程下沉 session/task/stream/file 状态。workspaceIdentity / remoteSessionId 贯穿 bridge、snapshot、撤销 target 和缓存 key;身份隔离使用 workspaceKey = workspaceIdentity?.trim() || workspacePath。N files changed +A -D;移动端保持同等信息,但按钮和文件行更紧凑。+/- 行数,不展示写入/修改次数;点击文件行或 Review 打开 code viewer diff。Review 按钮一致:打开右侧 code viewer 的 diff 预览Review 按钮保留文字入口,不展示图标,避免和整行点击入口形成重复视觉强调task_error 现在也会持久化本轮 fileChanges