The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import type { ComposerHandleRef } from "../../composerHandleContext"; |
| 2 | import type { BranchToolbarHandle } from "../BranchToolbar"; |
| 3 | import type { ChatComposerHandle } from "./ChatComposer"; |
| 4 | import type { ChatShortcutCommands } from "./useChatShortcuts"; |
| 5 | |
| 6 | const openControl = |
| 7 | (composerRef: ComposerHandleRef, control: Parameters<ChatComposerHandle["openControl"]>[0]) => |
| 8 | ({ event }: { readonly event: KeyboardEvent }) => { |
| 9 | if (!event.repeat) composerRef.current?.openControl(control); |
| 10 | }; |
| 11 | |
| 12 | /** Chords that open or step the composer's controls and its branch toolbar. Held keys do not repeat them. */ |
| 13 | export function composerShortcutCommands( |
| 14 | composerRef: ComposerHandleRef, |
| 15 | branchToolbarRef: { readonly current: BranchToolbarHandle | null }, |
| 16 | ): ChatShortcutCommands { |
| 17 | return { |
| 18 | "modelPicker.toggle": ({ event }) => { |
| 19 | if (!event.repeat) composerRef.current?.toggleModelPicker(); |
| 20 | }, |
| 21 | "composer.increaseEffort": ({ event }) => { |
| 22 | if (!event.repeat) composerRef.current?.stepReasoningEffort(1); |
| 23 | }, |
| 24 | "composer.decreaseEffort": ({ event }) => { |
| 25 | if (!event.repeat) composerRef.current?.stepReasoningEffort(-1); |
| 26 | }, |
| 27 | "composer.host": openControl(composerRef, "composer.host"), |
| 28 | "composer.effort": openControl(composerRef, "composer.effort"), |
| 29 | "composer.mode": openControl(composerRef, "composer.mode"), |
| 30 | "composer.workspace": openControl(composerRef, "composer.workspace"), |
| 31 | "composer.branch": ({ event }) => { |
| 32 | if (!event.repeat) branchToolbarRef.current?.openBranchPicker(); |
| 33 | }, |
| 34 | "composer.previousWorktree": ({ event }) => { |
| 35 | if (!event.repeat) branchToolbarRef.current?.usePreviousWorktree(); |
| 36 | }, |
| 37 | } satisfies ChatShortcutCommands; |
| 38 | } |