fix(web): clear terminal on workspace change; disable Mac Option as Meta
- terminal: on workspaceId change call terminal.clear() and terminal.reset() so the previous workspace's scrollback is wiped before the new shell's output appears. - terminal: set macOptionIsMeta: false. With the default (true), Mac Option+key sequences (e.g. Option+[ emits ESC) leak a literal 0x1b into the shell's stdin, which crashes downstream REPLs like Python's with "invalid non-printable character U+001B".
This commit is contained in:
@@ -38,6 +38,12 @@ export function TerminalPanel({ workspaceId }: TerminalPanelProps) {
|
|||||||
terminal = new Terminal({
|
terminal = new Terminal({
|
||||||
cursorBlink: true,
|
cursorBlink: true,
|
||||||
convertEol: 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:
|
fontFamily:
|
||||||
'Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
|
'Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
@@ -102,6 +108,10 @@ export function TerminalPanel({ workspaceId }: TerminalPanelProps) {
|
|||||||
hasWelcomedRef.current = false;
|
hasWelcomedRef.current = false;
|
||||||
isDeadRef.current = false;
|
isDeadRef.current = false;
|
||||||
setIsDead(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) => {
|
const removeInputHandler = terminal.onData((input) => {
|
||||||
if (!isDeadRef.current) {
|
if (!isDeadRef.current) {
|
||||||
|
|||||||
Reference in New Issue
Block a user