fix: wake cmux surfaces in hidden workspaces before sending launch commands#48
Draft
elucid wants to merge 2 commits into
Draft
fix: wake cmux surfaces in hidden workspaces before sending launch commands#48elucid wants to merge 2 commits into
elucid wants to merge 2 commits into
Conversation
de23b62 to
39ed6a2
Compare
39ed6a2 to
fc23b98
Compare
Contributor
Author
|
Ugh, this is actually no longer working after my rebase onto the changes #36 introduced. I need to go back to the drawing board... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a subagent is spawned while the user is viewing a different cmux workspace the launch command isn't evaluated.
Example, if you prompt the main agent, Cmd+2 to another workspace before the subagent pane is created, the new split pane opens, the shell-ready delay passes, and the
bash <script>command is sent but not evaluated. You'll see it there when you switch back to the initial workspace.Root Cause
Creating a fresh cmux surface in a hidden workspace creates the surface but defers terminal/PTY initialization until the surface receives activity or the workspace becomes visible. The first
cmux sendto the surface triggers initialization, but its payload is consumed as display text rather than shell input — the shell hasn't started yet when the text arrives.Confirmed via a red/green cmux integration test that uses the same low-level launch shape as subagents (
sendLongCommand()→bash <script>), without any LLM call:bash <script>before the login banner, but the script never executes (TEXT_ONLY)Fix
Layered the wake behavior into the cmux surface creation paths introduced by #36.
After creating and renaming a fresh cmux surface,
cmux.tschecks the pre-createcmux identify --jsonsnapshot. If the caller workspace differs from the focused workspace, the caller workspace is hidden, so Pi sends a harmless\nto the newly-created target surface. This forces cmux to initialize the hidden terminal before the existing shell-ready delay sends the real launch command.The wake is applied in both fresh cmux creation paths:
createCmuxSplitSurface()createSurfaceInPane()This preserves #36’s focus-neutral behaviour: no
focus-pane, noselect-workspace, and no replacement of theCMUX_SURFACE_IDanchored creation flow.