fix: clear terminal on connect, increase SIGWINCH settle time to 600ms
This commit is contained in:
parent
994b450fe4
commit
d085444adc
|
|
@ -103,20 +103,27 @@ struct MainTerminalView: View {
|
|||
Task { try? await conn.send(.keys(data: text)) }
|
||||
}
|
||||
|
||||
// On first connection: resize → brief pause (SIGWINCH propagation)
|
||||
// → snapshot. This avoids replaying history at the wrong size.
|
||||
// On first connection:
|
||||
// 1. Clear SwiftTerm immediately (removes stale content)
|
||||
// 2. Send resize so tmux + shell know the real dimensions
|
||||
// 3. Wait for SIGWINCH to propagate and shell to redraw
|
||||
// 4. Snapshot the now-stable screen state
|
||||
conn.$connectionState
|
||||
.filter { $0 == .connected }
|
||||
.first()
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak conn, terminalVC] _ in
|
||||
// Clear immediately — don’t show stale/mismatched content.
|
||||
terminalVC.feed(data: Data("\u{1B}[H\u{1B}[2J".utf8))
|
||||
|
||||
Task { @MainActor in
|
||||
let (cols, rows) = terminalVC.terminalSize
|
||||
if cols > 0 && rows > 0 {
|
||||
try? await conn?.send(.resize(cols: cols, rows: rows))
|
||||
}
|
||||
// Let tmux propagate SIGWINCH before snapshotting.
|
||||
try? await Task.sleep(nanoseconds: 250_000_000)
|
||||
// 600 ms: SIGWINCH → fish/bash redraws → tmux pane settles.
|
||||
// SSH sessions need extra round-trip time.
|
||||
try? await Task.sleep(nanoseconds: 600_000_000)
|
||||
try? await conn?.send(.snapshotRequest)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue