Add option for the notification interval

Closed
KE
5mo ago
+224-42

Summary by cubic

Adds a configurable toast duration for Magic Context notifications and threads it end-to-end from config to the TUI. The TUI loads it via a new toast-duration RPC and uses a unified toast helper; dream, status, setup, and restart toasts respect the setting, with 10s overrides for setup/restart.

  • New Features

    • Added toast_duration_ms to config/schema (1000–60000, default 5000ms); documented and exposed in the Dashboard Config Editor.
    • New toast-duration RPC; the TUI fetches and caches it on startup and uses a unified showToast with per-toast overrides.
    • NotificationParams and StatusDetail carry toastDurationMs; server notifications are queued via RPC and respect the duration.
  • Bug Fixes

    • Preserved toast_duration_ms in createSessionHooks and threaded it through getLiveNotificationParams and command handlers so dream notifications use the configured duration; added regression test.

Greptile Summary

This PR adds a configurable toast_duration_ms setting (1000–60000 ms, default 5000 ms) for Magic Context TUI notifications. The config is validated via Zod, exposed in the Dashboard Config Editor and CONFIGURATION.md, fetched by the TUI on startup via a new toast-duration RPC, and threaded through NotificationParams so server-side notifications (dream, recomp outcomes) respect the configured duration.

  • New RPC endpoint toast-duration lets the TUI fetch and cache toast_duration_ms on startup; a unified showToast helper uses the cached value with per-call override support (durationOverrideMs).
  • create-session-hooks.ts now passes toast_duration_ms into the magic-context hook config so /ctx-dream notifications use the configured duration instead of always falling back to 5 s; a regression test covers this.
  • Restart-required toasts correctly carry durationOverrideMs: 10_000, matching the intent called out in the previous review round.

Confidence Score: 4/5

Safe to merge after addressing the polling retry loop; all core notification paths behave correctly.

The 500 ms message poller fires refreshToastDurationMs() on every tick when the toast duration equals the default value. Because 5000 ms is both the configured default and the error-path fallback, this condition is permanently true for any user who has not overridden the setting — the overwhelming majority. Everything else in the PR (schema, RPC handler, dream notification threading, restart-toast overrides) is straightforward and correct.

packages/plugin/src/tui/index.tsx — the poller's retry guard at line 838

Important Files Changed

FilenameOverview
packages/plugin/src/tui/index.tsxAdds showToast helper, loadToastDurationMs on startup, and unified duration; restart toasts correctly carry durationOverrideMs: 10_000 — but the poller's retry guard fires every 500ms for default-config users
packages/plugin/src/plugin/rpc-handlers.tsAdds toast-duration RPC handler and populates StatusDetail.toastDurationMs; the toastDurationMs field on StatusDetail is computed and transported but never read by any TUI consumer
packages/plugin/src/hooks/magic-context/command-handler.tsAdds toastDurationMs to executeDreaming deps and dreamNotificationParams; correctly threads config value from createMagicContextCommandHandler
packages/plugin/src/plugin/hooks/create-session-hooks.tsThreads toast_duration_ms from pluginConfig into the magic-context hook config; regression test added
packages/plugin/src/shared/rpc-types.tsAdds toastDurationMs field to StatusDetail type with correct documentation
packages/plugin/src/tui/data/context-db.tsAdds loadToastDurationMs() RPC helper; clean implementation with safe fallback

Reviews (9): Last reviewed commit: "fix: thread toast duration through sessi..." | Re-trigger Greptile