A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
feat(gui): open a thread in a window of its own
RoversXc8aafe8cba03
diff --git a/mux/src/termwiztermtab.rs b/mux/src/termwiztermtab.rsindex 3f737234..0bc15c5a 100644--- a/mux/src/termwiztermtab.rs+++ b/mux/src/termwiztermtab.rs@@ -524,6 +524,20 @@ pub fn allocate((tw_term, pane)}+/// A pane with nothing behind it, known to no tab and not to the mux. A+/// window showing a page where its terminal would be hands it to the code+/// that needs a pane to run a key binding against; nothing reads what it is+/// sent.+pub fn inert_pane(+ size: TerminalSize,+ config: Arc<dyn TerminalConfiguration + Send + Sync>,+) -> anyhow::Result<Arc<dyn Pane>> {+ let render_pipe = Pipe::new()?;+ let (input_tx, _input_rx) = channel();+ let pane = TermWizTerminalPane::new(0, size, input_tx, render_pipe.read, Some(config));+ Ok(Arc::new(pane))+}+/// This function spawns a thread and constructs a GUI window with an/// associated termwiz Terminal object to execute the provided function./// The function is expected to run in a loop to manage input and outputdiff --git a/thinkterm-i18n/i18n/de-DE.ftl b/thinkterm-i18n/i18n/de-DE.ftlindex 8fcdc8c4..e8366d92 100644--- a/thinkterm-i18n/i18n/de-DE.ftl+++ b/thinkterm-i18n/i18n/de-DE.ftl@@ -433,6 +433,9 @@ menu-add-to-space-named = Zu „{ $name }“ hinzufügenmenu-move-to-space = In Space verschiebenmenu-remove-thread-ref = Aus diesem Space entfernenmenu-go-to-origin-space = Zum Ursprungs-Space+menu-open-thread-in-window = In neuem Fenster öffnen+thread-window-go-to = Zum Fenster+thread-window-page-note = Dieser Thread ist in einem anderen Fenster geöffnet.menu-rename-space = Space umbenennen…menu-rename-named-space = „{ $name }“ umbenennen…menu-disconnect-space = „{ $name }“ trennen (Server läuft weiter)diff --git a/thinkterm-i18n/i18n/en-US.ftl b/thinkterm-i18n/i18n/en-US.ftlindex e52a7c0a..0078df49 100644--- a/thinkterm-i18n/i18n/en-US.ftl+++ b/thinkterm-i18n/i18n/en-US.ftl@@ -433,6 +433,9 @@ menu-add-to-space-named = Add to “{ $name }”menu-move-to-space = Move to Spacemenu-remove-thread-ref = Remove from This Spacemenu-go-to-origin-space = Go to Origin Space+menu-open-thread-in-window = Open in New Window+thread-window-go-to = Go to Window+thread-window-page-note = This thread is open in another window.menu-rename-space = Rename Space…menu-rename-named-space = Rename “{ $name }”…menu-disconnect-space = Disconnect “{ $name }” (Server Keeps Running)diff --git a/thinkterm-i18n/i18n/fr-FR.ftl b/thinkterm-i18n/i18n/fr-FR.ftlindex 9c156500..2ece4f91 100644--- a/thinkterm-i18n/i18n/fr-FR.ftl+++ b/thinkterm-i18n/i18n/fr-FR.ftl@@ -433,6 +433,9 @@ menu-add-to-space-named = Ajouter à « { $name } »menu-move-to-space = Déplacer vers l’espacemenu-remove-thread-ref = Retirer de cet espacemenu-go-to-origin-space = Aller à l’espace d’origine+menu-open-thread-in-window = Ouvrir dans une nouvelle fenêtre+thread-window-go-to = Aller à la fenêtre+thread-window-page-note = Cette session est ouverte dans une autre fenêtre.menu-rename-space = Renommer l’espace…menu-rename-named-space = Renommer « { $name } »…menu-disconnect-space = Déconnecter « { $name } » (le serveur reste actif)diff --git a/thinkterm-i18n/i18n/ja-JP.ftl b/thinkterm-i18n/i18n/ja-JP.ftlindex da612df5..231a001a 100644--- a/thinkterm-i18n/i18n/ja-JP.ftl+++ b/thinkterm-i18n/i18n/ja-JP.ftl@@ -418,6 +418,9 @@ menu-add-to-space-named = “{ $name }”に追加menu-move-to-space = スペースへ移動menu-remove-thread-ref = このスペースから削除menu-go-to-origin-space = 元のスペースへ移動+menu-open-thread-in-window = 新しいウィンドウで開く+thread-window-go-to = ウィンドウへ移動+thread-window-page-note = このセッションは別のウィンドウで開いています。menu-rename-space = スペース名を変更…menu-rename-named-space = 「{ $name }」の名前を変更…menu-disconnect-space = 「{ $name }」を切断(サーバーは実行を継続)diff --git a/thinkterm-i18n/i18n/ru-RU.ftl b/thinkterm-i18n/i18n/ru-RU.ftlindex 178aba9a..5dff6dd5 100644--- a/thinkterm-i18n/i18n/ru-RU.ftl+++ b/thinkterm-i18n/i18n/ru-RU.ftl@@ -416,6 +416,9 @@ menu-add-to-space-named = Добавить в «{ $name }»menu-move-to-space = Переместить в пространствоmenu-remove-thread-ref = Убрать из этого пространстваmenu-go-to-origin-space = Перейти в исходное пространство+menu-open-thread-in-window = Открыть в новом окне+thread-window-go-to = Перейти к окну+thread-window-page-note = Эта ветка открыта в другом окне.menu-rename-space = Переименовать пространство…menu-rename-named-space = Переименовать «{ $name }»…menu-disconnect-space = Отключить «{ $name }» (сервер продолжит работу)diff --git a/thinkterm-i18n/i18n/zh-CN.ftl b/thinkterm-i18n/i18n/zh-CN.ftlindex cf3efae6..c7888e79 100644--- a/thinkterm-i18n/i18n/zh-CN.ftl+++ b/thinkterm-i18n/i18n/zh-CN.ftl@@ -418,6 +418,9 @@ menu-add-to-space-named = 添加到“{ $name }”menu-move-to-space = 移动到空间menu-remove-thread-ref = 从此空间移除menu-go-to-origin-space = 回到原空间+menu-open-thread-in-window = 在新窗口打开+thread-window-go-to = 前往窗口+thread-window-page-note = 这个会话已在另一个窗口打开。menu-rename-space = 重命名空间…menu-rename-named-space = 重命名“{ $name }”…menu-disconnect-space = 断开“{ $name }”(服务器继续运行)diff --git a/wezterm-gui/src/frontend.rs b/wezterm-gui/src/frontend.rsindex 2d311bf3..328bd3d3 100644--- a/wezterm-gui/src/frontend.rs+++ b/wezterm-gui/src/frontend.rs@@ -1,6 +1,7 @@use crate::scripting::guiwin::GuiWin;use crate::spawn::SpawnWhere;use crate::termwindow::TermWindowNotif;+use crate::workspace_threads::WorkspaceThreadId;use crate::TermWindow;use ::window::*;use anyhow::{anyhow, Context, Error};@@ -13,7 +14,7 @@ use mux::window::WindowId as MuxWindowId;use mux::{Mux, MuxNotification};use promise::{Future, Promise};use std::cell::{Cell, RefCell};-use std::collections::{BTreeMap, HashSet};+use std::collections::{BTreeMap, HashMap, HashSet};use std::rc::Rc;use std::sync::Arc;use wezterm_client::domain::{ClientDomain, FrontendRecoverySlot, ThinkTermFrontendRecoveryTarget};@@ -185,6 +186,13 @@ pub struct GuiFrontEnd {switching_workspaces: RefCell<usize>,spawned_mux_window: RefCell<HashSet<MuxWindowId>>,known_windows: RefCell<BTreeMap<Window, MuxWindowId>>,+ /// Threads in a window of their own (see `termwindow::thread_window`).+ /// `None` while the window is on its way. An entry goes with its window+ /// in `forget_known_window`, or in `thread_window_not_opened`.+ thread_windows: RefCell<HashMap<WorkspaceThreadId, Option<Window>>>,+ /// The first window has set about opening the thread windows the app+ /// was left with.+ thread_windows_reopening: Cell<bool>,/// Whether this process has shown a GUI window yet. AppKit asks a/// freshly launched app with no windows to "open an untitled file";/// before the first window exists that request is the launch itself,@@ -242,6 +250,8 @@ impl GuiFrontEnd {switching_workspaces: RefCell::new(0),spawned_mux_window: RefCell::new(HashSet::new()),known_windows: RefCell::new(BTreeMap::new()),+ thread_windows: RefCell::new(HashMap::new()),+ thread_windows_reopening: Cell::new(false),any_window_recorded: Cell::new(false),startup_settled: Cell::new(false),new_window_request_held: Cell::new(false),@@ -926,8 +936,13 @@ impl GuiFrontEnd {// for may be live in it still.crate::local_sessions::attach_host_if_detached().await;let mux = Mux::get();- let thread_id = crate::workspace_threads::ensure_active_thread_for_space(space_id)+ let mut thread_id = crate::workspace_threads::ensure_active_thread_for_space(space_id).ok_or_else(|| anyhow!("failed to ensure active thread for Space {space_id}"))?;+ // Its own window has it: two windows cannot share a thread.+ if front_end().thread_is_in_own_window(&thread_id) {+ thread_id = crate::workspace_threads::thread_beside_own_windows(space_id)+ .ok_or_else(|| anyhow!("no thread free for a new window of Space {space_id}"))?;+ }let live_workspaces = mux.iter_workspaces();let plan =crate::workspace_threads::activate_thread_record(&thread_id, &live_workspaces, true)@@ -1097,7 +1112,89 @@ impl GuiFrontEnd {}}+ /// Note that `thread_id` is getting a window of its own. False when it+ /// has one, or one is on its way.+ pub(crate) fn begin_thread_window(&self, thread_id: &str) -> bool {+ let mut windows = self.thread_windows.borrow_mut();+ if windows.contains_key(thread_id) {+ return false;+ }+ windows.insert(thread_id.to_string(), None);+ true+ }++ /// True once, for the window that sets about reopening thread windows.+ pub(crate) fn take_reopening_thread_windows(&self) -> bool {+ !self.thread_windows_reopening.replace(true)+ }++ pub(crate) fn thread_window_opened(&self, thread_id: &str, window: &Window) {+ self.thread_windows+ .borrow_mut()+ .insert(thread_id.to_string(), Some(window.clone()));+ }++ pub(crate) fn thread_window_not_opened(&self, thread_id: &str) {+ self.thread_windows.borrow_mut().remove(thread_id);+ self.tell_windows_thread_window_closed(thread_id.to_string());+ }++ /// The window of its own `thread_id` is open in.+ pub(crate) fn thread_window(&self, thread_id: &str) -> Option<Window> {+ self.thread_windows.borrow().get(thread_id)?.clone()+ }++ pub(crate) fn thread_is_in_own_window(&self, thread_id: &str) -> bool {+ self.thread_windows.borrow().contains_key(thread_id)+ }++ /// `window` is a thread's own, which shows that thread and no other.+ pub(crate) fn is_thread_window(&self, window: &Window) -> bool {+ self.thread_windows+ .borrow()+ .values()+ .any(|candidate| candidate.as_ref() == Some(window))+ }++ /// A window that shows whichever thread it is asked to, for what a+ /// thread's own window hands on: the one on the thread's Space if there+ /// is one.+ pub(crate) fn window_for_any_thread(&self, space_id: &str) -> Option<GuiWin> {+ crate::workspace_threads::window_owner_for_space(space_id)+ .and_then(|owner| {+ self.gui_window_for_recovery_slot(FrontendRecoverySlot::Window(owner))+ })+ .filter(|candidate| !self.is_thread_window(&candidate.window))+ .or_else(|| {+ self.gui_windows()+ .into_iter()+ .find(|candidate| !self.is_thread_window(&candidate.window))+ })+ }++ fn tell_windows_thread_window_closed(&self, thread_id: String) {+ for candidate in self.gui_windows() {+ let thread_id = thread_id.clone();+ candidate+ .window+ .notify(TermWindowNotif::Apply(Box::new(move |term_window| {+ term_window.thread_window_closed(&thread_id);+ })));+ }+ }+pub fn forget_known_window(&self, window: &Window) {+ let closed_thread = {+ let mut thread_windows = self.thread_windows.borrow_mut();+ let closed_thread = thread_windows+ .iter()+ .find(|(_, candidate)| candidate.as_ref() == Some(window))+ .map(|(thread_id, _)| thread_id.clone());+ if let Some(thread_id) = &closed_thread {+ thread_windows.remove(thread_id);+ }+ closed_thread+ };self.recovery_windows.borrow_mut().retain(|_, candidate| candidate != window);@@ -1123,6 +1220,9 @@ impl GuiFrontEnd {// windows materialize (see the WindowCreated handler).self.detach_when_windowless.set(true);}+ if let Some(thread_id) = closed_thread {+ self.tell_windows_thread_window_closed(thread_id);+ }if !self.is_switching_workspace() {self.reconcile_workspace();}diff --git a/wezterm-gui/src/notification_click.rs b/wezterm-gui/src/notification_click.rsindex 8e7f5256..63c17ef0 100644--- a/wezterm-gui/src/notification_click.rs+++ b/wezterm-gui/src/notification_click.rs@@ -154,9 +154,14 @@ fn last_used(windows: &[GuiWin]) -> Option<&GuiWin> {.active_identity().and_then(|client| mux.resolve_focused_pane(&client)).map(|(_domain, window_id, _tab_id, _pane_id)| window_id);+ // A thread's own window goes nowhere else, so it cannot be the start.+ let front_end = crate::frontend::front_end();+ let free = |gui: &&GuiWin| !front_end.is_thread_window(&gui.window);windows.iter()+ .filter(free).find(|gui| Some(gui.mux_window_id) == focused)+ .or_else(|| windows.iter().find(free)).or_else(|| windows.first())}diff --git a/wezterm-gui/src/termwindow/keyevent.rs b/wezterm-gui/src/termwindow/keyevent.rsindex 274c0d0f..376e1e2f 100644--- a/wezterm-gui/src/termwindow/keyevent.rs+++ b/wezterm-gui/src/termwindow/keyevent.rs@@ -900,7 +900,7 @@ impl super::TermWindow {}}let stage = crate::input_diagnostics::StageTimer::begin("get_active_pane");- let pane = self.get_active_pane_or_overlay();+ let pane = self.pane_for_key_bindings();stage.finish(pane.is_some());let pane = match pane {Some(pane) => pane,@@ -1209,7 +1209,7 @@ impl super::TermWindow {);let stage = crate::input_diagnostics::StageTimer::begin("get_active_pane");- let pane = self.get_active_pane_or_overlay();+ let pane = self.pane_for_key_bindings();stage.finish(pane.is_some());let pane = match pane {Some(pane) => pane,diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex e0063a13..1bb0a36e 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -172,6 +172,7 @@ mod sidebar_make_way;mod sidebar_slide;mod space_swipe;pub(crate) mod thread_numbers;+pub(crate) mod thread_window;mod window_tab_reveal;pub mod spawn;pub mod ssh_hosts_view;@@ -693,6 +694,10 @@ pub(crate) enum ContextMenuApplicationAction {space_id: String,thread_id: String,},+ /// Thread menu: give the thread a window of its own.+ OpenThreadInOwnWindow(crate::workspace_threads::WorkspaceThreadId),+ /// Thread menu: bring forward the window the thread is open in.+ GoToThreadWindow(crate::workspace_threads::WorkspaceThreadId),/// Sidebar view-options: show/hide threads with this work status.ToggleWorkspaceStatusFilter(crate::workspace_threads::WorkspaceThreadWorkStatus),/// Sidebar view-options: transiently reveal archived projects.@@ -3360,6 +3365,15 @@ pub struct TermWindow {/// windows spawned by the reconcile, e.g. reconnect/auth prompts): they/// close when their mux window dies instead of falling back to a thread.dies_with_mux_window: bool,+ /// The thread this window exists to show: a window of its own, with no+ /// sidebars, opened from the thread list (see `thread_window`).+ dedicated_thread: Option<crate::workspace_threads::WorkspaceThreadId>,+ /// The page standing in here for a thread open in its own window.+ elsewhere_page: Option<thread_window::ThreadElsewherePage>,+ /// A thread to give its own window as soon as it is on screen here.+ thread_bound_for_own_window: Option<thread_window::ThreadBoundForOwnWindow>,+ /// Thread windows the app was left with, still to open.+ threads_to_reopen: std::collections::VecDeque<crate::workspace_threads::WorkspaceThreadId>,/// Opened for a server's connection (Connect, `thinkterm connect`) that/// has not got through yet: if it fails or is turned down, the window/// goes, as it came for nothing else.@@ -4136,6 +4150,17 @@ impl TermWindow {}self.persist_workspace_layout_after_mutation("window close requested");+ // A thread's own window is one view of a thread that goes on running+ // in the thread list. As the last window it goes with the app, and+ // comes back with it.+ if let Some(thread_id) = &self.dedicated_thread {+ if front_end().gui_windows().len() > 1 {+ crate::workspace_threads::note_thread_left_own_window(thread_id);+ self.close_gui_window_now(window, true);+ return;+ }+ }+let mux = Mux::get();let preserve_mux_window = self.should_preserve_mux_window_on_gui_close();match self.config.window_close_confirmation {@@ -4747,7 +4772,8 @@ impl TermWindow {let mux = Mux::get();let ws = mux.get_window(self.mux_window_id)- .map(|w| w.get_workspace().to_string());+ .map(|w| w.get_workspace().to_string())+ .filter(|ws| !crate::workspace_threads::is_thread_page_workspace(ws));if let Some(ws) = ws {if mux.active_workspace() != ws {mux.set_active_workspace(&ws);@@ -4842,7 +4868,7 @@ impl TermWindow {impl TermWindow {pub async fn new_window(mux_window_id: MuxWindowId) -> anyhow::Result<()> {- Self::new_window_impl(mux_window_id, None, true, None).await+ Self::new_window_impl(mux_window_id, None, true, None, None).await}/// For domain-owned mux windows (remote mux windows arriving via a@@ -4850,7 +4876,7 @@ impl TermWindow {/// a saved workspace thread. Restoring would adopt this window onto a/// different mux window, orphaning/killing the one the domain created.pub async fn new_window_without_restore(mux_window_id: MuxWindowId) -> anyhow::Result<()> {- Self::new_window_impl(mux_window_id, None, false, None).await+ Self::new_window_impl(mux_window_id, None, false, None, None).await}pub async fn new_window_with_claimed_space(@@ -4864,6 +4890,26 @@ impl TermWindow {Some((space_owner_id, active_space_id)),false,remote_open_domain,+ None,+ )+ .await+ }++ /// A window of its own for `thread_id`, showing its running mux window.+ /// It sits in the thread's Space without holding it: the window with the+ /// sidebar goes on holding that, and never hears of this one.+ pub(crate) async fn new_thread_window(+ mux_window_id: MuxWindowId,+ space_id: String,+ request: thread_window::OwnWindowRequest,+ ) -> anyhow::Result<()> {+ let space_owner_id = crate::workspace_threads::next_space_owner_id();+ Self::new_window_impl(+ mux_window_id,+ Some((space_owner_id, space_id)),+ false,+ None,+ Some(request),).await}@@ -4873,6 +4919,7 @@ impl TermWindow {claimed_space: Option<(u64, String)>,restore_saved_thread: bool,remote_open_domain: Option<DomainId>,+ own_window: Option<thread_window::OwnWindowRequest>,) -> anyhow::Result<()> {let config = configuration();let native_settings = crate::native_settings::load();@@ -4960,7 +5007,12 @@ impl TermWindow {// A window tab row that hides gives its height to the terminal: the// window opens without it, and the shell starts at the size it asked// for rather than being resized as the window appears.- let window_tab_reveal = window_tab_reveal::WindowTabReveal::new();+ let in_own_window = own_window.is_some();+ let window_tab_reveal = if in_own_window {+ window_tab_reveal::WindowTabReveal::always_hiding()+ } else {+ window_tab_reveal::WindowTabReveal::new()+ };let window_tab_row_height = if window_tab_reveal.in_layout() {Self::tab_bar_pixel_height_impl(&fontconfig)? as usize} else {@@ -5008,9 +5060,9 @@ impl TermWindow {// A right sidebar that starts open, as it was left, takes its width// beside the terminal rather than out of it: the shell starts at the// size asked for instead of being resized as the window opens.- let right_sidebar_shown =- crate::native_settings::right_sidebar_starts_shown(&native_settings.chrome)- && RightSidebarMode::any_panel_enabled();+ let right_sidebar_shown = !in_own_window+ && crate::native_settings::right_sidebar_starts_shown(&native_settings.chrome)+ && RightSidebarMode::any_panel_enabled();let right_sidebar_width = if right_sidebar_shown {ui::right_sidebar_width_for_metrics(&render_metrics, dpi as usize)} else {@@ -5027,7 +5079,7 @@ impl TermWindow {let mut dimensions = Dimensions {pixel_width: (terminal_size.pixel_width- + workspace_sidebar_width+ + if in_own_window { 0 } else { workspace_sidebar_width }+ right_sidebar_width+ padding_left+ padding_right) as usize,@@ -5055,7 +5107,8 @@ impl TermWindow {let render_state = None;let connection_name = Connection::get().unwrap().name();- let dies_with_mux_window = claimed_space.is_none() && !restore_saved_thread;+ let dies_with_mux_window =+ in_own_window || (claimed_space.is_none() && !restore_saved_thread);let (space_owner_id, active_space_id) = claimed_space.unwrap_or_else(|| {let space_owner_id = crate::workspace_threads::next_space_owner_id();// Windows created without a saved-thread restore are incidental@@ -5318,13 +5371,18 @@ impl TermWindow {space_owner_id,active_space_id,dies_with_mux_window,+ dedicated_thread: own_window.as_ref().map(|request| request.thread_id.clone()),+ elsewhere_page: None,+ thread_bound_for_own_window: None,+ threads_to_reopen: std::collections::VecDeque::new(),opened_to_connect: remote_open_domain.is_some(),space_reconnects_in_flight: HashSet::new(),watched_space_connection_state: None,workspace_layout_structure_fingerprint,workspace_sidebar_width,workspace_sidebar_pending_thread_selection: None,- workspace_sidebar_collapsed: !native_settings.onboarding.show_left_sidebar_by_default,+ workspace_sidebar_collapsed: in_own_window+ || !native_settings.onboarding.show_left_sidebar_by_default,workspace_sidebar_scroll_offset: 0.0,workspace_sidebar_scroll_offsets: HashMap::new(),workspace_sidebar_swipe: space_swipe::SidebarSpaceSwipeState::default(),@@ -5530,7 +5588,8 @@ impl TermWindow {//// macOS is untouched by any of this and keeps using AppKit's frame// autosave below; `frame_to_restore` yields nothing there.- let restored_frame = if crate::main_window_placement::claim_main_window(mux_window_id)+ let restored_frame = if !in_own_window+ && crate::main_window_placement::claim_main_window(mux_window_id)&& native_settings.window.restore_main_window_frame&& x.is_none()&& y.is_none()@@ -5548,7 +5607,10 @@ impl TermWindow {macos_frame_autosave_name: if cfg!(target_os = "macos")&& native_settings.window.restore_main_window_frame{- Some("ThinkTerm.MainWindow".to_string())+ Some(match &own_window {+ Some(request) => format!("ThinkTerm.ThreadWindow.{}", request.frame_slot),+ None => "ThinkTerm.MainWindow".to_string(),+ })} else {None},@@ -5571,7 +5633,13 @@ impl TermWindow {},).await?;- window.set_titlebar_sidebar_button_visible(true);+ window.set_titlebar_sidebar_button_visible(!in_own_window);+ // Its one bar is where the system keeps the title bar: what is on the+ // bar has to stay put under the pointer, and only its blank moves+ // the window (`pane_bar_blank_is_title_bar`).+ if in_own_window {+ window.set_moved_on_request_only();+ }{let mut tw = tw.borrow_mut();tw.window.replace(window.clone());@@ -5699,7 +5767,12 @@ impl TermWindow {} else {myself.sync_current_workspace_thread();}- myself.maybe_show_onboarding();+ if myself.dedicated_thread.is_none() {+ myself.maybe_show_onboarding();+ }+ if restore_saved_thread && front_end().take_reopening_thread_windows() {+ myself.begin_reopening_thread_windows();+ }// The mux window can predate this native window, so no// TabAddedToWindow notification is guaranteed after the GUI has// subscribed. Converge the already-active tab before the first@@ -5708,6 +5781,9 @@ impl TermWindow {if !myself.content_view_foreground() {myself.resize_mux_tabs_to_current_terminal_size();}+ if let Some(position) = own_window.as_ref().and_then(|request| request.position) {+ window.set_window_position(position);+ }window.show();// Maximizing after the window is shown, rather than asking for a// maximized window up front: `show` is an ordinary "restore and@@ -5738,6 +5814,9 @@ impl TermWindow {)};front_end().record_known_window(window.clone(), adopted_mux_window_id, recovery_slot);+ if let Some(request) = &own_window {+ front_end().thread_window_opened(&request.thread_id, &window);+ }// A Project directory refused before this window existed has been// waiting for somewhere to be shown; this is the first moment there is@@ -5788,7 +5867,9 @@ impl TermWindow {}match event {WindowEvent::Destroyed => {- crate::main_window_placement::window_closed(self.mux_window_id);+ if self.dedicated_thread.is_none() {+ crate::main_window_placement::window_closed(self.mux_window_id);+ }self.flush_right_sidebar_note_blocking();self.save_right_sidebar_markdown_preview_before_destroy();self.clear_gui_recovery_intent();@@ -5805,7 +5886,9 @@ impl TermWindow {// Get the placement on disk before anything that might quit// the process gets going. The claim is kept: the close may// still be called off by a confirmation prompt.- crate::main_window_placement::close_requested(self.mux_window_id);+ if self.dedicated_thread.is_none() {+ crate::main_window_placement::close_requested(self.mux_window_id);+ }self.close_requested(window);Ok(true)}@@ -5813,7 +5896,9 @@ impl TermWindow {// While a restored frame is still being asserted the window is// passing through geometry nobody chose; recording it would// save the startup wobble rather than where the window lives.- if !self.settle_restored_frame(frame, maximized, window) {+ if self.dedicated_thread.is_none()+ && !self.settle_restored_frame(frame, maximized, window)+ {crate::main_window_placement::record(self.mux_window_id, frame, maximized);}Ok(true)@@ -5858,7 +5943,7 @@ impl TermWindow {// A native context menu delivers its selection this way;// whichever way the menu ended, it is over now.self.native_context_menu_open = false;- if let Some(pane) = self.get_active_pane_or_overlay() {+ if let Some(pane) = self.pane_for_key_bindings() {self.perform_key_assignment(&pane, &action)?;window.invalidate();}@@ -6783,6 +6868,7 @@ impl TermWindow {// leaving a live window that never hears PaneOutput again, painting// only on input events and the 1s render watchdog.self.subscribe_to_pane_updates();+ self.leave_thread_elsewhere_page(mux_window_id);// Keep the frontend's window<->mux mapping accurate so that the// additive reconcile does not try to spawn a duplicate window for the@@ -6823,6 +6909,7 @@ impl TermWindow {// be up).self.resize_mux_tabs_to_current_terminal_size();self.sync_current_workspace_thread();+ self.send_on_thread_bound_for_own_window(mux_window_id);// A Space/thread switch can replace the active pane without changing// the native window's focus state, so no FocusChanged event follows@@ -6901,7 +6988,7 @@ impl TermWindow {if let Some(thread_id) =crate::workspace_threads::ensure_active_thread_for_space(&self.active_space_id){- self.activate_workspace_thread(thread_id, &window);+ self.show_thread_or_its_page(thread_id, &window);return;}}@@ -6933,6 +7020,21 @@ impl TermWindow {}}}+ // A mirror rebuilt on reconnecting gets a new window for the same+ // thread.+ if let Some(workspace) = self+ .dedicated_thread+ .as_deref()+ .and_then(crate::workspace_threads::thread_workspace_name)+ {+ if let Some(target) = crate::workspace_threads::window_to_show_in_workspace(&workspace)+ {+ if !front_end().has_mux_window(target) {+ self.switch_to_mux_window(target);+ return;+ }+ }+ }let recovery_thread = if self.dies_with_mux_window {None} else if let Some(domain_name) =@@ -6968,6 +7070,9 @@ impl TermWindow {crate::workspace_threads::thread_to_recover_after_window_death(&self.active_space_id)};let Some(thread_id) = recovery_thread else {+ if let Some(thread_id) = &self.dedicated_thread {+ crate::workspace_threads::note_thread_left_own_window(thread_id);+ }window.close();front_end().forget_known_window(&window);return;@@ -6977,7 +7082,7 @@ impl TermWindow {// subscription id still names the dead mux window, so a queued// WindowRemoved would match and kill a subscription made now.// switch_to_mux_window re-subscribes after updating the id.- self.activate_workspace_thread(thread_id, &window);+ self.show_thread_or_its_page(thread_id, &window);}/// Put the connection page of `domain_name`'s Space on screen: a mux@@ -7838,6 +7943,10 @@ impl TermWindow {}fn sync_current_workspace_thread(&mut self) {+ // Which thread the Space is on is for the window with its sidebar.+ if self.dedicated_thread.is_some() {+ return;+ }let Some(workspace) = self.current_mux_workspace() else {return;};@@ -7936,6 +8045,9 @@ impl TermWindow {preferred_thread: Option<String>,window: &Window,) -> bool {+ if self.dedicated_thread.is_some() {+ return false;+ }// Navigating elsewhere cancels the earlier window-opening intent.self.remote_open_intent = None;if self.workspace_sidebar_swipe.pending_switch_target() != Some(space_id.as_str()) {@@ -7978,7 +8090,7 @@ impl TermWindow {let target_thread = preferred_thread.or_else(|| crate::workspace_threads::ensure_active_thread_for_space(&space_id));if let Some(thread_id) = target_thread {- self.activate_workspace_thread(thread_id, window);+ self.show_thread_or_its_page(thread_id, window);} else {// Nothing to adopt; settle the reflow immediately.self.consume_pending_sidebar_reflow();@@ -11571,6 +11683,29 @@ impl TermWindow {}}+ if self.elsewhere_page.is_some() {+ // Whether to quit is asked in a terminal, and there is none here.+ if matches!(assignment, QuitApplication | QuitAndStopSessionServer) {+ self.hand_to_thread_on_page(assignment.clone());+ return Ok(PerformAssignmentResult::Handled);+ }+ if thread_window::needs_a_terminal(assignment) {+ return Ok(PerformAssignmentResult::Handled);+ }+ }+ if self.dedicated_thread.is_some() {+ match thread_window::own_window_assignment(assignment) {+ thread_window::OwnWindowAssignment::Perform => {}+ thread_window::OwnWindowAssignment::HandOn => {+ self.hand_on_assignment(assignment.clone());+ return Ok(PerformAssignmentResult::Handled);+ }+ thread_window::OwnWindowAssignment::Ignore => {+ return Ok(PerformAssignmentResult::Handled);+ }+ }+ }+if self.right_sidebar_has_text_focus() {match assignment {CopyTo(destination) => {diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rsindex 278ce544..2805344f 100644--- a/wezterm-gui/src/termwindow/mouseevent.rs+++ b/wezterm-gui/src/termwindow/mouseevent.rs@@ -579,6 +579,7 @@ impl super::TermWindow {pub(crate) fn window_tab_chrome_params(&self) -> WindowTabChromeParams {WindowTabChromeParams {workspace_sidebar_width: self.workspace_sidebar_width(),+ has_workspace_sidebar: self.dedicated_thread.is_none(),window_state: self.window_state,window_decorations: self.config.window_decorations,integrated_title_button_alignment: self.config.integrated_title_button_alignment,@@ -1078,6 +1079,7 @@ impl super::TermWindow {// out; one open while it is away keeps it from revealing.let overlay_open = self.menu_or_overlay_open();let eligible = crate::native_settings::workspace_sidebar_hover_reveal_enabled()+ && self.dedicated_thread.is_none()&& self.workspace_sidebar_collapsed&& !self.content_view_foreground()&& !self.content_view_transition_running()@@ -2607,11 +2609,7 @@ impl super::TermWindow {}}super::SidebarRowKind::Thread { thread_id, .. } => {- if !self.open_remote_workspace_thread_without_connecting(- &thread_id, context,- ) {- self.activate_workspace_thread(thread_id, context);- }+ self.pick_sidebar_thread(thread_id, context);}}}@@ -6950,6 +6948,25 @@ impl super::TermWindow {crate::workspace_threads::thread_connection_state(&thread_id, &live_workspaces);let mut items = vec![];+ let in_own_window = front_end().thread_is_in_own_window(&thread_id);+ items.push(self.context_menu_application_item_with_icon(+ crate::i18n::tr(if in_own_window {+ "thread-window-go-to"+ } else {+ "menu-open-thread-in-window"+ }),+ ContextMenuIcon::Window,+ if in_own_window {+ crate::termwindow::ContextMenuApplicationAction::GoToThreadWindow(thread_id.clone())+ } else {+ crate::termwindow::ContextMenuApplicationAction::OpenThreadInOwnWindow(+ thread_id.clone(),+ )+ },+ true,+ ));+ items.push(ContextMenuItem::Separator);+if let Some(connection) = connection.as_ref() {let remote_host_exists = connection.is_remote&& crate::ssh_hosts::host_spec(@@ -7684,6 +7701,16 @@ impl super::TermWindow {orphan_candidate_window_id: Option<MuxWindowId>,workspaces_to_kill_after_adopt: Vec<String>,) {+ if self.dedicated_thread.is_some() {+ if self.dedicated_thread.as_deref() != Some(thread_id.as_str()) {+ self.hand_on_assignment(KeyAssignment::ActivateWorkspaceThread {+ space_id: self.active_space_id.clone(),+ thread_id,+ });+ }+ return;+ }+ self.forget_thread_bound_for_own_window_unless(&thread_id);let thread_home_space = crate::workspace_threads::thread_space_id(&thread_id);let in_this_space = thread_home_space.as_deref() == Some(self.active_space_id.as_str());// A window may activate any thread its Space references: the@@ -7754,6 +7781,18 @@ impl super::TermWindow {if let Some(other) =crate::frontend::front_end().gui_window_for_mux_window(target){+ // What this window showed is being ended, and+ // the thread it was to go on to is in a window of+ // its own.+ if !workspaces_to_kill_after_adopt.is_empty()+ && front_end().thread_is_in_own_window(&plan.thread_id)+ {+ self.show_thread_elsewhere_page(plan.thread_id.clone());+ }+ kill_workspace_windows(+ &workspaces_to_kill_after_adopt,+ Some(&plan.workspace_name),+ );let workspace = plan.workspace_name.clone();let project_path = plan.project_path.clone();let project_id = plan.project_id.clone();@@ -8189,6 +8228,7 @@ impl super::TermWindow {if let Err(err) = result {log::error!("failed to materialize ThinkTerm thread: {err:#}");+ self.thread_bound_for_own_window_failed(&thread_id);// Nothing landed, so there is nothing for the first-open claim// to take; leaving it armed would claim the next tab shown.self.remote_open_intent = None;diff --git a/wezterm-gui/src/termwindow/resize.rs b/wezterm-gui/src/termwindow/resize.rsindex 25153ff9..24319950 100644--- a/wezterm-gui/src/termwindow/resize.rs+++ b/wezterm-gui/src/termwindow/resize.rs@@ -2168,12 +2168,26 @@ impl super::TermWindow {return;};let space_id = self.space_id_for_layout_snapshot(window.get_workspace());- crate::workspace_threads::snapshot_active_space_thread_layout_with_font_scales(- &space_id,- window.get_workspace(),- self.mux_window_id,- |pane_id| self.persisted_font_scale_for_pane(pane_id),- );+ self.snapshot_layout_under(&space_id, window.get_workspace());+ }++ fn snapshot_layout_under(&self, space_id: &str, workspace: &str) {+ let pane_font_scale = |pane_id| self.persisted_font_scale_for_pane(pane_id);+ if self.dedicated_thread.is_some() {+ crate::workspace_threads::snapshot_own_window_thread_layout(+ space_id,+ workspace,+ self.mux_window_id,+ pane_font_scale,+ );+ } else {+ crate::workspace_threads::snapshot_active_space_thread_layout_with_font_scales(+ space_id,+ workspace,+ self.mux_window_id,+ pane_font_scale,+ );+ }}/// The Space a layout snapshot should be recorded under. A window@@ -2192,12 +2206,7 @@ impl super::TermWindow {return;};let space_id = self.space_id_for_layout_snapshot(window.get_workspace());- crate::workspace_threads::snapshot_active_space_thread_layout_with_font_scales(- &space_id,- window.get_workspace(),- self.mux_window_id,- |pane_id| self.persisted_font_scale_for_pane(pane_id),- );+ self.snapshot_layout_under(&space_id, window.get_workspace());}fn apply_font_scales_to_mux_window_panes(diff --git a/wezterm-gui/src/termwindow/thread_numbers.rs b/wezterm-gui/src/termwindow/thread_numbers.rsindex ee2c9d3e..94577637 100644--- a/wezterm-gui/src/termwindow/thread_numbers.rs+++ b/wezterm-gui/src/termwindow/thread_numbers.rs@@ -529,9 +529,7 @@ impl TermWindow {let Some(thread_id) = threads.get(index).map(|thread| thread.id.clone()) else {return;};- if !self.open_remote_workspace_thread_without_connecting(&thread_id, window) {- self.activate_workspace_thread(thread_id, window);- }+ self.pick_sidebar_thread(thread_id, window);window.invalidate();}}diff --git a/wezterm-gui/src/termwindow/thread_window.rs b/wezterm-gui/src/termwindow/thread_window.rsnew file mode 100644index 00000000..c1e4ec9a--- /dev/null+++ b/wezterm-gui/src/termwindow/thread_window.rs@@ -0,0 +1,895 @@+//! A thread in a window of its own.+//!+//! Every thread already runs in a mux window of its own, and a GUI window+//! shows one mux window at a time; the threads not on screen go on running+//! behind it. So nothing moves when a thread gets its own window: a new GUI+//! window, with no sidebars and no Space of its own, shows the thread's mux+//! window, and closing that window leaves the thread running unseen again.+//!+//! Two GUI windows cannot share a mux window, each resizing its terminals to+//! fit itself. A window that was showing the thread has to show something+//! else, so it goes to a page saying where the thread went, over an empty mux+//! window kept for the page alone. No thread owns that window and nothing+//! snapshots it (`is_thread_page_workspace`). Without a tab it has no pane to+//! run key bindings against, so the page brings an inert one.++use crate::frontend::front_end;+use crate::termwindow::content_view::{+ ContentView, ContentViewId, ContentViewResponse,+};+use crate::quad::TripleLayerQuadAllocator;+use crate::termwindow::{domain_is_attached, TermWindow, TermWindowNotif};+use crate::ui::{+ rect, ControlState, DrawContext, InteractionState, UiContext, UiPalette,+ WidgetKind,+};+use crate::workspace_threads::{self, WorkspaceThreadId};+use config::keyassignment::KeyAssignment;+use config::TermConfig;+use mux::pane::Pane;+use mux::window::WindowId as MuxWindowId;+use mux::Mux;+use std::collections::VecDeque;+use std::rc::Rc;+use std::sync::Arc;+use wezterm_font::LoadedFont;+use wezterm_term::{KeyCode, KeyModifiers};+use window::{MouseEventKind as WMEK, MousePress, RectF, ScreenPoint, Window, WindowOps};++/// Keeps the page's mux window alive with no tab in it, whichever view is in+/// front of the page at the moment.+const THREAD_PAGE_SURFACE: &str = "thinkterm-thread-elsewhere";++const THREAD_PAGE_VIEW_KEY_PREFIX: &str = "thread-elsewhere:";++const HERO_ICON_SIZE: f32 = 76.0;+const BUTTON_MARGIN: f32 = 6.0;+const BUTTON_PADDING: f32 = 16.0;+const PAD: f32 = 32.0;++/// A page standing in for a thread that is open in a window of its own.+pub(crate) struct ThreadElsewherePage {+ pub(crate) thread_id: WorkspaceThreadId,+ pub(crate) mux_window_id: MuxWindowId,+ view_id: ContentViewId,+ /// What key bindings run against while there is no terminal here.+ key_pane: Option<Arc<dyn Pane>>,+}++/// A thread on its way to a window of its own, once it is running.+pub(crate) struct ThreadBoundForOwnWindow {+ thread_id: WorkspaceThreadId,+ position: Option<ScreenPoint>,+ /// What this window was showing before it opened the thread to get it+ /// running, to go back to.+ return_to: Option<WorkspaceThreadId>,+}++/// What a thread's own window is opened with.+pub(crate) struct OwnWindowRequest {+ pub(crate) thread_id: WorkspaceThreadId,+ pub(crate) frame_slot: u32,+ /// Where it was asked to open: the top left of its content. By default+ /// it opens where the frame slot last was.+ pub(crate) position: Option<ScreenPoint>,+}++/// What a thread's own window does with a key assignment.+#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub(crate) enum OwnWindowAssignment {+ /// It concerns this window's terminals.+ Perform,+ /// It is about the threads and Spaces around this one, which this window+ /// does not show: a window that does gets it.+ HandOn,+ /// It has no meaning in a window with no sidebars.+ Ignore,+}++pub(crate) fn own_window_assignment(assignment: &KeyAssignment) -> OwnWindowAssignment {+ use KeyAssignment::*;+ match assignment {+ ActivateWorkspaceThread { .. }+ | ActivateWorkspaceThreadByIndex(_)+ | ActivateSpaceRelative(_)+ | SwitchSpace(_)+ | CreateSpace+ | CreateSpaceOnDomain(_)+ | CreateWorkspaceThread(_)+ | CreateWorkspaceThreadInActiveProject+ | SwitchToWorkspace { .. }+ | SwitchWorkspaceRelative(_)+ | ToggleLiveOverview+ | ToggleLibrary+ | OpenThreadSearch+ | SpawnWindow+ | SpawnCommandInNewWindow(_) => OwnWindowAssignment::HandOn,+ ToggleWorkspaceSidebar | ToggleRightSidebar | FocusPluginPanel(_) => {+ OwnWindowAssignment::Ignore+ }+ _ => OwnWindowAssignment::Perform,+ }+}++/// Whether `assignment` needs a terminal in this window, or would put one in+/// the page's mux window, where no thread would ever find it.+pub(crate) fn needs_a_terminal(assignment: &KeyAssignment) -> bool {+ use KeyAssignment::*;+ matches!(+ assignment,+ SpawnTab(_)+ | SpawnTabToRight(_)+ | SpawnCommandInNewTab(_)+ | SplitHorizontal(_)+ | SplitVertical(_)+ | SplitPane(_)+ | ShowLauncher+ | ShowLauncherArgs(_)+ | ShowTabNavigator+ | Search(_)+ | ActivateCopyMode+ | QuickSelect+ | QuickSelectArgs(_)+ | CharSelect(_)+ | PaneSelect(_)+ )+}++impl TermWindow {+ /// Open `thread_id` in a window of its own, at `position` when that was+ /// chosen, or bring its window forward if it has one.+ pub(crate) fn open_thread_in_own_window(+ &mut self,+ thread_id: WorkspaceThreadId,+ position: Option<ScreenPoint>,+ window: &Window,+ ) {+ self.open_thread_in_own_window_then(thread_id, position, None, window);+ }++ /// As `open_thread_in_own_window`. A window showing the thread goes on+ /// to `return_to`, when it is running, rather than to the page.+ fn open_thread_in_own_window_then(+ &mut self,+ thread_id: WorkspaceThreadId,+ position: Option<ScreenPoint>,+ return_to: Option<WorkspaceThreadId>,+ window: &Window,+ ) {+ if self.dedicated_thread.is_some() {+ return;+ }+ if front_end().thread_is_in_own_window(&thread_id) {+ self.focus_thread_window(&thread_id);+ return;+ }+ let live_workspaces = Mux::get().iter_workspaces();+ let plan = workspace_threads::activation_plan_for_thread(&thread_id, &live_workspaces)+ .filter(|plan| !plan.needs_materialize);+ let Some(plan) = plan else {+ // Not running. Opening it here knows everything that can take: a+ // server to connect to, a folder to ask for. It moves out once+ // it is on screen.+ let return_to = if self.elsewhere_page.is_some() {+ None+ } else {+ workspace_threads::recorded_active_thread_for_space(&self.active_space_id)+ };+ self.thread_bound_for_own_window = Some(ThreadBoundForOwnWindow {+ thread_id: thread_id.clone(),+ position,+ return_to,+ });+ self.activate_workspace_thread(thread_id, window);+ return;+ };+ let Some(mux_window_id) =+ workspace_threads::window_to_show_in_workspace(&plan.workspace_name)+ else {+ return;+ };+ // Another window shows it, through a reference: that one has to let+ // go of it.+ if mux_window_id != self.mux_window_id {+ if let Some(showing) = front_end().gui_window_for_mux_window(mux_window_id) {+ showing+ .window+ .notify(TermWindowNotif::Apply(Box::new(move |term_window| {+ if let Some(window) = term_window.window.clone() {+ term_window.open_thread_in_own_window(thread_id, position, &window);+ }+ })));+ return;+ }+ }+ let Some(space_id) = workspace_threads::thread_space_id(&thread_id) else {+ return;+ };+ if !front_end().begin_thread_window(&thread_id) {+ return;+ }+ if mux_window_id == self.mux_window_id {+ let live_workspaces = Mux::get().iter_workspaces();+ let return_to = return_to.filter(|thread_id| {+ workspace_threads::activation_plan_for_thread(thread_id, &live_workspaces)+ .is_some_and(|plan| !plan.needs_materialize)+ });+ match return_to {+ Some(return_to) => self.activate_workspace_thread(return_to, window),+ None => self.show_thread_elsewhere_page(thread_id.clone()),+ }+ }+ // The reconcile must leave this one to us: it has a window coming.+ front_end().claim_spawned_mux_window(mux_window_id);+ let request = OwnWindowRequest {+ frame_slot: workspace_threads::note_thread_in_own_window(&thread_id),+ thread_id: thread_id.clone(),+ position,+ };+ promise::spawn::spawn(async move {+ match TermWindow::new_thread_window(mux_window_id, space_id, request).await {+ Ok(()) => {+ if let Some(window) = front_end().thread_window(&thread_id) {+ window.focus();+ }+ }+ Err(err) => {+ log::error!("failed to open a window for thread {thread_id}: {err:#}");+ workspace_threads::note_thread_left_own_window(&thread_id);+ front_end().thread_window_not_opened(&thread_id);+ }+ }+ })+ .detach();+ }++ /// Open again the thread windows the app was left with, one at a time:+ /// a thread that is not running goes through this window first.+ pub(crate) fn begin_reopening_thread_windows(&mut self) {+ self.threads_to_reopen =+ VecDeque::from(workspace_threads::threads_to_reopen_in_own_windows());+ self.reopen_next_thread_window();+ }++ fn reopen_next_thread_window(&mut self) {+ if self.local_thread_activation.is_some() || self.thread_bound_for_own_window.is_some() {+ return;+ }+ let Some(window) = self.window.clone() else {+ return;+ };+ while let Some(thread_id) = self.threads_to_reopen.pop_front() {+ if !self.can_reopen_thread_window(&thread_id) {+ continue;+ }+ self.open_thread_in_own_window(thread_id, None, &window);+ window.notify(TermWindowNotif::Apply(Box::new(|term_window| {+ term_window.reopen_next_thread_window();+ })));+ return;+ }+ }++ /// A thread that is running can go straight to its window. One that is+ /// not has to open here, which only a thread of this Space can, and no+ /// server is woken for a window the person did not just ask for.+ fn can_reopen_thread_window(&self, thread_id: &str) -> bool {+ let live_workspaces = Mux::get().iter_workspaces();+ let running = workspace_threads::activation_plan_for_thread(thread_id, &live_workspaces)+ .is_some_and(|plan| !plan.needs_materialize);+ if running {+ return true;+ }+ let here = workspace_threads::thread_space_id(thread_id).as_deref()+ == Some(self.active_space_id.as_str());+ let local = workspace_threads::thread_connection_state(thread_id, &live_workspaces)+ .is_some_and(|state| !state.is_remote)+ && workspace_threads::client_domain_for_space(&self.active_space_id).is_none();+ here && local+ }++ pub(crate) fn focus_thread_window(&self, thread_id: &str) {+ if let Some(window) = front_end().thread_window(thread_id) {+ window.focus();+ }+ }++ /// Hand `assignment` to a window that shows the thread list, from one+ /// that does not.+ pub(crate) fn hand_on_assignment(&self, assignment: KeyAssignment) {+ let Some(target) = front_end().window_for_any_thread(&self.active_space_id) else {+ // Only threads' own windows are left: the next try has a window+ // to go to.+ front_end().spawn_space_window();+ return;+ };+ target.window.focus();+ target+ .window+ .notify(TermWindowNotif::Apply(Box::new(move |term_window| {+ if let Some(pane) = term_window.pane_for_key_bindings() {+ if let Err(err) = term_window.perform_key_assignment(&pane, &assignment) {+ log::error!("{assignment:?} failed: {err:#}");+ }+ }+ })));+ }++ /// Hand `assignment` to the window of the thread this window's page+ /// stands in for: it asks something of a terminal, which is there.+ pub(crate) fn hand_to_thread_on_page(&self, assignment: KeyAssignment) {+ let Some(window) = self+ .elsewhere_page+ .as_ref()+ .and_then(|page| front_end().thread_window(&page.thread_id))+ else {+ return;+ };+ window.focus();+ window.notify(TermWindowNotif::Apply(Box::new(move |term_window| {+ if let Some(pane) = term_window.pane_for_key_bindings() {+ if let Err(err) = term_window.perform_key_assignment(&pane, &assignment) {+ log::error!("{assignment:?} failed: {err:#}");+ }+ }+ })));+ }++ /// The pane key bindings run against: the terminal's, or the page's+ /// stand-in for it.+ pub(crate) fn pane_for_key_bindings(&self) -> Option<Arc<dyn Pane>> {+ self.get_active_pane_or_overlay().or_else(|| {+ self.elsewhere_page+ .as_ref()+ .and_then(|page| page.key_pane.clone())+ })+ }++ /// The window has a thread to show that may be open in its own window.+ /// A thread picked in the sidebar, by its row or its number. One open in+ /// a window of its own shows its page here, as when this window lands on+ /// it by itself: going over there is the page's button.+ pub(crate) fn pick_sidebar_thread(+ &mut self,+ thread_id: WorkspaceThreadId,+ context: &dyn WindowOps,+ ) {+ if self.dedicated_thread.is_none() && front_end().thread_is_in_own_window(&thread_id) {+ self.forget_thread_bound_for_own_window_unless(&thread_id);+ self.local_thread_activation = None;+ self.workspace_sidebar_pending_thread_selection = None;+ self.show_thread_or_its_page(thread_id, context);+ context.invalidate();+ } else if !self.open_remote_workspace_thread_without_connecting(&thread_id, context) {+ self.activate_workspace_thread(thread_id, context);+ }+ }++ pub(crate) fn show_thread_or_its_page(+ &mut self,+ thread_id: WorkspaceThreadId,+ context: &dyn WindowOps,+ ) {+ if front_end().thread_is_in_own_window(&thread_id) {+ // In this order: leaving a thread saves its layout under the+ // pointers the record is about to move.+ self.show_thread_elsewhere_page(thread_id.clone());+ self.note_thread_on_page(&thread_id);+ } else {+ self.activate_workspace_thread(thread_id, context);+ }+ }++ /// What this window has selected, for its sidebar and the next start,+ /// though the thread itself stays where it is.+ fn note_thread_on_page(&self, thread_id: &str) {+ let own_space = workspace_threads::thread_space_id(thread_id).as_deref()+ == Some(self.active_space_id.as_str());+ if own_space {+ workspace_threads::clear_thread_active_ref(&self.active_space_id);+ } else {+ workspace_threads::note_thread_active_ref(&self.active_space_id, thread_id);+ }+ workspace_threads::activate_thread_record(+ thread_id,+ &Mux::get().iter_workspaces(),+ own_space,+ );+ }++ /// Show the page for `thread_id` in place of whatever this window shows.+ pub(crate) fn show_thread_elsewhere_page(&mut self, thread_id: WorkspaceThreadId) {+ let title = self.thread_page_title(&thread_id);+ let view = Box::new(ThreadElsewhereView::new(thread_id.clone(), title));+ if let Some(page) = self.elsewhere_page.as_mut() {+ // Already on a page: the same one, or another thread's.+ if page.thread_id == thread_id {+ let view_id = page.view_id;+ self.set_active_content_view_id(Some(view_id));+ return;+ }+ let old_view_id = page.view_id;+ page.thread_id = thread_id;+ self.close_content_view_by_id(old_view_id);+ let view_id = self.open_content_view(view);+ if let Some(page) = self.elsewhere_page.as_mut() {+ page.view_id = view_id;+ }+ return;+ }++ self.snapshot_active_workspace_thread_layout();+ let mux = Mux::get();+ let workspace = format!(+ "{}{}",+ workspace_threads::THREAD_PAGE_WORKSPACE_PREFIX,+ self.space_owner_id+ );+ let builder = mux.new_empty_window_for_domain(Some(workspace.clone()), None, None);+ let page_window_id = *builder;+ mux.register_window_ui_surface(page_window_id, THREAD_PAGE_SURFACE.to_string());+ // Shown here before the frontend hears of it, so the reconcile finds+ // it taken instead of opening a window of its own for it. The active+ // workspace stays out of it: that is where new terminals go, and+ // this one is to have none.+ self.switch_to_mux_window(page_window_id);+ drop(builder);+ let key_pane = self.inert_key_pane();+ let view_id = self.open_content_view(view);+ self.elsewhere_page = Some(ThreadElsewherePage {+ thread_id,+ mux_window_id: page_window_id,+ view_id,+ key_pane,+ });+ }++ fn inert_key_pane(&self) -> Option<Arc<dyn Pane>> {+ let term_config = Arc::new(TermConfig::with_config(self.config.clone()));+ match mux::termwiztermtab::inert_pane(self.terminal_size, term_config) {+ Ok(pane) => Some(pane),+ Err(err) => {+ log::error!("no pane for key bindings on the thread page: {err:#}");+ None+ }+ }+ }++ fn thread_page_title(&self, thread_id: &str) -> String {+ workspace_threads::thread_name(thread_id).unwrap_or_default()+ }++ /// This window is going to `next_mux_window_id`: a page it was on goes.+ pub(crate) fn leave_thread_elsewhere_page(&mut self, next_mux_window_id: MuxWindowId) {+ let leaving = self+ .elsewhere_page+ .as_ref()+ .is_some_and(|page| page.mux_window_id != next_mux_window_id);+ if !leaving {+ return;+ }+ let Some(page) = self.elsewhere_page.take() else {+ return;+ };+ self.close_content_view_by_id(page.view_id);+ // Empty now, so this is the end of the page's mux window.+ Mux::get().unregister_window_ui_surface(page.mux_window_id, THREAD_PAGE_SURFACE);+ }++ /// A thread's own window has gone. Every window hears of it: its sidebar+ /// row changes, and a page standing in for the thread has nothing to+ /// stand in for.+ pub(crate) fn thread_window_closed(&mut self, thread_id: &str) {+ self.invalidate_window();+ // A thread on its way here means the person has moved on already.+ let on_its_page = self.local_thread_activation.is_none()+ && self+ .elsewhere_page+ .as_ref()+ .is_some_and(|page| page.thread_id == thread_id);+ if !on_its_page {+ return;+ }+ let Some(window) = self.window.clone() else {+ return;+ };+ let live_workspaces = Mux::get().iter_workspaces();+ let still_running =+ workspace_threads::activation_plan_for_thread(thread_id, &live_workspaces)+ .is_some_and(|plan| !plan.needs_materialize);+ if still_running {+ self.activate_workspace_thread(thread_id.to_string(), &window);+ return;+ }+ // It ended in its window: on to another, as when a window's own+ // thread ends, or out of a server's Space with none left to go to.+ let next = match workspace_threads::client_domain_for_space(&self.active_space_id) {+ Some(domain_name) => {+ let other = domain_is_attached(&domain_name)+ .then(|| {+ workspace_threads::existing_thread_to_recover_after_window_death(+ &self.active_space_id,+ )+ })+ .flatten();+ if other.is_none() {+ let return_space_id = self+ .previous_space_id+ .clone()+ .unwrap_or_else(workspace_threads::default_space_id);+ self.return_from_unreachable_space(return_space_id, None, &window);+ return;+ }+ other+ }+ None => workspace_threads::thread_to_recover_after_window_death(&self.active_space_id),+ };+ if let Some(next) = next {+ self.show_thread_or_its_page(next, &window);+ }+ }++ /// Whether `mux_window_id` being on screen here is what a thread bound+ /// for its own window was waiting for.+ pub(crate) fn send_on_thread_bound_for_own_window(&mut self, mux_window_id: MuxWindowId) {+ let arrived = self+ .thread_bound_for_own_window+ .as_ref()+ .is_some_and(|bound| {+ let Some(workspace) = workspace_threads::thread_workspace_name(&bound.thread_id)+ else {+ return false;+ };+ Mux::get()+ .get_window(mux_window_id)+ .is_some_and(|window| window.get_workspace() == workspace)+ });+ let Some(window) = self.window.clone() else {+ return;+ };+ // The next thread only sets off after this one has gone: going back+ // to where this window was would call the next one off.+ if !arrived {+ if !self.threads_to_reopen.is_empty() {+ window.notify(TermWindowNotif::Apply(Box::new(|term_window| {+ term_window.reopen_next_thread_window();+ })));+ }+ return;+ }+ let Some(bound) = self.thread_bound_for_own_window.take() else {+ return;+ };+ window.notify(TermWindowNotif::Apply(Box::new(move |term_window| {+ if let Some(window) = term_window.window.clone() {+ term_window.open_thread_in_own_window_then(+ bound.thread_id,+ bound.position,+ bound.return_to,+ &window,+ );+ term_window.reopen_next_thread_window();+ }+ })));+ }++ /// `thread_id` could not be got running: if it was bound for a window of+ /// its own it stays a row, and the rest go on without it.+ pub(crate) fn thread_bound_for_own_window_failed(&mut self, thread_id: &str) {+ if self+ .thread_bound_for_own_window+ .as_ref()+ .is_some_and(|bound| bound.thread_id == thread_id)+ {+ self.thread_bound_for_own_window = None;+ workspace_threads::note_thread_left_own_window(thread_id);+ }+ if !self.threads_to_reopen.is_empty() {+ if let Some(window) = self.window.as_ref() {+ window.notify(TermWindowNotif::Apply(Box::new(|term_window| {+ term_window.reopen_next_thread_window();+ })));+ }+ }+ }++ /// Opening another thread here gives up on a thread bound for its own+ /// window.+ pub(crate) fn forget_thread_bound_for_own_window_unless(&mut self, thread_id: &str) {+ if self+ .thread_bound_for_own_window+ .as_ref()+ .is_some_and(|bound| bound.thread_id != thread_id)+ {+ self.thread_bound_for_own_window = None;+ }+ }+}++#[derive(Debug, Clone, Copy, PartialEq, Eq)]+enum ThreadPageAction {+ GoToWindow,+}++/// What a window shows while a thread it would show is in its own window.+struct ThreadElsewhereView {+ thread_id: WorkspaceThreadId,+ title: String,+ widgets: UiContext<ThreadPageAction>,+ interaction: InteractionState<ThreadPageAction>,+}++impl ThreadElsewhereView {+ fn new(thread_id: WorkspaceThreadId, title: String) -> Self {+ Self {+ thread_id,+ title,+ widgets: UiContext::default(),+ interaction: InteractionState::default(),+ }+ }++ fn go_to_window(&self) -> ContentViewResponse {+ let thread_id = self.thread_id.clone();+ ContentViewResponse::Run(Box::new(move |term_window| {+ term_window.focus_thread_window(&thread_id);+ }))+ }++ fn button_state(&self) -> ControlState {+ let action = Some(ThreadPageAction::GoToWindow);+ if self.interaction.pressed == action {+ ControlState::Pressed+ } else if self.interaction.hovered == action {+ ControlState::Hovered+ } else {+ ControlState::Normal+ }+ }+}++impl ContentView for ThreadElsewhereView {+ fn title(&self) -> String {+ self.title.clone()+ }++ fn show_in_tab_bar(&self) -> bool {+ false+ }++ fn tab_key(&self) -> Option<String> {+ Some(format!("{THREAD_PAGE_VIEW_KEY_PREFIX}{}", self.thread_id))+ }++ fn paint(+ &mut self,+ ctx: &DrawContext,+ layers: &mut TripleLayerQuadAllocator<'_>,+ area: RectF,+ palette: UiPalette,+ font: &Rc<LoadedFont>,+ _title_font: &Rc<LoadedFont>,+ section_font: &Rc<LoadedFont>,+ caption_font: &Rc<LoadedFont>,+ _cursor_on: bool,+ ) -> anyhow::Result<()> {+ self.widgets.clear();+ ctx.draw_rect(+ layers,+ 0,+ area.origin.x,+ area.origin.y,+ area.size.width,+ area.size.height,+ palette.window_bg,+ )?;++ let center_x = area.origin.x + area.size.width / 2.0;+ let max_width = (area.size.width - ctx.px(PAD) * 2.0).max(0.0);+ let line_height = ctx.metrics.cell_size.height as f32;+ let icon_size = ctx.px(HERO_ICON_SIZE);+ let button_height = line_height + ctx.px(BUTTON_MARGIN) * 2.0;+ let title_gap = ctx.px(14.0);+ let note_gap = ctx.px(4.0);+ let button_gap = ctx.px(16.0);+ let stack_height = icon_size+ + title_gap+ + line_height+ + note_gap+ + line_height+ + button_gap+ + button_height;+ let mut y = area.origin.y + ((area.size.height - stack_height) / 2.0).max(0.0);++ // What the sidebar shows for the thread, as Settings has it laid out.+ let layout = crate::native_settings::sidebar_thread_icons();+ let by_workspace = crate::thread_marks::icons_by_workspace();+ let terminal = crate::tab_icons::resolve_window_tab();+ let icons = workspace_threads::thread_workspace_name(&self.thread_id)+ .and_then(|workspace| by_workspace.get(&workspace))+ .filter(|icons| !icons.is_empty())+ .map_or(std::slice::from_ref(&terminal), Vec::as_slice);+ let count_metrics =+ crate::utilsprites::RenderMetrics::with_font_metrics(&caption_font.metrics());+ let icon_width = crate::thread_marks::drawn_width(layout, icons.len(), icon_size);+ crate::thread_marks::draw_slot(+ ctx,+ layers,+ layout,+ icons,+ center_x - icon_width / 2.0,+ y + icon_size / 2.0,+ icon_size,+ &crate::thread_marks::IconStyle {+ surface: palette.window_bg,+ dark: palette.is_dark(),+ count_font: caption_font,+ count_metrics: &count_metrics,+ count_color: palette.muted_text,+ opacity: 1.0,+ },+ )?;+ y += icon_size + title_gap;++ let name = workspace_threads::thread_name(&self.thread_id);+ let name = name.as_deref().unwrap_or(&self.title);+ let title = ctx.text_with_ellipsis(section_font, name, max_width);+ let title_width = ctx.measure_text_width(section_font, &title);+ ctx.draw_text(+ layers,+ section_font,+ center_x - title_width / 2.0,+ y,+ &title,+ palette.text,+ max_width,+ )?;+ y += line_height + note_gap;++ let note = crate::i18n::tr("thread-window-page-note");+ let note = ctx.text_with_ellipsis(font, ¬e, max_width);+ let note_width = ctx.measure_text_width(font, ¬e);+ ctx.draw_text(+ layers,+ font,+ center_x - note_width / 2.0,+ y,+ ¬e,+ palette.muted_text,+ max_width,+ )?;+ y += line_height + button_gap;++ let label = crate::i18n::tr("thread-window-go-to");+ let label_width = ctx.measure_text_width(font, &label);+ let button_width = (label_width + ctx.px(BUTTON_PADDING) * 2.0).min(max_width);+ let button = rect(+ center_x - button_width / 2.0,+ y,+ button_width,+ button_height,+ );+ self.widgets+ .push(button, WidgetKind::Button, ThreadPageAction::GoToWindow);+ let fill = palette.accent.mul_alpha(match self.button_state() {+ ControlState::Pressed => 0.32,+ ControlState::Hovered => 0.24,+ _ => 0.16,+ });+ ctx.draw_rounded_frame(+ layers,+ 0,+ button.origin.x,+ button.origin.y,+ button.size.width,+ button.size.height,+ fill,+ fill,+ button.size.height / 2.0,+ )?;+ ctx.draw_text(+ layers,+ font,+ center_x - label_width / 2.0,+ button.origin.y + ((button.size.height - line_height) / 2.0).max(0.0),+ &label,+ palette.accent,+ button.size.width,+ )?;+ Ok(())+ }++ fn on_mouse(&mut self, x: f32, y: f32, kind: WMEK) -> ContentViewResponse {+ let hit = self.widgets.hit_test(x, y).map(|target| target.action);+ match kind {+ WMEK::Move => {+ if self.interaction.hovered != hit {+ self.interaction.hovered = hit;+ ContentViewResponse::Redraw+ } else {+ ContentViewResponse::Ignored+ }+ }+ WMEK::Press(MousePress::Left) => {+ self.interaction.pressed = hit;+ ContentViewResponse::Redraw+ }+ WMEK::Release(MousePress::Left) => {+ let pressed = self.interaction.pressed.take();+ if hit.is_some() && hit == pressed {+ return self.go_to_window();+ }+ ContentViewResponse::Redraw+ }+ _ => ContentViewResponse::Ignored,+ }+ }++ fn on_key(&mut self, key: KeyCode, mods: KeyModifiers) -> ContentViewResponse {+ match key {+ KeyCode::Enter if mods == KeyModifiers::NONE => self.go_to_window(),+ _ => ContentViewResponse::Ignored,+ }+ }++ /// The page goes when the window moves on, not by being closed.+ fn on_close_requested(&mut self) -> ContentViewResponse {+ ContentViewResponse::Ignored+ }+}++#[cfg(test)]+mod tests {+ use super::*;+ use config::keyassignment::SpawnTabDomain;++ #[test]+ fn a_threads_own_window_hands_on_what_is_about_other_threads() {+ for assignment in [+ KeyAssignment::ActivateWorkspaceThreadByIndex(2),+ KeyAssignment::ActivateSpaceRelative(1),+ KeyAssignment::CreateWorkspaceThreadInActiveProject,+ KeyAssignment::ToggleLiveOverview,+ KeyAssignment::SpawnWindow,+ ] {+ assert_eq!(+ own_window_assignment(&assignment),+ OwnWindowAssignment::HandOn,+ "{assignment:?}"+ );+ }+ }++ #[test]+ fn a_threads_own_window_has_no_sidebars_to_toggle() {+ for assignment in [+ KeyAssignment::ToggleWorkspaceSidebar,+ KeyAssignment::ToggleRightSidebar,+ ] {+ assert_eq!(+ own_window_assignment(&assignment),+ OwnWindowAssignment::Ignore,+ "{assignment:?}"+ );+ }+ }++ #[test]+ fn a_threads_own_window_keeps_what_is_about_its_terminals() {+ assert_eq!(+ own_window_assignment(&KeyAssignment::SpawnTab(SpawnTabDomain::CurrentPaneDomain)),+ OwnWindowAssignment::Perform+ );+ }++ #[test]+ fn the_page_puts_no_terminal_in_its_window() {+ assert!(needs_a_terminal(&KeyAssignment::SpawnTab(+ SpawnTabDomain::CurrentPaneDomain+ )));+ assert!(!needs_a_terminal(+ &KeyAssignment::ActivateWorkspaceThreadByIndex(0)+ ));+ assert!(!needs_a_terminal(&KeyAssignment::ToggleWorkspaceSidebar));+ }+}diff --git a/wezterm-gui/src/termwindow/ui/context_menu.rs b/wezterm-gui/src/termwindow/ui/context_menu.rsindex 0edfeaac..c649d989 100644--- a/wezterm-gui/src/termwindow/ui/context_menu.rs+++ b/wezterm-gui/src/termwindow/ui/context_menu.rs@@ -337,7 +337,7 @@ impl crate::TermWindow {let space = self.active_space_id.clone();if let Some(thread_id) = crate::workspace_threads::ensure_active_thread_for_space(&space) {if !self.open_remote_workspace_thread_without_connecting(&thread_id, &window) {- self.activate_workspace_thread(thread_id, &window);+ self.show_thread_or_its_page(thread_id, &window);}} else {window.invalidate();@@ -490,6 +490,14 @@ impl crate::TermWindow {}}}+ crate::termwindow::ContextMenuApplicationAction::OpenThreadInOwnWindow(thread_id) => {+ if let Some(window) = self.window.clone() {+ self.open_thread_in_own_window(thread_id, None, &window);+ }+ }+ crate::termwindow::ContextMenuApplicationAction::GoToThreadWindow(thread_id) => {+ self.focus_thread_window(&thread_id);+ }crate::termwindow::ContextMenuApplicationAction::RemoveThreadFromCollection {collection_space_id,thread_id,@@ -521,7 +529,7 @@ impl crate::TermWindow {if !self.open_remote_workspace_thread_without_connecting(&next, &window,) {- self.activate_workspace_thread(next, &window);+ self.show_thread_or_its_page(next, &window);}}None => self.leave_detached_ref_content(),diff --git a/wezterm-gui/src/termwindow/ui/platform_chrome.rs b/wezterm-gui/src/termwindow/ui/platform_chrome.rsindex dd094a7c..07104349 100644--- a/wezterm-gui/src/termwindow/ui/platform_chrome.rs+++ b/wezterm-gui/src/termwindow/ui/platform_chrome.rs@@ -13,6 +13,9 @@ use window::{#[derive(Debug, Clone, Copy)]pub struct WindowTabChromeParams {pub workspace_sidebar_width: usize,+ /// False in a thread's own window, which has no sidebar to toggle and so+ /// keeps no place for the button.+ pub has_workspace_sidebar: bool,pub window_state: WindowState,pub window_decorations: WindowDecorations,pub integrated_title_button_alignment: IntegratedTitleButtonAlignment,@@ -97,7 +100,7 @@ impl WindowTabChromeParams {}pub fn leading_action_slot_count(self) -> usize {- if self.workspace_sidebar_width > 0 {+ if self.workspace_sidebar_width > 0 || !self.has_workspace_sidebar {return 0;}@@ -117,7 +120,8 @@ impl WindowTabChromeParams {}pub fn shows_sidebar_toggle_action(self) -> bool {- self.workspace_sidebar_width == 0+ self.has_workspace_sidebar+ && self.workspace_sidebar_width == 0&& (self.window_state.contains(WindowState::FULL_SCREEN) || !cfg!(target_os = "macos"))}@@ -269,6 +273,7 @@ mod tests {) -> WindowTabChromeParams {WindowTabChromeParams {workspace_sidebar_width,+ has_workspace_sidebar: true,window_state,window_decorations: WindowDecorations::INTEGRATED_BUTTONS | WindowDecorations::RESIZE,integrated_title_button_alignment: IntegratedTitleButtonAlignment::Right,@@ -279,6 +284,21 @@ mod tests {}}+ #[test]+ fn a_window_without_a_sidebar_keeps_no_place_for_its_toggle() {+ let params = WindowTabChromeParams {+ has_workspace_sidebar: false,+ ..test_params(0, WindowState::default(), Some(38))+ };+ assert!(!params.shows_sidebar_toggle_action());+ assert_eq!(params.leading_action_slot_count(), 0);+ assert_eq!(params.leading_action_area_width_pixels(), 0.0);+ assert!(+ params.left_padding_pixels()+ < test_params(0, WindowState::default(), Some(38)).left_padding_pixels()+ );+ }+#[test]fn sidebar_toggle_size_tracks_the_fancy_row_and_never_collapses() {let px = |v: usize| scale_ui_usize(v, 96);diff --git a/wezterm-gui/src/termwindow/ui/right_sidebar.rs b/wezterm-gui/src/termwindow/ui/right_sidebar.rsindex f4d308af..35319e67 100644--- a/wezterm-gui/src/termwindow/ui/right_sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/right_sidebar.rs@@ -2320,7 +2320,7 @@ impl crate::TermWindow {/// terminal reclaims the space through the same zero-width path collapse/// already uses, so nothing downstream needs its own special case.pub(crate) fn right_sidebar_has_panels(&self) -> bool {- RightSidebarMode::any_panel_enabled()+ self.dedicated_thread.is_none() && RightSidebarMode::any_panel_enabled()}/// The width the TERMINAL is laid out against. Zero whenever the sidebar@@ -2597,7 +2597,8 @@ impl crate::TermWindow {|| self.context_menu.is_some()|| self.native_context_menu_open|| self.inline_tab_rename.is_some();- let eligible = self.right_sidebar_collapsed+ let eligible = self.dedicated_thread.is_none()+ && self.right_sidebar_collapsed&& self.right_sidebar_has_panels()&& !self.content_view_foreground()&& !self.content_view_transition_running()diff --git a/wezterm-gui/src/termwindow/window_tab_reveal.rs b/wezterm-gui/src/termwindow/window_tab_reveal.rsindex 5fa830dd..3475b441 100644--- a/wezterm-gui/src/termwindow/window_tab_reveal.rs+++ b/wezterm-gui/src/termwindow/window_tab_reveal.rs@@ -31,6 +31,9 @@ use window::{MouseEvent, WindowDecorations, WindowOps, WindowState};pub(crate) struct WindowTabReveal {mode: NativeWindowTabs,pinned: bool,+ /// A thread's own window: the row hides whatever Settings say, so the+ /// pane bar shares the traffic lights' row.+ always_hiding: bool,hover: SidebarHoverReveal,/// How far out the row is, 0 to 1, as of the last step: what geometry/// reads between steps, so a frame and the clicks on it agree.@@ -53,6 +56,15 @@ impl WindowTabReveal {}}+ pub(crate) fn always_hiding() -> Self {+ Self {+ mode: NativeWindowTabs::AutoHide,+ pinned: false,+ always_hiding: true,+ ..Default::default()+ }+ }+/// The row keeps its place in the layout.pub(crate) fn in_layout(&self) -> bool {row_in_layout(self.mode, self.pinned)@@ -60,7 +72,7 @@ impl WindowTabReveal {/// The row carries its pin: it auto-hides, pinned or not.pub(crate) fn shows_pin(&self) -> bool {- self.mode == NativeWindowTabs::AutoHide+ self.mode == NativeWindowTabs::AutoHide && !self.always_hiding}pub(crate) fn pinned(&self) -> bool {@@ -334,7 +346,7 @@ impl TermWindow {else {return false;};- self.pane_bars_stand_in()+ (self.pane_bars_stand_in() || self.window_tab_reveal.always_hiding)&& !self.config.window_decorations.contains(WindowDecorations::TITLE)&& !self.window_state@@ -369,6 +381,12 @@ impl TermWindow {fn window_tab_hover_input(&self) -> HoverInput {let overlay_open = self.menu_or_overlay_open();let presented = self.window_tab_reveal.hover.is_presented();+ // A thread's own window with one tab has nothing to bring down, and+ // the top of it is what moves the window.+ let lone_tab = self.window_tab_reveal.always_hiding+ && Mux::get()+ .get_window(self.mux_window_id)+ .is_some_and(|window| window.len() < 2);// A row out for a rename goes back the usual way once it is done,// whatever the mode. Unlike the sidebars, a terminal that is// connecting or offline does not hold the row back: it is the way@@ -376,6 +394,7 @@ impl TermWindow {let eligible = (!self.window_tab_reveal.in_layout()|| self.renaming_window_tab()|| presented)+ && !lone_tab&& self.tab_bar_pixel_height().unwrap_or(0.0) > 0.0&& !self.content_view_is_full_window()&& (!overlay_open || presented);@@ -475,6 +494,9 @@ impl TermWindow {/// Take a new mode or pin from Settings: the terminal gets the row's/// height back, or gives it up, once.pub(crate) fn refresh_window_tabs(&mut self) {+ if self.window_tab_reveal.always_hiding {+ return;+ }let before = self.window_tab_reveal.in_layout();let (mode, pinned) = crate::native_settings::window_tabs_choice();self.window_tab_reveal.mode = mode;diff --git a/wezterm-gui/src/thread_marks.rs b/wezterm-gui/src/thread_marks.rsindex cfe415ff..7f0a6224 100644--- a/wezterm-gui/src/thread_marks.rs+++ b/wezterm-gui/src/thread_marks.rs@@ -146,6 +146,17 @@ pub(crate) fn slot_width(layout: NativeThreadIcons, diameter: f32) -> f32 {}}+/// How much of the slot `count` icons `diameter` across fill, for setting+/// them apart from a row: centred on their own, say.+pub(crate) fn drawn_width(layout: NativeThreadIcons, count: usize, diameter: f32) -> f32 {+ match layout {+ NativeThreadIcons::Badge | NativeThreadIcons::Trailing if count > 1 => diameter * 1.33,+ NativeThreadIcons::Badge | NativeThreadIcons::Trailing => diameter,+ NativeThreadIcons::Coins => diameter * (1.0 + 0.175 * (count.clamp(1, 3) - 1) as f32),+ NativeThreadIcons::Cluster => diameter * 1.2,+ }+}+/// How icons are drawn on a row: what sets one off from another, and what/// a count is written in.pub(crate) struct IconStyle<'a> {