cb18296f88
* feat(agent-manager): add keyboard shortcut tooltips and worktree hover cards - Add TooltipKeybind to all agent manager buttons (tabs, new session, close tab, terminal, new worktree, delete worktree, promote to worktree) - Add HoverCard popovers on worktree items showing branch name, base branch, session count, creation date, and navigation shortcut hint - Show directional keybind hints only for directly adjacent items (tabs: ⌘←/⌘→, worktrees: ⌘↑/⌘↓) - Resolve keybindings from package.json at runtime per platform (Mac symbols vs Windows/Linux Ctrl+key format) - Send resolved keybindings from extension to webview via new agentManager.keybindings message instead of hardcoding shortcuts - Prevent multiple HoverCards from appearing simultaneously via shared hover state lifted above the For loop - Suppress HoverCard when hovering the delete button * refactor: extract formatKeybinding and adjacentHint into testable modules - Extract formatKeybinding into format-keybinding.ts (pure function, no vscode dependency, takes mac boolean parameter) - Extract adjacentHint into navigate.ts as a reusable pure function for computing directional keybind hints - Add tests for adjacentHint (12 cases) and formatKeybinding (13 cases) - Simplify tab/worktree direction logic in AgentManagerApp to use adjacentHint instead of inline index arithmetic
73 lines
2.3 KiB
TypeScript
73 lines
2.3 KiB
TypeScript
import { describe, it, expect } from "bun:test"
|
|
import { formatKeybinding } from "../../src/agent-manager/format-keybinding"
|
|
|
|
describe("formatKeybinding", () => {
|
|
describe("mac", () => {
|
|
it("formats cmd as ⌘", () => {
|
|
expect(formatKeybinding("cmd+w", true)).toBe("⌘W")
|
|
})
|
|
|
|
it("formats cmd+shift as ⌘⇧", () => {
|
|
expect(formatKeybinding("cmd+shift+w", true)).toBe("⌘⇧W")
|
|
})
|
|
|
|
it("formats ctrl as ⌃", () => {
|
|
expect(formatKeybinding("ctrl+c", true)).toBe("⌃C")
|
|
})
|
|
|
|
it("formats alt as ⌥", () => {
|
|
expect(formatKeybinding("alt+f", true)).toBe("⌥F")
|
|
})
|
|
|
|
it("formats arrow keys as symbols", () => {
|
|
expect(formatKeybinding("cmd+left", true)).toBe("⌘←")
|
|
expect(formatKeybinding("cmd+right", true)).toBe("⌘→")
|
|
expect(formatKeybinding("cmd+up", true)).toBe("⌘↑")
|
|
expect(formatKeybinding("cmd+down", true)).toBe("⌘↓")
|
|
})
|
|
|
|
it("formats special keys", () => {
|
|
expect(formatKeybinding("cmd+backspace", true)).toBe("⌘⌫")
|
|
expect(formatKeybinding("cmd+enter", true)).toBe("⌘↵")
|
|
expect(formatKeybinding("escape", true)).toBe("Esc")
|
|
})
|
|
|
|
it("joins without separator on mac", () => {
|
|
expect(formatKeybinding("cmd+shift+alt+t", true)).toBe("⌘⇧⌥T")
|
|
})
|
|
|
|
it("formats plain key", () => {
|
|
expect(formatKeybinding("cmd+/", true)).toBe("⌘/")
|
|
})
|
|
})
|
|
|
|
describe("windows/linux", () => {
|
|
it("formats cmd as Ctrl", () => {
|
|
expect(formatKeybinding("cmd+w", false)).toBe("Ctrl+W")
|
|
})
|
|
|
|
it("formats ctrl as Ctrl", () => {
|
|
expect(formatKeybinding("ctrl+w", false)).toBe("Ctrl+W")
|
|
})
|
|
|
|
it("formats ctrl+shift", () => {
|
|
expect(formatKeybinding("ctrl+shift+w", false)).toBe("Ctrl+Shift+W")
|
|
})
|
|
|
|
it("formats alt as Alt", () => {
|
|
expect(formatKeybinding("alt+f", false)).toBe("Alt+F")
|
|
})
|
|
|
|
it("formats arrow keys as symbols", () => {
|
|
expect(formatKeybinding("ctrl+left", false)).toBe("Ctrl+←")
|
|
expect(formatKeybinding("ctrl+right", false)).toBe("Ctrl+→")
|
|
expect(formatKeybinding("ctrl+up", false)).toBe("Ctrl+↑")
|
|
expect(formatKeybinding("ctrl+down", false)).toBe("Ctrl+↓")
|
|
})
|
|
|
|
it("joins with + separator on non-mac", () => {
|
|
expect(formatKeybinding("ctrl+shift+alt+t", false)).toBe("Ctrl+Shift+Alt+T")
|
|
})
|
|
})
|
|
})
|