fix(#618): iTerm2 OSC 1337 ClearScrollback on attach and detach
Eliminates cross-session scrollback bleedover on iTerm2 3.6.x with "Save lines to scrollback in alternate screen mode" OFF — regression of #419 reported by @godlen4332 in discussion #609.
Change
- Add iTerm2-specific OSC 1337
ClearScrollbackescape (\x1b]1337;ClearScrollback\a) alongside the existing CSI 3 J at both attach entry andcleanupAttach()detach. - Factor both call sites through a single
emitScrollbackClear()helper so the attach/detach boundaries cannot drift apart — the exact parallel-paths pattern that caused this regression. - Additive, no regression risk for WezTerm/Alacritty/Ghostty/Kitty/Terminal.app/xterm (they parse and discard unknown OSC payloads).
Tests
Three regression guards in internal/tmux/pty_test.go (2 CI-safe + 1 TTY-gated), all appended to .claude/release-tests.yaml:
TestITermClearScrollback_ConstantContentsTestEmitScrollbackClear_IncludesBothEscapesTestCleanupAttach_EmitsITermClearScrollback
Closes #618.
Note: Release workflow test step failed on pre-existing, unrelated TestPrepareCommand_* failures in internal/session/ (also blocked v1.7.13 release). The fix for #618 is cleanly merged on main (c90440e). Release artifacts built locally via goreleaser and uploaded manually, matching the v1.7.13 recovery path.