Skip to content

Keep terminal mounted with an exit banner when a session dies#58

Draft
HaydnG wants to merge 1 commit into
doctly:mainfrom
HaydnG:fix/show-exit-banner-instead-of-silent-close
Draft

Keep terminal mounted with an exit banner when a session dies#58
HaydnG wants to merge 1 commit into
doctly:mainfrom
HaydnG:fix/show-exit-banner-instead-of-silent-close

Conversation

@HaydnG

@HaydnG HaydnG commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • When a pre-launch command (or claude itself) fails fast — wrong flag, missing binary, immediate stderr — the renderer's `onProcessExited` handler was calling `destroySession` immediately, which disposes the xterm instance and removes the DOM element. Anything the failing command wrote to stderr (`claude: command not found`, `devbox: unknown flag`, shell errors) was torn down with the terminal, leaving the user with no feedback at all — a terminal opens for a moment and vanishes.
  • Now, on `process-exited`, the renderer writes a styled `── session exited (code N) — re-click this session in the sidebar to relaunch, or click another to dismiss ──` banner into the terminal and defers the destroy. The terminal stays mounted so the user can scroll back through whatever was printed before the exit.
  • Re-clicking the session destroys + relaunches via the existing closed-entry branch in `openSession` (`public/app.js:779`).
  • Plain terminal sessions stay ephemeral (destroyed and removed from the sidebar immediately on exit).

Why this matters

This was triggered for me by an org-specific misconfiguration (using `devbox ai --cli` as a pre-launch command, which is actually an installer not a launcher — it exited non-zero and the terminal vanished), but it's a generic UX cliff for any failed launch: misspelled `preLaunchCmd`, missing `aws-vault` profile, etc.

Test plan

  • Set a pre-launch command to something that fails fast (e.g. `exit 1 &&`). Launch a session. Banner appears with code 1; terminal stays visible.
  • Set a pre-launch command to something that prints to stderr then exits (e.g. `echo "boom" >&2; exit 2;`). Banner shows code 2; "boom" is still readable above the banner.
  • Normal session exit (claude exits cleanly): banner shows code 0 with dim styling; terminal stays visible.
  • Re-click the failed session in the sidebar: terminal destroyed + reopened via the closed-entry branch.
  • Plain terminal: exit still removes it from the sidebar (no regression).

When a pre-launch command (or claude itself) fails fast, the renderer's
onProcessExited handler was calling destroySession immediately, which
disposes the xterm and removes the DOM element. Any stderr the failing
command wrote (claude: command not found, devbox: unknown flag, shell
errors, etc.) was destroyed with the terminal, leaving the user with no
feedback — a blank terminal opens for a moment and vanishes.

Write a styled "── session exited (code N) ──" banner into the terminal
and defer the destroy. For Claude sessions the terminal stays mounted so
the user can scroll back and read whatever was printed before the exit;
re-clicking the session destroys + relaunches via the existing closed-
entry branch in openSession. Plain terminal sessions remain ephemeral
(destroyed and removed from the sidebar immediately).
JeanBaptisteRenard referenced this pull request in JeanBaptisteRenard/switchboard Jun 9, 2026
…exit-banner

feat(terminal): keep terminal mounted with exit banner on session death (port upstream #58)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant