Skip to content

fix: Windows snapshot fails with non-ASCII filenames (Chinese, Japanese, etc.)#9844

Closed
yimingll wants to merge 1 commit intoanomalyco:devfrom
yimingll:fix/windows-non-ascii-snapshot
Closed

fix: Windows snapshot fails with non-ASCII filenames (Chinese, Japanese, etc.)#9844
yimingll wants to merge 1 commit intoanomalyco:devfrom
yimingll:fix/windows-non-ascii-snapshot

Conversation

@yimingll
Copy link
Copy Markdown

@yimingll yimingll commented Jan 21, 2026

Summary

Fix undo/revert not working on Windows when project contains non-ASCII filenames (e.g., Chinese, Japanese, Korean characters).

Problem

On Windows, Bun's $ template literal incorrectly handles variable interpolation, replacing variables with placeholders like ?__bunstr_0 instead of actual values. This causes:

  1. git add . to silently fail adding non-ASCII filenames to snapshot
  2. git checkout / git ls-tree to fail finding files during revert
  3. Undo command only reverts conversation but not code changes

Solution

Replace all $ template calls with Bun.spawn() which correctly passes arguments as an array, bypassing shell interpolation issues.

Also adds unquote() function to decode git octal-escaped non-ASCII filenames in diff output (when core.quotepath=true, which is the default).

Testing

Tested on Windows 11 with Chinese filenames (e.g., 公共函数.cpp) - undo now correctly reverts files.

Fixes #10210

@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

PR #9408: test(snapshot): add extended test cases for revert functionality

This PR is related as it addresses snapshot and revert functionality testing, which is directly relevant to the snapshot/revert issues being fixed in PR #9844.

However, this appears to be a test PR rather than a fix for the same issue, so it's more of a complementary PR than a true duplicate.

No duplicate PRs found addressing the same Windows non-ASCII filename snapshot issue.

On Windows, Bun's $ template literal incorrectly handles variable interpolation,
replacing variables with placeholders like ?__bunstr_0 instead of actual values.

This causes:
- git add . to silently fail adding non-ASCII filenames to snapshot
- git checkout / git ls-tree to fail finding files during revert
- Undo command only reverts conversation but not code changes

Solution: Replace all $ template calls with Bun.spawn() which correctly
passes arguments as an array, bypassing shell interpolation issues.

Also adds unquote() function to decode git's octal-escaped non-ASCII filenames
in diff output (when core.quotepath=true, which is the default).

Tested on Windows 11 with Chinese filenames - undo now correctly reverts files.

Fixes anomalyco#10210
@github-actions
Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions bot closed this Mar 25, 2026
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.

Undo/revert fails for files with non-ASCII filenames on Windows

1 participant