Add idle tab auto archive policy

This commit is contained in:
2026-05-08 02:27:29 -04:00
parent 15cf65be62
commit 7f479ff9e1
7 changed files with 229 additions and 10 deletions
+4
View File
@@ -51,4 +51,8 @@ impl Space {
pub fn archive_policy(&self) -> &ArchivePolicy {
&self.archive_policy
}
pub fn set_archive_policy(&mut self, archive_policy: ArchivePolicy) {
self.archive_policy = archive_policy;
}
}
+21
View File
@@ -1,3 +1,5 @@
use std::time::SystemTime;
use crate::{ProfileId, SpaceId, SplitId, TabId, UrlText};
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -27,6 +29,8 @@ pub struct BrowserTab {
state: TabState,
flags: TabFlags,
split_id: Option<SplitId>,
created_at: SystemTime,
last_active_at: SystemTime,
}
impl BrowserTab {
@@ -38,6 +42,7 @@ impl BrowserTab {
title: impl Into<String>,
url: UrlText,
) -> Self {
let created_at = SystemTime::now();
Self {
id,
space_id,
@@ -47,6 +52,8 @@ impl BrowserTab {
state: TabState::Ready,
flags: TabFlags::default(),
split_id: None,
created_at,
last_active_at: created_at,
}
}
@@ -85,6 +92,20 @@ impl BrowserTab {
&self.state
}
#[must_use]
pub fn created_at(&self) -> SystemTime {
self.created_at
}
#[must_use]
pub fn last_active_at(&self) -> SystemTime {
self.last_active_at
}
pub fn record_activity(&mut self, active_at: SystemTime) {
self.last_active_at = active_at;
}
pub fn mark_archived(&mut self) {
self.state = TabState::Archived;
}