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, 11:00 UTC
fix(web): Enter sends when a panel-conditioned shortcut is inactive (#37198)
Co-authored-by: Grok 4.7 <noreply@x.ai> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 15, 2026 at 13:52 UTC
6d3f6423a341b315a091567aee5ab34a3b8b0373
6 files changed
+90
-2
apps/web/src/components/ChatView.tsx
+1
@@ -3726,6 +3726,7 @@ export default function ChatView(props: ChatViewProps) {
3726
resolvedTheme={resolvedTheme}
3727
settings={settings}
3728
keybindings={keybindings}
3729
+ getShortcutContext={getShortcutContextStable}
3730
terminalOpen={Boolean(terminalUiState.terminalOpen)}
3731
gitCwd={gitCwd}
3732
pullRequestProjectId={
apps/web/src/components/chat/ChatComposer.tsx
+5
-1
@@ -142,7 +142,7 @@ import { useDictationSubmissionShortcut } from "../../speech/useDictationSubmiss
142
import { useEnvironmentSpeechInput } from "../../speech/useEnvironmentSpeechInput";
143
import { ComposerSpeechButton, ComposerSpeechRecordingPill } from "./ComposerSpeechButton";
144
import type { AssistantCitationSourceAnchor } from "~/lib/assistantTextSelection";
145
-import { shortcutLabelForCommand } from "../../keybindings";
145
+import { shortcutLabelForCommand, type ShortcutMatchContext } from "../../keybindings";
146
import {
147
type TerminalContextDraft,
148
type TerminalContextSelection,
@@ -420,6 +420,7 @@ export interface ChatComposerProps {
420
resolvedTheme: "light" | "dark";
421
settings: UnifiedSettings;
422
keybindings: ResolvedKeybindingsConfig;
423
+ getShortcutContext: (eventTarget: EventTarget | null) => ShortcutMatchContext;
424
terminalOpen: boolean;
425
gitCwd: string | null;
426
pullRequestProjectId: ProjectId | null;
@@ -533,6 +534,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
534
resolvedTheme,
535
settings,
536
keybindings,
537
+ getShortcutContext,
538
terminalOpen,
539
gitCwd,
540
pullRequestProjectId,
@@ -2199,6 +2201,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
2201
const intent = composerSubmissionIntentForKey({
2202
event,
2203
keybindings,
2204
+ context: getShortcutContext(event.target),
2205
isSoftwareKeyboardOpen,
2206
isDraftThread: routeKind === "draft",
2207
isRunning: phase === "running" || phase === "connecting",
@@ -2318,6 +2321,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
2321
const onComposerCommandKey = (key: string, event: KeyboardEvent, isTaskItem?: boolean) =>
2322
composerCommandKeyHandler({
2323
keybindings,
2324
+ getShortcutContext,
2325
sendShortcut: settings.sendShortcut,
2326
routeKind,
2327
phase,
apps/web/src/components/chat/composerCommandKey.ts
+3
@@ -40,6 +40,7 @@ import type { Dispatch, RefObject, SetStateAction } from "react";
40
*/
41
export function composerCommandKeyHandler(input: {
42
readonly keybindings: ChatComposerProps["keybindings"];
43
+ readonly getShortcutContext: ChatComposerProps["getShortcutContext"];
44
readonly sendShortcut: ChatComposerProps["settings"]["sendShortcut"];
45
readonly routeKind: ChatComposerProps["routeKind"];
46
readonly phase: ChatComposerProps["phase"];
@@ -101,6 +102,7 @@ export function composerCommandKeyHandler(input: {
102
}) {
103
const {
104
keybindings,
105
+ getShortcutContext,
106
sendShortcut,
107
routeKind,
108
phase,
@@ -223,6 +225,7 @@ export function composerCommandKeyHandler(input: {
225
const submissionIntent = composerSubmissionIntentForKey({
226
event,
227
keybindings,
228
+ context: getShortcutContext(event.target),
229
isSoftwareKeyboardOpen,
230
isDraftThread: routeKind === "draft",
231
isRunning: phase === "running" || phase === "connecting",
apps/web/src/composer-logic.test.ts
+14
@@ -98,6 +98,7 @@ describe("formatAssistantCitationForComposer", () => {
98
describe("composerSubmissionIntentForKey", () => {
99
const input = {
100
keybindings: DEFAULT_RESOLVED_KEYBINDINGS,
101
+ context: {},
102
platform: "Linux",
103
isSoftwareKeyboardOpen: false,
104
isDraftThread: false,
@@ -244,6 +245,19 @@ describe("composerSubmissionIntentForKey", () => {
245
},
246
);
247
248
+ it("sends on Enter when a binding conditioned on !rightPanelOpen is inactive", () => {
249
+ const keybindings = mergeWithDefaultKeybindings(
250
+ compileResolvedKeybindingsConfig([
251
+ { key: "enter", command: "commandPalette.toggle", when: "!rightPanelOpen" },
252
+ ]),
253
+ );
254
+ const conditioned = { ...input, keybindings, sendShortcut: "enter" as const, event: enter };
255
+ expect(composerSubmissionIntentForKey(conditioned)).toBeNull();
256
+ expect(
257
+ composerSubmissionIntentForKey({ ...conditioned, context: { rightPanelOpen: true } }),
258
+ ).toBe("foreground");
259
+ });
260
+
261
it.each([
262
{ isSoftwareKeyboardOpen: true },
263
{ event: { ...enter, isComposing: true } },
apps/web/src/composer-logic.ts
+8
-1
@@ -15,7 +15,11 @@ import {
15
type ComposerPromptSegment,
16
} from "./composer-editor-mentions";
17
18
-import { resolveShortcutCommand, type ShortcutEventLike } from "./keybindings";
18
+import {
19
+ resolveShortcutCommand,
20
+ type ShortcutEventLike,
21
+ type ShortcutMatchContext,
22
+} from "./keybindings";
23
24
export type ComposerTriggerKind = "path" | "pull-request" | "slash-command" | "skill";
25
export type ComposerSlashCommand = "model" | "side" | "btw" | "clear";
@@ -59,6 +63,8 @@ export function composerRequiresModifier(
63
export function composerSubmissionIntentForKey(input: {
64
event: ShortcutEventLike & { isComposing?: boolean; keyCode?: number; repeat?: boolean };
65
keybindings: ResolvedKeybindingsConfig;
66
+ /** The when-clause context ChatView's shortcut listeners see, so both resolve Enter alike. */
67
+ context: Partial<ShortcutMatchContext>;
68
platform?: string;
69
isSoftwareKeyboardOpen: boolean;
70
isDraftThread: boolean;
@@ -73,6 +79,7 @@ export function composerSubmissionIntentForKey(input: {
79
const command = resolveShortcutCommand(event, input.keybindings, {
80
...(input.platform === undefined ? {} : { platform: input.platform }),
81
context: {
82
+ ...input.context,
83
composerFocus: true,
84
draftThreadRoute: input.isDraftThread,
85
turnRunning: input.isRunning === true,
scripts/scenarios/panel-conditioned-enter-still-sends.e2e.ts
new
+59
@@ -0,0 +1,59 @@
1
+import { expect } from "e2e";
2
+import * as Effect from "effect/Effect";
3
+import * as FileSystem from "effect/FileSystem";
4
+import * as Path from "effect/Path";
5
+
6
+import { T3_HOME } from "../e2e.config.ts";
7
+import { runPromise, test, WEB } from "./t3.ts";
8
+
9
+// A saved rule that binds Enter to the command palette only while the right panel is closed.
10
+const panelConditionedEnter = Effect.gen(function* () {
11
+ const fs = yield* FileSystem.FileSystem;
12
+ const keybindingsPath = (yield* Path.Path).join(T3_HOME, "userdata/keybindings.json");
13
+ const original = (yield* fs.exists(keybindingsPath))
14
+ ? yield* fs.readFileString(keybindingsPath)
15
+ : null;
16
+ return {
17
+ save: fs.writeFileString(
18
+ keybindingsPath,
19
+ '[{ "key": "enter", "command": "commandPalette.toggle", "when": "!rightPanelOpen" }]\n',
20
+ ),
21
+ restore:
22
+ original === null
23
+ ? fs.remove(keybindingsPath, { force: true })
24
+ : fs.writeFileString(keybindingsPath, original),
25
+ };
26
+});
27
+
28
+test(
29
+ "Enter sends from the composer while the right panel is open and a rule binds it when closed",
30
+ WEB,
31
+ async ({ t3, app, screen }) => {
32
+ const keybindings = await runPromise(panelConditionedEnter);
33
+ try {
34
+ await runPromise(keybindings.save);
35
+ const project = await t3.project("demo");
36
+ const thread = await t3.thread({ project, title: "Panel work", messages: ["Start"] });
37
+
38
+ // The settings list shows the rule once the server has loaded the saved file.
39
+ await t3.open("/settings/keybindings");
40
+ await screen
41
+ .getByRole("button", "Edit shortcut for Command Palette: Toggle: Enter")
42
+ .waitFor();
43
+
44
+ await t3.open(thread);
45
+ await screen.getByRole("button", "Toggle right panel").tap();
46
+ await screen.getByRole("button", { name: "Toggle right panel", pressed: true }).waitFor();
47
+
48
+ const composer = screen.getByTestId("composer-editor");
49
+ await composer.tap();
50
+ await composer.pressSequentially("Hello with the panel open");
51
+ await composer.press("Enter");
52
+ await app.screenshot("after-enter");
53
+ await expect(composer).toHaveText("");
54
+ await expect(screen.getByText("Hello with the panel open")).toBeVisible();
55
+ } finally {
56
+ await runPromise(keybindings.restore);
57
+ }
58
+ },
59
+);