fix: adopting a shell session no longer types into the foreign pane (release review)

startShell() writes `clear\n` 100 ms after a new mux attach, and for an adopted
session that write reaches someone else's live pane through the wrapper's tmux
client. Measured on an isolated instance: a shell with `echo DRAFT_NOT_SUBMITTED_`
typed at its prompt ran `echo DRAFT_NOT_SUBMITTED_clear` the moment the tab
opened. `shell` is the feature's primary case and also the classifier's answer
for anything it cannot name (vim, psql, a `read` prompt), so every adoption put
those six bytes in front of whatever was reading stdin.

After the fix a byte recorder in the foreign pane saw 0 bytes in the 6 s after
adopting, and a real input afterwards arrived intact. Not in the review: its
recorder covered the trust-dialog path, which is `claude` mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-11-06 04:38:05 +01:00
1 parent aa40cca343
commit 25214fcc5f
2 files changed
+49 -5

No files matched your search

+4 -1
View File
@@ -4382,7 +4382,10 @@ export class Session extends EventEmitter {
// For NEW sessions: clear by sending 'clear' command to the shell
// For RESTORED sessions: don't clear - we want to see the existing output
if (!isRestored) {
// ⚠️ Never for an ADOPTED one: this pane is someone else's, so the write would land
// on their half-typed command and submit it (measured), or in whatever is reading
// stdin. `shell` is also the mode of anything the classifier cannot name.
if (!isRestored && !this._adopt) {
setTimeout(() => {
if (this.ptyProcess) {
this._terminalBuffer.clear();