Keeping a macOS terminal UI responsive during large SSH output bursts

I recently wrote up one of the harder performance problems I ran into while building a native macOS SSH client in SwiftUI: incoming SSH output can arrive much faster than a WebKit-backed terminal should render it.

The article focuses on:

  • keeping SSH reads off the main actor
  • batching bytes around a single UI flush point
  • applying backpressure instead of letting queues grow without bound
  • preserving the terminal’s lifetime across SwiftUI navigation
  • measuring end-to-end latency, not just raw throughput

The implementation comes from Nexus Shell, a commercial app I develop. I am sharing this as engineering notes rather than a product announcement. I would be especially interested in how others model backpressure when a Swift producer feeds a web-backed renderer.

Article: https://nexusshell.hashnode.dev/keeping-a-macos-terminal-ui-responsive-during-large-ssh-output-bursts

Disclosure: I used Codex to help edit the article, and verified the technical details against the implementation.

1 Like