Fix SSH PTY reattach error flood and input replay

Merged
AU
3mo ago
+1439-317

Closes #10173

Summary

The persistent SSH PTY retry path used to print every OpenSSH/daemon error into the pane, retry without visible backoff, replay queued input, and re-render stale scrollback. The root cause was split retry ownership: the attach command exposed child diagnostics and left terminal input active while an outer shell loop repeatedly rebuilt the bridge.

This change gives restored panes and normal persistent SSH startup one shared retry state machine. It classifies host outage, control-master/auth failure, daemon startup, no-progress, and transient bridge phases; applies bounded exponential backoff; renders one localized in-place status line; routes managed diagnostics to the debug log; pauses and flushes detached input; and restores terminal state on every exit path. Replay state is tracked per session lifecycle with a bounded fingerprint-verified prefix, preserving detached output and failing open on missing/corrupt state. Main's replay-query filter remains active for persistent attach scrollback.

Testing

  • Regression test commit ce21dbe9c2 precedes the implementation commits.
  • swift test --package-path Packages/macOS/CmuxFoundation --filter SSHPTYAttachRetryScriptBuilderTests (10 test functions; 13 parameterized cases where applicable).
  • swift test --package-path Packages/macOS/CmuxFoundation --filter SSHPTYAttachExitCodeTests (13 tests).
  • swift test --package-path Packages/macOS/CmuxFoundation --filter SSHPTYReplayOutputFilterTests (6 tests).
  • Focused package run: 29 tests passed.
  • swiftc -frontend -parse on changed Swift files, PBX test-wiring lint (700 files), package/workspace policy checks, and the 20-locale localization audit passed.
  • No local app build, xcodebuild, or XCUITest was run.

Review notes

The merge commit incorporates current origin/main, including the persistent replay-query filter and finite retry-budget hardening. The PR remains open for dogfood and review.