You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Directory picker skips the last suggestion when Up is pressed initially #44960
In the directory picker autocomplete, pressing Up before any suggestion is active selects the penultimate result. This makes reverse keyboard navigation skip the last suggestion on the first key press.
Steps to reproduce
Open the directory picker in the web or desktop app.
Type a path or search term that produces at least three autocomplete suggestions.
Leave the suggestions unselected.
Press Up once.
Observed behavior
The penultimate suggestion becomes active.
Expected behavior
The last suggestion should become active so reverse navigation wraps from the unselected state to the end of the list.
Additional context
Down correctly starts at the first suggestion. Up should mirror that behavior from the opposite end. The issue is independent of the operating system and terminal because it occurs in the picker index calculation.
Thanks for the clear report, @sdivyanshu90. I can confirm this, and it still happens on the latest dev (a882cf9).
When no suggestion is active, the picker stores the index as -1. nextSuggestionIndex then calculates (-1 - 1 + n) % n, which is n - 2, so the first Up press lands on the second-to-last suggestion. Down calculates (-1 + 1 + n) % n, which is 0, so it works.
In the picker you see this when the input ends in / (or is ~ or /), because those are the cases where nothing is active. With a plain search term the first suggestion is already active, so Up correctly wraps to the last one.
The script below calls the picker's own index function and shows the wrong result on v2.2.0 and on dev.
Related: #44998, your PR with a fix, which the stale-PR cleanup closed without merging.
Reproduction script (repro.ts)
// Reproduces #44960: directory picker ArrowUp from the unselected state// selects the second-to-last suggestion instead of the last.// Usage: bun /workspace/repro/repro.ts [path/to/packages/app/src/workspaces/selection/domain.ts]constpath=process.argv[2]??"/workspace/repo/packages/app/src/workspaces/selection/domain.ts"const{ nextSuggestionIndex }=awaitimport(path)// dialog.tsx activeSuggestionIndex() returns -1 (nothing active) when the// input is "~", "~/", "/" or ends with "/", e.g. "~/projects/".constunselected=-1constcount=3constdown=nextSuggestionIndex(unselected,1,count)constup=nextSuggestionIndex(unselected,-1,count)console.log(`suggestions=${count}, nothing active`)console.log(`ArrowDown -> index ${down} (expected 0)`)console.log(`ArrowUp -> index ${up} (expected ${count-1})`)if(up!==count-1){console.log("BUG: ArrowUp skipped the last suggestion")process.exit(1)}console.log("OK")
Activity
sdivyanshu90 commentedon Sep 19, 2026
Could you please review this issue?
opencodejr commentedon Oct 28, 2026
Thanks for the clear report, @sdivyanshu90. I can confirm this, and it still happens on the latest
dev(a882cf9).When no suggestion is active, the picker stores the index as
-1.nextSuggestionIndexthen calculates(-1 - 1 + n) % n, which isn - 2, so the first Up press lands on the second-to-last suggestion. Down calculates(-1 + 1 + n) % n, which is0, so it works.In the picker you see this when the input ends in
/(or is~or/), because those are the cases where nothing is active. With a plain search term the first suggestion is already active, so Up correctly wraps to the last one.The script below calls the picker's own index function and shows the wrong result on v2.2.0 and on
dev.Related: #44998, your PR with a fix, which the stale-PR cleanup closed without merging.
Reproduction script (repro.ts)
Run it:
bun repro.ts