mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
Merge pull request #12954 from Kilo-Org/refactor/extract-agent-manager-keybind-defaults
refactor(agent-manager): extract keybinding defaults into keybind-defaults.ts
This commit is contained in:
@@ -44,8 +44,9 @@ export default [
|
||||
{
|
||||
files: ["webview-ui/agent-manager/AgentManagerApp.tsx"],
|
||||
// Lowered 3210 → 2800 after extracting the sidebar body (SidebarBody.tsx)
|
||||
// and the tab bar (TabBar.tsx) into components. Keep shrinking as more
|
||||
// logic moves out; do not raise.
|
||||
// and the tab bar (TabBar.tsx) into components. The keybinding defaults
|
||||
// (keybind-defaults.ts) extraction offsets the terminal-ux additions; keep
|
||||
// shrinking as more logic moves out; do not raise.
|
||||
rules: { complexity: ["error", 74], "max-lines": ["error", 2800] },
|
||||
},
|
||||
{
|
||||
|
||||
@@ -64,6 +64,7 @@ const TSX_FILES = [
|
||||
path.join(ROOT, "webview-ui/diff-viewer/BaseBranchPicker.tsx"),
|
||||
]
|
||||
const TSX_FILE = TSX_FILES[0]!
|
||||
const KEYBIND_DEFAULTS_FILE = path.join(ROOT, "webview-ui/agent-manager/keybind-defaults.ts")
|
||||
const PROVIDER_FILE = path.join(ROOT, "src/agent-manager/AgentManagerProvider.ts")
|
||||
const DIFF_CONTROLLER_FILE = path.join(ROOT, "src/agent-manager/worktree-diff-controller.ts")
|
||||
const IMPORTER_FILE = path.join(ROOT, "src/agent-manager/worktree-importer.ts")
|
||||
@@ -365,7 +366,6 @@ describe("Agent Manager Worktree Actions", () => {
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(ROOT, "package.json"), "utf-8")) as {
|
||||
contributes: { keybindings: { command: string; key?: string; mac?: string }[] }
|
||||
}
|
||||
const source = fs.readFileSync(TSX_FILE, "utf-8")
|
||||
const dialog = manifest.contributes.keybindings.find(
|
||||
(item) => item.command === "kilo-code.new.agentManager.newWorktree",
|
||||
)
|
||||
@@ -375,8 +375,9 @@ describe("Agent Manager Worktree Actions", () => {
|
||||
|
||||
expect(dialog).toMatchObject({ key: "ctrl+n", mac: "cmd+n" })
|
||||
expect(quick).toMatchObject({ key: "ctrl+shift+n", mac: "cmd+shift+n" })
|
||||
expect(source).toContain('newWorktree: isMac ? "⌘N" : "Ctrl+N"')
|
||||
expect(source).toContain('quickWorktree: isMac ? "⌘⇧N" : "Ctrl+Shift+N"')
|
||||
const bindings = fs.readFileSync(KEYBIND_DEFAULTS_FILE, "utf-8")
|
||||
expect(bindings).toContain('newWorktree: isMac ? "⌘N" : "Ctrl+N"')
|
||||
expect(bindings).toContain('quickWorktree: isMac ? "⌘⇧N" : "Ctrl+Shift+N"')
|
||||
})
|
||||
|
||||
it("reserves Cmd+Shift+M for the Agent Manager instead of Problems", () => {
|
||||
|
||||
@@ -199,39 +199,10 @@ interface SetupState {
|
||||
type SidebarSelection = typeof LOCAL | string | null
|
||||
type SidePanel = "diff" | "pr" | "terminal" | null
|
||||
const isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.userAgent)
|
||||
// Fallback keybindings before extension sends resolved ones
|
||||
const MAX_JUMP_INDEX = 9
|
||||
const SIDE_RESIZE_INTERVAL_MS = 32
|
||||
|
||||
const defaultBindings: Record<string, string> = {
|
||||
previousSession: isMac ? "⌘⌥↑" : "Ctrl+Alt+↑",
|
||||
nextSession: isMac ? "⌘⌥↓" : "Ctrl+Alt+↓",
|
||||
previousTab: isMac ? "⌘⌥←" : "Ctrl+Alt+←",
|
||||
nextTab: isMac ? "⌘⌥→" : "Ctrl+Alt+→",
|
||||
previousTerminal: isMac ? "⌘⇧[" : "Ctrl+Shift+[",
|
||||
nextTerminal: isMac ? "⌘⇧]" : "Ctrl+Shift+]",
|
||||
search: isMac ? "⌘F" : "Ctrl+F",
|
||||
showTerminal: isMac ? "⌘/" : "Ctrl+/",
|
||||
newTerminal: isMac ? "⌘⇧T" : "Ctrl+Shift+T",
|
||||
runScript: isMac ? "⌘E" : "Ctrl+E",
|
||||
toggleDiff: isMac ? "⌘D" : "Ctrl+D",
|
||||
showShortcuts: isMac ? "⌘⇧/" : "Ctrl+Shift+/",
|
||||
newTab: isMac ? "⌘T" : "Ctrl+T",
|
||||
closeTab: isMac ? "⌘W" : "Ctrl+W",
|
||||
newWorktree: isMac ? "⌘N" : "Ctrl+N",
|
||||
quickWorktree: isMac ? "⌘⇧N" : "Ctrl+Shift+N",
|
||||
closeWorktree: isMac ? "⌘⇧W" : "Ctrl+Shift+W",
|
||||
openWorktree: isMac ? "⌘⇧O" : "Ctrl+Shift+O",
|
||||
openPR: isMac ? "⌘⇧R" : "Ctrl+Shift+R",
|
||||
agentManagerOpen: isMac ? "⌘⇧M" : "Ctrl+Shift+M",
|
||||
cycleAgentMode: isMac ? "⌘." : "Ctrl+.",
|
||||
cyclePreviousAgentMode: isMac ? "⌘⇧." : "Ctrl+Shift+.",
|
||||
...Object.fromEntries(
|
||||
Array.from({ length: MAX_JUMP_INDEX }, (_, i) => [`jumpTo${i + 1}`, isMac ? `⌘${i + 1}` : `Ctrl+${i + 1}`]),
|
||||
),
|
||||
}
|
||||
|
||||
import { parseBindingTokens } from "./keybind-tokens"
|
||||
import { defaultBindings } from "./keybind-defaults"
|
||||
|
||||
const AgentManagerContent: Component = () => {
|
||||
const { t } = useLanguage()
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
const isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.userAgent)
|
||||
|
||||
const MAX_JUMP_INDEX = 9
|
||||
|
||||
/** Fallback keybindings before the extension sends resolved ones. */
|
||||
export const defaultBindings: Record<string, string> = {
|
||||
previousSession: isMac ? "⌘⌥↑" : "Ctrl+Alt+↑",
|
||||
nextSession: isMac ? "⌘⌥↓" : "Ctrl+Alt+↓",
|
||||
previousTab: isMac ? "⌘⌥←" : "Ctrl+Alt+←",
|
||||
nextTab: isMac ? "⌘⌥→" : "Ctrl+Alt+→",
|
||||
previousTerminal: isMac ? "⌘⇧[" : "Ctrl+Shift+[",
|
||||
nextTerminal: isMac ? "⌘⇧]" : "Ctrl+Shift+]",
|
||||
search: isMac ? "⌘F" : "Ctrl+F",
|
||||
showTerminal: isMac ? "⌘/" : "Ctrl+/",
|
||||
newTerminal: isMac ? "⌘⇧T" : "Ctrl+Shift+T",
|
||||
runScript: isMac ? "⌘E" : "Ctrl+E",
|
||||
toggleDiff: isMac ? "⌘D" : "Ctrl+D",
|
||||
showShortcuts: isMac ? "⌘⇧/" : "Ctrl+Shift+/",
|
||||
newTab: isMac ? "⌘T" : "Ctrl+T",
|
||||
closeTab: isMac ? "⌘W" : "Ctrl+W",
|
||||
newWorktree: isMac ? "⌘N" : "Ctrl+N",
|
||||
quickWorktree: isMac ? "⌘⇧N" : "Ctrl+Shift+N",
|
||||
closeWorktree: isMac ? "⌘⇧W" : "Ctrl+Shift+W",
|
||||
openWorktree: isMac ? "⌘⇧O" : "Ctrl+Shift+O",
|
||||
openPR: isMac ? "⌘⇧R" : "Ctrl+Shift+R",
|
||||
agentManagerOpen: isMac ? "⌘⇧M" : "Ctrl+Shift+M",
|
||||
cycleAgentMode: isMac ? "⌘." : "Ctrl+.",
|
||||
cyclePreviousAgentMode: isMac ? "⌘⇧." : "Ctrl+Shift+.",
|
||||
...Object.fromEntries(
|
||||
Array.from({ length: MAX_JUMP_INDEX }, (_, i) => [`jumpTo${i + 1}`, isMac ? `⌘${i + 1}` : `Ctrl+${i + 1}`]),
|
||||
),
|
||||
}
|
||||
Reference in New Issue
Block a user