Skip to content

fix: resync clients on broadcast lag (audit round 3, P4) - #27

Merged
mizu-jun merged 1 commit into
masterfrom
fix/audit-round3-p4-broadcast-lagged
Jul 5, 2026
Merged

fix: resync clients on broadcast lag (audit round 3, P4)#27
mizu-jun merged 1 commit into
masterfrom
fix/audit-round3-p4-broadcast-lagged

Conversation

@mizu-jun

@mizu-jun mizu-jun commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Addresses finding P4 from the round 3 audit (docs/plans/audit-round3-2026h2.md).

Problem

Both broadcast forwarders handled RecvError::Lagged by logging and continuing. tokio::sync::broadcast drops the oldest messages on overflow, so when a slow or remote client fell behind, dropped GridDiff messages left the terminal permanently corrupt until an unrelated FullRefresh happened to arrive.

Fix

  • New Session::focused_window_full_refresh() rebuilds a FullRefresh for every pane in the focused window.
  • IPC forwarder (session_dispatch.rs): on Lagged, replay each pane's current grid to the client. Captures the sessions Arc and session name into the forwarder task.
  • WebSocket forwarder (ws.rs): same recovery, converted to text for xterm.js.

Disconnect during replay ends the forwarder cleanly.

Tests

  • focused_window_full_refresh_covers_every_pane: one FullRefresh per pane, correct dimensions. #[ignore]-gated like the other PTY-spawning tests in this crate (they hang on interactive shell close in CI); runnable locally with --ignored on Linux/macOS.
  • cargo test -p nexterm-server (267 passed), cargo clippy --all-targets -- -D warnings, cargo fmt --check all green.

Notes

Remaining findings (P3, C2, P5–P7, S1 (LOW), R5/A5) stay tracked in the audit report for a later pass; the report's implementation-status section is updated here.

When a client's broadcast receiver overflowed, both forwarders logged the
RecvError::Lagged and continued, so a dropped GridDiff left the screen
corrupt until the next unrelated FullRefresh.

Add Session::focused_window_full_refresh, which rebuilds a FullRefresh for
every pane in the focused window, and call it from both forwarders on lag:

- IPC forwarder (session_dispatch): replay each pane's current grid to the
  client, capturing the sessions Arc + session name into the task.
- WebSocket forwarder (ws): same, converted to text for xterm.js.

Also update the audit report with the implementation status.

Tested: focused_window_full_refresh_covers_every_pane (ignore-gated like the
other PTY-spawning tests). cargo test / clippy -D warnings / fmt --check green.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Coverage report


Generated by cargo llvm-cov (workspace minus nexterm-client-gpu and nexterm-i18n).

@mizu-jun
mizu-jun merged commit 71986cf into master Jul 5, 2026
12 checks passed
@mizu-jun
mizu-jun deleted the fix/audit-round3-p4-broadcast-lagged branch July 5, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant