the runtime your coding agents live on
Rust agentagent-orchestrationaiai-agentsclaude-codeclicodexcoding-agentsdeveloper-toolsdevtoolsmultiplexerrustterminalterminal-multiplexerterminal-uitmuxtuiworkspace-manager
fix: reject stale pane surfaces after reconnect (#4141)
JJ Liebigf867dabbe676
diff --git a/src/client/shell/composition.rs b/src/client/shell/composition.rsindex 0a5772957..e0888d0de 100644--- a/src/client/shell/composition.rs+++ b/src/client/shell/composition.rs@@ -147,9 +147,11 @@ impl ClientShellState {return Some(self.compose_unavailable(cols, rows));}let snapshot = self.snapshot.as_deref()?;- // A one-step successor is retained separately until its exact snapshot arrives; do not- // keep composing the now-superseded current pair while it is pending.- if self.pending_pane_surface.is_some() {+ // Do not compose a retained surface while waiting for its matching snapshot or+ // connection generation.+ if self.pending_pane_surface.is_some()+ || self.pane_surface_generation != self.active_snapshot_generation+ {return None;}let surface = self.pane_surface.as_ref()?;diff --git a/src/client/shell/tests/endpoints.rs b/src/client/shell/tests/endpoints.rsindex 4ac8183c1..b43b9a31e 100644--- a/src/client/shell/tests/endpoints.rs+++ b/src/client/shell/tests/endpoints.rs@@ -1559,6 +1559,7 @@ fn reconnect_same_endpoint_accepts_new_generation_surface_revision() {state.set_endpoint_status(&endpoint_id, ClientEndpointStatus::Online);assert!(state.activate_endpoint_projection(&endpoint_id));+ assert!(state.compose(106, 20).is_none());let mut reconnected_surface = surface();reconnected_surface.boot_id = "shared-server-boot".into();reconnected_surface.projection_revision = 1;@@ -1570,6 +1571,7 @@ fn reconnect_same_endpoint_accepts_new_generation_surface_revision() {assert_eq!(state.pane_surface.as_ref().unwrap().surface_revision, 1);assert!(state.pending_pane_surface.is_none());assert_eq!(state.agent_scroll, 7);+ assert!(state.compose(106, 20).is_some());}}diff --git a/src/client/shell/tests/workspace_navigation.rs b/src/client/shell/tests/workspace_navigation.rsindex 2a100957a..7ea020666 100644--- a/src/client/shell/tests/workspace_navigation.rs+++ b/src/client/shell/tests/workspace_navigation.rs@@ -431,6 +431,7 @@ fn active_preview_is_not_retargeted_by_deletion_or_reboot() {7,Box::new(local.clone()),);+ state.set_pane_surface(surface());state.compose(100, 28).unwrap();enter_navigation(&mut state);preview_key(&mut state, b"\x1b[B");