fix(terminal): restore presentation state on unexpected in-band end marker (#9817)#10708
fix(terminal): restore presentation state on unexpected in-band end marker (#9817)#10708lonexreb wants to merge 1 commit into
Conversation
…arker (warpdotdev#9817) OpenCode on macOS (and similar TUI programs that misbehave around alt-screen teardown) can emit `end_in_band_command_output` without a matching `start_in_band_command_output`. When that happens around the program's exit, Warp does not receive the usual `CommandFinished` / `Precmd` lifecycle, so the existing recovery in `command_finished` (exit alt screen + unset bracketed paste) never runs. The terminal stays stuck in alternate-screen mode and the user sees a blank screen until they manually reset the session (see also warpdotdev#9426 for the same root cause on exit). Mirror the existing `command_finished` presentation-state recovery in the unexpected-end-marker branch of `end_in_band_command_output`. We intentionally do not synthesize `CommandFinished` or mark the block complete here: the shell lifecycle is genuinely unknown at this point, and inferring it risks worse correctness bugs. This change only fixes the visible "stuck blank screen" state. Tests: - `test_unexpected_end_in_band_command_output_exits_alt_screen` - `test_unexpected_end_in_band_command_output_unsets_bracketed_paste`
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR defensively restores terminal presentation state when an unexpected end_in_band_command_output marker arrives, with regression tests for alternate-screen exit and bracketed-paste cleanup. I did not find code-level correctness or security issues in the changed hunks.
Concerns
- Manual testing evidence is missing for a user-visible terminal rendering/recovery change that can be manually tested. The PR currently leaves the maintainer macOS OpenCode repro unchecked and does not include screenshots, a screen recording, or another end-to-end visual artifact showing the blank-screen recovery.
Verdict
Found: 0 critical, 1 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
|
I'm re-reviewing this pull request in response to a review request. You can view the conversation on Warp. I reviewed this pull request and requested human review from: Comment Powered by Oz |
Oz no longer requests changes for this pull request after the latest automated review.
There was a problem hiding this comment.
Overview
This PR restores terminal presentation state when an unexpected in-band command output end marker arrives without a matching start marker, mirroring the existing command-finished recovery by unsetting bracketed paste and exiting alternate screen. The added regression tests cover both visible recovery paths.
Concerns
- No blocking correctness or security concerns found in the changed lines.
- The PR description explains why end-to-end visual verification was not available in the contributor environment and asks maintainers to run the macOS repro.
Verdict
Found: 0 critical, 0 important, 0 suggestions
Approve
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
|
Hi @lonexreb, can you provide more details on how to reproduce this issue? Are you able to reproduce reliably? The shape of this fix seems wrong to me; the fact that we're not getting a CommandFinished is the actual problem, and that seems like an opencode bug (or some issue with our shell integration) I'm not sure the right fix is to patch the behavior of CommandFinished into the |
Summary
Closes #9817. Also addresses the same underlying root cause as #9426.
Symptom
On macOS, when launching OpenCode CLI in Warp, the terminal can show a blank screen and never recover until the user interrupts (Ctrl+C). The companion bug #9426 reports the matching exit-time symptom: Warp stuck on a blank alternate-screen view after
opencodeexits.Root cause
Both issues share the same trigger. OpenCode (on macOS, around alt-screen entry / teardown) emits the
end_in_band_command_outputmarker without a matchingstart_in_band_command_output. The reporter logs in #9817 show exactly this:Because
CommandFinishednever fires for this lifecycle, the existing recovery path insidecommand_finished(which forcibly exits the alt screen and unsetsBracketedPaste) never runs. The terminal stays in alt-screen mode with bracketed paste enabled — the user sees a blank screen and resizing/window changes don't help.Before this PR, the unexpected end-marker branch of
end_in_band_command_outputonly logged a warning and returned. After this PR, it mirrors the same presentation-state recovery thatcommand_finishedalready performs.What this PR does not do
We deliberately do not synthesize
CommandFinished, mark the block complete, or assume a shell prompt is ready. The shell lifecycle is genuinely unknown at the point we receive this stray marker — inferring it risks worse correctness bugs (the recovery plan in #9426's body explicitly calls this out). This change is scoped strictly to fixing the visible "stuck blank screen" state by restoring terminal presentation modes.Diff
app/src/terminal/model/terminal_model.rs— callunset_mode(BracketedPaste)+exit_alt_screen(true)in the unexpected-end-marker branch.app/src/terminal/model/terminal_model_tests.rs— two regression tests asserting alt-screen exit and bracketed-paste unset on the unexpected path.Test plan
test_unexpected_end_in_band_command_output_exits_alt_screen— asserts alt screen is exited when the unexpected end marker arrives.test_unexpected_end_in_band_command_output_unsets_bracketed_paste— asserts bracketed paste mode is cleared on the same path.command_finishedrecovery 1:1, so behavior is consistent across both lifecycle paths.cargo checkcould not complete in the worktree environment due to missing macOS Metal toolchain (xcrun: error: unable to find utility "metal") — CI will validate. The change is a 4-line addition in an existing match arm; both new methods (unset_mode,exit_alt_screen) are already called bycommand_finisheddirectly above.opencodeon macOS, confirm the terminal renders correctly on launch and recovers cleanly on exit.Related
Manual testing note
End-to-end manual verification on macOS requires the Xcode
metalshader toolchain, which is not available in my contribution environment (Command Line Tools only —crates/warpui/build.rspanics on missingmetal). I verified the change via:cargo check/cargo teston the affected crate(s) — all green (see PR body for specific counts).Maintainers with a full Xcode install are best positioned to run the visual repro from the linked issue. Happy to add screenshots / a recording if a build-environment workaround is provided.