消息 summary 中的文件变更按钮用于撤销本轮文件修改。旧链路直接调用 workspace rewind,
只依赖 checkpoint 的 beforeContent 写回,无法确认用户点击时文件是否已经被其他进程改过。
当同一个文件在同一轮里被多个 tool 连续修改时,也必须按照 checkpoint 的创建顺序倒序逐次回放,
不能只使用最终聚合 diff 做一次写回。
fileChanges.snapshots 或 tool result 推断写回内容;真正的预检和写回由 agent runtime 完成。applyFileRewind 保持 workspace-only;它可以展示 ignored shell 文件并撤销其余安全文件。editUserQuery(workspaceMode=rewind) 要求完整回滚目标轮:unsafe、ignored shell、
unsupported 或没有安全 checkpoint 都返回结构化 blocked,不写文件、不裁 conversation、不发模型请求。新增两个 ZCode Protocol session 方法:
session/previewFileRewindsession/applyFileRewind参数复用 session 历史 target:
{
sessionId: string;
target: ZCodeSessionHistoryTarget;
expectedRevision?: number;
}
preview 返回文件级结果:
{
sessionId: string;
target: ZCodeSessionHistoryTarget;
canApply: boolean;
safeFiles: Array<{
path: string;
action: "restore" | "delete";
operationCount: number;
toolNames: string[];
}>;
unsafeFiles: Array<{
path: string;
reason:
| "external_modified"
| "checkpoint_missing"
| "checkpoint_unreadable"
| "unsupported_checkpoint"
| "file_read_failed";
operationCount: number;
toolNames: string[];
}>;
ignoredFiles: Array<{
path: string;
reason: "bash_ignored";
operationCount: number;
toolNames: string[];
}>;
}
applyFileRewind 返回重新预检后的 preview、是否 applied,以及应用后的 snapshot。
turn target 同样解析到对应轮次的 user message。beforeContent + structuredPatch 重建。canApply=false 时不写文件。fileState 更新为 reverted。该能力是 session command,不改变 task realtime 传输语义。桌面端仍保持
desktop-continuous 主链路;手机远控通过 shared-host attachment 调用同一 session host,
再按 replayable snapshot 恢复 UI,不把 replayable 运行态恢复逻辑扩散到桌面端。