Elffuss BraidHub

kikocis/continue public

71fd2e7d4456 · 3.6 KiBRawPermalink
1import { useMemo } from "react";
2import Shortcut from "../../components/gui/Shortcut";
3import { isJetBrains } from "../../util";
4
5interface KeyboardShortcutProps {
6 shortcut: string;
7 description: string;
8 isEven: boolean;
9}
10
11function KeyboardShortcut(props: KeyboardShortcutProps) {
12 return (
13 <div
14 className={`flex flex-col items-start p-2 py-2 sm:flex-row sm:items-center ${props.isEven ? "" : "bg-table-odd-rows"}`}
15 >
16 <div className="w-full flex-grow pb-1 pr-4 sm:w-auto sm:pb-0">
17 <span className="block break-words text-xs">{props.description}:</span>
18 </div>
19 <div className="flex-shrink-0 whitespace-nowrap">
20 <Shortcut>{props.shortcut}</Shortcut>
21 </div>
22 </div>
23 );
24}
25
26// Shortcut strings will be rendered correctly based on the platform by the Shortcut component
27const vscodeShortcuts: Omit<KeyboardShortcutProps, "isEven">[] = [
28 {
29 shortcut: "cmd '",
30 description: "Toggle Selected Model",
31 },
32 {
33 shortcut: "cmd I",
34 description: "Edit highlighted code",
35 },
36 {
37 shortcut: "cmd L",
38 description:
39 "New Chat / New Chat With Selected Code / Close Continue Sidebar If Chat Already In Focus",
40 },
41 {
42 shortcut: "cmd backspace",
43 description: "Cancel response",
44 },
45 {
46 shortcut: "cmd shift I",
47 description: "Toggle inline edit focus",
48 },
49 {
50 shortcut: "cmd shift L",
51 description:
52 "Focus Current Chat / Add Selected Code To Current Chat / Close Continue Sidebar If Chat Already In Focus",
53 },
54 {
55 shortcut: "cmd shift R",
56 description: "Debug Terminal",
57 },
58 {
59 shortcut: "cmd shift backspace",
60 description: "Reject Diff",
61 },
62 {
63 shortcut: "cmd shift enter",
64 description: "Accept Diff",
65 },
66 {
67 shortcut: "alt cmd N",
68 description: "Reject Top Change in Diff",
69 },
70 {
71 shortcut: "alt cmd Y",
72 description: "Accept Top Change in Diff",
73 },
74 {
75 shortcut: "cmd K cmd A",
76 description: "Toggle Autocomplete Enabled",
77 },
78 {
79 shortcut: "cmd K cmd M",
80 description: "Toggle Full Screen",
81 },
82];
83
84const jetbrainsShortcuts: Omit<KeyboardShortcutProps, "isEven">[] = [
85 {
86 shortcut: "cmd '",
87 description: "Toggle Selected Model",
88 },
89 {
90 shortcut: "cmd I",
91 description: "Edit highlighted code",
92 },
93 {
94 shortcut: "cmd J",
95 description:
96 "New Chat / New Chat With Selected Code / Close Continue Sidebar If Chat Already In Focus",
97 },
98 {
99 shortcut: "cmd backspace",
100 description: "Cancel response",
101 },
102 {
103 shortcut: "cmd shift I",
104 description: "Toggle inline edit focus",
105 },
106 {
107 shortcut: "cmd shift J",
108 description:
109 "Focus Current Chat / Add Selected Code To Current Chat / Close Continue Sidebar If Chat Already In Focus",
110 },
111 {
112 shortcut: "cmd shift backspace",
113 description: "Reject Diff",
114 },
115 {
116 shortcut: "cmd shift enter",
117 description: "Accept Diff",
118 },
119 {
120 shortcut: "alt shift J",
121 description: "Quick Input",
122 },
123 {
124 shortcut: "alt cmd J",
125 description: "Toggle Sidebar",
126 },
127];
128
129function KeyboardShortcuts() {
130 const shortcuts = useMemo(() => {
131 return isJetBrains() ? jetbrainsShortcuts : vscodeShortcuts;
132 }, []);
133
134 return (
135 <div className="h-full overflow-auto p-5">
136 <h3 className="mb-5 text-xl">Keyboard shortcuts</h3>
137 <div>
138 {shortcuts.map((shortcut, i) => {
139 return (
140 <KeyboardShortcut
141 key={i}
142 shortcut={shortcut.shortcut}
143 description={shortcut.description}
144 isEven={i % 2 === 0}
145 />
146 );
147 })}
148 </div>
149 </div>
150 );
151}
152
153export default KeyboardShortcuts;