Skip to content

Full-screen session via the terminal alternate screen buffer#20

Merged
karava merged 1 commit into
mainfrom
claude/compassionate-mccarthy-hn7hla
Jun 18, 2026
Merged

Full-screen session via the terminal alternate screen buffer#20
karava merged 1 commit into
mainfrom
claude/compassionate-mccarthy-hn7hla

Conversation

@karava

@karava karava commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

devflow start now takes over the screen like vim / less / htop: it switches to the terminal's alternate screen buffer (and hides the cursor) on launch, and restores the user's original terminal — scrollback and all — on exit.

Behavior

  • On by default, TTY-guarded. Only activates when process.stdout.isTTY; piped/non-interactive output (CI, redirects) is byte-for-byte unchanged. One code path — no rendering-mode flag to maintain.

  • Always restores. Enter happens only after every early-exit validation (so error paths stay on the real terminal). Restore runs in the single cleanup() teardown and a process.on("exit") safety net, guaranteeing the terminal is restored on every exit path: natural completion, stop, Ctrl+C, SIGTERM, even an unexpected throw. (The two restore calls are idempotent.)

  • Leaves a trace. Since the alt screen erases the in-session phase log on exit, a compact recap is printed to the real terminal after leaving the alt screen, so it persists in scrollback:

    ✓ done  ·  1h 15m focused  ·  3 pomodoros  ·  lo-fi
    

    (Reads stopped · … when interrupted.)

Implementation

  • src/lib/display.ts: enterFullscreen() / exitFullscreen() helpers (alt buffer + cursor show/hide), best-effort and TTY-guarded.
  • src/commands/start.ts: enter before the header; restore + summary in cleanup(); sessionSummary() built from the same snapshot already used for history logging; first-run setup tip moved to print inside the takeover (no flash).

Verification

  • pnpm typecheck + pnpm build pass.
  • Exercised under a real pseudo-TTY: confirmed the enter/hide-cursor sequences on launch, the restore sequences on exit, and that the summary line lands in the real terminal — for both an interrupted (stopped) and a naturally completed (✓ done · 1m focused) session.

🤖 Generated with Claude Code


Generated by Claude Code

`devflow start` now takes over the screen like vim/less/htop: it switches to
the alternate screen buffer (and hides the cursor) on launch, and restores the
user's original terminal — scrollback and all — on exit.

- Guarded on `process.stdout.isTTY`, so piped/non-interactive output is
  unchanged (single code path, no rendering-mode flag to maintain).
- Enter happens only after every early-exit validation, so error paths stay on
  the real terminal. Restore runs in the single `cleanup()` teardown plus a
  `process.on("exit")` safety net, so the terminal is always restored on every
  exit path (complete, stop, Ctrl+C, SIGTERM, unexpected throw).
- On exit, a compact summary line (e.g. `✓ done · 1h 15m focused · 3 pomodoros
  · lo-fi`) is printed to the real terminal after leaving the alt screen, so a
  trace of the session survives in scrollback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013BGajYfJGLkYwBWbgoKcjM
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.

2 participants