commit 12e30f72d70a84056297e4d0c66e37e59a4b40dd
parent 6822dbfcf0e5978f9b58a826ae85478f1ae96ea4
Author: William Casarin <jb55@jb55.com>
Date: Mon, 23 Feb 2026 16:36:42 -0800
fix: use hostname matching for local vs remote session detection
Previously both restore_sessions_from_ndb() and poll_session_state_events()
determined local vs remote solely by checking if the session's cwd path
existed on the filesystem. This meant sessions from other hosts would be
incorrectly classified as local if both machines had the same path.
Now hostname comparison is the primary signal: if the event's hostname
doesn't match the current machine's hostname, the session is remote.
The cwd existence check is kept as a fallback for old events that may
lack a hostname field.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat:
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/crates/notedeck_dave/src/lib.rs b/crates/notedeck_dave/src/lib.rs
@@ -1494,16 +1494,18 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
);
session.chat = loaded.messages;
- // Determine if this is a remote session (cwd doesn't exist locally)
- let cwd = std::path::PathBuf::from(&state.cwd);
- if !cwd.exists() {
+ // Determine if this is a remote session: hostname mismatch
+ // is the primary signal, with cwd non-existence as fallback
+ // for old events that may lack a hostname.
+ if (!state.hostname.is_empty() && state.hostname != self.hostname)
+ || (state.hostname.is_empty() && !std::path::PathBuf::from(&state.cwd).exists())
+ {
session.source = session::SessionSource::Remote;
}
- let is_remote = session.is_remote();
// Local sessions use the current machine's hostname;
// remote sessions use what was stored in the event.
- session.details.hostname = if is_remote {
+ session.details.hostname = if session.is_remote() {
state.hostname.clone()
} else {
self.hostname.clone()
@@ -1707,9 +1709,12 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
session.chat = loaded.messages;
}
- // Determine if this is a remote session
- let cwd_path = std::path::PathBuf::from(&state.cwd);
- if !cwd_path.exists() {
+ // Determine if this is a remote session: hostname mismatch
+ // is the primary signal, with cwd non-existence as fallback
+ // for old events that may lack a hostname.
+ if (!state.hostname.is_empty() && state.hostname != self.hostname)
+ || (state.hostname.is_empty() && !std::path::PathBuf::from(&state.cwd).exists())
+ {
session.source = session::SessionSource::Remote;
}