Close workspace windows when their final tab disappears

This commit is contained in:
James Magahern
2026-11-17 18:13:06 -08:00
parent 0f272d5298
commit 119df745fc
3 changed files with 20 additions and 16 deletions
+3 -2
View File
@@ -277,8 +277,9 @@ GUI detach/reattach. Collapsed shells keep running; their grids are sent only wh
expanded, and their output does not redraw unchanged visible grids.
When a shell exits, its pane closes automatically. An empty tab closes too,
and focus moves to an adjacent remaining pane or tab when needed. After the
last shell exits, the window stays open with `+` available to start another tab.
and focus moves to an adjacent remaining pane or tab when needed. When the
last pane exits or the last tab closes, every window showing that session
closes. Windows showing other sessions stay open.
Each session has its own tabs, panes, focus, and scrollback. Windows attached
to the same session share those and the underlying PTY grid. Each window keeps
+1 -1
View File
@@ -2467,7 +2467,7 @@ mod tests {
let empty = snapshot(&mut client, |s| s.tabs.is_empty());
assert!(empty.panes.is_empty());
assert_eq!(empty.active_tab, 0);
// Removing the final shell leaves this GUI attached to a live server.
// Protocol clients that stay connected after the empty snapshot can start a new tab.
send(&mut client, ClientMessage::Ping);
loop {
if matches!(
+16 -13
View File
@@ -388,6 +388,11 @@ impl Workspace {
view.error = Some(error);
}
if let Some(snapshot) = update.snapshot {
// A remote tab can still be connecting with no visible panes.
if snapshot.tabs.is_empty() {
window.remove_window();
return;
}
let metadata_changed = view.snapshot.as_ref().is_none_or(|old| {
old.active_tab != snapshot.active_tab
|| old.tabs != snapshot.tabs
@@ -618,19 +623,17 @@ impl Render for Workspace {
let mut incoming = scene(incoming_offset).id("incoming-scene");
if let Some(snapshot) = &self.snapshot {
incoming = pane_scene(snapshot, &self.panes, incoming_offset, Some(&self.client));
if snapshot.panes.is_empty() {
let status = match snapshot.active_tab() {
Some(tab) if tab.is_connecting() => tab
.remote
.as_ref()
.map(|host| format!("Connecting to {host}…")),
Some(_) => None, // The selected tab's grid is still in transit.
None => Some("No sessions. Use + to open a terminal.".to_owned()),
};
if let Some(status) = status {
incoming =
incoming.child(div().p_4().text_color(rgb(chrome::MUTED)).child(status));
}
if let Some(host) = snapshot
.active_tab()
.filter(|tab| tab.is_connecting())
.and_then(|tab| tab.remote.as_ref())
{
incoming = incoming.child(
div()
.p_4()
.text_color(rgb(chrome::MUTED))
.child(format!("Connecting to {host}…")),
);
}
} else {
incoming = incoming.child(