diff --git a/src/document/manager.rs b/src/document/manager.rs index 08941b1..4699438 100644 --- a/src/document/manager.rs +++ b/src/document/manager.rs @@ -63,7 +63,6 @@ impl DocumentManager { // Session lifecycle SessionCommand::NewSession { name } => self.new_session(&name), SessionCommand::OpenSession { path } => self.open_session_file(&path), - SessionCommand::CloseSession => self.close_session(), SessionCommand::DeleteSession => self.delete_session(), SessionCommand::SaveSession => self.save_session(), SessionCommand::SelectSession { name } => self.select_session(&name), @@ -150,27 +149,18 @@ impl DocumentManager { match store::load_sessions(path) { Ok(mut loaded) => { for session in &mut loaded { - match session.kind { - CollectionKind::DirectoryBrowser => { - if let Some(dir) = session.path.clone() { - scan_directory_into(session, &dir); - } + session.items.retain(|item| { + if item.path.exists() { + true + } else { + warn!( + "Session '{}': {}", + session.name, + Error::NotFound(item.path.display().to_string()) + ); + false } - CollectionKind::DocumentCollection => { - session.items.retain(|item| { - if item.path.exists() { - true - } else { - warn!( - "Session '{}': {}", - session.name, - Error::NotFound(item.path.display().to_string()) - ); - false - } - }); - } - } + }); } let browser_index = loaded @@ -189,13 +179,9 @@ impl DocumentManager { } } - fn close_session(&mut self) { - // Close session only removes it from runtime, keeps it in .ron file - // For actual deletion, use delete_session() - // Currently acts same as delete for backwards compatibility - // TODO: Implement proper close behavior (hide from UI but keep in .ron) - self.delete_session(); - } + // We have no 'Close session' it wouldbe only removes it from runtime, keeps it in .ron file + // For actual deletion, use delete_session() + // So 'close_session' from ui view is save_session and close session view. fn delete_session(&mut self) { let Some(idx) = self.active_session_index else { diff --git a/src/document/session/command.rs b/src/document/session/command.rs index da87086..4b74877 100644 --- a/src/document/session/command.rs +++ b/src/document/session/command.rs @@ -24,8 +24,6 @@ pub enum SessionCommand { NewSession { name: String }, /// Load sessions from an existing .ron file. OpenSession { path: PathBuf }, - /// Close the active session (removes from runtime, kept in .ron file). - CloseSession, /// Persist all sessions to the .ron file. SaveSession, /// Set the active session cursor by name. diff --git a/src/main.rs b/src/main.rs index 56faa36..f61905a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -338,17 +338,6 @@ fn run_session_test(mgr: &mut DocumentManager, active_name: &str) { }; println!(" {marker} {}", session.name); } - - exec( - mgr, - "CloseSession (closes 'Archive')", - SessionCommand::CloseSession, - ); - - step("All sessions after close:"); - for session in mgr.sessions() { - println!(" {DIM}-{RESET} {}", session.name); - } } fn run_cli(args: Args) {