@@ -141,6 +141,8 @@ pub struct Dave {
141141 /// Sessions pending deletion state event publication.
142142 /// Populated in delete_session(), drained in the update loop where AppContext is available.
143143 pending_deletions : Vec < DeletedSessionInfo > ,
144+ /// Local machine hostname, included in session state events.
145+ hostname : String ,
144146}
145147
146148/// A permission response queued for relay publishing.
@@ -306,13 +308,20 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
306308 // Create IPC listener for external spawn-agent commands
307309 let ipc_listener = ipc:: create_listener ( ctx) ;
308310
311+ let hostname = gethostname:: gethostname ( )
312+ . to_string_lossy ( )
313+ . into_owned ( ) ;
314+
309315 // In Chat mode, create a default session immediately and skip directory picker
310316 // In Agentic mode, show directory picker on startup
311317 let ( session_manager, active_overlay) = match ai_mode {
312318 AiMode :: Chat => {
313319 let mut manager = SessionManager :: new ( ) ;
314320 // Create a default session with current directory
315- manager. new_session ( std:: env:: current_dir ( ) . unwrap_or_default ( ) , ai_mode) ;
321+ let sid = manager. new_session ( std:: env:: current_dir ( ) . unwrap_or_default ( ) , ai_mode) ;
322+ if let Some ( session) = manager. get_mut ( sid) {
323+ session. hostname = hostname. clone ( ) ;
324+ }
316325 ( manager, DaveOverlay :: None )
317326 }
318327 AiMode :: Agentic => ( SessionManager :: new ( ) , DaveOverlay :: DirectoryPicker ) ,
@@ -346,6 +355,7 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
346355 session_state_sub : None ,
347356 pending_perm_responses : Vec :: new ( ) ,
348357 pending_deletions : Vec :: new ( ) ,
358+ hostname,
349359 }
350360 }
351361
@@ -894,6 +904,7 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
894904 self . show_scene ,
895905 self . ai_mode ,
896906 cwd,
907+ & self . hostname ,
897908 ) ;
898909 }
899910
@@ -913,6 +924,7 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
913924 cwd,
914925 resume_session_id,
915926 title,
927+ & self . hostname ,
916928 )
917929 }
918930
@@ -924,6 +936,7 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
924936 & mut self . scene ,
925937 self . show_scene ,
926938 self . ai_mode ,
939+ & self . hostname ,
927940 ) ;
928941 }
929942
@@ -943,6 +956,7 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
943956
944957 // Focus on new session
945958 if let Some ( session) = self . session_manager . get_mut ( id) {
959+ session. hostname = self . hostname . clone ( ) ;
946960 session. focus_requested = true ;
947961 if self . show_scene {
948962 self . scene . select ( id) ;
@@ -1107,6 +1121,7 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
11071121 & session. title ,
11081122 & cwd,
11091123 status,
1124+ & self . hostname ,
11101125 & sk,
11111126 ) {
11121127 Ok ( evt) => {
@@ -1140,6 +1155,7 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
11401155 & info. title ,
11411156 & info. cwd ,
11421157 "deleted" ,
1158+ & self . hostname ,
11431159 & sk,
11441160 ) {
11451161 Ok ( evt) => {
@@ -1265,6 +1281,14 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
12651281 }
12661282 let is_remote = session. is_remote ( ) ;
12671283
1284+ // Local sessions use the current machine's hostname;
1285+ // remote sessions use what was stored in the event.
1286+ session. hostname = if is_remote {
1287+ state. hostname . clone ( )
1288+ } else {
1289+ self . hostname . clone ( )
1290+ } ;
1291+
12681292 if let Some ( agentic) = & mut session. agentic {
12691293 if let ( Some ( root) , Some ( last) ) = ( loaded. root_note_id , loaded. last_note_id ) {
12701294 agentic. live_threading . seed ( root, last, loaded. event_count ) ;
@@ -1395,11 +1419,15 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
13951419 . to_string ( ) ;
13961420 let cwd_str = session_events:: get_tag_value ( & note, "cwd" ) . unwrap_or ( "" ) ;
13971421 let cwd = std:: path:: PathBuf :: from ( cwd_str) ;
1422+ let hostname = session_events:: get_tag_value ( & note, "hostname" )
1423+ . unwrap_or ( "" )
1424+ . to_string ( ) ;
13981425
13991426 tracing:: info!(
1400- "discovered new session from relay: '{}' ({})" ,
1427+ "discovered new session from relay: '{}' ({}) on {} " ,
14011428 title,
1402- claude_sid
1429+ claude_sid,
1430+ hostname,
14031431 ) ;
14041432
14051433 existing_ids. insert ( claude_sid. to_string ( ) ) ;
@@ -1415,6 +1443,7 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
14151443 let loaded = session_loader:: load_session_messages ( ctx. ndb , & txn, claude_sid) ;
14161444
14171445 if let Some ( session) = self . session_manager . get_mut ( dave_sid) {
1446+ session. hostname = hostname;
14181447 if !loaded. messages . is_empty ( ) {
14191448 tracing:: info!(
14201449 "loaded {} messages for discovered session" ,
0 commit comments