From 2a5993e4a8daec9d39110927d0542ea569db6059 Mon Sep 17 00:00:00 2001 From: rvdavid-rbi <214916231+rvdavid-rbi@users.noreply.github.com> Date: Wed, 24 Jun 2026 07:11:43 +1000 Subject: [PATCH] fix(tui): preserve Ctrl+J newline in VTE terminals --- ui-tui/src/__tests__/textInputPassThrough.test.ts | 6 +++++- ui-tui/src/components/textInput.tsx | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ui-tui/src/__tests__/textInputPassThrough.test.ts b/ui-tui/src/__tests__/textInputPassThrough.test.ts index 1fb47779b0f70..bffa83c87c781 100644 --- a/ui-tui/src/__tests__/textInputPassThrough.test.ts +++ b/ui-tui/src/__tests__/textInputPassThrough.test.ts @@ -17,7 +17,11 @@ describe('shouldPreserveCtrlJNewline', () => { ).toBe(true) }) - it('keeps bare local POSIX LF-compatible prompts submitting on Ctrl+J', () => { + it('preserves Ctrl+J as newline in VTE terminals like GNOME Console/Terminal', () => { + expect(shouldPreserveCtrlJNewline({ TERM: 'xterm-256color', VTE_VERSION: '8400' })).toBe(true) + }) + + it('keeps bare local POSIX LF-compatible prompts submitting when no terminal fingerprint is available', () => { expect(shouldPreserveCtrlJNewline({ TERM: 'xterm-256color' })).toBe(false) }) }) diff --git a/ui-tui/src/components/textInput.tsx b/ui-tui/src/components/textInput.tsx index deb22914695ba..9da718369138f 100644 --- a/ui-tui/src/components/textInput.tsx +++ b/ui-tui/src/components/textInput.tsx @@ -124,6 +124,10 @@ export function applyPrintableInsert( export const shouldRouteMultiCharInputAsPaste = (text: string): boolean => text.includes('\n') export function shouldPreserveCtrlJNewline(env: MinimalEnv = process.env): boolean { + if (env.VTE_VERSION) { + return true + } + if (env.WT_SESSION) { return true }