From 9269a0222ed6abae542f176946c64414decaef6f Mon Sep 17 00:00:00 2001 From: Donald Silveira Date: Mon, 28 Sep 2026 16:07:50 -0300 Subject: [PATCH] fix(web): order every Usage keybinding before sorting by label The Keybindings page sorts Usage commands by a fixed order and everything else by label, but `usage.open` was missing from that order. Comparing it by label against ordered Usage commands made the comparator inconsistent, so the list order depended on the input order: adding any unrelated keybinding command reshuffled the Usage rows and failed the ordering test. Put `usage.open` first in the order so every Usage command sorts by it. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../settings/KeybindingsSettings.logic.test.ts | 2 +- .../src/components/settings/KeybindingsSettings.logic.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/settings/KeybindingsSettings.logic.test.ts b/apps/web/src/components/settings/KeybindingsSettings.logic.test.ts index 7729ce1837541..ea699d0c76f48 100644 --- a/apps/web/src/components/settings/KeybindingsSettings.logic.test.ts +++ b/apps/web/src/components/settings/KeybindingsSettings.logic.test.ts @@ -48,8 +48,8 @@ describe("KeybindingsSettings.logic", () => { ); it("orders Usage bindings and command choices like the page", () => { const expected = [ - "usage.cost", "usage.open", + "usage.cost", "usage.tokens", "usage.limits", "usage.period.day", diff --git a/apps/web/src/components/settings/KeybindingsSettings.logic.ts b/apps/web/src/components/settings/KeybindingsSettings.logic.ts index a06628e5d5052..76d32196fdf40 100644 --- a/apps/web/src/components/settings/KeybindingsSettings.logic.ts +++ b/apps/web/src/components/settings/KeybindingsSettings.logic.ts @@ -15,8 +15,15 @@ import { shortcutKeyFromEvent } from "../../keybindings"; import { isMacPlatform } from "../../lib/utils"; import { METRIC_OPTIONS, WINDOW_OPTIONS } from "../usage/usageShortcuts"; +// Every `usage.*` command needs a place here: the sorts fall back to labels for the rest, and a +// usage command ordered by label against ordered ones makes the comparison inconsistent. const usageCommandOrder = new Map( - [...METRIC_OPTIONS, ...WINDOW_OPTIONS].map((option, index) => [option.command, index]), + ( + [ + "usage.open", + ...[...METRIC_OPTIONS, ...WINDOW_OPTIONS].map((option) => option.command), + ] as const + ).map((command, index) => [command, index]), ); function compareUsageCommands(left: KeybindingCommand, right: KeybindingCommand): number | null {