From 42d33ac06cb6a16e1a690c6ae05ba75274e40c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 7 May 2026 20:09:42 -0400 Subject: [PATCH] Track archived tab state transitions --- crates/ely_browser_core/tests/tabs.rs | 10 ++++++++-- crates/ely_domain/src/archive.rs | 7 +++++-- crates/ely_domain/src/tab.rs | 8 ++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/crates/ely_browser_core/tests/tabs.rs b/crates/ely_browser_core/tests/tabs.rs index 603c8d7..f385970 100644 --- a/crates/ely_browser_core/tests/tabs.rs +++ b/crates/ely_browser_core/tests/tabs.rs @@ -1,7 +1,7 @@ use std::error::Error; use ely_browser_core::{BrowserCore, CoreError, InitialBrowserConfig}; -use ely_domain::{CommandIntent, CommandScope, UrlText}; +use ely_domain::{CommandIntent, CommandScope, TabState, UrlText}; #[test] fn opens_new_tab_below_active_tab() -> Result<(), Box> { @@ -38,6 +38,7 @@ fn closes_active_tab_and_selects_next_neighbor() -> Result<(), Box> { assert_eq!(snapshot.active_tab_id, active_tab_id); assert_eq!(snapshot.archived_tabs.len(), 1); assert_eq!(snapshot.archived_tabs[0].tab().id(), &second_tab_id); + assert_eq!(snapshot.archived_tabs[0].tab().state(), &TabState::Archived); Ok(()) } @@ -69,7 +70,12 @@ fn restores_last_archived_tab() -> Result<(), Box> { assert_eq!(restored_tab_id, closed_tab_id); assert_eq!(snapshot.active_tab_id, closed_tab_id); assert!(snapshot.archived_tabs.is_empty()); - assert!(snapshot.tabs.iter().any(|tab| tab.id() == &closed_tab_id)); + let restored_tab = snapshot + .tabs + .iter() + .find(|tab| tab.id() == &closed_tab_id) + .ok_or(CoreError::MissingActiveTab)?; + assert_eq!(restored_tab.state(), &TabState::Ready); Ok(()) } diff --git a/crates/ely_domain/src/archive.rs b/crates/ely_domain/src/archive.rs index 23c1519..f4340e2 100644 --- a/crates/ely_domain/src/archive.rs +++ b/crates/ely_domain/src/archive.rs @@ -17,7 +17,8 @@ pub struct ArchivedTab { impl ArchivedTab { #[must_use] - pub fn new(tab: BrowserTab, source: ArchiveSource) -> Self { + pub fn new(mut tab: BrowserTab, source: ArchiveSource) -> Self { + tab.mark_archived(); Self { tab, archived_at: SystemTime::now(), source } } @@ -38,6 +39,8 @@ impl ArchivedTab { #[must_use] pub fn into_tab(self) -> BrowserTab { - self.tab + let mut tab = self.tab; + tab.mark_ready(); + tab } } diff --git a/crates/ely_domain/src/tab.rs b/crates/ely_domain/src/tab.rs index a60974e..9e7738c 100644 --- a/crates/ely_domain/src/tab.rs +++ b/crates/ely_domain/src/tab.rs @@ -85,6 +85,14 @@ impl BrowserTab { &self.state } + pub fn mark_archived(&mut self) { + self.state = TabState::Archived; + } + + pub fn mark_ready(&mut self) { + self.state = TabState::Ready; + } + #[must_use] pub fn flags(&self) -> &TabFlags { &self.flags