@@ -40,6 +40,7 @@ let resizeObserver: ResizeObserver | null = null;
4040let ipcCleanups: (() => void )[] = [];
4141let wsReconnectTimer: ReturnType <typeof setTimeout > | null = null ;
4242let disposed = false ;
43+ let muteOutput = false ;
4344// Use local node-pty only in Electron + local mode (not in share mode — share always uses WebSocket)
4445const useLocalPty = !! electronTerminal && getMode () === " local" && ! isSharing .value ;
4546
@@ -116,17 +117,26 @@ function connectWs() {
116117 if (! props .shareTerminalId ) {
117118 emit (" shareCreated" , msg .terminalId , msg .name ?? " " );
118119 }
119- // Re-fit xterm to container. For subscribed terminals, do NOT resize the
120- // PTY — doing so changes dimensions for the host, causing cursor glitch
121- // and triggering zsh's PROMPT_SP `%` mark.
120+ // Re-fit xterm to container and sync PTY dimensions.
121+ // Guests subscribing to host terminals must NOT resize the PTY — that would
122+ // change the host's dimensions, causing cursor glitch + zsh PROMPT_SP `%`.
123+ // Host subscribing to guest-created terminals DOES resize (needs correct cursor)
124+ // with a brief output mute to suppress the `%` mark.
122125 nextTick (() => {
123126 doFit ();
124- if (! props .shareTerminalId && term && ws && ws .readyState === WebSocket .OPEN ) {
127+ const isSubscribing = !! props .shareTerminalId ;
128+ const shouldResize = ! isSubscribing || shareIsHost .value ;
129+ if (shouldResize && term && ws && ws .readyState === WebSocket .OPEN ) {
125130 ws .send (JSON .stringify ({ type: " resize" , terminalId: sharedTerminalId , cols: term .cols , rows: term .rows }));
131+ // Mute output briefly after resize on subscribe to suppress zsh PROMPT_SP `%`
132+ if (isSubscribing ) {
133+ muteOutput = true ;
134+ setTimeout (() => { muteOutput = false ; }, 150 );
135+ }
126136 }
127137 });
128138 } else if (msg .type === " output" && term ) {
129- term .write (msg .data );
139+ if ( ! muteOutput ) term .write (msg .data );
130140 } else if (msg .type === " exit" && term ) {
131141 term .write (` \r\n\x1b [90m[Process exited with code ${msg .code }]\x1b [0m\r\n ` );
132142 }
0 commit comments