Skip to content

refactor(ui): consolidate timed notices - #872

Merged
benvinegar merged 1 commit into
mainfrom
refactor/timed-notices
Aug 27, 2026
Merged

benvinegar merged 1 commit into
mainfrom
refactor/timed-notices

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Summary

  • consolidate App's transient and session notice timers behind useTimedNotice
  • preserve independent durations, stable callbacks, status precedence, and stale-timer protection
  • add deterministic scheduler, StrictMode lifecycle, replacement, clear, and cleanup coverage

Testing

  • bun test src/ui/hooks/useTimedNotice.test.tsx
  • relevant AppHost notice interaction suites (112 tests)
  • bun run typecheck
  • bun run deps:check
  • bun run format:check
  • bun run lint

This PR description was generated by Pi using GPT-5.6 Sol

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hunk-web Ignored Ignored Preview Aug 27, 2026 1:46am

Request Review

@greptile-apps

greptile-apps Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR consolidates transient and session notice timing behind a reusable useTimedNotice hook while preserving each channel’s duration and display precedence.

  • Replaces duplicated timer state and cleanup logic in App.
  • Adds generation-based stale-callback protection and stable show/clear callbacks.
  • Adds deterministic coverage for replacement, clearing, cleanup, StrictMode replay, scheduler changes, and independent notice channels.

Confidence Score: 5/5

The PR appears safe to merge, with the existing notice durations, callers, precedence, and lifecycle behavior preserved.

The shared hook cancels replaced timers, invalidates stale callbacks, cleans up on unmount, and retains separate three- and four-second channels; current callers remain compatible and the new tests exercise the relevant lifecycle transitions.

Important Files Changed

Filename Overview
src/ui/hooks/useTimedNotice.ts Introduces a reusable timed-notice hook with stable callbacks, timer ownership, stale-callback invalidation, and unmount cleanup.
src/ui/hooks/useTimedNotice.test.tsx Adds deterministic tests covering timing, replacement, explicit clearing, channel isolation, lifecycle cleanup, StrictMode behavior, and scheduler changes.
src/ui/App.tsx Replaces duplicated transient and session timer implementations with independently configured hook instances while retaining status precedence.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Caller[Notice caller] --> Show[show text]
  Show --> Cancel[Cancel pending channel timer]
  Cancel --> Generation[Advance generation]
  Generation --> Display[Update notice text]
  Display --> Schedule[Schedule channel-specific timeout]
  Schedule --> Check{Generation still current?}
  Check -- Yes --> Clear[Clear notice text]
  Check -- No --> Ignore[Ignore stale callback]
  Unmount[Unmount or explicit clear] --> Invalidate[Advance generation and cancel timer]
  Invalidate --> Ignore
Loading

Reviews (1): Last reviewed commit: "refactor(ui): consolidate timed notices" | Re-trigger Greptile

@benvinegar
benvinegar force-pushed the refactor/timed-notices branch from fb2843e to 0548939 Compare August 27, 2026 01:46
@benvinegar
benvinegar enabled auto-merge (squash) August 27, 2026 01:47
@benvinegar
benvinegar merged commit b854ded into main Aug 27, 2026
12 checks passed
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