Skip to content

Commit 1a1f9ac

Browse files
fix(web): Ctrl/Cmd+Enter sends new threads when the send shortcut needs it (#34810)
1 parent 2ed6f10 commit 1a1f9ac

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎apps/web/src/composer-logic.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,25 @@ describe("composerSubmissionIntentForKey", () => {
122122
).toBe(expected);
123123
});
124124

125+
it.each([
126+
["mod-enter", "one line"],
127+
["mod-enter-multiline", "two\nlines"],
128+
] as const)(
129+
"starts a new thread in the foreground on Mod+Enter with %s",
130+
(sendShortcut, prompt) => {
131+
const draft = { ...input, isDraftThread: true, sendShortcut, prompt };
132+
expect(composerSubmissionIntentForKey({ ...draft, event: { ...enter, ctrlKey: true } })).toBe(
133+
"foreground",
134+
);
135+
expect(
136+
composerSubmissionIntentForKey({
137+
...draft,
138+
event: { ...enter, ctrlKey: true, altKey: true },
139+
}),
140+
).toBe("background");
141+
},
142+
);
143+
125144
it("honors the send preference with an existing install's saved alternate binding", () => {
126145
const keybindings = mergeWithDefaultKeybindings(
127146
compileResolvedKeybindingsConfig([

‎apps/web/src/keybindings.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ function shortcutForContext(binding: ResolvedKeybindingRule, context: ShortcutMa
115115
// Resolve persisted Mod+Enter against send preference without rewriting saved shortcuts.
116116
if (
117117
context.composerRequiresModifier &&
118-
binding.command === "composer.sendAlternate" &&
118+
(binding.command === "composer.sendAlternate" ||
119+
binding.command === "composer.sendBackground") &&
119120
shortcut.key === "enter" &&
120121
shortcut.modKey &&
121122
!shortcut.metaKey &&

0 commit comments

Comments
 (0)