feat: add usage alerts before session resets#446
feat: add usage alerts before session resets#446fathiraz wants to merge 5 commits intorobinebers:mainfrom
Conversation
add desktop notification when your near the usage limit before it reset. pick from threshold presets or set custom value, choose alert sound too. support claude, codex, kimi, minimax, opencode go, zai plugins. add tauri notification plugin for cross-platform alerts. tests included for settings and bootstrap.
There was a problem hiding this comment.
3 issues found across 21 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/lib/settings.ts">
<violation number="1" location="src/lib/settings.ts:360">
P2: `isUsageAlertThreshold` accepts `25`, which is not in `UsageAlertThreshold`; this makes the type guard unsound and can return an invalid threshold from `loadUsageAlertThreshold`.</violation>
</file>
<file name="src/hooks/app/use-usage-alert.ts">
<violation number="1" location="src/hooks/app/use-usage-alert.ts:54">
P2: Marks the provider as notified before the async notification completes, so failed notification attempts are never retried.</violation>
</file>
<file name="src-tauri/src/plugin_engine/manifest.rs">
<violation number="1" location="src-tauri/src/plugin_engine/manifest.rs:112">
P1: Icon path is canonicalized and read without any plugin-directory containment check, enabling reads of files outside the plugin directory.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
|
@codex review |
There was a problem hiding this comment.
Pull request overview
Adds a cross-platform “Usage Alerts” feature that triggers a desktop notification when a provider’s session usage drops below a configured remaining-% threshold, with settings for enablement, threshold presets/custom value, and notification sound. This integrates into the existing probe/update flow so alerts can fire as fresh usage data is fetched.
Changes:
- Added new persisted preferences for usage alerts (enabled, threshold preset/custom, sound) and bootstrapped them on app start.
- Introduced a
useUsageAlerthook wired into probe results to send Tauri desktop notifications (optionally with provider icon attachment). - Extended plugin metadata to include an icon file path (in addition to the existing icon data URL) and enabled the Tauri notification plugin/capability.
Reviewed changes
Copilot reviewed 20 out of 22 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/stores/app-preferences-store.ts | Adds usage alert preferences + setters to the preferences store. |
| src/pages/settings.tsx | Adds “Usage Alerts” settings UI + test notification button. |
| src/lib/settings.ts | Defines alert types/options/defaults; adds load/save helpers for new settings. |
| src/lib/settings.test.ts | Updates PluginMeta fixtures for new iconFilePath field. |
| src/lib/plugin-types.ts | Extends PluginMeta with iconFilePath. |
| src/hooks/app/use-usage-alert.ts | New hook to evaluate usage and trigger desktop notifications. |
| src/hooks/app/use-settings-display-actions.ts | Adds persistence/actions for usage alert settings. |
| src/hooks/app/use-settings-bootstrap.ts | Loads usage alert settings during bootstrap and populates state. |
| src/hooks/app/use-settings-bootstrap.test.ts | Updates mocks/fixtures to cover new settings + iconFilePath. |
| src/hooks/app/use-probe.ts | Updates onProbeResult callback to receive PluginOutput. |
| src/hooks/app/use-probe-state.ts | Passes probe output to onProbeResult. |
| src/components/app/app-content.tsx | Plumbs usage alert props through to Settings page. |
| src/App.tsx | Wires probe results into useUsageAlert and passes settings handlers. |
| src/App.test.tsx | Updates plugin meta fixtures for new iconFilePath field. |
| src-tauri/src/plugin_engine/runtime.rs | Updates test fixture for new loaded plugin field. |
| src-tauri/src/plugin_engine/manifest.rs | Canonicalizes/validates icon path and stores it on loaded plugin. |
| src-tauri/src/lib.rs | Exposes icon_file_path to frontend; initializes notification plugin. |
| src-tauri/Cargo.toml | Adds tauri-plugin-notification. |
| src-tauri/Cargo.lock | Locks new notification dependency tree. |
| src-tauri/capabilities/default.json | Enables notification:default capability. |
| package.json | Adds @tauri-apps/plugin-notification. |
| bun.lock | Locks new JS notification dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| async function sendNotificationAsync(payload: Parameters< | ||
| typeof import("@tauri-apps/plugin-notification").sendNotification | ||
| >[0]) { | ||
| const { sendNotification } = await import("@tauri-apps/plugin-notification") | ||
| return sendNotification(payload) | ||
| } |
855dfe2 to
da7d302
Compare
- Move sendNotificationAsync into src/lib/notification.ts - Fix duplicate alert bug by marking provider notified on error
* main: chore: bump version to 0.6.23 chore(analytics): drop UI-side Aptabase events (robinebers#449) fix(claude): remove peak hours indicator integration (robinebers#447)
|
not sure about this one. we're not tracking usage in real time. the thresholds are set specifically to avoid hammering the providers' endpoints. if the data isn't guaranteed to be current sending alerts feels misleading. a late notification is worse than no notification imo |
fair concern @validatedev . the non realtime data definitely makes this less reliable than i initially thought would you be open to keeping it as an experimental opt-in feature with clear disclaimers? or do you think its better to just close this? either way works for me, since i dont want to push something that doesnt fit the apps philosophy |
Description
Related Issue
#326
Type of Change
Testing
I ran
bun run buildand it succeededI ran
bun run testand all tests passI tested the change locally with
bun tauri devScreenshots
Claude below threshold
Settings - default
Settings - enabled
Settings - with custom percentage
Settings - change sound notification
Settings - clicked button send test notification
Checklist
mainbranchSummary by cubic
Add usage alerts that notify you before a session limit resets. Choose presets or a custom %, pick a sound, and get cross-platform desktop notifications via
@tauri-apps/plugin-notification/tauri-plugin-notificationfor Claude, Codex, Kimi, MiniMax, OpenCode Go, and Zai.New Features
Bug Fixes
Written for commit b54acba. Summary will update on new commits.