File paths with special characters (#) or non-ASCII characters fail to load in Diff/Review view #7061

Closed
opened 2026-02-16 18:06:03 -05:00 by yindo · 1 comment
Owner

Originally created by @shirukai on GitHub (Jan 21, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

There are two related issues regarding how file paths are handled in the application, causing issues when files contain special characters (like #) or non-ASCII characters (like Chinese).

  1. Frontend Path Truncation: In packages/app, file paths are processed as URLs. If a filename contains a # (e.g., feature#1.ts), stripQueryAndHash incorrectly interprets the part after # as a URL fragment and removes it. This results in the application looking for a truncated filename (e.g., feature) which does not exist.
  2. Backend Git Path Parsing: In packages/opencode, the git diff and git show commands output filenames with non-ASCII or special characters in a quoted, octal-escaped format (e.g., "\344\270\255\226\207.ts"). The current snapshot logic does not decode these paths, leading to ENOENT errors when trying to retrieve file content or diffs.

Plugins

No response

OpenCode version

v1.1.28

Steps to reproduce

  1. Initialize the project and start the dev server.
  2. Create a file with a # in the name, e.g., styles/main#v2.css.
  3. Create a file with Chinese characters, e.g., docs/说明.md.
  4. Stage or commit these files.
  5. Open the Session Review or Diff View pane.
  6. Click on the files to view the diff.

Expected behavior: The diff should load and display the file content correctly.
Actual behavior:

  • For styles/main#v2.css: The file might fail to open, or show empty content, because the request path is truncated to styles/main.
  • For docs/说明.md: The diff shows empty "Before" and "After" content because the backend failed to resolve the escaped path "\344\270...".

Screenshot and/or share link

Image Image

Operating System

macOS

Terminal

No response

Originally created by @shirukai on GitHub (Jan 21, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description There are two related issues regarding how file paths are handled in the application, causing issues when files contain special characters (like `#`) or non-ASCII characters (like Chinese). 1. **Frontend Path Truncation**: In `packages/app`, file paths are processed as URLs. If a filename contains a `#` (e.g., `feature#1.ts`), `stripQueryAndHash` incorrectly interprets the part after `#` as a URL fragment and removes it. This results in the application looking for a truncated filename (e.g., `feature`) which does not exist. 2. **Backend Git Path Parsing**: In `packages/opencode`, the `git diff` and `git show` commands output filenames with non-ASCII or special characters in a quoted, octal-escaped format (e.g., `"\344\270\255\226\207.ts"`). The current snapshot logic does not decode these paths, leading to `ENOENT` errors when trying to retrieve file content or diffs. ### Plugins _No response_ ### OpenCode version v1.1.28 ### Steps to reproduce 1. Initialize the project and start the dev server. 2. Create a file with a `#` in the name, e.g., `styles/main#v2.css`. 3. Create a file with Chinese characters, e.g., `docs/说明.md`. 4. Stage or commit these files. 5. Open the **Session Review** or **Diff View** pane. 6. Click on the files to view the diff. **Expected behavior**: The diff should load and display the file content correctly. **Actual behavior**: * For `styles/main#v2.css`: The file might fail to open, or show empty content, because the request path is truncated to `styles/main`. * For `docs/说明.md`: The diff shows empty "Before" and "After" content because the backend failed to resolve the escaped path `"\344\270..."`. ### Screenshot and/or share link <img width="1124" height="725" alt="Image" src="https://github.com/user-attachments/assets/40752b02-3563-45b3-a4da-e2af205a54f6" /> <img width="1358" height="991" alt="Image" src="https://github.com/user-attachments/assets/3bc52607-f990-47c3-b78c-46c0fa36a096" /> ### Operating System macOS ### Terminal _No response_
yindo added the bug label 2026-02-16 18:06:03 -05:00
yindo closed this issue 2026-02-16 18:06:03 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 21, 2026):

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

  • #9173: SyntaxError: CSS selector not properly escaped for file paths with special characters
  • #9330: data-key="file^" is not a valid selector (non-ASCII characters in filenames)
  • #8172: OpenCode 桌面版 不支持读取中文名文件 (Chinese filenames not supported)
  • #5926: Windows version of the .exe terminal will report an error when opening a project folder with Chinese characters
  • #2904: Icons/Unicode characters cause file editing failures

These issues describe the same root cause: improper handling of special characters and non-ASCII characters in file paths, affecting both the frontend (CSS selector escaping, URL fragment handling) and backend (git path parsing).

Feel free to ignore if these don't address your specific case.

@github-actions[bot] commented on GitHub (Jan 21, 2026): This issue might be a duplicate of existing issues. Please check: - #9173: SyntaxError: CSS selector not properly escaped for file paths with special characters - #9330: data-key="file^" is not a valid selector (non-ASCII characters in filenames) - #8172: OpenCode 桌面版 不支持读取中文名文件 (Chinese filenames not supported) - #5926: Windows version of the .exe terminal will report an error when opening a project folder with Chinese characters - #2904: Icons/Unicode characters cause file editing failures These issues describe the same root cause: improper handling of special characters and non-ASCII characters in file paths, affecting both the frontend (CSS selector escaping, URL fragment handling) and backend (git path parsing). Feel free to ignore if these don't address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7061