Skip to content

The agent that grows with you

fix(desktop): honour arrowed slash-picker highlight on bare '/' query

salch-cred9b0eb7f51831
diff --git a/apps/desktop/src/app/chat/composer/composer-utils.test.ts b/apps/desktop/src/app/chat/composer/composer-utils.test.ts
index d55d88c04f0..7e5ae99c96e 100644
--- a/apps/desktop/src/app/chat/composer/composer-utils.test.ts
+++ b/apps/desktop/src/app/chat/composer/composer-utils.test.ts
@@ -134,6 +134,18 @@ describe('implicitSlashAcceptIndex', () => {
expect(implicitSlashAcceptIndex('review', rows, 0, true)).toBe(0)
})
+ // Regression for #98535: bare `/` + arrow-key selection must commit the
+ // highlighted row, not return null. Before the fix, `!typed` fired first
+ // and the explicit-pick branch was never reached.
+ it('honours an arrowed pick on a bare `/` query', () => {
+ expect(implicitSlashAcceptIndex('/', rows, 1, true)).toBe(1)
+ expect(implicitSlashAcceptIndex('/', rows, 2, true)).toBe(2)
+ })
+
+ it('still returns null on a bare `/` with no arrow-key selection', () => {
+ expect(implicitSlashAcceptIndex('/', rows, 0, false)).toBeNull()
+ })
+
it('matches an arg-stage prefix against the full completion text', () => {
expect(implicitSlashAcceptIndex('personality alic', ['/personality alice', '/personality none'], 0, false)).toBe(0)
})
diff --git a/apps/desktop/src/app/chat/composer/composer-utils.ts b/apps/desktop/src/app/chat/composer/composer-utils.ts
index 69e7b743206..ab9c2a0577d 100644
--- a/apps/desktop/src/app/chat/composer/composer-utils.ts
+++ b/apps/desktop/src/app/chat/composer/composer-utils.ts
@@ -118,16 +118,20 @@ export function implicitSlashAcceptIndex(
activeIndex: number,
activeExplicit: boolean
): number | null {
+ // A deliberately arrowed highlight ALWAYS wins — "Enter means I want this
+ // one", even on a bare `/` query where no command name has been typed yet.
+ // This must be checked before the `!typed` early-return so an explicit pick
+ // is never suppressed on a bare `/` (#98535).
+ if (activeExplicit && itemTexts[activeIndex] != null) {
+ return activeIndex
+ }
+
const typed = slashCompletionToken(query)
if (!typed) {
return null
}
- if (activeExplicit && itemTexts[activeIndex] != null) {
- return activeIndex
- }
-
const exact = itemTexts.findIndex(text => slashCompletionToken(text) === typed)
if (exact >= 0) {