From 022fdf47c0df436541487dfb0eecc5fbf6d2f694 Mon Sep 17 00:00:00 2001 From: canvrno <46584286+canvrno@users.noreply.github.com> Date: Thu, 17 Apr 2025 17:23:29 -0700 Subject: [PATCH] ENG-501/Detection of command termination using Ctrl+C (#2960) * Detect Ctrl C input when users terminal a long running terminal command * Remove terminal-output-truncation.md documentation file --- .changeset/bright-apples-protect.md | 5 +++++ src/integrations/terminal/TerminalProcess.ts | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 .changeset/bright-apples-protect.md diff --git a/.changeset/bright-apples-protect.md b/.changeset/bright-apples-protect.md new file mode 100644 index 00000000..55111778 --- /dev/null +++ b/.changeset/bright-apples-protect.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Detect Ctrl+C termination of terminal activity on long running commands diff --git a/src/integrations/terminal/TerminalProcess.ts b/src/integrations/terminal/TerminalProcess.ts index 6d4587d2..0528503d 100644 --- a/src/integrations/terminal/TerminalProcess.ts +++ b/src/integrations/terminal/TerminalProcess.ts @@ -94,6 +94,15 @@ export class TerminalProcess extends EventEmitter { data = stripAnsi(data) } + // Ctrl+C detection: if user presses Ctrl+C, treat as command terminated + if (data.includes("^C") || data.includes("\u0003")) { + if (this.hotTimer) { + clearTimeout(this.hotTimer) + } + this.isHot = false + break + } + // first few chunks could be the command being echoed back, so we must ignore // note this means that 'echo' commands won't work if (!didOutputNonCommand) {