Skip to content

Fix/opencode tui exit stuck terminal#9429

Open
nkootstra wants to merge 3 commits intowarpdotdev:masterfrom
nkootstra:fix/opencode-tui-exit-stuck-terminal
Open

Fix/opencode tui exit stuck terminal#9429
nkootstra wants to merge 3 commits intowarpdotdev:masterfrom
nkootstra:fix/opencode-tui-exit-stuck-terminal

Conversation

@nkootstra
Copy link
Copy Markdown

Description

Fixes #9426.

Recover terminal presentation modes when Warp receives an unexpected in-band command output end marker from the Warp OSC sequence. This prevents Warp from remaining stuck on a blank alternate-screen-style view after opencode exits or tears down without the normal CommandFinished/Precmd shell lifecycle.
This intentionally only restores presentation state:

  • exits alternate screen
  • unsets bracketed paste only if Warp believes it is enabled
  • does not synthesize CommandFinished
  • does not mark the command/block complete
  • does not assume the shell prompt is ready
    The recovery is limited to the real OSC marker path and does not run for internal cleanup calls.

Testing

Added focused terminal model tests covering:

  • unexpected OSC in-band output end exits alt screen without finishing the active block
  • unexpected OSC in-band output end unsets bracketed paste without finishing the active block
  • internal non-OSC cleanup does not recover terminal modes
  • redundant bracketed-paste unset events are not emitted
    Ran:
  • cargo fmt --check
  • DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer" cargo test -p warp in_band_command_output_end
  • DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer" cargo test -p warp terminal::model::terminal_model::tests
    Also ran:
  • DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer" cargo test -p warp
    The full warp crate test suite completed with unrelated existing failures: 3604 passed, 9 failed, 6 ignored. The failures were outside the touched terminal model recovery path.
    Also fix your later headers/checklist formatting:

Server API dependencies

No server API dependencies.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Changelog Entries for Stable

CHANGELOG-BUG-FIX: Fixed an issue where Warp could remain stuck on a blank alternate-screen view after opencode exits.

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 29, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @nkootstra on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment @cla-bot check to trigger another check.

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Apr 29, 2026

@nkootstra

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and posted feedback on this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@nkootstra
Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Apr 29, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 29, 2026

The cla-bot has been summoned, and re-checked this pull request!

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR adds targeted recovery for terminal presentation modes when an unexpected OSC in-band command output end marker arrives, preserving the active command/block state while exiting alternate screen and conditionally unsetting bracketed paste. The added tests cover the OSC recovery path, internal cleanup behavior, active block state preservation, and avoiding redundant bracketed-paste unset events.

Concerns

  • No blocking correctness or security concerns found in the changed lines.

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

@captainsafia captainsafia requested a review from vorporeal April 29, 2026 16:41
@vorporeal
Copy link
Copy Markdown
Contributor

Hey @nkootstra, thanks for the PR! Question to help me better understand the context here:

after opencode exits or tears down without the normal CommandFinished/Precmd shell lifecycle

Some of the existing comments vis-a-vis bracketed paste have to do with what happens when there's an SSH disconnection. Is that the context for the opencode/TUI issue here too, or is there a way to reproduce this with a fully-local session?

@nkootstra
Copy link
Copy Markdown
Author

nkootstra commented Apr 29, 2026

This reproduces in a fully-local session, not over SSH.

My repro was Warp on macOS with local zsh, running opencode directly, then exiting shortly after the TUI initializes. In affected sessions Warp logs the unexpected end_in_band_command_output marker after Preexec, but does not receive the normal CommandFinished/Precmd lifecycle afterward.

I also checked the PR description and linked issue context: the repro path is local Warp/macOS/zsh running opencode, so the similarity to the existing bracketed-paste/SSH comments is the terminal-mode recovery problem, not an SSH disconnect context.

P.S. This was a fresh install. Since Warp is open source, I wanted to try it on my work MacBook. This was my first experience with Warp on this machine, and I noticed the same issue once more today.

@vorporeal
Copy link
Copy Markdown
Contributor

gotcha, interesting. i'm not able to trivially reproduce this on my machine, unfortunately.

i'd like to understand why you're getting the in-band output OSC instead of CommandFinished. @zachbai was the original author of the in-band command functionality; i'd love his input here.

@vorporeal vorporeal requested a review from zachbai April 29, 2026 21:09
@captainsafia captainsafia added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Apr 30, 2026 — with Warp Dev Github Integration
@vorporeal
Copy link
Copy Markdown
Contributor

@nkootstra would you mind reproducing this again (perhaps with a local build) and then sharing the logs with us? i want to make sure we understand why your instance of warp is in this state instead of us just papering over what feels like a larger underlying bug with a fix for the symptoms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warp can stay stuck on a blank alternate-screen view after opencode exits

3 participants