Problem
The terminal can display redundant prompts on the same line, for example browser.cpp:~$ browser.cpp:~$ . This has been observed when the clear terminal button or shortcut redraws the prompt after one is already visible, and the same class of bug can occur anywhere a prompt is restored without first ensuring the cursor is at the start of a fresh line.
Desired behavior
Every newly displayed shell prompt should begin on its own terminal line. Prompt redraws should never concatenate with an existing prompt, partially typed command, compiler/runtime output, or informational message.
Proposed solution
Centralize prompt rendering in src/ui/terminal.js behind a newline-aware helper. The helper should track whether the terminal cursor/output is already at a fresh prompt position and insert CRLF before writing a new prompt whenever the previous terminal write did not end on a fresh line. Then route prompt-producing paths such as clearTerminal(), resetTerminalSession(), showInitialPrompt(), onCompileResult(), onRunResult(), command completion, idle Ctrl+C, and Ctrl+L through the same invariant.
Acceptance criteria
- Pressing the clear terminal button after the prompt is visible redraws exactly one prompt, and that prompt starts on a new line.
- Pressing Ctrl+K after the prompt is visible has the same behavior as the clear button.
- The terminal never renders adjacent prompt text like
browser.cpp:~$ browser.cpp:~$ .
- Existing startup behavior remains intact: the initial prompt is not shown before compiler readiness and is only written once.
- Existing command, compile, run, stdin, Ctrl+C, Ctrl+L, and workspace reset prompt flows continue to restore prompts correctly.
- Node E2E tests cover prompt newline behavior and the full E2E suite, lint, and build pass.
Problem
The terminal can display redundant prompts on the same line, for example
browser.cpp:~$ browser.cpp:~$. This has been observed when the clear terminal button or shortcut redraws the prompt after one is already visible, and the same class of bug can occur anywhere a prompt is restored without first ensuring the cursor is at the start of a fresh line.Desired behavior
Every newly displayed shell prompt should begin on its own terminal line. Prompt redraws should never concatenate with an existing prompt, partially typed command, compiler/runtime output, or informational message.
Proposed solution
Centralize prompt rendering in
src/ui/terminal.jsbehind a newline-aware helper. The helper should track whether the terminal cursor/output is already at a fresh prompt position and insertCRLFbefore writing a new prompt whenever the previous terminal write did not end on a fresh line. Then route prompt-producing paths such asclearTerminal(),resetTerminalSession(),showInitialPrompt(),onCompileResult(),onRunResult(), command completion, idle Ctrl+C, and Ctrl+L through the same invariant.Acceptance criteria
browser.cpp:~$ browser.cpp:~$.