From 4ff29e50091dc1aead003c0eb8f62476437247f3 Mon Sep 17 00:00:00 2001 From: Kang Date: Mon, 28 Sep 2026 14:59:52 +0800 Subject: [PATCH] fix(terminal): enhance fallback command detection for quit commands --- src/components/terminal/commandNavigation.test.ts | 2 ++ src/components/terminal/commandNavigation.ts | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/terminal/commandNavigation.test.ts b/src/components/terminal/commandNavigation.test.ts index 0edd0f4e..98218385 100644 --- a/src/components/terminal/commandNavigation.test.ts +++ b/src/components/terminal/commandNavigation.test.ts @@ -167,5 +167,7 @@ describe("fallback command detection", () => { expect(nextFallbackInteractiveState(true, "\x04", "")).toBe(false); expect(nextFallbackInteractiveState(false, "\r", "ls")).toBe(false); expect(nextFallbackInteractiveState(true, "\r", "exit()")).toBe(false); + expect(nextFallbackInteractiveState(true, "\r", "\\q")).toBe(false); + expect(nextFallbackInteractiveState(true, "\r", ".quit")).toBe(false); }); }); diff --git a/src/components/terminal/commandNavigation.ts b/src/components/terminal/commandNavigation.ts index 1cb09e12..1e9ddf48 100644 --- a/src/components/terminal/commandNavigation.ts +++ b/src/components/terminal/commandNavigation.ts @@ -15,7 +15,9 @@ export function nextFallbackInteractiveState( if (data === "\x04") return false; if (data !== "\r" || !command) return interactive; if (startsObviousInteractiveSession(command)) return true; - if (/^(?:exit|quit|\.exit)(?:\(\))?$/iu.test(command.trim())) return false; + if (/^(?:(?:exit|quit)(?:\(\))?|\.exit|\.quit|\\q)$/iu.test(command.trim())) { + return false; + } return interactive; }