Skip to content

/undo does not restore code, and /redo corrupts Git state by committing all changes #27664

Closed as not planned

Description

@itwxb

Description

English Version

Title

[BUG] /undo does not restore code, and /redo corrupts Git state by committing all changes

Description

When the project is linked to Git, using the /undo command to revert the previous command in the conversation does not restore the code. Then using /redo completely messes up the Git state — all unstaged changes are committed (or forced into a single commit), breaking the normal Git workflow.

Expected Behavior

  • /undo should revert all file system and code changes made by the last command, including discarding uncommitted edits.
  • /redo should re‑apply the previously undone command, and should not interfere with Git history or trigger any automatic commits.
  • Same as Claude Code – have a double‑tap Esc feature that performs a normal undo/rollback without interfering with Git history.

Actual Behavior

  • After /undo, code files remain unchanged — no restoration occurs.
  • After /redo, the Git repository is corrupted: all local changes are committed at once (seems like git add . && git commit), disrupting incremental commit workflows.

Steps to Reproduce

  1. Start the AI coding assistant in a project that is already a Git repository.
  2. Execute a command that modifies code (e.g., edit or create a file).
  3. Type /undo to attempt reverting the previous change.
  4. Check the code files — they are not restored.
  5. Type /redo.
  6. Check Git status — all changes are committed automatically, and the history is messy.

Environment

  • Assistant/IDE plugin version: (please fill)
  • Git version: (please fill)
  • OS: (please fill)

Is this normal?

No, it is not normal.
/undo and /redo should only affect the file system state of the current session. They must not manipulate Git’s commit history or automatically stage/commit files. The current /redo behavior is a severe bug (possibly incorrectly calling git commit or triggering a global save action), causing users to lose fine‑grained control over commits.

Suggestion

Please review the implementation of /redo to ensure it never automatically invokes Git commit commands. /undo and /redo should roll back file content using in‑memory snapshots or local backups, rather than interfering with the version control system.



中文版

标题

[BUG] /undo 无法恢复代码,/redo 导致 Git 混乱并提交所有改动

描述

在项目已链接 Git 的情况下,使用 /undo 命令尝试恢复上一次对话中执行的命令时,代码并未被实际恢复。随后使用 /redo 命令,Git 状态被严重破坏 —— 所有未暂存的改动被自动提交(或强制加入了一次完整提交),导致 Git 历史混乱。

预期行为

  • /undo 应当撤销上一个命令对文件系统和代码的所有影响,包括回退未提交的编辑。
  • /redo 应当重新应用刚才被撤销的命令,且不应干预 Git 的提交历史或触发自动提交。
  • 和 Claude Code 一样,能够通过双击 Esc 实现正常的撤销 / 回退功能,且不会干扰 Git 历史。

实际行为

  • /undo 执行后,代码文件保持原状,未恢复。
  • /redo 执行后,Git 仓库出现异常:所有本地改动被一次性提交(可能是 git add . && git commit 行为),打乱了正常的增量提交流程。

复现步骤

  1. 在已初始化为 Git 仓库的项目中启动 AI 编程助手。
  2. 执行某个修改代码的命令(例如编辑或创建文件)。
  3. 输入 /undo 尝试回退上一步的改动。
  4. 检查代码文件 —— 发现并未恢复。
  5. 输入 /redo。
  6. 检查 Git 状态 —— 所有改动被自动提交,历史记录异常。

环境信息

  • 助手版本 / IDE 插件版本:(请填写)
  • Git 版本:(请填写)
  • 操作系统:(请填写)

这是否正常?

不正常。 /undo 和 /redo 仅应影响当前会话的文件系统状态,而不应操纵 Git 的提交历史或自动暂存/提交所有文件。目前的 redo 行为属于严重错误(可能错误调用了 git commit 或触发了全局保存逻辑),会导致用户丢失细粒度的提交控制。

建议

请检查 /redo 的实现逻辑,确保不会自动调用 Git 提交命令。/undo/redo 应基于内存或本地快照回滚文件内容,而非干扰版本控制系统。


Plugins

superpower

OpenCode version

1.14.51

Steps to reproduce

Additional Reproduction Steps / 补充复现步骤
English:

Have a Git‑linked project with some existing commit history.

In a conversation, execute /undo – the files are not restored.

Execute /redo – the Git state becomes messy, and the files are restored to a much earlier (unexpected) state.

中文:

一个链接了 Git 的项目,且该 Git 仓库已有一些提交记录。

在对话中执行 /undo,文件并未被恢复。

执行 /redo,Git 状态混乱,文件被恢复到了一个很早之前的状态。

Screenshot and/or share link

https://opncd.ai/share/CaF35McR

Operating System

windows10

Terminal

windos terminal

Activity

  1. github-actions commented on May 15, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    The /redo corrupting Git state aspect may be a new angle — if so, please confirm whether the above issues cover your case or if this is distinct enough to warrant a separate report.

  2. github-actions commented on Jul 15, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions