From e6078c10ca1ef7b4f26498a489fa9f3a92c04cd7 Mon Sep 17 00:00:00 2001
From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com>
Date: Sun, 16 Aug 2026 02:26:56 +0800
Subject: [PATCH] fix(ssh): stop a failed shell probe disabling integration for
good
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
`remote_bootstrap` cached whatever `probe_remote_shell` returned, and
that function answers `None` for two unrelated reasons: the remote runs a
shell there is no bootstrap for, and the probe never got asked — the
channel would not open, the exec failed, or the five-second read ended
before the answer arrived.
The cache is a `HashMap` on the process-wide `SshManager`, behind a
`OnceLock`, with no TTL and nothing that evicts. So one slow or busy
moment on the first pane to a host turned into "this host has no shell
integration" for the rest of the daemon's life: no prompt marks, no cwd
tracking, no command status, no error, and reconnecting does not clear it
because the entry outlives the connection.
Told the two apart at the only place that can tell them apart — the
output. `probe_answer` reads exactly as far as `parse_probe` does before
it can form an opinion, and returns `None` when the marker and the line
it introduces did not both arrive. Only an answer is remembered; a
silence is asked again on the next pane.
The cost lands on the case that deserves it: a host that genuinely cannot
be probed pays one probe per pane instead of one per daemon, bounded by
the same timeout as before. A host that answers pays nothing extra.
The decision is a pure function over the probe's text, so it is tested
rather than argued about; the async path around it is unchanged bar the
return type.
---
.../tty7-core/src/daemon/shell_integration.rs | 53 +++++++++++++++++++
crates/tty7-core/src/daemon/ssh/mod.rs | 35 ++++++++----
2 files changed, 77 insertions(+), 11 deletions(-)
diff --git a/crates/tty7-core/src/daemon/shell_integration.rs b/crates/tty7-core/src/daemon/shell_integration.rs
index 6f4aeea3..9b0664c7 100644
--- a/crates/tty7-core/src/daemon/shell_integration.rs
+++ b/crates/tty7-core/src/daemon/shell_integration.rs
@@ -1296,6 +1296,26 @@ pub mod remote {
}
}
+ /// What the probe *said*, kept apart from its having said nothing.
+ ///
+ /// `None` means the far side never answered: the channel or the command
+ /// failed, or the timeout cut the read off before the marker and the line
+ /// it introduces both arrived. That is a different fact from "answered,
+ /// and logs in with a shell there is no bootstrap for", which is
+ /// `Some(None)`. Only the second is worth remembering — the first is a
+ /// slow link or a busy server, and the next pane deserves a fresh ask.
+ pub(crate) fn probe_answer(output: &str) -> Option