diff --git a/packages/coding-agent/src/modes/controllers/input-controller.ts b/packages/coding-agent/src/modes/controllers/input-controller.ts index 9fd238744..aa70e59ca 100644 --- a/packages/coding-agent/src/modes/controllers/input-controller.ts +++ b/packages/coding-agent/src/modes/controllers/input-controller.ts @@ -552,7 +552,7 @@ export class InputController { const wasPythonMode = this.ctx.isPythonMode; const trimmed = text.trimStart(); this.ctx.isBashMode = trimmed.startsWith("!"); - this.ctx.isPythonMode = pythonCommandPrefixLength(trimmed) > 0; + this.ctx.isPythonMode = parsePythonCommandInput(trimmed) !== undefined; if (wasBashMode !== this.ctx.isBashMode || wasPythonMode !== this.ctx.isPythonMode) { this.ctx.updateEditorBorderColor(); } diff --git a/packages/coding-agent/test/input-controller-keybindings.test.ts b/packages/coding-agent/test/input-controller-keybindings.test.ts index 772dbf9cd..e0f1e9382 100644 --- a/packages/coding-agent/test/input-controller-keybindings.test.ts +++ b/packages/coding-agent/test/input-controller-keybindings.test.ts @@ -251,6 +251,23 @@ describe("InputController keybinding setup", () => { expect(spies.resetDisplay).toHaveBeenCalledTimes(1); }); + it("does not mark pasted shell prompts as Python mode while editing", async () => { + const { InputController, ctx, editor } = await createContext(); + const controller = new InputController(ctx); + + controller.setupKeyHandlers(); + + editor.onChange?.("$ cd ~/project && sudo ./build-and-push.sh o5.7 2>&1 | tail -4"); + + expect(ctx.isPythonMode).toBe(false); + expect(ctx.updateEditorBorderColor).not.toHaveBeenCalled(); + + editor.onChange?.("$ print(1)"); + + expect(ctx.isPythonMode).toBe(true); + expect(ctx.updateEditorBorderColor).toHaveBeenCalledTimes(1); + }); + it("registers retry as an editor action and retries the failed turn", async () => { const { InputController, ctx, editor, spies } = await createContext(); const controller = new InputController(ctx);