Skip to content

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

@shirukai

Description

@shirukai

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions