tui: @ directory completion yields double slash; /cd select never submits exact path
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- cli
Research direction
Start in packages/tui/src/component/prompt/autocomplete.tsx and read expandDirectory() and select() for the @ and /cd directory branches. Reproduce both flows in the TUI, then verify that directory expansion preserves one trailing slash and that selecting an exact /cd directory submits the command instead of only reinserting the path.
Written by the indexing model from the issue text.
Description
Summary
Two related directory-completion problems in the TUI prompt: (1) the @ file reference autocomplete produces a double slash (@dir//) when expanding a directory, breaking further drill-down; (2) in /cd directory argument completion, prompt.autocomplete.select only re-inserts the already-exact path and closes the popup without submitting, leaving the command unexecuted.
Environment
- opencode version: 2.0.8
- OS: Darwin 27.2.0 (darwin arm64)
- Terminal: TERM_PROGRAM=WezTerm, TERM=xterm-256color, COLORTERM=truecolor
- Shell: /bin/zsh
- Install/channel: latest
- Active plugins: @prevalentware/opencode-goal-plugin, billion-context@0.1.118-pr.936.774
Reproduction
Both reproduced in a real terminal (tmux-captured pty) with the TUI running v2.0.8.
Bug 1: @ directory expansion yields @dir//
- In a project containing a directory
sub1/, type@sub1in the prompt. - Select the directory entry and press the
prompt.autocomplete.completekey (Enter in my keymap; Tab by default). - The input becomes
@sub1//and the popup switches to "No matching files" — drill-down into the directory is broken.
Root cause (v2.0.8 source): packages/tui/src/component/prompt/autocomplete.tsx, expandDirectory() — the @ branch runs input.insertText("@" + selectedPath + "/") unconditionally, while the server fs.find already returns directory paths with a trailing slash (sub1/). The adjacent directory-mode branch (/cd, same function) guards with selectedPath.endsWith(path.sep) ? selectedPath : selectedPath + path.sep; the @ branch lacks this guard. Git history: at commit 106f8e94 the line was insertText("@" + path) (correct, since dir paths carry a trailing slash); a later commit added the extra + "/".
Bug 2: /cd select never submits, even on an exact path
Keymap: prompt.autocomplete.complete: return, prompt.autocomplete.select: shift+return.
- Type a complete, valid directory argument:
/cd ~/.config/opencode/scripts/ - The popup shows that exact directory as the first (exact-match) entry plus its children.
- Press
prompt.autocomplete.select(Shift+Enter). The popup closes and nothing happens — the working directory is unchanged; the text just sits in the input. - Only a second Enter (with the popup now hidden) submits the command.
Root cause: in the same file, select()'s directory branch only calls selected.onSelect?.() (which is insertDirectory(value)) and hide(true) — there is no submission path. When the typed argument is already an exact, valid directory, select re-inserts identical text and does nothing, which reads as "the key didn't work".
A related UX papercut that compounds this: the /cd popup lists only the current directory itself and its children — no parent or sibling entries — so after drilling down, pressing complete on the first (exact/self) entry is a no-op and the picker appears "stuck". To reach a sibling directory the user must know to type ...
Expected Behavior
@directory expansion should not duplicate the trailing slash:@sub1/and drill-down should continue to work.- When the
/cdargument is already an exact valid directory,selectshould submit the command (or an explicit binding should exist that does), rather than re-inserting identical text.
Actual Behavior
@sub1//— double slash, autocomplete breaks.- Working directory unchanged after
select; a second Enter with the popup dismissed is required.
Additional Context
- Reproducibility: both 100% consistent.
- Bug 1 was verified against the v2.0.8 tagged source and via git history (correct at 106f8e94, broken after a later change to
expandDirectory). - Bug 2 verified by pty reproduction: after Shift+Enter the status-bar cwd is unchanged; after a following Enter it switches.
- Suggested fix for bug 1: apply the same
endsWith(path.sep)guard in the@branch ofexpandDirectory(). - Suggested fix for bug 2: in
select()'s directory branch, submit when the option is the exact match for the current query (or document/select a "submit" affordance for argument popups).
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- Avg merge
- 7h 20m
- Merged PRs (30d)
- 358
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from anomalyco/opencode
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
[FEATURE]: Bump gitlab-ai-provider to 6.15.1 on v2 (Fable 5.1, GPT-6 Astra, workflow reconnect fix) Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
All issues in anomalyco/opencode
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·