Add option for the notification interval
Summary by cubic
Adds a configurable toast duration for Magic Context notifications across the TUI. The TUI loads it via RPC and uses a unified showToast; dream and status flows use the configured duration, with explicit 10s overrides for setup/restart.
-
New Features
- Added
toast_duration_msto config/schema (1000–60000, default 5000ms); documented inCONFIGURATION.mdand exposed in the Dashboard Config Editor. - New
toast-durationRPC; the TUI fetches and caches it on startup and uses a unifiedshowToastwith per-toast overrides. NotificationParamscarriestoastDurationMs; server notifications are queued via RPC and respect the duration.StatusDetailexposestoastDurationMs.
- Added
-
Bug Fixes
- Preserved
toast_duration_msin the session hook config and threaded it throughgetLiveNotificationParamsand command handlers so dream notifications use the configured duration instead of falling back to 5s; added regression test.
- Preserved
Written for commit cfc5a93ac1e6d89b9afb3333b1623baf04166d9f. Summary will update on new commits.
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-durationlets the TUI fetch and cachetoast_duration_mson startup; a unifiedshowToasthelper uses the cached value with per-call override support (durationOverrideMs). create-session-hooks.tsnow passestoast_duration_msinto the magic-context hook config so/ctx-dreamnotifications 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
| Filename | Overview |
|---|---|
| packages/plugin/src/tui/index.tsx | Adds 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.ts | Adds 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.ts | Adds toastDurationMs to executeDreaming deps and dreamNotificationParams; correctly threads config value from createMagicContextCommandHandler |
| packages/plugin/src/plugin/hooks/create-session-hooks.ts | Threads toast_duration_ms from pluginConfig into the magic-context hook config; regression test added |
| packages/plugin/src/shared/rpc-types.ts | Adds toastDurationMs field to StatusDetail type with correct documentation |
| packages/plugin/src/tui/data/context-db.ts | Adds loadToastDurationMs() RPC helper; clean implementation with safe fallback |
Reviews (9): Last reviewed commit: "fix: thread toast duration through sessi..." | Re-trigger Greptile
Thanks for this @kecsap — the implementation is clean and the feature is reasonable. Could you rebase onto current master? Two things have changed since you opened it that will conflict with our CI:
-
Removed config keys.
nudge_interval_tokens,auto_drop_tool_age, anddrop_tool_structurewere removed in the nudge redesign (v0.22.x). YourCONFIGURATION.mdhunks addtoast_duration_msnext to those now-deleted rows, and there's aremoved-config-keys.test.tsguard that scans docs + schema and will fail on any reference to them. Please drop those neighboring lines when you rebase. -
Schema is now generated.
assets/magic-context.schema.jsonis no longer hand-edited — it's generated from the Zod schema viabun packages/plugin/scripts/build-schema.ts. Your Zod change inmagic-context.tsis the right source edit; just run the generator so the committed JSON stays in sync (there's a drift-guard test for this too).
Once rebased + schema regenerated and green, happy to merge. Appreciate the contribution.
There were still problems with the dreamer notifications. It did not honor the new setting. Now, everything is addressed and fixed after rebasing.
Thanks for this — toast_duration_ms is a clean, well-scoped addition and the wiring (schema → toast-duration RPC → TUI cache → unified showToast, plus the dashboard field and a regression test) looks right.
Two things before it can merge, both from the branch having been opened before our v0.23 nudge redesign:
-
Rebase onto
masterand drop the deleted-key lines. YourCONFIGURATION.mdhunk adds thetoast_duration_msrow next tonudge_interval_tokens,auto_drop_tool_age, anddrop_tool_structure— those three config keys were removed in v0.23.x. We have a guard test (removed-config-keys.test.ts) that scans the docs and schema and fails CI on any reference to them, so please remove those neighboring rows when you rebase. -
Generate the schema instead of hand-editing it.
assets/magic-context.schema.jsonis now auto-generated from the Zod schema (there's a drift-guard test that fails if the committed file doesn't match the generator). So rather than editing the JSON directly, add the field toMagicContextConfigSchemainpackages/plugin/src/config/schema/magic-context.tswith a.describe(...), then runbun packages/plugin/scripts/build-schema.tsto regenerate the asset.
After that, bun test in packages/plugin + bunx tsc should be green and we'll merge.
One non-blocking note for later: this is OpenCode-only — Pi delivers toasts via ctx.ui.notify, so full parity would want the duration honored there too. We can handle that as a follow-up; it doesn't hold up this PR.
I rebased the commit. I think these two comments are not relevant anymore after the rebase.
Merged to master (cherry-picked as 2981b810, your authorship preserved). Thank you — this is a genuinely useful knob and a few other users had asked for it.
Two follow-ups on top (commit 4e79d8f4):
toast_duration_ms: 0now disables Magic Context toasts entirely (per a maintainer request) — the schema min is 0, andshowToastskips when the effective duration is non-positive. Explicit positive per-call overrides (e.g. the restart-required toast) still show, so0silences routine notifications without hiding the critical ones.- Reworked the test: the module-level
mock.module("../../hooks/magic-context")leaked process-globally under Bun (itsmock.restore()doesn't undomock.module) and broke 12 assertions inhook.test.tswhen the full suite ran. I extracted a purebuildMagicContextHookConfig()and test that directly instead — same coverage of the toast-duration threading, no global-mock leak.
Closing as merged. Appreciate the contribution.