openai / openai/codex

[Desktop UI] Inline code comments fail to open file when repo name matches a subpackage folder (e.g., `src/<repo_name>/...`)

Open
#45,650 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app bug code-review windows-os
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of the Codex App are you using (From “About Codex” dialog)?

26.908.70816

What subscription do you have?

pro 20x

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What issue are you seeing?

When clicking an inline code comment card (::code-comment{...}) in the chat transcript or review pane, the desktop app fails to open the target file and displays an error toast:

  • Toast error message: Could not open file (The i18n key textFileEditor.openError).
  • Underlying error: Main process RPC readFileMetadata / read-file fails with ENOENT: no such file or directory.

The root cause is that the desktop UI's path normalization function (qT) erroneously strips leading path components (e.g., src/<reponame>/) when the repository folder name (<reponame>) matches a subdirectory in the source tree (src/<reponame>/...), resolving the file to a nonexistent path (pkg/storage/media.py).

What steps can reproduce the bug?
Bug explanation

The UI parses ::code-comment directives via Bos(), which invokes qT(filePath, workspaceRoot) to strip redundant workspace folder names if the model outputs them. However, qT checks if the workspace root's folder name appears anywhere in the path with a preceding slash (lowerPath[c - 1] === "/"). For standard Python, Go, or Java projects structured as src/<project_name>/..., this causes src/<project_name>/ to be mistakenly sliced off.

Reproduction steps
  1. Open a workspace where the root folder name matches a package subfolder inside src/ (e.g., workspace directory /path/to/my-project with file src/<reponame>/pkg/storage/media.py).
  2. Have the assistant emit an inline code comment directive pointing to a relative file path inside that package:
    ::code-comment{title="[P1] Unescaped regex dot" body="Sample issue description" file="src/<reponame>/pkg/storage/media.py" start=26 end=26 priority=1}
    
  3. Click the generated comment card / file badge in the desktop UI.
  4. The editor attempts to open <workspaceRoot>\pkg\storage\media.py, fails with ENOENT, and toasts Could not open file.
Standalone reproduction script

The bug in the frontend normalization logic can be isolated with this snippet:

function qT(e, t) {
  if (!t) return e;
  let n = t.replace(/\\/g, "/"),
      r = e.replace(/\\/g, "/"),
      i = n.endsWith("/") ? n.slice(0, -1) : n,
      [a, o] = [i.toLowerCase(), r.toLowerCase()];
  if (o.startsWith(a + "/")) return r.slice(i.length + 1);
  let s = (a.split("/").at(-1) ?? a) + "/",
      c = o.indexOf(s);
  // BUG: `o[c - 1] === "/"` matches subdirectories anywhere in the path
  return c !== -1 && (c === 0 || o[c - 1] === "/") ? r.slice(c + s.length) : r;
}

const workspaceRoot = "/path/to/my-project";
const directiveFile = "src/<reponame>/pkg/storage/media.py";

console.log(qT(directiveFile, workspaceRoot));
// Output: "pkg/storage/media.py" (WRONG: "src/<reponame>/" was stripped!)
What is the expected behavior?

Clicking the inline comment card should open src/<reponame>/pkg/storage/media.py at lines 26-26.

Path prefix stripping should only strip the workspace folder name if it appears at the very start of the relative path (c === 0), or should use standard path relativity (path.relative(workspaceRoot, path.resolve(workspaceRoot, path))), rather than slicing arbitrary subdirectories containing the workspace name.

Additional information
Code location

In the desktop app bundle (webview/assets/app-primary-*.js), Bos constructs the comment position using qT:

// Inside Bos():
let m = Zvi({ cwd: t ?? null, path: o, workspaceRoots: n ?? (t == null ? [] : [t]) });
return {
  content: [{ content_type: "text", text: p }],
  ...m == null ? {} : { localWorkspaceRoot: m },
  position: {
    side: "right",
    path: qT(o, m ?? void 0), // <-- strips valid src/<repo-name>/ paths
    line: f,
    ...f === u ? {} : { start_line: u }
  }
};
Suggested fix

In qT, restrict the strip condition so that it only removes the workspace name if it is the leading path segment:

- return c !== -1 && (c === 0 || o[c - 1] === "/") ? r.slice(c + s.length) : r;
+ return c === 0 ? r.slice(s.length) : r;

Or resolve and relativize using canonical path utilities.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in webview/assets/app-primary-*.js and trace Bos() to the qT path-normalization function. Reproduce the standalone example and verify that clicking an inline comment opens src/<repo_name>/pkg/storage/media.py at the requested lines without an ENOENT error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.