From f4552cd60e1d46ac7fbbe8f956fa7190f73aedee Mon Sep 17 00:00:00 2001 From: Yuto Nishida Date: Sat, 10 Oct 2026 14:30:12 -0700 Subject: [PATCH] papyrus: preserve Shift+Enter for Codex sessions --- .../papyrus/client/src/components/Sidebar.tsx | 1 + .../client/src/components/Terminal.tsx | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/experimental/papyrus/client/src/components/Sidebar.tsx b/experimental/papyrus/client/src/components/Sidebar.tsx index 5db2792..68e5c50 100644 --- a/experimental/papyrus/client/src/components/Sidebar.tsx +++ b/experimental/papyrus/client/src/components/Sidebar.tsx @@ -771,6 +771,7 @@ export function Sidebar() { diff --git a/experimental/papyrus/client/src/components/Terminal.tsx b/experimental/papyrus/client/src/components/Terminal.tsx index fed598a..67563b7 100644 --- a/experimental/papyrus/client/src/components/Terminal.tsx +++ b/experimental/papyrus/client/src/components/Terminal.tsx @@ -7,10 +7,11 @@ import { fontStack, fontSizeFor } from "../settings"; interface TerminalProps { sessionId: string; + kind: string; color: string; } -export function Terminal({ sessionId, color }: TerminalProps) { +export function Terminal({ sessionId, kind, color }: TerminalProps) { const terminalRef = useRef(null); const backendRef = useRef(null); const wsRef = useRef(null); @@ -245,6 +246,26 @@ export function Terminal({ sessionId, color }: TerminalProps) { return () => el.removeEventListener("paste", onPaste, { capture: true }); }, []); + useEffect(() => { + if (kind !== "codex") return; + const el = terminalRef.current; + if (!el) return; + const onKeyDown = (e: KeyboardEvent) => { + if ( + e.key !== "Enter" || !e.shiftKey || e.ctrlKey || e.altKey || e.metaKey || e.isComposing + ) return; + // Send the modified key before either emulator turns Shift+Enter into plain Enter. + e.preventDefault(); + e.stopImmediatePropagation(); + const ws = wsRef.current; + if (ws?.readyState === WebSocket.OPEN) { + ws.send(JSON.stringify({ type: "input", data: "\x1b[13;2u" })); + } + }; + el.addEventListener("keydown", onKeyDown, { capture: true }); + return () => el.removeEventListener("keydown", onKeyDown, { capture: true }); + }, [kind]); + return (