# Fix Web Terminal Resilience — Tasks ## Review Workload Forecast | Field | Value | | ------- | ------- | | Estimated changed lines | 180–280 | | 400-line budget risk | Low | | Chained PRs recommended | No | | Suggested split | Single focused change | | Delivery strategy | single-pr | | Chain strategy | feature-branch-chain | Decision needed before apply: No Chained PRs recommended: No Chain strategy: feature-branch-chain 400-line budget risk: Low ## Tasks - [x] **RED — backend input/control concurrency:** characterize a PTY write that waits for readiness while an acknowledgement is received; prove the acknowledgement is handled without waiting for that write to finish. - [x] **GREEN — ordered input writer:** move PTY writes behind one cancellable ordered queue/worker while retaining the current public WebSocket message protocol and input ordering. - [x] **TRIANGULATE — lifecycle:** cover worker cancellation and queued-write failure/disconnect handling. - [x] **RED — frontend socket ownership:** characterize stale close/retry callbacks after a newer socket has become current. - [x] **GREEN — reconnect ownership:** ensure only the current socket can update state or schedule a retry; cancel retry timers during cleanup. - [x] **REFACTOR:** keep the connection lifecycle readable and avoid changing the intentional desktop scrollback configuration. - [x] **Verify:** run targeted backend and frontend tests, frontend typecheck/lint/build, backend checks practical in the isolated worktree, and inspect diagnostics. (Backend pytest is unavailable locally: no pytest/uv executable; Docker test execution was explicitly declined.)