diff --git a/web/src/components/terminal/TerminalPanel.tsx b/web/src/components/terminal/TerminalPanel.tsx index 94ca9be..0d411d1 100644 --- a/web/src/components/terminal/TerminalPanel.tsx +++ b/web/src/components/terminal/TerminalPanel.tsx @@ -38,6 +38,12 @@ export function TerminalPanel({ workspaceId }: TerminalPanelProps) { terminal = new Terminal({ cursorBlink: true, convertEol: true, + // Prevent Mac Option+key from emitting ESC. Without this, typing + // Option+[ etc. leaks a literal 0x1b into the shell's stdin, which + // can break downstream programs that don't interpret escape + // sequences (e.g. Python's REPL reports "invalid non-printable + // character U+001B"). + macOptionIsMeta: false, fontFamily: 'Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace', fontSize: 12, @@ -102,6 +108,10 @@ export function TerminalPanel({ workspaceId }: TerminalPanelProps) { hasWelcomedRef.current = false; isDeadRef.current = false; setIsDead(false); + // Clear the previous workspace's scrollback so the user does not see + // shell output from another workspace in the new one. + terminal.clear(); + terminal.reset(); const removeInputHandler = terminal.onData((input) => { if (!isDeadRef.current) {