diff --git a/extensions/cli/src/ui/TextBuffer.ts b/extensions/cli/src/ui/TextBuffer.ts index 121deb46c..f0edea6e4 100644 --- a/extensions/cli/src/ui/TextBuffer.ts +++ b/extensions/cli/src/ui/TextBuffer.ts @@ -323,10 +323,8 @@ export class TextBuffer { // Fallback paste detection: some terminals send large pastes as rapid chunks // instead of using bracketed paste mode. We detect this by timing between inputs. - if ( - input.length > RAPID_INPUT_THRESHOLD || - (input.length >= 50 && this._rapidInputBuffer.length === 0) - ) { + // Only trigger for actually large chunks to avoid interfering with normal typing + if (input.length > RAPID_INPUT_THRESHOLD) { this._rapidInputStartPos = this._cursor; // Accumulate chunks without inserting to avoid visual flicker @@ -524,7 +522,8 @@ export class TextBuffer { } // Fallback: detect chunked paste operations - if (this.handleRapidInput(input)) { + // Don't trigger rapid input detection for small inputs (e.g. single characters like "/" or "@") + if (input.length > 50 && this.handleRapidInput(input)) { return true; } diff --git a/extensions/cli/src/ui/__tests__/TUIChat.slashCommands.test.tsx b/extensions/cli/src/ui/__tests__/TUIChat.slashCommands.test.tsx index 9bb1f0ee6..6b46546fb 100644 --- a/extensions/cli/src/ui/__tests__/TUIChat.slashCommands.test.tsx +++ b/extensions/cli/src/ui/__tests__/TUIChat.slashCommands.test.tsx @@ -1,4 +1,4 @@ -import { testBothModes, renderInMode } from "./TUIChat.dualModeHelper.js"; +import { renderInMode, testBothModes } from "./TUIChat.dualModeHelper.js"; describe("TUIChat - Slash Commands Tests", () => { testBothModes("shows slash when user types /", async (mode) => { @@ -28,17 +28,15 @@ describe("TUIChat - Slash Commands Tests", () => { const { lastFrame, stdin } = renderInMode(mode); // Type /log to trigger slash command filtering - stdin.write("/log"); + stdin.write("/exi"); // Wait a bit for the UI to update (allow extra time in both modes) - await new Promise((resolve) => - setTimeout(resolve, mode === "remote" ? 200 : 150), - ); + await new Promise((resolve) => setTimeout(resolve, 200)); const frame = lastFrame(); // Should show the typed command - expect(frame).toContain("/log"); + expect(frame).toContain("/exi"); // Mode-specific UI elements if (mode === "remote") { @@ -53,7 +51,7 @@ describe("TUIChat - Slash Commands Tests", () => { const { lastFrame, stdin } = renderInMode(mode); // Type /log and then tab - stdin.write("/log"); + stdin.write("/exi"); await new Promise((resolve) => setTimeout(resolve, 50)); @@ -83,9 +81,7 @@ describe("TUIChat - Slash Commands Tests", () => { // Type just / stdin.write("/"); - await new Promise((resolve) => - setTimeout(resolve, mode === "remote" ? 120 : 50), - ); + await new Promise((resolve) => setTimeout(resolve, 200)); const frame = lastFrame();