refactor(session): rethink and so ... remove useless close_session command

This commit is contained in:
mow 2026-03-12 16:53:29 +01:00
parent 93fc1bf829
commit 4c1af08fb7
3 changed files with 14 additions and 41 deletions

View file

@ -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,13 +149,6 @@ 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);
}
}
CollectionKind::DocumentCollection => {
session.items.retain(|item| {
if item.path.exists() {
true
@ -170,8 +162,6 @@ impl DocumentManager {
}
});
}
}
}
let browser_index = loaded
.iter()
@ -189,13 +179,9 @@ impl DocumentManager {
}
}
fn close_session(&mut self) {
// Close session only removes it from runtime, keeps it in .ron file
// We have no 'Close session' it wouldbe 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();
}
// 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 {

View file

@ -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.

View file

@ -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) {