Add option for the notification interval#92
Conversation
There was a problem hiding this comment.
1 issue found across 10 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
There was a problem hiding this comment.
No issues found across 10 files
Tip: cubic could auto-approve low-risk PRs like this, if it thinks it's safe to merge. Learn more
Re-trigger cubic
| onConfirm={() => { | ||
| api.ui.toast({ message: "Restart OpenCode to enable Magic Context", variant: "warning", duration: 10000 }) | ||
| showToast(api, { message: "Restart OpenCode to enable Magic Context", variant: "warning" }) |
There was a problem hiding this comment.
"Restart required" toasts silently dropped their 10-second override
Both the "Restart OpenCode to enable Magic Context" (line 125) and "Restart OpenCode to see the sidebar" (line 174) toasts previously used duration: 10000. This PR replaces them with showToast calls that carry no durationOverrideMs, so they now use whatever the user configured. At the minimum allowed value of 1000 ms the toast will vanish before most users finish reading the restart instruction, effectively making the post-fix/post-setup call-to-action invisible. Other latency-sensitive toasts in this file were correctly preserved with explicit durationOverrideMs (e.g. "Recomp cancelled" → 3000, "Upgrade skipped" → 4000); these two should be treated similarly with durationOverrideMs: 10000.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| pushNotification( | ||
| "action", | ||
| { | ||
| action: "show-status-dialog", | ||
| toast_duration_ms: deps.toastDurationMs ?? 5000, | ||
| }, | ||
| sessionId, | ||
| ); | ||
| sessionLog( | ||
| sessionId, | ||
| `command ctx-status: pushed show-status-dialog to TUI (toast_duration_ms=${String( | ||
| deps.toastDurationMs ?? 5000, | ||
| )})`, | ||
| ); |
There was a problem hiding this comment.
The
toast_duration_ms field added to the show-status-dialog action payload is never read by the TUI message handler. When the TUI receives an action message it only reads msg.payload?.action, msg.payload?.resume, etc. — there is no code path that extracts toast_duration_ms from an action payload. The TUI already loads the authoritative duration via loadToastDurationMs() on startup, so the payload field is dead and the log line creates a false impression that the duration propagates per-action.
| pushNotification( | |
| "action", | |
| { | |
| action: "show-status-dialog", | |
| toast_duration_ms: deps.toastDurationMs ?? 5000, | |
| }, | |
| sessionId, | |
| ); | |
| sessionLog( | |
| sessionId, | |
| `command ctx-status: pushed show-status-dialog to TUI (toast_duration_ms=${String( | |
| deps.toastDurationMs ?? 5000, | |
| )})`, | |
| ); | |
| pushNotification( | |
| "action", | |
| { | |
| action: "show-status-dialog", | |
| }, | |
| sessionId, | |
| ); | |
| sessionLog( | |
| sessionId, | |
| "command ctx-status: pushed show-status-dialog to TUI", | |
| ); |
Summary by cubic
Adds a configurable toast duration for Magic Context notifications across the TUI. The TUI loads a unified duration from config via RPC and uses a single
showToasthelper with per-toast overrides.New Features
toast_duration_msto config/schema (1000–60000, default 5000ms); documented in CONFIGURATION.md.toast-durationRPC; TUI loads and caches the unified duration on startup.api.ui.toast()calls with ashowToasthelper; removed hardcoded durations.NotificationParamsnow includestoastDurationMs; duration is forwarded viapushNotificationtoasts,send-session-notification, and theshow-status-dialogaction payload (toast_duration_ms).StatusDetailincludestoastDurationMsfor visibility.Migration
toast_duration_msin your config to adjust TUI toast lifetime. Defaults to 5000ms.Written for commit ba38b8a. Summary will update on new commits.
Greptile Summary
This PR introduces a configurable
toast_duration_mssetting (1000–60000 ms, default 5000) that flows from the Zod schema through a newtoast-durationRPC into a module-levelunifiedToastDurationMsvariable in the TUI, applied via a newshowToasthelper. The server-side notification path is also updated to carrytoastDurationMsthroughNotificationParamsso server-pushed toasts honour the same configured duration.toast_duration_msis added toMagicContextConfigSchemawith correct min/max/default constraints, exposed via a dedicatedtoast-durationRPC handler and surfaced inStatusDetail.api.ui.toast()calls are replaced withshowToast(api, {...}), which readsunifiedToastDurationMs(loaded on startup) unless adurationOverrideMsis supplied per-call.toastDurationMsis added toNotificationParamsand propagated throughgetLiveNotificationParams, hook wiring, andexecuteDreamingso server-side notifications carry the configured duration to the TUI poller."Confidence Score: 5/5
Safe to merge; all toast paths default to 5000 ms and the schema enforces the 1000–60000 ms bounds.
The config plumbing is consistent end-to-end and the fallback to 5000 ms at every layer means the feature degrades gracefully if the RPC call fails at startup. The two flagged observations are style and minor logic concerns that do not affect runtime correctness.
packages/plugin/src/hooks/magic-context/send-session-notification.ts — the catch block reachability assumption changed silently with the refactor.
Important Files Changed
unifiedToastDurationMsloaded at startup,showToasthelper that respects per-calldurationOverrideMs, and migrates all directapi.ui.toast()calls to use the helper.tui.showToast()SDK call withpushNotification()queue; usesparams.toastDurationMsfor duration. Thecatchblock now only guards against a dynamic import failure that is practically impossible after the same module was already imported and used two lines above.toastDurationMsto deps forexecuteDreamingandcreateMagicContextCommandHandler; threads the value into notification params. JSDoc on the new field inaccurately describes it as "forwarded into diagnostics logs" when its primary use is populatingNotificationParams.deps.config.toast_duration_msinto fourgetLiveNotificationParamscall-sites and the command handler; additions are symmetric and correct.toast-durationRPC handler returning resolved config value, exposestoastDurationMsinStatusDetailviabuildStatusDetail, and threads config value intogetLiveNotificationParams.toast_duration_ms(1000–60000 ms, default 5000) to config interface and Zod schema with correct min/max/default constraints.toastDurationMs: numberfield toStatusDetailinterface; straightforward type addition.loadToastDurationMs()helper that calls thetoast-durationRPC and returns the resolved value or falls back to 5000; also seeds the emptyStatusDetaildefault withtoastDurationMs: 5000.toastDurationMstogetLiveNotificationParamssignature and spreads it into the result object only when defined; clean conditional spread.{ toastDurationMs: 5000 }in notification params, matching the new default-fallback behavior.toast_duration_msfield with its range and default, and adds an example value to the sample config block.Reviews (3): Last reviewed commit: "Add option for the notification interval" | Re-trigger Greptile