From c25316d7dccf5fd435451d776095f957a69b8040 Mon Sep 17 00:00:00 2001 From: Dan Smolsky Date: Sat, 7 Nov 2026 06:46:25 -0500 Subject: [PATCH] fix(app): select the last directory suggestion on first up arrow --- packages/app/src/workspaces/selection/domain.test.ts | 1 + packages/app/src/workspaces/selection/domain.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/app/src/workspaces/selection/domain.test.ts b/packages/app/src/workspaces/selection/domain.test.ts index 7f9579a8aa6..27712c2c5ce 100644 --- a/packages/app/src/workspaces/selection/domain.test.ts +++ b/packages/app/src/workspaces/selection/domain.test.ts @@ -561,6 +561,7 @@ test("listing a folder passes the abort signal to the request", async () => { test("wraps autocomplete keyboard navigation", () => { expect(nextSuggestionIndex(-1, 1, 4)).toBe(0) + expect(nextSuggestionIndex(-1, -1, 4)).toBe(3) expect(nextSuggestionIndex(3, 1, 4)).toBe(0) expect(nextSuggestionIndex(0, -1, 4)).toBe(3) expect(nextSuggestionIndex(0, 1, 0)).toBe(-1) diff --git a/packages/app/src/workspaces/selection/domain.ts b/packages/app/src/workspaces/selection/domain.ts index 8899d64f379..f87570cba72 100644 --- a/packages/app/src/workspaces/selection/domain.ts +++ b/packages/app/src/workspaces/selection/domain.ts @@ -215,6 +215,7 @@ export function createPriorityTaskQueue(concurrency: number) { export function nextSuggestionIndex(current: number, delta: -1 | 1, count: number) { if (count === 0) return -1 + if (current < 0) return delta > 0 ? 0 : count - 1 return (current + delta + count) % count }