Skip to content

Conversation

@jdm64
Copy link
Contributor

@jdm64 jdm64 commented Dec 29, 2025

Context

When the list of autocomplete items is shown for commands or files the first item should always be selected. Currently no item is selected and the arrow keys must be used to select. This fix makes autocomplete quicker to work with and matches how OpenCode works.

Implementation

This actually fixes what looks like a bug -- selecting the first item looks like the intended behavior, but has a subtle issue.

In cli/src/state/hooks/useCommandInput.ts function useCommandInput() suggestions are being set but the order of the calls to set the suggestions are resetting the selected index.

setFileMentionSuggestionsAction(suggestions) // <-- index is set to 0
setFileMentionContextAction(fileMentionCtx)
setSuggestionsAction([]) // <-- index is reset to -1
setArgumentSuggestionsAction([])

This fix proposes adding updateAllSuggestionsAtom() which takes all suggestion types and determines which one has any items and sets the index accordingly.

How to Test

  • Start typing "/"

  • The first command autocomplete item should be selected

  • Start typing "@"

  • The first file autocomplete item should be selected

@changeset-bot
Copy link

changeset-bot bot commented Dec 29, 2025

🦋 Changeset detected

Latest commit: b5f002a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@kilocode/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jdm64 jdm64 changed the title make sure first autocomplete item is selected fix: make sure first autocomplete item is selected Dec 30, 2025
@jdm64 jdm64 force-pushed the auto-select-first branch from af4f467 to 3f6b97c Compare January 3, 2026 07:29
@marius-kilocode marius-kilocode self-requested a review January 5, 2026 11:55
@marius-kilocode
Copy link
Collaborator

@jdm64 looks very good and works. However, the tests fail. Could you have a look at them? It's a simple mismatch.

@marius-kilocode
Copy link
Collaborator

@jdm64 I recreated this in #4797 to get it merged. Thanks for contributing!

@jdm64
Copy link
Contributor Author

jdm64 commented Jan 5, 2026

@marius-kilocode Thanks for adopting my solution. Looking forward to seeing this fixed in the next release.

@marius-kilocode
Copy link
Collaborator

marius-kilocode commented Jan 5, 2026

No worries @jdm64, if you have further suggestion on how to shape the CLI, let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants