Skip to content

fix(core): preserve renamed files when undoing changes - #45383

Merged
kitlangton merged 1 commit into
v2from
fix-rename-undo
Aug 27, 2026
Merged

kitlangton merged 1 commit into
v2from
fix-rename-undo

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Why

Undoing a file rename can remove the renamed file without restoring its original path. Snapshot change lists use rename-aware git diff --name-only, which reports only the destination; the revert plan therefore removes that destination but never restores the source.

What Changes

Enumerate tree changes with --no-renames, matching the existing per-file diff behavior. Both paths are then included in newly recorded snapshot change lists.

Operation Before After
Record old name.txt renamed to new name.txt Only the new path is recorded Both paths are recorded
Stage Undo Both paths can be absent Original path and content are restored; new path is removed

The regression uses a real Git repository, Location-scoped snapshots, durable Session event projection, and the public Session.revert.stage / clear operations. It also verifies that clearing staged Undo restores the renamed path and content, and that unrelated later edits survive both operations. Only model execution is disabled. A lower-level test verifies filename enumeration and added/deleted diffs with Git rename detection explicitly enabled.

Scope

One Git comparison flag, its explanation, regression coverage, and a Core patch changeset. This fixes newly computed snapshot file lists; it does not rewrite older Session history whose persisted file lists already omitted a rename source.

Verification

# packages/core
bun run test test/git.test.ts test/snapshot.test.ts test/session-revert.test.ts test/session-prompt.test.ts
bun run test test/git.test.ts test/session-revert.test.ts --test-name-pattern 'both sides of a rename|undoes and restores a file rename' --rerun-each 10
bun run test
bun typecheck
bun run build

# worktree root
bunx prettier --check packages/core/src/git.ts packages/core/test/git.test.ts packages/core/test/session-revert.test.ts .changeset/rename-undo.md
bunx oxlint packages/core/src/git.ts packages/core/test/git.test.ts packages/core/test/session-revert.test.ts
bunx ast-grep scan -c script/ast-grep/effect-simplifications/sgconfig.yml --off=unused-suppression packages/core/src/git.ts packages/core/test/git.test.ts packages/core/test/session-revert.test.ts
git diff --check
# Normal push hook also ran all workspace typecheck tasks.
git push -u origin fix-rename-undo
  • Both new regressions failed on the unchanged production code across three repetitions: the old path was omitted, and public Undo left both paths absent.
  • Focused suites: 56 passed, 184 assertions.
  • Repeated regressions after the fix: 20 passed, 100 assertions.
  • Full Core suite: 3,654 passed, 39 skipped, 0 failed across 217 files; 78,250 assertions.
  • Core typecheck, build, formatting, Effect simplification scan, and whitespace checks passed.
  • Oxlint: no errors; one pre-existing consistent-return warning in git.ts.
  • All 33 workspace pre-push typecheck tasks passed.
  • Independent read-only correctness review found no issues. Windows execution is left to CI; local verification was on macOS.

@kitlangton
kitlangton merged commit d68031b into v2 Aug 27, 2026
10 checks passed
@kitlangton
kitlangton deleted the fix-rename-undo branch August 27, 2026 00:42
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
brentyates-swx pushed a commit to swxtchio/swx-opencode-archive that referenced this pull request Nov 4, 2026
brentyates-swx added a commit to swxtchio/swx-opencode-archive that referenced this pull request Nov 4, 2026
* chore(opencode): plan upstream backports

- Keep all four assigned fixes as separate full-SHA cherry-pick -x commits.
- Adapt producer-driven regressions at the fork RPC, browser launcher, V2 undo, and Copilot stream/replay boundaries.
- Prove each changed behavior with focused red/green runs, then record provenance and compatibility in CHANGESET.md.

Claude-Session: unknown

* fix(opencode): answer a failed TUI worker request instead of hanging (anomalyco#54936)

Co-authored-by: James Long <[email protected]>
(cherry picked from commit bbad8f3)

* fix(opencode): catch completed MCP browser launcher failures (anomalyco#51538)

Co-authored-by: rekram1-node <[email protected]>
(cherry picked from commit b471c2b)

* fix(core): preserve renamed files when undoing changes (anomalyco#45383)

(cherry picked from commit d68031b)

* fix(core): accept interleaved Copilot reasoning_opaque values (anomalyco#54207)

(cherry picked from commit b2a3926)

* test(opencode): cover RPC worker failures

Claude-Session: unknown

* test(opencode): cover completed browser exit races

Claude-Session: unknown

* test(core): adapt rename undo regression to SessionV2

Claude-Session: unknown

* test(core): prove interleaved Copilot reasoning replay

Claude-Session: unknown

* test(opencode): assert completed launcher failure result

Claude-Session: unknown

* test(opencode): await isolated RPC outcomes together

Claude-Session: unknown

* test(opencode): keep RPC worker cleanup bounded

Claude-Session: unknown

* test(core): exercise rename through projected revert

Claude-Session: unknown

* test(core): use branded paths in rename regression

Claude-Session: unknown

* docs(opencode): record upstream backports

Claude-Session: unknown

* docs(opencode): record mutation-backed regressions

Claude-Session: unknown

* test(opencode): inline delayed browser test flow

Claude-Session: unknown

* test(opencode): acknowledge delayed launcher readiness

Claude-Session: unknown

* docs(opencode): clarify Copilot replay coverage

Claude-Session: unknown

* docs(opencode): describe delayed browser fixture acknowledgments

Claude-Session: unknown

---------

Co-authored-by: Damian Nowak <[email protected]>
Co-authored-by: James Long <[email protected]>
Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: rekram1-node <[email protected]>
Co-authored-by: Kit Langton <[email protected]>
Co-authored-by: Aiden Cline <[email protected]>
brentyates-swx added a commit to swxtchio/swx-opencode-archive that referenced this pull request Nov 6, 2026
Merge only 055d95b, the first parent of promotion 5caf1f9, across the 696f41b..055d95b range of 84 upstream commits.

Preserve the V1 CLI/server and SessionPrompt owners plus the fork queue, asks, usage, SQLite retry, process-group and retention paths.

Keep both .gitignore rules; retain Bun 1.4.4 and Solid 1.9.15 while taking the xAI 3.0.139 patch; keep the native FFF library copy and macOS ad-hoc re-signing.

Reconcile the in-range anomalyco#51538 and anomalyco#54207 backports at their existing production owners and retain the stronger fork browser and Copilot replay controls; keep anomalyco#54936 and anomalyco#45383 within the selected cut boundary.

nix/hashes.json refresh pending: values come from the FFF native platform validation nix-node-modules job logs (all four systems) once the PR leaves draft.

Claude-Session: unknown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant