Skip to content

Commit 4aa77fb

Browse files
committed
fix: terminals resize when shared
1 parent 31cd977 commit 4aa77fb

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

.github/workflows/electron-build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ jobs:
1414
strategy:
1515
matrix:
1616
include:
17-
- os: windows
18-
platform: win
19-
artifact: .exe
17+
# - os: windows
18+
# platform: win
19+
# artifact: .exe
2020
- os: macos
2121
platform: mac
2222
artifact: .dmg
23-
- os: ubuntu
24-
platform: linux
25-
artifact: .AppImage
23+
# - os: ubuntu
24+
# platform: linux
25+
# artifact: .AppImage
2626

2727
runs-on: ${{ matrix.os }}-latest
2828

app/components/Terminal.client.vue

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ let resizeObserver: ResizeObserver | null = null;
4040
let ipcCleanups: (() => void)[] = [];
4141
let wsReconnectTimer: ReturnType<typeof setTimeout> | null = null;
4242
let disposed = false;
43+
let muteOutput = false;
4344
// Use local node-pty only in Electron + local mode (not in share mode — share always uses WebSocket)
4445
const 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

Comments
 (0)