Skip to content

fix(terminal): a woken pane's new prompt starts on its own line when reattached - #33494

Merged
nwparker merged 1 commit into
mainfrom
nwparker/wake-prompt-newline
Oct 25, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/wake-prompt-newline

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​25 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15

ELI5

After waking a sleeping terminal and then reloading the window (or opening it from another window or the phone), the new shell's prompt appeared on the same line as the old one, like p7/sub$ orca@awin:~/projects/p7$. Now the new prompt starts on its own line, the same way it already does the first time the terminal is shown.

What Changed

Before:

  • On Wake, the window paints the restored history, then blanks its viewport so the new shell starts on a clean screen.
  • The terminal daemon keeps its own copy of the screen, which later reattaches are served from. It was seeded with the same history but skipped the blanking.
  • Its cursor stayed after the dead shell's last prompt, so the new shell printed its prompt there.
  • Any later view showed the doubled prompt. A Windows/WSL verification run found it on plain Sleep → Wake, and it never grew.

After: the daemon's copy matches what the window shows. The history is kept in scrollback and the new prompt starts on a fresh viewport.

Mechanism:

  • getRecoveredHistorySeedSegments now ends the seed with the same viewport-blanking sequence the window writes after a cold restore, after the existing process-boundary ground.
  • The sequence builder (buildFreshShellViewportBlankingSequence) moved from the renderer to src/shared/terminal-fresh-shell-viewport.ts, so both sides use one definition.
  • The ground itself still never moves the cursor. That old test is narrowed to say exactly that, and a new test pins the prompt starting on its own line.

Why

The window's viewport blanking is the proven behaviour on first view. Doing the same in the daemon makes every later view agree with it, rather than inventing a second rule, such as appending a bare newline, that could disagree with the window.

Linked Issue

Found by a Windows/WSL verification run of plain Sleep → Wake. It is not caused by the recent WSL folder fixes (#33398, #33425). The daemon seed has never blanked its viewport; it shows on bash, which, unlike zsh, doesn't move a prompt off a partial line by itself.

Visual Proof

N/A: main-process terminal state with no UI code change. Pinned by an emulator test that seeds a dead shell's screen and writes the new prompt.

Testing

  • process-boundary-ground.test.ts:

    • New: a seeded screen followed by the new shell's prompt keeps OLD_OUTPUT_1, OLD_OUTPUT_2 and the old $, and the prompt sits on its own last line. Fails on main.
    • Narrowed: the ground alone never moves the cursor.
  • terminal-history-seed-segments.test.ts: the seed's segments end with the blanking, on both the normal and alternate-screen branches.

  • pnpm test src/main/daemon src/renderer/src/components/terminal-pane src/main/runtime/orca-runtime.test.ts: the only failures fail on clean main too here: the real-shell shell-ready tests, and two existing-folder import tests.

  • pnpm tc, check:code-quality:changed and run-ratchets.mjs pass.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • All platforms: the daemon's reattach view now matches the window's first view.
  • Durable checkpoints: these replay the same seed, so they stay consistent with the live screen.
  • SSH: unchanged.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

🤖 Generated with Claude Code

…reattached

After Wake the window paints the restored history and then blanks its viewport, so the new
shell's prompt starts on a clean screen. The daemon's own copy of the screen, seeded with the
same history, skipped that step. A later reattach (a reload, a second window, the phone)
therefore showed the new prompt beside the dead shell's last one: `p7/sub$ orca@awin:~/projects/p7$`
(awin verify-11). The seed now ends with the same viewport blanking the window writes, built by
one shared function, after the process-boundary ground, which still never moves the cursor.

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2cafa158-8917-4cb1-9924-8d8ac1da068a
Commits

Reviewing files that changed from the base of the PR and between 0b28553 and 4a31855.

Files selected for processing: 8
  • src/main/daemon/process-boundary-ground.test.ts
  • src/main/daemon/terminal-history-seed-segments.test.ts
  • src/main/daemon/terminal-history-seed-segments.ts
  • src/renderer/src/components/terminal-pane/pty-connection-cold-restore-repaint.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection/fresh-spawn-follow-reset.ts
  • src/renderer/src/components/terminal-pane/terminal-restored-viewport.test.ts
  • src/renderer/src/components/terminal-pane/terminal-restored-viewport.ts
  • src/shared/terminal-fresh-shell-viewport.ts
Files with no reviewable changes: 1
  • src/renderer/src/components/terminal-pane/terminal-restored-viewport.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Walkthrough

The viewport blanking sequence builder now resides in a shared module, and renderer imports use that module. Both recovered-history paths append the sequence after the process boundary, using the restored terminal row count. Tests cover the sequence in both paths and verify cursor positioning and shell-prompt placement after recovery.

Priority: Normal

Merge Risk: Minimal · up to 4a318

No actionable merge-blocking risk is established for this change.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title is concise, specific, and accurately describes the main user-facing change: the prompt starts on its own line after reattachment.
Description check Passed The description is detailed and covers the user impact, mechanism, rationale, testing, and checklist. It does not include an actual linked issue despite the template requirement, and manual testing pl…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and covers the user impact, mechanism, rationale, testing, and checklist. It does not include an actual linked issue despite the template requirement, and manual testing plus the full validation checklist remain incomplete, but the description is otherwise substantially complete.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 069d85f into main Oct 25, 2026
60 checks passed
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