fix(cmd): respect SetStdin/SetStdout/SetStderr for tea.Exec compatibility - #522
fix(cmd): respect SetStdin/SetStdout/SetStderr for tea.Exec compatibility#522puneet-chandna wants to merge 2 commits into
Conversation
…lity Previously, wish.Cmd's Set* methods were no-ops, causing alt screen escape sequences to be out of sync with child process output when using tea.Exec with bubbletea.Middleware. Now wish.Cmd stores and uses custom I/O handles when set by tea.Exec, ensuring proper sequencing of alt screen commands. Fixes charmbracelet#506
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #522 +/- ##
==========================================
- Coverage 77.23% 68.75% -8.49%
==========================================
Files 19 22 +3
Lines 940 976 +36
==========================================
- Hits 726 671 -55
- Misses 160 250 +90
- Partials 54 55 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
aymanbagabas
left a comment
There was a problem hiding this comment.
Hey, this looks good! Could you look at our x/xpty library and use it to spawn the process instead?
- Use xpty.WaitProcess on Windows for proper ConPTY waiting - Implement SetStdin/SetStdout/SetStderr to store and use custom I/O - Require all stdio to be set for custom path (avoids PTY deadlocks) Fixes charmbracelet#506
|
@aymanbagabas Thanks for the suggestion! I’ve updated the implementation to use the x/xpty library for spawning the process. Please let me know if this matches what you had in mind. |
|
Hi! Just a gentle follow-up on this PR. I’ve addressed the requested changes (switched process spawning to x/xpty) and CI is passing. Whenever you have time, I’d appreciate a re-review. Thanks! |
aymanbagabas
left a comment
There was a problem hiding this comment.
Looks good! Could you back port this to the v2-exp branch in a separate PR?
|
I’ve opened a backport PR targeting the v2-exp branch with the same changes. Thanks! |
This PR fixes issue #506 where Bubble Tea programs running under Wish's
bubbletea.Middlewarewithssh.AllocatePty()would not properly release the alternate screen when executing child processes viatea.Exec.Problem
When using
tea.Execwithwish.Command, the child process output appeared "stacked" below the TUI instead of replacing it. This happened becausewish.Cmd's SetStdin, [SetStdout](cci:1: wish/cmd.go:76:0-79:1), and SetStderr methods were no-ops, causing Bubble Tea's alt screen escape sequences to be written to a different output path than the child process.Solution
Modified
wish.Cmdto properly store and use the I/O handles set by Bubble Tea's exec flow:stdin,stdout,stderrfields to [Cmd](cci:2 /wish/cmd.go:31:0-37:1) structChanges
ppty.Slaveon Windows)Testing
Before/After
Before: Child process output appears below TUI frame; scrollback shows "stacked" output
After: Child process replaces TUI cleanly; alt screen properly exits/enters around exec
Fixes #506