aboutsummaryrefslogtreecommitdiff
path: root/src/server/headless/tests
diff options
context:
space:
mode:
authorJJ Liebig <jonathan.liebig@gmail.com>2026-09-14 18:35:18 +0200
committerGitHub <noreply@github.com>2026-09-14 18:35:18 +0200
commitad415672878a98bfac92d0e7abed0fc8db26e16a (patch)
treecdbc98801405977b9282477fb080da6ad68635df /src/server/headless/tests
parentb5154541cc75f9f12b7c14964d4d277d505a5f45 (diff)
fix: scope window titles to each client view (#4130)
refs #4091
Diffstat (limited to 'src/server/headless/tests')
-rw-r--r--src/server/headless/tests/mod.rs77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/server/headless/tests/mod.rs b/src/server/headless/tests/mod.rs
index 0ad5f8a3..4850203f 100644
--- a/src/server/headless/tests/mod.rs
+++ b/src/server/headless/tests/mod.rs
@@ -586,6 +586,83 @@ fn a_newly_promoted_client_gets_the_window_title_again() {
shutdown_test_runtimes(&mut server);
}
+#[tokio::test]
+async fn promoted_client_window_title_uses_its_own_view() {
+ let mut server = test_headless_server();
+ let mut survivor = crate::workspace::Workspace::test_new("survivor");
+ let survivor_tab_index = survivor.test_add_tab(Some("survivor-tab"));
+ let survivor_pane = survivor.tabs[survivor_tab_index].layout.focused();
+ let disconnected = crate::workspace::Workspace::test_new("disconnected");
+ let disconnected_pane = disconnected.tabs[0].layout.focused();
+ server.app.state.workspaces = vec![survivor, disconnected];
+ server.app.state.active = Some(1);
+ server.app.state.selected = 1;
+ server.app.state.ensure_test_terminals();
+ let survivor_terminal = server.app.state.workspaces[0].tabs[survivor_tab_index]
+ .terminal_id(survivor_pane)
+ .expect("survivor terminal")
+ .clone();
+ let terminal = server
+ .app
+ .state
+ .terminals
+ .get_mut(&survivor_terminal)
+ .expect("survivor terminal state");
+ terminal.manual_label = Some("client-pane".into());
+ terminal.set_terminal_title(Some("CLIENT OSC".into()));
+ server
+ .app
+ .configure_window_title("{workspace}/{tab}/{pane}/{terminal_title}");
+
+ let (survivor_control, _) = connect_matching_test_shell(&mut server, 1);
+ let (disconnected_control, _) = connect_matching_test_shell(&mut server, 2);
+ let survivor_tab_id = server
+ .app
+ .public_tab_id(0, survivor_tab_index)
+ .expect("survivor tab id");
+ assert!(server.focus_shell_client_on_tab(1, &survivor_tab_id));
+ server.promote_client_to_foreground(2);
+ drain_window_titles(&survivor_control);
+ drain_window_titles(&disconnected_control);
+
+ assert!(server.handle_server_event(ServerEvent::ClientDisconnected { client_id: 2 }));
+ server.sync_window_title();
+
+ assert_eq!(
+ next_window_title(&survivor_control),
+ Some(Some("survivor/survivor-tab/client-pane/CLIENT OSC".into()))
+ );
+ assert_eq!(server.app.state.active, Some(1));
+ assert_eq!(
+ server.shell_tab_id_for_client(1).as_deref(),
+ Some(survivor_tab_id.as_str())
+ );
+
+ let runtime = crate::terminal::TerminalRuntime::test_with_screen_bytes(80, 24, b"");
+ runtime.test_process_pty_bytes(b"\x1b]0;UPDATED OSC\x07");
+ server
+ .app
+ .terminal_runtimes
+ .insert(survivor_terminal, runtime);
+ assert!(
+ server
+ .sync_terminal_title_sources(&HashSet::from([survivor_pane]))
+ .1
+ );
+ assert_eq!(
+ next_window_title(&survivor_control),
+ Some(Some("survivor/survivor-tab/client-pane/UPDATED OSC".into()))
+ );
+ assert!(
+ !server
+ .sync_terminal_title_sources(&HashSet::from([disconnected_pane]))
+ .1
+ );
+ assert!(no_window_title(&survivor_control));
+
+ shutdown_test_runtimes(&mut server);
+}
+
fn test_client_writer() -> (
ClientWriter,
std::sync::mpsc::Receiver<Vec<u8>>,