Close local tabs and detach or reattach live SSH sessions

Remember the remote daemon and session identity for hostless reattachment. Keep other tabs usable after a discarded snapshot and preserve the last live detach target when a remote shell exits. Reject remote flags for local daemon control commands.
This commit is contained in:
James Magahern
2026-11-17 16:15:28 -08:00
parent f2390ca9b4
commit 153838061e
12 changed files with 874 additions and 162 deletions
+27 -4
View File
@@ -24,8 +24,13 @@ pub struct SessionIdentity {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SessionTarget {
New { cwd: Option<String> },
New {
cwd: Option<String>,
},
Attach(Option<SessionId>),
/// Local launcher request. The transport attaches by numeric ID on the v6
/// wire and verifies the daemon identity in the first snapshot.
Remembered(SessionIdentity),
}
/// SSH settings inherited from the shell that requested a remote tab.
@@ -35,6 +40,14 @@ pub struct SshOptions {
pub agent_socket: Option<std::path::PathBuf>,
}
/// Reconnect using the original remote binary and verify the daemon that owned the shell.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct DetachedRemote {
pub destination: String,
pub identity: SessionIdentity,
pub executable: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SessionInfo {
pub id: SessionId,
@@ -84,8 +97,10 @@ pub enum ClientMessage {
FocusPane {
pane: PaneId,
},
ClosePane {
pane: PaneId,
/// Close a pane or an entire local tab. Pane and tab IDs are allocated
/// from the same sequence. Older v6 daemons only recognize pane IDs here.
Close {
id: u64,
},
OpenWindow {
target: Option<String>,
@@ -137,9 +152,16 @@ pub enum ClientMessage {
target: SessionTarget,
ssh: SshOptions,
},
ClosePendingTab {
/// Detach the SSH session displayed by this tab. Older v6 servers accept
/// this same wire command only while the connection is pending.
DetachRemote {
tab: TabId,
},
/// Local launcher requests used to reopen a detached SSH connection.
LastDetachedRemote {
origin: Option<SessionIdentity>,
},
RememberDetachedRemote(DetachedRemote),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
@@ -205,6 +227,7 @@ pub enum ServerMessage {
Closing,
Connected { session: SessionId },
Sessions(Vec<SessionInfo>),
DetachedRemote(DetachedRemote),
}
#[derive(Debug, Clone, Serialize, Deserialize)]