Skip to content

Auto-dismiss thread toasts after 10s of visible time - #54

Merged
juliusmarminge merged 1 commit into
mainfrom
codething/8c14cb40
Feb 16, 2026
Merged

juliusmarminge merged 1 commit into
mainfrom
codething/8c14cb40

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Feb 16, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add support for dismissAfterVisibleMs in thread toast metadata.
  • Set Git action thread toasts to auto-dismiss after 10,000ms of visible/focused time.
  • Implement visibility-aware auto-dismiss logic that pauses on tab blur/hidden and resumes when visible.
  • Clean up stored per-toast remaining timeout state when toasts are removed.

Testing

  • Not run (no test execution details were provided with the commit/diff).

Open with Devin

Summary by CodeRabbit

  • New Features
    • Toast notifications now automatically dismiss after 10 seconds when visible, with awareness of page visibility and browser focus states for a smoother user experience.

- Add `dismissAfterVisibleMs` support to thread toasts
- Pause/resume countdown based on tab visibility and window focus
- Set Git action result toasts to dismiss after 10s when visible
@coderabbitai

coderabbitai Bot commented Feb 16, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉


Walkthrough

These changes implement auto-dismiss functionality for thread toasts. GitActionsControl.tsx now includes dismissAfterVisibleMs in toast data, while toast.tsx adds a ThreadToastVisibleAutoDismiss component to manage automatic dismissal after specified durations with awareness of visibility and focus states.

Changes

Cohort / File(s) Summary
Toast Auto-Dismiss Configuration
apps/web/src/components/GitActionsControl.tsx
Extends toast data payload to include dismissAfterVisibleMs: 10000 field, enabling automatic dismissal after 10 seconds for success toasts.
Toast Auto-Dismiss Implementation
apps/web/src/components/ui/toast.tsx
Introduces ThreadToastVisibleAutoDismiss component to manage auto-dismiss timers with per-toast state tracking, visibility/focus awareness, and timer cleanup on component unmount or toast removal.

Sequence Diagram

sequenceDiagram
    participant Component as Toast Component
    participant Renderer as Toast Renderer
    participant AutoDismiss as ThreadToastVisibleAutoDismiss
    participant TimerMgr as Timer & Visibility Manager
    participant DOM as Toast DOM

    Component->>Renderer: Render toast with dismissAfterVisibleMs
    Renderer->>AutoDismiss: Inject auto-dismiss controller
    AutoDismiss->>TimerMgr: Initialize timer (dismissAfterVisibleMs)
    AutoDismiss->>TimerMgr: Listen to visibility/focus changes
    TimerMgr->>TimerMgr: Pause timer on blur/hidden
    TimerMgr->>TimerMgr: Resume timer on focus/visible
    TimerMgr->>DOM: Monitor remaining time
    alt Timer Expires
        TimerMgr->>AutoDismiss: Time remaining = 0
        AutoDismiss->>Renderer: Close toast
        Renderer->>DOM: Remove toast element
    end
    AutoDismiss->>TimerMgr: Cleanup on unmount
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (5 files):

⚔️ apps/web/src/components/GitActionsControl.tsx (content)
⚔️ apps/web/src/components/ThreadTerminalDrawer.tsx (content)
⚔️ apps/web/src/components/ui/toast.tsx (content)
⚔️ apps/web/src/keybindings.test.ts (content)
⚔️ apps/web/src/keybindings.ts (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: implementing auto-dismiss functionality for thread toasts after 10 seconds of visible time, which aligns with the core modifications across both affected files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codething/8c14cb40
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch codething/8c14cb40
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@macroscopeapp

macroscopeapp Bot commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Auto-dismiss Git action success thread toasts in GitActionsControl after 10,000 ms of visible time and track visibility-aware countdown in apps/web/src/components/ui/toast.tsx

Add dismissAfterVisibleMs to thread toast data and implement a visibility- and focus-aware auto-dismiss timer that closes toasts after 10s of foreground-visible time; update GitActionsControl to set this value on success toasts.

📍Where to Start

Start with the ThreadToastVisibleAutoDismiss logic in toast.tsx, then see how GitActionsControl sets dismissAfterVisibleMs in GitActionsControl.tsx.


Macroscope summarized 70752a0.

@greptile-apps

greptile-apps Bot commented Feb 16, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds visibility-aware auto-dismiss behavior for git action success toasts. A new ThreadToastVisibleAutoDismiss renderless component tracks how long the tab has been visible/focused and auto-closes the toast after 10 seconds of actual visible time. The timer pauses when the tab is hidden or loses focus, and resumes when the user returns. A module-level Map stores per-toast remaining time so the countdown survives React re-renders.

  • toast.tsx: New ThreadToastVisibleAutoDismiss component with visibilitychange/focus/blur listeners, plus a cleanup effect in Toasts that prunes stale Map entries when toasts are removed.
  • GitActionsControl.tsx: Spreads dismissAfterVisibleMs: 10_000 into the data of success-result toasts. Error toasts intentionally keep the old behavior (no auto-dismiss).
  • The implementation correctly handles edge cases: tab hidden at transition time, external toast dismissal via swipe, and effect re-runs on prop changes.

Confidence Score: 4/5

  • This PR is safe to merge — the auto-dismiss logic is well-isolated and handles edge cases correctly.
  • The implementation is clean with proper event listener cleanup, correct handling of visibility/focus state transitions, and safe Map mutation during iteration. The only minor concern is that the module-level Map is tightly coupled to toastManager (not anchoredToastManager), which is fine today but could cause confusion if the pattern is extended later. No runtime bugs identified.
  • No files require special attention.

Important Files Changed

Filename Overview
apps/web/src/components/ui/toast.tsx Adds ThreadToastVisibleAutoDismiss component with visibility-aware auto-dismiss logic and module-level Map for persisting remaining timeout. Clean, well-structured implementation with proper event listener cleanup.
apps/web/src/components/GitActionsControl.tsx Minimal change — spreads dismissAfterVisibleMs: 10_000 into the success toast data for git actions. Error toasts intentionally omit auto-dismiss.

Sequence Diagram

sequenceDiagram
    participant GA as GitActionsControl
    participant TM as toastManager
    participant TD as ThreadToastVisibleAutoDismiss
    participant Doc as Document/Window

    GA->>TM: add(loading toast, no dismissAfterVisibleMs)
    Note over TD: Effect skips (dismissAfterVisibleMs undefined)
    GA->>TM: update(success toast, dismissAfterVisibleMs: 10000)
    TM-->>TD: Re-render with dismissAfterVisibleMs=10000
    TD->>Doc: Check visibilityState & hasFocus
    alt Tab visible & focused
        TD->>TD: start() — setTimeout(10s)
        Doc-->>TD: blur event
        TD->>TD: pause() — save remaining ms to Map
        Doc-->>TD: focus event
        TD->>TD: start() — setTimeout(remaining ms)
        TD->>TM: close(toastId)
    else Tab hidden/blurred
        TD->>TD: Timer paused, waiting for visibility
    end
Loading

Last reviewed commit: 70752a0

@juliusmarminge
juliusmarminge merged commit 3863901 into main Feb 16, 2026
4 checks passed
maria-rcks pushed a commit to maria-rcks/t3libre that referenced this pull request Sep 21, 2026
i2cjak referenced this pull request in i2cjak/Backplane Sep 29, 2026
UI fixes, /btw, light mode, headless mode, faster phone app with a fuller viewer, KiCad checks, and release packages
@joeljanson joeljanson mentioned this pull request Oct 7, 2026
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.

1 participant