feat(app): cycle agent modes with Shift+Tab
This commit is contained in:
@@ -8,6 +8,12 @@ describe("formatShortcut", () => {
|
||||
expect(formatShortcut(["mod", "E"], "mac")).toBe("⌘E");
|
||||
});
|
||||
|
||||
it("spells out Shift in shortcut labels", () => {
|
||||
expect(formatShortcut(["shift", "Tab"], "mac")).toBe("Shift+Tab");
|
||||
expect(formatShortcut(["mod", "shift", "P"], "mac")).toBe("Shift+⌘+P");
|
||||
expect(formatShortcut(["shift", "Tab"], "non-mac")).toBe("Shift+Tab");
|
||||
});
|
||||
|
||||
it("uses Ctrl+ on non-mac platforms", () => {
|
||||
expect(formatShortcut(["mod", "B"], "non-mac")).toBe("Ctrl+B");
|
||||
expect(formatShortcut(["mod", "E"], "non-mac")).toBe("Ctrl+E");
|
||||
|
||||
@@ -27,18 +27,22 @@ export function formatShortcut(keys: ShortcutKey[], os: ShortcutOs): string {
|
||||
const order = ["ctrl", "alt", "shift", "mod", "meta"];
|
||||
const symbols: Record<string, string> = {
|
||||
mod: "⌘",
|
||||
shift: "⇧",
|
||||
alt: "⌥",
|
||||
ctrl: "⌃",
|
||||
meta: "⌘",
|
||||
};
|
||||
|
||||
const modifierSet = new Set(normalized);
|
||||
const mods = order.filter((k) => modifierSet.has(k)).map((k) => symbols[k] ?? "");
|
||||
const mods = order
|
||||
.filter((k) => modifierSet.has(k))
|
||||
.map((k) => (k === "shift" ? "Shift" : (symbols[k] ?? "")));
|
||||
const main = normalized
|
||||
.filter((k) => !order.includes(k))
|
||||
.map(normalizeKey)
|
||||
.join("");
|
||||
if (mods.includes("Shift")) {
|
||||
return [...mods, main].filter(Boolean).join("+");
|
||||
}
|
||||
return `${mods.join("")}${main}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user