host: low memory only for parked tabs, not for tabs hidden behind a shell overlay; skip unchanged targets

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
CRTkafa 2026-09-28 19:42:34 +07:00
parent 3ef4a27a6b
commit edf5171435
2 changed files with 23 additions and 8 deletions

View file

@ -26,6 +26,11 @@ pub struct TabLayout {
pub width: f64,
pub height: f64,
pub visible: bool,
/// Not shown for a reason other than a shell overlay (a background tab of its group, a pane
/// with no room). Only parked tabs get the low memory target; a tab merely covered by a shell
/// menu or the command palette stays at normal.
#[serde(default)]
pub parked: bool,
/// Another site pane of the same account already shows the site's navigation rail.
#[serde(default)]
pub nav_redundant: bool,
@ -168,11 +173,11 @@ pub enum MemoryTarget {
Low,
}
pub fn memory_target(visible: bool) -> MemoryTarget {
if visible {
MemoryTarget::Normal
} else {
pub fn memory_target(visible: bool, parked: bool) -> MemoryTarget {
if !visible && parked {
MemoryTarget::Low
} else {
MemoryTarget::Normal
}
}
@ -240,8 +245,9 @@ mod tests {
#[test]
fn hidden_tabs_target_low_memory() {
assert_eq!(memory_target(false), MemoryTarget::Low);
assert_eq!(memory_target(true), MemoryTarget::Normal);
assert_eq!(memory_target(false, true), MemoryTarget::Low, "a parked background tab");
assert_eq!(memory_target(true, false), MemoryTarget::Normal);
assert_eq!(memory_target(false, false), MemoryTarget::Normal, "hidden only behind a shell overlay");
}
#[test]