Skip to content

Conversation

@marius-kilocode
Copy link
Collaborator

@marius-kilocode marius-kilocode commented Jan 5, 2026

Summary

  • Auto-selects the first autocomplete item when showing suggestions for / commands or @ file mentions
  • Adds updateAllSuggestionsAtom() to update all suggestion types atomically and set the selection index correctly
  • Fixes test expectations to match the actual behavior (reset to -1 when clearing suggestions)

This makes autocomplete quicker to work with and matches how OpenCode works.

Follow-up to

This is a follow-up to #4708 by @jdm64 with test fixes applied.

Test plan

  • Start typing "/" - first command autocomplete item should be selected
  • Start typing "@" - first file autocomplete item should be selected
  • Run cd cli && npx vitest run src/state/atoms/__tests__/default-selection.test.ts - all 13 tests pass
image

When the list of autocomplete items is shown for commands or files,
the first item is now selected by default. This makes autocomplete
quicker to work with and matches how OpenCode works.

The fix adds updateAllSuggestionsAtom() which updates all suggestion
types atomically and determines which one has items to set the
index accordingly.

Co-authored-by: marius-kilocode <[email protected]>
@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2026

🦋 Changeset detected

Latest commit: ac644f2

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

@kiloconnect
Copy link
Contributor

kiloconnect bot commented Jan 5, 2026

✅ No Issues Found

4 files reviewed | Confidence: 95% | Recommendation: Merge

Review Details

Files:

  • .changeset/cli-slash-command-default-selection.md (changeset)
  • cli/src/state/atoms/__tests__/default-selection.test.ts (new test file)
  • cli/src/state/atoms/ui.ts (new updateAllSuggestionsAtom)
  • cli/src/state/hooks/useCommandInput.ts (uses new atom)

Checked: Security, bugs, performance, error handling, state management

Summary:

  • The new updateAllSuggestionsAtom correctly handles atomic updates of all suggestion state
  • Priority order (fileMention > command > argument) is properly implemented
  • Selection index is correctly set to 0 when suggestions exist, -1 when cleared
  • Test coverage is comprehensive (13 tests covering all suggestion types and edge cases)
  • The approval atom already handles selection reset correctly for new messages
  • Code follows established Jotai patterns in the codebase

@marius-kilocode marius-kilocode enabled auto-merge (squash) January 5, 2026 17:32
@kiloconnect
Copy link
Contributor

kiloconnect bot commented Jan 5, 2026

✅ Previous Issues Addressed

The dependency array issue from my previous review has been resolved:

  • Removed unused imports (setSuggestionsAtom, setArgumentSuggestionsAtom, setFileMentionSuggestionsAtom, setFileMentionContextAtom)
  • Removed unused useSetAtom declarations
  • Updated dependency array to correctly include updateAllSuggestionsAction and extensionState?.customModes

4 files reviewed | Confidence: 95% | Recommendation: Merge

Review Details

Files:

  • .changeset/cli-slash-command-default-selection.md
  • cli/src/state/atoms/__tests__/default-selection.test.ts ✅ (comprehensive tests covering all suggestion types)
  • cli/src/state/atoms/ui.ts ✅ (new updateAllSuggestionsAtom is well-designed)
  • cli/src/state/hooks/useCommandInput.ts ✅ (dependency array now correct)

Checked: Security, bugs, performance, error handling

@Drilmo
Copy link
Contributor

Drilmo commented Jan 6, 2026

Hey @marius-kilocode,

Quick question about this PR: Since merging, we've noticed an issue where slash commands are being ignored in certain situations when using the ask_followup_question tool.

The behavior we're seeing:

  • When typing a /command in the followup question input, the command gets ignored
  • Instead, the first suggestion is automatically selected and used
  • The /commands are not visible/accessible in the followup suggestions menu

Could this change be related? I see in the tests that followupSuggestions intentionally sets selectedIndex to -1 (no selection by design), but wondering if there's a code path where this isn't being respected when the followup suggestions interact with command input?

Let me know if you need more details to reproduce this!

Thanks!

@marius-kilocode
Copy link
Collaborator Author

@Drilmo thanks for flagging. I will check for the root cause.

@marius-kilocode
Copy link
Collaborator Author

@Drilmo found and fixed the issue. #4827 will fix this.

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.

5 participants