Skip to content

feat:web端接入代码回退按键和功能,修复代码回退功能,还有优化界面#594

Merged
phantom5099 merged 4 commits into1024XEngineer:mainfrom
Yumiue:html_progress
May 10, 2026
Merged

feat:web端接入代码回退按键和功能,修复代码回退功能,还有优化界面#594
phantom5099 merged 4 commits into1024XEngineer:mainfrom
Yumiue:html_progress

Conversation

@Yumiue
Copy link
Copy Markdown
Collaborator

@Yumiue Yumiue commented May 9, 2026

概要

本次变更围绕“代码回退”补齐前后端闭环,主要包括:

  • Web 端文件变更面板新增 Rollback 回退入口
  • checkpoint 恢复/撤销恢复后,自动刷新会话、消息和文件变更视图
  • Runtime 侧补齐 run 级 baseline、workspace 漂移检测与回灌逻辑
  • 修复 restore 影响范围过宽、回退基线错绑等问题

主要改动

Web 端

  • 文件变更面板新增 Rollback 按钮,并增加二次确认弹窗
  • 新增 pending 状态展示,用于表示工具执行中的临时文件变更
  • checkpoint 恢复期间禁用相关操作,避免重复触发
  • checkpoint restored / undo restore 事件触发后,重新拉取当前会话状态,统一刷新消息、insight 和文件变更列表
  • 扩展事件协议,支持 bash_side_effect 事件和文件项 kind 字段

Runtime / Checkpoint

  • 新增 run 级 baseline 管理,持久化当前回退基线和 workspace 指纹
  • 在 run 开始前检测 workspace 是否发生外部漂移,必要时自动重锚 baseline
  • checkpoint diff 逻辑增加 run 范围校验,避免跨 run 误用 checkpoint
  • restore 逻辑收敛到目标 checkpoint 及其相关后续 checkpoint,减少无关文件被回滚的风险
  • restore 后同步记录 workspace 状态,保证后续异步 diff 可读取到一致基线

存储层

  • 新增 workspace fingerprint、workspace checkpoint state、run checkpoint baseline 的 SQLite 持久化表与读写接口

测试

  • 补充了 checkpoint、runtime、eventBridge、FileChangePanel 等相关测试,覆盖回退、恢复、漂移检测和状态同步路径

备注

  • 这次改动的核心目标是把“回退”从单点 UI 动作升级为完整链路:
    UI -> Gateway -> Runtime -> Checkpoint Store -> 状态回灌 -> UI

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copy link
Copy Markdown

@fennoai fennoai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the PR in four passes (code quality, performance, security, documentation). I found 3 issues worth fixing before relying on this rollback/baseline flow in production.

Comment thread internal/runtime/checkpoint_gate.go Outdated
runID := state.runID
state.mu.Unlock()

workdir := strings.TrimSpace(session.Workdir)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[high] This drift-rebase path uses session.Workdir directly, but Run() now does drift detection against agentsession.EffectiveWorkdir(...). For sessions that rely on the configured default workdir, session.Workdir is empty, so drift detection can fire while this function immediately returns workdir is empty, which disables the new rebase flow entirely for that common case. Please pass the effective workdir through here or normalize it the same way as the caller.

Comment thread internal/runtime/run.go Outdated
}
if statePtr != nil {
runEndCtx := context.Background()
s.recordRunEndWorkspaceState(runEndCtx, statePtr.session.ID, statePtr.session.Workdir, statePtr.lastEndOfTurnCheckpointID)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[high] This persists the post-run fingerprint/baseline using statePtr.session.Workdir. If the session is using the default workdir fallback, that field is empty and recordRunEndWorkspaceState becomes a no-op, so the next run has no persisted fingerprint/baseline to compare against. That breaks the new cross-run drift detection/baseline recovery logic for default-workdir sessions. This should use the effective workdir that was already computed at run start (or store it on runState).

_pendingRollbackAppliedRunId = undefined
}

const requestId = ++_latestRestoreSyncRequestId
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] Starting a restore reload here does not invalidate any in-flight _refreshRunFileChanges() requests. If an end-of-turn diff request from the pre-restore run resolves after this, it will still pass the current guards and call replaceFileChanges(...), repopulating the panel with stale pre-restore diffs. Please bump/cancel the run-diff request generation when a restore/undo sync begins.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

@phantom5099 phantom5099 merged commit c435f78 into 1024XEngineer:main May 10, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants