Skip to content

Commit 84e174d

Browse files
committed
feat: add raw mode shortcut ctrl+r
1 parent 766b057 commit 84e174d

5 files changed

Lines changed: 28 additions & 2 deletions

File tree

src/tests/prompt-input-keys.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
getPromptReturnKeyAction,
1616
isPromptCursorAtWrapBoundary,
1717
isClearImageAttachmentsShortcut,
18+
isRawModeShortcut,
1819
removeCurrentSlashToken,
1920
resolvePromptTerminalCursorPosition,
2021
toggleSkillSelection,
@@ -206,6 +207,13 @@ test("parseTerminalInput recognizes ctrl+x as the image attachment clear shortcu
206207
assert.equal(isClearImageAttachmentsShortcut(input, key), true);
207208
});
208209

210+
test("parseTerminalInput recognizes ctrl+r as the raw mode shortcut", () => {
211+
const { input, key } = parseTerminalInput("\u0012");
212+
assert.equal(input, "r");
213+
assert.equal(key.ctrl, true);
214+
assert.equal(isRawModeShortcut(input, key), true);
215+
});
216+
209217
test("parseTerminalInput recognizes ctrl+- modifyOtherKeys sequence (standard)", () => {
210218
const { input, key } = parseTerminalInput("\u001B[45;5u");
211219
assert.equal(input, "-");

src/tests/welcome-screen.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ test("buildWelcomeTips includes built-in slash commands and loaded skills", () =
3232
const labels = tips.map((tip) => tip.label);
3333
assert.ok(labels.includes("/new"));
3434
assert.ok(labels.includes("/loaded"));
35+
assert.ok(labels.includes("Ctrl+R"));
3536
assert.equal(labels.includes("/fresh"), false);
3637
});

src/ui/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export {
2626
toggleSkillSelection,
2727
removeCurrentSlashToken,
2828
isClearImageAttachmentsShortcut,
29+
isRawModeShortcut,
2930
getPromptReturnKeyAction,
3031
renderBufferWithCursor,
3132
buildInitPromptSubmission,

src/ui/views/PromptInput.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,19 @@ export const PromptInput = React.memo(function PromptInput({
169169
const showFileMentionMenu =
170170
!showSkillsDropdown &&
171171
!showModelDropdown &&
172+
!openRawModelDropdown &&
172173
fileMentionToken !== null &&
173174
fileMentionKey !== dismissedFileMentionKey;
174175
const slashItems = React.useMemo(() => buildSlashCommands(skills), [skills]);
175176
const slashToken = getCurrentSlashToken(buffer);
176177
const slashMenu = React.useMemo(
177178
() =>
178-
showSkillsDropdown || showModelDropdown || showFileMentionMenu
179+
showSkillsDropdown || showModelDropdown || openRawModelDropdown || showFileMentionMenu
179180
? []
180181
: slashToken
181182
? filterSlashCommands(slashItems, slashToken)
182183
: [],
183-
[showSkillsDropdown, showModelDropdown, showFileMentionMenu, slashToken, slashItems]
184+
[showSkillsDropdown, showModelDropdown, openRawModelDropdown, showFileMentionMenu, slashToken, slashItems]
184185
);
185186
const showMenu = slashMenu.length > 0;
186187
const promptHistoryKey = React.useMemo(() => promptHistory.join("\0"), [promptHistory]);
@@ -315,6 +316,9 @@ export const PromptInput = React.memo(function PromptInput({
315316
}
316317

317318
if (key.escape) {
319+
if (openRawModelDropdown) {
320+
return;
321+
}
318322
if (showFileMentionMenu) {
319323
return;
320324
}
@@ -325,6 +329,13 @@ export const PromptInput = React.memo(function PromptInput({
325329
return;
326330
}
327331

332+
if (isRawModeShortcut(input, key)) {
333+
setShowSkillsDropdown(false);
334+
setShowModelDropdown(false);
335+
setOpenRawModelDropdown(true);
336+
return;
337+
}
338+
328339
if (key.ctrl && (input === "o" || input === "O")) {
329340
if (runningProcesses && runningProcesses.size > 0 && onToggleProcessStdout) {
330341
onToggleProcessStdout();
@@ -887,6 +898,10 @@ export function isClearImageAttachmentsShortcut(input: string, key: Pick<InputKe
887898
return key.ctrl && (input === "x" || input === "X");
888899
}
889900

901+
export function isRawModeShortcut(input: string, key: Pick<InputKey, "ctrl">): boolean {
902+
return key.ctrl && (input === "r" || input === "R");
903+
}
904+
890905
export type PromptReturnKeyAction = "submit" | "newline" | null;
891906

892907
export function getPromptReturnKeyAction(key: Pick<InputKey, "return" | "shift" | "meta">): PromptReturnKeyAction {

src/ui/views/WelcomeScreen.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const SHORTCUT_TIPS = [
2323
{ label: "Enter", description: "Send the prompt" },
2424
{ label: "Shift+Enter", description: "Insert a newline" },
2525
{ label: "Ctrl+V", description: "Paste an image from the clipboard" },
26+
{ label: "Ctrl+R", description: "Open raw display mode selection" },
2627
{ label: "Esc", description: "Interrupt the current model turn" },
2728
{ label: "/", description: "Open the skills and commands menu" },
2829
{ label: "Ctrl+D twice", description: "Quit Deep Code CLI" },

0 commit comments

Comments
 (0)