Skip to content

Fix #26: bound ToastStack retention - #27

Merged
kakarot-dev merged 2 commits into
masterfrom
agent/26-toast-retention
Aug 30, 2026
Merged

Fix #26: bound ToastStack retention#27
kakarot-dev merged 2 commits into
masterfrom
agent/26-toast-retention

Conversation

@kakarot-dev

Copy link
Copy Markdown
Contributor

Summary

  • ToastStack::push/set_keyed grew items: Vec<Toast> without bound. push_error/push_warning create sticky toasts (until: None) that only leave via a per-toast dismiss click or clear_keyedMAX_VISIBLE (5) only capped what toast_overlay renders, not what's retained. A recurring failure condition (e.g. tokito-native's repeated catalog-transport errors) accumulated an unbounded Vec<Toast> over a long session — the one confirmed memory leak from tokito's #585 evaluator.
  • Added ToastStack::MAX_RETAINED (100) and an enforce_capacity step run from push/set_keyed: once over the cap, already-expired entries are dropped first (mirrors prune), then the oldest remaining ones — but the newest MAX_VISIBLE entries (exactly what toast_overlay renders, items.iter().rev().take(MAX_VISIBLE)) are never touched, so an on-screen sticky error can never be evicted out from under the user.
  • Dismissal was already immediate (toast_overlay's retain(|t| t.id != id)) — unchanged, just covered by a test now.

Test plan

  • 6 new unit tests in src/components.rs (toast_stack_tests module), including hammering push_error/mixed kinds/set_keyed 10k times and asserting items.len() <= MAX_RETAINED, that the newest MAX_VISIBLE toasts always survive, that an already-expired toast is evicted before any live one, and that a dismissed toast is removed immediately.
  • cargo test --lib toast_stack_tests — 6 passed
  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo build
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps

Closes #26

🤖 Generated with Claude Code

kakarot-dev and others added 2 commits August 20, 2026 22:50
Two review follow-ups from TokitoAI/tokito#525's gate_overlay consumer:

1. The overlay claimed its rect with Sense::hover() and a doc comment
   claiming that blocked clicks to whatever's behind it. Under egui
   0.35's hit-testing a hover-only rect never actually intercepts a
   click — Sense::click_and_drag() is what's needed to make "nothing
   behind it is clickable while gated" true. Fixed the comment to match.
2. The depth glow behind the card was two flat circle_filled discs,
   which reads as concentric rings rather than a soft glow. Replaced
   with a 7-step alpha ramp (lerp_color accent -> accent_2 outer to
   inner, gamma_multiply fading alpha per step) so it falls off
   smoothly instead of banding.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
push_error/push_warning create sticky toasts (until: None) that only
leave the stack via a per-toast dismiss click or clear_keyed. A
recurring failure condition calling push_error in a loop (e.g.
tokito-native's repeated catalog-transport errors) accumulated an
unbounded items: Vec<Toast> — MAX_VISIBLE only capped rendering, not
retention.

Add ToastStack::MAX_RETAINED (100) and enforce it from push/set_keyed:
once over the cap, already-expired entries are dropped first, then the
oldest remaining ones — but the newest MAX_VISIBLE entries (exactly
what toast_overlay renders) are never touched, so an on-screen sticky
error can never be evicted out from under the user. Dismissal was
already immediate (retain by id in toast_overlay); this doesn't change
that.

Covered by 6 unit tests hammering push/push_error/set_keyed 10k times,
asserting the bound holds, the visible window survives, and dismissed
toasts are gone immediately.

Closes #26

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kakarot-dev
kakarot-dev merged commit c265037 into master Aug 30, 2026
1 check passed
@kakarot-dev
kakarot-dev deleted the agent/26-toast-retention branch August 30, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ToastStack: sticky error/warning toasts grow items: Vec<Toast> without a cap

1 participant