Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
907508614c | ||
|
|
bd99acdb5b | ||
|
|
fb4afca9ce |
No files matched your search
+7
-2
@@ -22,7 +22,10 @@ See the full schema for more details: [`packages/contracts/src/keybindings.ts`](
|
|||||||
{ "key": "mod+j", "command": "terminal.toggle" },
|
{ "key": "mod+j", "command": "terminal.toggle" },
|
||||||
{ "key": "mod+d", "command": "terminal.split", "when": "terminalFocus" },
|
{ "key": "mod+d", "command": "terminal.split", "when": "terminalFocus" },
|
||||||
{ "key": "mod+n", "command": "terminal.new", "when": "terminalFocus" },
|
{ "key": "mod+n", "command": "terminal.new", "when": "terminalFocus" },
|
||||||
{ "key": "mod+shift+o", "command": "chat.new" },
|
{ "key": "mod+w", "command": "terminal.close", "when": "terminalFocus" },
|
||||||
|
{ "key": "mod+n", "command": "chat.new", "when": "!terminalFocus" },
|
||||||
|
{ "key": "mod+shift+o", "command": "chat.new", "when": "!terminalFocus" },
|
||||||
|
{ "key": "mod+shift+n", "command": "chat.newLocal", "when": "!terminalFocus" },
|
||||||
{ "key": "mod+o", "command": "editor.openFavorite" }
|
{ "key": "mod+o", "command": "editor.openFavorite" }
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
@@ -46,7 +49,9 @@ Invalid rules are ignored. Invalid config files are ignored. Warnings are logged
|
|||||||
- `terminal.toggle`: open/close terminal drawer
|
- `terminal.toggle`: open/close terminal drawer
|
||||||
- `terminal.split`: split terminal (in focused terminal context by default)
|
- `terminal.split`: split terminal (in focused terminal context by default)
|
||||||
- `terminal.new`: create new terminal (in focused terminal context by default)
|
- `terminal.new`: create new terminal (in focused terminal context by default)
|
||||||
- `chat.new`: create a new chat thread for the active project
|
- `terminal.close`: close/kill the focused terminal (in focused terminal context by default)
|
||||||
|
- `chat.new`: create a new chat thread preserving the active thread's branch/worktree state
|
||||||
|
- `chat.newLocal`: create a new local chat thread for the active project (no worktree context)
|
||||||
- `editor.openFavorite`: open current project/worktree in the last-used editor
|
- `editor.openFavorite`: open current project/worktree in the last-used editor
|
||||||
|
|
||||||
### Key Syntax
|
### Key Syntax
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ export const DEFAULT_KEYBINDINGS: ReadonlyArray<KeybindingRule> = [
|
|||||||
{ key: "mod+j", command: "terminal.toggle" },
|
{ key: "mod+j", command: "terminal.toggle" },
|
||||||
{ key: "mod+d", command: "terminal.split", when: "terminalFocus" },
|
{ key: "mod+d", command: "terminal.split", when: "terminalFocus" },
|
||||||
{ key: "mod+n", command: "terminal.new", when: "terminalFocus" },
|
{ key: "mod+n", command: "terminal.new", when: "terminalFocus" },
|
||||||
{ key: "mod+shift+o", command: "chat.new" },
|
{ key: "mod+w", command: "terminal.close", when: "terminalFocus" },
|
||||||
|
{ key: "mod+n", command: "chat.new", when: "!terminalFocus" },
|
||||||
|
{ key: "mod+shift+o", command: "chat.new", when: "!terminalFocus" },
|
||||||
|
{ key: "mod+shift+n", command: "chat.newLocal", when: "!terminalFocus" },
|
||||||
{ key: "mod+o", command: "editor.openFavorite" },
|
{ key: "mod+o", command: "editor.openFavorite" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import BranchToolbar from "./BranchToolbar";
|
|||||||
import GitActionsControl from "./GitActionsControl";
|
import GitActionsControl from "./GitActionsControl";
|
||||||
import {
|
import {
|
||||||
isOpenFavoriteEditorShortcut,
|
isOpenFavoriteEditorShortcut,
|
||||||
|
isTerminalCloseShortcut,
|
||||||
isTerminalNewShortcut,
|
isTerminalNewShortcut,
|
||||||
isTerminalSplitShortcut,
|
isTerminalSplitShortcut,
|
||||||
isTerminalToggleShortcut,
|
isTerminalToggleShortcut,
|
||||||
@@ -278,6 +279,10 @@ export default function ChatView() {
|
|||||||
() => shortcutLabelForCommand(keybindings, "terminal.new"),
|
() => shortcutLabelForCommand(keybindings, "terminal.new"),
|
||||||
[keybindings],
|
[keybindings],
|
||||||
);
|
);
|
||||||
|
const closeTerminalShortcutLabel = useMemo(
|
||||||
|
() => shortcutLabelForCommand(keybindings, "terminal.close"),
|
||||||
|
[keybindings],
|
||||||
|
);
|
||||||
|
|
||||||
const envLocked = Boolean(
|
const envLocked = Boolean(
|
||||||
activeThread &&
|
activeThread &&
|
||||||
@@ -554,6 +559,14 @@ export default function ChatView() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isTerminalCloseShortcut(event, keybindings, { context: shortcutContext })) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
if (!activeThread?.terminalOpen) return;
|
||||||
|
closeTerminal(activeThread.activeTerminalId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isTerminalNewShortcut(event, keybindings, { context: shortcutContext })) return;
|
if (!isTerminalNewShortcut(event, keybindings, { context: shortcutContext })) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@@ -570,7 +583,9 @@ export default function ChatView() {
|
|||||||
return () => window.removeEventListener("keydown", handler);
|
return () => window.removeEventListener("keydown", handler);
|
||||||
}, [
|
}, [
|
||||||
activeThread?.terminalOpen,
|
activeThread?.terminalOpen,
|
||||||
|
activeThread?.activeTerminalId,
|
||||||
activeThreadId,
|
activeThreadId,
|
||||||
|
closeTerminal,
|
||||||
createNewTerminal,
|
createNewTerminal,
|
||||||
dispatch,
|
dispatch,
|
||||||
splitTerminal,
|
splitTerminal,
|
||||||
@@ -1453,6 +1468,7 @@ export default function ChatView() {
|
|||||||
onNewTerminal={createNewTerminal}
|
onNewTerminal={createNewTerminal}
|
||||||
splitShortcutLabel={splitTerminalShortcutLabel ?? undefined}
|
splitShortcutLabel={splitTerminalShortcutLabel ?? undefined}
|
||||||
newShortcutLabel={newTerminalShortcutLabel ?? undefined}
|
newShortcutLabel={newTerminalShortcutLabel ?? undefined}
|
||||||
|
closeShortcutLabel={closeTerminalShortcutLabel ?? undefined}
|
||||||
onActiveTerminalChange={activateTerminal}
|
onActiveTerminalChange={activateTerminal}
|
||||||
onCloseTerminal={closeTerminal}
|
onCloseTerminal={closeTerminal}
|
||||||
onHeightChange={(height) =>
|
onHeightChange={(height) =>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { useTheme } from "../hooks/useTheme";
|
|||||||
import { DEFAULT_MODEL } from "../model-logic";
|
import { DEFAULT_MODEL } from "../model-logic";
|
||||||
import { derivePendingApprovals } from "../session-logic";
|
import { derivePendingApprovals } from "../session-logic";
|
||||||
import { useStore } from "../store";
|
import { useStore } from "../store";
|
||||||
import { isChatNewShortcut } from "../keybindings";
|
import { isChatNewLocalShortcut, isChatNewShortcut } from "../keybindings";
|
||||||
import {
|
import {
|
||||||
DEFAULT_THREAD_TERMINAL_HEIGHT,
|
DEFAULT_THREAD_TERMINAL_HEIGHT,
|
||||||
DEFAULT_THREAD_TERMINAL_ID,
|
DEFAULT_THREAD_TERMINAL_ID,
|
||||||
@@ -140,7 +140,13 @@ export default function Sidebar() {
|
|||||||
}, [state.threads]);
|
}, [state.threads]);
|
||||||
|
|
||||||
const handleNewThread = useCallback(
|
const handleNewThread = useCallback(
|
||||||
(projectId: string) => {
|
(
|
||||||
|
projectId: string,
|
||||||
|
options?: {
|
||||||
|
branch?: string | null;
|
||||||
|
worktreePath?: string | null;
|
||||||
|
},
|
||||||
|
) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: "ADD_THREAD",
|
type: "ADD_THREAD",
|
||||||
thread: {
|
thread: {
|
||||||
@@ -166,8 +172,8 @@ export default function Sidebar() {
|
|||||||
events: [],
|
events: [],
|
||||||
error: null,
|
error: null,
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
branch: null,
|
branch: options?.branch ?? null,
|
||||||
worktreePath: null,
|
worktreePath: options?.worktreePath ?? null,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -381,14 +387,23 @@ export default function Sidebar() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onWindowKeyDown = (event: KeyboardEvent) => {
|
const onWindowKeyDown = (event: KeyboardEvent) => {
|
||||||
if (!isChatNewShortcut(event, keybindings)) return;
|
|
||||||
|
|
||||||
const activeThread = state.threads.find((t) => t.id === state.activeThreadId);
|
const activeThread = state.threads.find((t) => t.id === state.activeThreadId);
|
||||||
|
if (isChatNewLocalShortcut(event, keybindings)) {
|
||||||
|
const projectId = activeThread?.projectId ?? state.projects[0]?.id;
|
||||||
|
if (!projectId) return;
|
||||||
|
event.preventDefault();
|
||||||
|
handleNewThread(projectId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isChatNewShortcut(event, keybindings)) return;
|
||||||
const projectId = activeThread?.projectId ?? state.projects[0]?.id;
|
const projectId = activeThread?.projectId ?? state.projects[0]?.id;
|
||||||
if (!projectId) return;
|
if (!projectId) return;
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
handleNewThread(projectId);
|
handleNewThread(projectId, {
|
||||||
|
branch: activeThread?.branch ?? null,
|
||||||
|
worktreePath: activeThread?.worktreePath ?? null,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("keydown", onWindowKeyDown);
|
window.addEventListener("keydown", onWindowKeyDown);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { FitAddon } from "@xterm/addon-fit";
|
import { FitAddon } from "@xterm/addon-fit";
|
||||||
import { Plus, SquareSplitHorizontal, TerminalSquare, Trash2 } from "lucide-react";
|
import { Plus, SquareSplitHorizontal, TerminalSquare, Trash2, XIcon } from "lucide-react";
|
||||||
import { type NativeApi } from "@t3tools/contracts";
|
import { type NativeApi } from "@t3tools/contracts";
|
||||||
import { Terminal, type ITheme } from "@xterm/xterm";
|
import { Terminal, type ITheme } from "@xterm/xterm";
|
||||||
import {
|
import {
|
||||||
@@ -18,10 +18,7 @@ import {
|
|||||||
preferredTerminalEditor,
|
preferredTerminalEditor,
|
||||||
resolvePathLinkTarget,
|
resolvePathLinkTarget,
|
||||||
} from "../terminal-links";
|
} from "../terminal-links";
|
||||||
import {
|
import { isTerminalClearShortcut, terminalNavigationShortcutData } from "../keybindings";
|
||||||
isTerminalClearShortcut,
|
|
||||||
terminalNavigationShortcutData,
|
|
||||||
} from "../keybindings";
|
|
||||||
import {
|
import {
|
||||||
DEFAULT_THREAD_TERMINAL_HEIGHT,
|
DEFAULT_THREAD_TERMINAL_HEIGHT,
|
||||||
DEFAULT_THREAD_TERMINAL_ID,
|
DEFAULT_THREAD_TERMINAL_ID,
|
||||||
@@ -161,10 +158,7 @@ function TerminalViewport({
|
|||||||
try {
|
try {
|
||||||
await api.terminal.write({ threadId, terminalId, data });
|
await api.terminal.write({ threadId, terminalId, data });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
writeSystemMessage(
|
writeSystemMessage(activeTerminal, error instanceof Error ? error.message : fallbackError);
|
||||||
activeTerminal,
|
|
||||||
error instanceof Error ? error.message : fallbackError,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -429,6 +423,7 @@ interface ThreadTerminalDrawerProps {
|
|||||||
onNewTerminal: () => void;
|
onNewTerminal: () => void;
|
||||||
splitShortcutLabel?: string | undefined;
|
splitShortcutLabel?: string | undefined;
|
||||||
newShortcutLabel?: string | undefined;
|
newShortcutLabel?: string | undefined;
|
||||||
|
closeShortcutLabel?: string | undefined;
|
||||||
onActiveTerminalChange: (terminalId: string) => void;
|
onActiveTerminalChange: (terminalId: string) => void;
|
||||||
onCloseTerminal: (terminalId: string) => void;
|
onCloseTerminal: (terminalId: string) => void;
|
||||||
onHeightChange: (height: number) => void;
|
onHeightChange: (height: number) => void;
|
||||||
@@ -444,15 +439,9 @@ interface TerminalActionButtonProps {
|
|||||||
function TerminalActionButton({ label, className, onClick, children }: TerminalActionButtonProps) {
|
function TerminalActionButton({ label, className, onClick, children }: TerminalActionButtonProps) {
|
||||||
return (
|
return (
|
||||||
<Popover>
|
<Popover>
|
||||||
<PopoverTrigger openOnHover
|
<PopoverTrigger
|
||||||
render={
|
openOnHover
|
||||||
<button
|
render={<button type="button" className={className} onClick={onClick} aria-label={label} />}
|
||||||
type="button"
|
|
||||||
className={className}
|
|
||||||
onClick={onClick}
|
|
||||||
aria-label={label}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
@@ -483,6 +472,7 @@ export default function ThreadTerminalDrawer({
|
|||||||
onNewTerminal,
|
onNewTerminal,
|
||||||
splitShortcutLabel,
|
splitShortcutLabel,
|
||||||
newShortcutLabel,
|
newShortcutLabel,
|
||||||
|
closeShortcutLabel,
|
||||||
onActiveTerminalChange,
|
onActiveTerminalChange,
|
||||||
onCloseTerminal,
|
onCloseTerminal,
|
||||||
onHeightChange,
|
onHeightChange,
|
||||||
@@ -598,6 +588,9 @@ export default function ThreadTerminalDrawer({
|
|||||||
),
|
),
|
||||||
[normalizedTerminalIds],
|
[normalizedTerminalIds],
|
||||||
);
|
);
|
||||||
|
const closeTerminalActionLabel = closeShortcutLabel
|
||||||
|
? `Close Terminal (${closeShortcutLabel})`
|
||||||
|
: "Close Terminal";
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onHeightChangeRef.current = onHeightChange;
|
onHeightChangeRef.current = onHeightChange;
|
||||||
@@ -709,7 +702,9 @@ export default function ThreadTerminalDrawer({
|
|||||||
<TerminalActionButton
|
<TerminalActionButton
|
||||||
className="p-1 text-foreground/90 transition-colors hover:bg-accent"
|
className="p-1 text-foreground/90 transition-colors hover:bg-accent"
|
||||||
onClick={onSplitTerminal}
|
onClick={onSplitTerminal}
|
||||||
label={splitShortcutLabel ? `Split Terminal (${splitShortcutLabel})` : "Split Terminal"}
|
label={
|
||||||
|
splitShortcutLabel ? `Split Terminal (${splitShortcutLabel})` : "Split Terminal"
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<SquareSplitHorizontal className="size-3.25" />
|
<SquareSplitHorizontal className="size-3.25" />
|
||||||
</TerminalActionButton>
|
</TerminalActionButton>
|
||||||
@@ -725,7 +720,7 @@ export default function ThreadTerminalDrawer({
|
|||||||
<TerminalActionButton
|
<TerminalActionButton
|
||||||
className="p-1 text-foreground/90 transition-colors hover:bg-accent"
|
className="p-1 text-foreground/90 transition-colors hover:bg-accent"
|
||||||
onClick={() => onCloseTerminal(resolvedActiveTerminalId)}
|
onClick={() => onCloseTerminal(resolvedActiveTerminalId)}
|
||||||
label="Close Terminal"
|
label={closeTerminalActionLabel}
|
||||||
>
|
>
|
||||||
<Trash2 className="size-3.25" />
|
<Trash2 className="size-3.25" />
|
||||||
</TerminalActionButton>
|
</TerminalActionButton>
|
||||||
@@ -805,16 +800,14 @@ export default function ThreadTerminalDrawer({
|
|||||||
<TerminalActionButton
|
<TerminalActionButton
|
||||||
className="inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70"
|
className="inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70"
|
||||||
onClick={onNewTerminal}
|
onClick={onNewTerminal}
|
||||||
label={
|
label={newShortcutLabel ? `New Terminal (${newShortcutLabel})` : "New Terminal"}
|
||||||
newShortcutLabel ? `New Terminal (${newShortcutLabel})` : "New Terminal"
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Plus className="size-3.25" />
|
<Plus className="size-3.25" />
|
||||||
</TerminalActionButton>
|
</TerminalActionButton>
|
||||||
<TerminalActionButton
|
<TerminalActionButton
|
||||||
className="inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70"
|
className="inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70"
|
||||||
onClick={() => onCloseTerminal(resolvedActiveTerminalId)}
|
onClick={() => onCloseTerminal(resolvedActiveTerminalId)}
|
||||||
label="Close Terminal"
|
label={closeTerminalActionLabel}
|
||||||
>
|
>
|
||||||
<Trash2 className="size-3.25" />
|
<Trash2 className="size-3.25" />
|
||||||
</TerminalActionButton>
|
</TerminalActionButton>
|
||||||
@@ -852,6 +845,9 @@ export default function ThreadTerminalDrawer({
|
|||||||
>
|
>
|
||||||
{terminalGroup.terminalIds.map((terminalId) => {
|
{terminalGroup.terminalIds.map((terminalId) => {
|
||||||
const isActive = terminalId === resolvedActiveTerminalId;
|
const isActive = terminalId === resolvedActiveTerminalId;
|
||||||
|
const closeTerminalLabel = `Close ${
|
||||||
|
terminalLabelById.get(terminalId) ?? "terminal"
|
||||||
|
}${isActive && closeShortcutLabel ? ` (${closeShortcutLabel})` : ""}`;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={terminalId}
|
key={terminalId}
|
||||||
@@ -875,18 +871,30 @@ export default function ThreadTerminalDrawer({
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
{normalizedTerminalIds.length > 1 && (
|
{normalizedTerminalIds.length > 1 && (
|
||||||
<button
|
<Popover>
|
||||||
type="button"
|
<PopoverTrigger
|
||||||
className="rounded px-1 text-xs font-medium leading-none text-muted-foreground opacity-0 transition hover:bg-accent hover:text-foreground group-hover:opacity-100"
|
openOnHover
|
||||||
onClick={(event) => {
|
render={
|
||||||
event.stopPropagation();
|
<button
|
||||||
onCloseTerminal(terminalId);
|
type="button"
|
||||||
}}
|
className="inline-flex size-3.5 items-center justify-center rounded text-xs font-medium leading-none text-muted-foreground opacity-0 transition hover:bg-accent hover:text-foreground group-hover:opacity-100"
|
||||||
aria-label={`Close ${terminalLabelById.get(terminalId) ?? "terminal"}`}
|
onClick={() => onCloseTerminal(terminalId)}
|
||||||
title={`Close ${terminalLabelById.get(terminalId) ?? "terminal"}`}
|
aria-label={closeTerminalLabel}
|
||||||
>
|
/>
|
||||||
×
|
}
|
||||||
</button>
|
>
|
||||||
|
<XIcon className="size-2.5" />
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverPopup
|
||||||
|
tooltipStyle
|
||||||
|
side="bottom"
|
||||||
|
sideOffset={6}
|
||||||
|
align="center"
|
||||||
|
className="pointer-events-none select-none"
|
||||||
|
>
|
||||||
|
{closeTerminalLabel}
|
||||||
|
</PopoverPopup>
|
||||||
|
</Popover>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ import {
|
|||||||
import {
|
import {
|
||||||
formatShortcutLabel,
|
formatShortcutLabel,
|
||||||
isChatNewShortcut,
|
isChatNewShortcut,
|
||||||
|
isChatNewLocalShortcut,
|
||||||
isOpenFavoriteEditorShortcut,
|
isOpenFavoriteEditorShortcut,
|
||||||
isTerminalClearShortcut,
|
isTerminalClearShortcut,
|
||||||
|
isTerminalCloseShortcut,
|
||||||
isTerminalNewShortcut,
|
isTerminalNewShortcut,
|
||||||
isTerminalSplitShortcut,
|
isTerminalSplitShortcut,
|
||||||
isTerminalToggleShortcut,
|
isTerminalToggleShortcut,
|
||||||
@@ -83,7 +85,13 @@ const DEFAULT_BINDINGS = compile([
|
|||||||
command: "terminal.new",
|
command: "terminal.new",
|
||||||
whenAst: whenIdentifier("terminalFocus"),
|
whenAst: whenIdentifier("terminalFocus"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
shortcut: modShortcut("w"),
|
||||||
|
command: "terminal.close",
|
||||||
|
whenAst: whenIdentifier("terminalFocus"),
|
||||||
|
},
|
||||||
{ shortcut: modShortcut("o", { shiftKey: true }), command: "chat.new" },
|
{ shortcut: modShortcut("o", { shiftKey: true }), command: "chat.new" },
|
||||||
|
{ shortcut: modShortcut("n", { shiftKey: true }), command: "chat.newLocal" },
|
||||||
{ shortcut: modShortcut("o"), command: "editor.openFavorite" },
|
{ shortcut: modShortcut("o"), command: "editor.openFavorite" },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -101,8 +109,8 @@ describe("isTerminalToggleShortcut", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("split/new terminal shortcuts", () => {
|
describe("split/new/close terminal shortcuts", () => {
|
||||||
it("requires terminalFocus for default split/new bindings", () => {
|
it("requires terminalFocus for default split/new/close bindings", () => {
|
||||||
assert.isFalse(
|
assert.isFalse(
|
||||||
isTerminalSplitShortcut(event({ key: "d", metaKey: true }), DEFAULT_BINDINGS, {
|
isTerminalSplitShortcut(event({ key: "d", metaKey: true }), DEFAULT_BINDINGS, {
|
||||||
platform: "MacIntel",
|
platform: "MacIntel",
|
||||||
@@ -115,6 +123,12 @@ describe("split/new terminal shortcuts", () => {
|
|||||||
context: { terminalFocus: false },
|
context: { terminalFocus: false },
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
assert.isFalse(
|
||||||
|
isTerminalCloseShortcut(event({ key: "w", ctrlKey: true }), DEFAULT_BINDINGS, {
|
||||||
|
platform: "Linux",
|
||||||
|
context: { terminalFocus: false },
|
||||||
|
}),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches split/new when terminalFocus is true", () => {
|
it("matches split/new when terminalFocus is true", () => {
|
||||||
@@ -130,6 +144,12 @@ describe("split/new terminal shortcuts", () => {
|
|||||||
context: { terminalFocus: true },
|
context: { terminalFocus: true },
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
assert.isTrue(
|
||||||
|
isTerminalCloseShortcut(event({ key: "w", ctrlKey: true }), DEFAULT_BINDINGS, {
|
||||||
|
platform: "Linux",
|
||||||
|
context: { terminalFocus: true },
|
||||||
|
}),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("supports when expressions", () => {
|
it("supports when expressions", () => {
|
||||||
@@ -225,6 +245,27 @@ describe("chat/editor shortcuts", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("matches chat.newLocal shortcut", () => {
|
||||||
|
assert.isTrue(
|
||||||
|
isChatNewLocalShortcut(
|
||||||
|
event({ key: "n", metaKey: true, shiftKey: true }),
|
||||||
|
DEFAULT_BINDINGS,
|
||||||
|
{
|
||||||
|
platform: "MacIntel",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
assert.isTrue(
|
||||||
|
isChatNewLocalShortcut(
|
||||||
|
event({ key: "n", ctrlKey: true, shiftKey: true }),
|
||||||
|
DEFAULT_BINDINGS,
|
||||||
|
{
|
||||||
|
platform: "Linux",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("matches editor.openFavorite shortcut", () => {
|
it("matches editor.openFavorite shortcut", () => {
|
||||||
assert.isTrue(
|
assert.isTrue(
|
||||||
isOpenFavoriteEditorShortcut(event({ key: "o", metaKey: true }), DEFAULT_BINDINGS, {
|
isOpenFavoriteEditorShortcut(event({ key: "o", metaKey: true }), DEFAULT_BINDINGS, {
|
||||||
|
|||||||
@@ -190,6 +190,14 @@ export function isTerminalNewShortcut(
|
|||||||
return matchesCommandShortcut(event, keybindings, "terminal.new", options);
|
return matchesCommandShortcut(event, keybindings, "terminal.new", options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isTerminalCloseShortcut(
|
||||||
|
event: ShortcutEventLike,
|
||||||
|
keybindings: ResolvedKeybindingsConfig,
|
||||||
|
options?: ShortcutMatchOptions,
|
||||||
|
): boolean {
|
||||||
|
return matchesCommandShortcut(event, keybindings, "terminal.close", options);
|
||||||
|
}
|
||||||
|
|
||||||
export function isChatNewShortcut(
|
export function isChatNewShortcut(
|
||||||
event: ShortcutEventLike,
|
event: ShortcutEventLike,
|
||||||
keybindings: ResolvedKeybindingsConfig,
|
keybindings: ResolvedKeybindingsConfig,
|
||||||
@@ -198,6 +206,14 @@ export function isChatNewShortcut(
|
|||||||
return matchesCommandShortcut(event, keybindings, "chat.new", options);
|
return matchesCommandShortcut(event, keybindings, "chat.new", options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isChatNewLocalShortcut(
|
||||||
|
event: ShortcutEventLike,
|
||||||
|
keybindings: ResolvedKeybindingsConfig,
|
||||||
|
options?: ShortcutMatchOptions,
|
||||||
|
): boolean {
|
||||||
|
return matchesCommandShortcut(event, keybindings, "chat.newLocal", options);
|
||||||
|
}
|
||||||
|
|
||||||
export function isOpenFavoriteEditorShortcut(
|
export function isOpenFavoriteEditorShortcut(
|
||||||
event: ShortcutEventLike,
|
event: ShortcutEventLike,
|
||||||
keybindings: ResolvedKeybindingsConfig,
|
keybindings: ResolvedKeybindingsConfig,
|
||||||
|
|||||||
@@ -14,6 +14,18 @@ describe("keybindings contracts", () => {
|
|||||||
command: "terminal.toggle",
|
command: "terminal.toggle",
|
||||||
});
|
});
|
||||||
assert.strictEqual(parsed.command, "terminal.toggle");
|
assert.strictEqual(parsed.command, "terminal.toggle");
|
||||||
|
|
||||||
|
const parsedClose = keybindingRuleSchema.parse({
|
||||||
|
key: "mod+w",
|
||||||
|
command: "terminal.close",
|
||||||
|
});
|
||||||
|
assert.strictEqual(parsedClose.command, "terminal.close");
|
||||||
|
|
||||||
|
const parsedLocal = keybindingRuleSchema.parse({
|
||||||
|
key: "mod+shift+n",
|
||||||
|
command: "chat.newLocal",
|
||||||
|
});
|
||||||
|
assert.strictEqual(parsedLocal.command, "chat.newLocal");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("rejects invalid command values", () => {
|
it("rejects invalid command values", () => {
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ export const keybindingCommandSchema = z.enum([
|
|||||||
"terminal.toggle",
|
"terminal.toggle",
|
||||||
"terminal.split",
|
"terminal.split",
|
||||||
"terminal.new",
|
"terminal.new",
|
||||||
|
"terminal.close",
|
||||||
"chat.new",
|
"chat.new",
|
||||||
|
"chat.newLocal",
|
||||||
"editor.openFavorite",
|
"editor.openFavorite",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user