Problem
Starting a new terminal session, such as after opening or restoring a workspace, can leave two prompts visible (browser.cpp:~$ browser.cpp:~$). Previous terminal output may also remain visible. Terminal lifecycle transitions currently split responsibility across clearTerminal(), setWorkspace(), and showInitialPrompt(), so session resets are not atomic.
Proposed behavior
Whenever a new terminal session starts—fresh workspace open, restored workspace, or Start new project—the terminal should clear all previous visible output and show exactly one prompt:
browser.cpp:~$
The prompt must be written only after compiler startup has enabled the initial prompt. Cancelling a folder open must not clear the current terminal. User-initiated Clear/Ctrl+K behavior must remain unchanged, and background workspace refreshes must not clear terminal output or reset the working directory.
Implementation plan
- Add focused terminal reset tests using the existing fake terminal harness. Cover reset after initial prompt, reset before initial prompt, repeated resets, prompt-path reset to
~, and clearing typed input. - Add an exported
resetTerminalSession(workspace = null) API in src/ui/terminal.js. It should update workspace state, clear transient input, clear terminal output, and write exactly one prompt only when initial prompt display is already enabled. It must not call showInitialPrompt(). - Wire toolbar lifecycle transitions through the new API:
- Start new project / no-workspace restore resets to
null. - Open-folder success resets to the selected workspace.
- Workspace restore resets to the restored workspace.
- Avoid composing multiple clear/prompt operations.
- Keep
setWorkspace() state-only, preserve refreshWorkspace() behavior, and keep user-initiated Clear/Ctrl+K behavior intact. - Clear stale terminal state safely on transitions, including typed input; do not disrupt active run/STDIN state unexpectedly.
Acceptance criteria
Verification
npm run lintnpm run buildnpm run test:e2e- Optional browser smoke:
npm run test:browser:chrome
Risks
- xterm
clear() may not clear scrollback; confirm whether the acceptance requirement is viewport-only or full scrollback reset. - Resetting during an active run may orphan STDIN/run state; transitions should either be blocked during runs or normalize that state before reset.
- Prompt assertions must account for ANSI color sequences.
Problem
Starting a new terminal session, such as after opening or restoring a workspace, can leave two prompts visible (
browser.cpp:~$ browser.cpp:~$). Previous terminal output may also remain visible. Terminal lifecycle transitions currently split responsibility acrossclearTerminal(),setWorkspace(), andshowInitialPrompt(), so session resets are not atomic.Proposed behavior
Whenever a new terminal session starts—fresh workspace open, restored workspace, or Start new project—the terminal should clear all previous visible output and show exactly one prompt:
browser.cpp:~$The prompt must be written only after compiler startup has enabled the initial prompt. Cancelling a folder open must not clear the current terminal. User-initiated Clear/Ctrl+K behavior must remain unchanged, and background workspace refreshes must not clear terminal output or reset the working directory.
Implementation plan
~, and clearing typed input.resetTerminalSession(workspace = null)API insrc/ui/terminal.js. It should update workspace state, clear transient input, clear terminal output, and write exactly one prompt only when initial prompt display is already enabled. It must not callshowInitialPrompt().null.setWorkspace()state-only, preserverefreshWorkspace()behavior, and keep user-initiated Clear/Ctrl+K behavior intact.Acceptance criteria
browser.cpp:~$prompt after compiler readiness.browser.cpp:~$ browser.cpp:~$.Verification
npm run lintnpm run buildnpm run test:e2enpm run test:browser:chromeRisks
clear()may not clear scrollback; confirm whether the acceptance requirement is viewport-only or full scrollback reset.