- Replace `chat.newSameGitState` with `chat.newLocal` across contracts, server/web defaults, docs, and tests - Make `chat.new` preserve branch/worktree state while `chat.newLocal` creates a local thread - Show terminal close shortcut labels in drawer action tooltips and tab close controls
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const keybindingCommandSchema = z.enum([
|
|
"terminal.toggle",
|
|
"terminal.split",
|
|
"terminal.new",
|
|
"terminal.close",
|
|
"chat.new",
|
|
"chat.newLocal",
|
|
"editor.openFavorite",
|
|
]);
|
|
|
|
const keybindingValueSchema = z.string().trim().min(1).max(64);
|
|
const keybindingWhenSchema = z.string().trim().min(1).max(256);
|
|
|
|
export const keybindingRuleSchema = z.object({
|
|
key: keybindingValueSchema,
|
|
command: keybindingCommandSchema,
|
|
when: keybindingWhenSchema.optional(),
|
|
});
|
|
|
|
export const keybindingsConfigSchema = z.array(keybindingRuleSchema).max(256);
|
|
|
|
export const keybindingShortcutSchema = z.object({
|
|
key: z.string().trim().min(1).max(32),
|
|
metaKey: z.boolean(),
|
|
ctrlKey: z.boolean(),
|
|
shiftKey: z.boolean(),
|
|
altKey: z.boolean(),
|
|
modKey: z.boolean(),
|
|
}).strict();
|
|
|
|
export type KeybindingWhenNode =
|
|
| { type: "identifier"; name: string }
|
|
| { type: "not"; node: KeybindingWhenNode }
|
|
| { type: "and"; left: KeybindingWhenNode; right: KeybindingWhenNode }
|
|
| { type: "or"; left: KeybindingWhenNode; right: KeybindingWhenNode };
|
|
|
|
export const keybindingWhenNodeSchema: z.ZodType<KeybindingWhenNode> = z.lazy(() =>
|
|
z.union([
|
|
z.object({
|
|
type: z.literal("identifier"),
|
|
name: z.string().min(1),
|
|
}),
|
|
z.object({
|
|
type: z.literal("not"),
|
|
node: keybindingWhenNodeSchema,
|
|
}),
|
|
z.object({
|
|
type: z.literal("and"),
|
|
left: keybindingWhenNodeSchema,
|
|
right: keybindingWhenNodeSchema,
|
|
}),
|
|
z.object({
|
|
type: z.literal("or"),
|
|
left: keybindingWhenNodeSchema,
|
|
right: keybindingWhenNodeSchema,
|
|
}),
|
|
]),
|
|
);
|
|
|
|
export const resolvedKeybindingRuleSchema = z.object({
|
|
command: keybindingCommandSchema,
|
|
shortcut: keybindingShortcutSchema,
|
|
whenAst: keybindingWhenNodeSchema.optional(),
|
|
}).strict();
|
|
|
|
export const resolvedKeybindingsConfigSchema = z.array(resolvedKeybindingRuleSchema).max(256);
|
|
|
|
export type KeybindingCommand = z.infer<typeof keybindingCommandSchema>;
|
|
export type KeybindingRule = z.infer<typeof keybindingRuleSchema>;
|
|
export type KeybindingsConfig = z.infer<typeof keybindingsConfigSchema>;
|
|
export type KeybindingShortcut = z.infer<typeof keybindingShortcutSchema>;
|
|
export type ResolvedKeybindingRule = z.infer<typeof resolvedKeybindingRuleSchema>;
|
|
export type ResolvedKeybindingsConfig = z.infer<typeof resolvedKeybindingsConfigSchema>;
|