Prefix `./` to completion of `@{filename}` if the path is not obviously a path
Open 💬 3 comments Opened May 24, 2026 by user202729
What variant of Codex are you using?
CLI
What feature would you like to see?
This is similar to https://github.com/openai/codex/issues/6915, but the feature request is different: the author request for @ to be kept after the tab completion.
Instead, I propose the following: say there's a file hello in the current directory, you type @h and tab, it will complete to hello. Since the agent has no idea that it was tab-completed from a filename, it wouldn't know it's intended to be a filename.
It would be better (and still reasonably backwards compatible) to: if the file does not have an extension and is in the current directory, prefix ./. So in the example above the agent will see ./hello which is obviously a file path.
Additional information
_No response_
3 Comments
Thanks for the report. I traced this through the TUI file-mention flow, and the selected match is currently inserted as the raw relative path. That means a current-directory extensionless match such as
hellois submitted ashello, not./hello.A minimal implementation path would be to normalize at the composer insertion point: prefix
./when the selected path is a single component, extensionless, and not already path-like, while leaving nested paths such assrc/main.rsand existing path-like values such as./hello,../hello, or.hiddenunchanged. This should be applied consistently to both the legacy file-search popup and the mentions v2 file selection path.I also checked that this can be covered with a focused chat-composer regression test for
@he<Tab>->./hello, alongside the existing coverage that nested file completion still insertssrc/main.rs.Because external code PRs are invitation-only per
docs/contributing.md, I am leaving this as an implementation note rather than opening an unsolicited PR.🔧 Proposed Solution
Root Cause
The
@mention/completion system completes filenames without any path prefix, making it ambiguous for the agent whether the completed text is a filename reference or just a regular word. Files without extensions (e.g.,hello,Makefile) are especially ambiguous.Fix
./for extensionless files in the current directorycompletionPrefixDotSlashsetting for users who prefer the old behaviorFiles to Modify
src/cli/completion/file-completer.ts— Add path prefix logicsrc/settings.ts— AddcompletionPrefixDotSlashsettingsrc/tui/completion-menu.ts— Update display to show inserted textComplexity: Low (1-2 hours, additive prefix logic)
Full solution document:
codex-24307-filename-completion-prefix-fix.mdI had the same problem with a PDF. After selecting
@Tang_Primer_25K_Dock_60033_Schematic.pdfcodex tried to find the file online instead of opening it locally. Because the file had an extension, the proposed./prefix would not fix this case. Could@completions add structured metadata similar to how pasted images work?