Skip to content

Show agent usage freshness and alert on low allowance - #13198

Open
strataga wants to merge 1 commit into
omacom:quattrofrom
strataga:feat/agents-freshness-alerts
Open

strataga wants to merge 1 commit into
omacom:quattrofrom
strataga:feat/agents-freshness-alerts

Conversation

@strataga

Copy link
Copy Markdown

When an agent usage record stops refreshing, the panel still shows its last limits without telling the user how old they are. And when a subscription window or prepaid balance runs low, the user only finds out by opening the panel.

Show the record's update age in the agents panel and bar tooltip, with a stale warning after two refresh intervals (at least 30 minutes). Notify once per shell session when a fresh subscription allowance or funded prepaid balance reaches 10% remaining; the threshold is configurable, and the alert rearms after recovery. Records with a usage error or stale timestamp do not trigger alerts. Synced-only agents use the aggregate update time for freshness.

This leaves the bar percentage and Used/Left display controls to #10175 and #7547, which already propose those features.

Validation: agents-panel-test.sh, plugin-validate-test.sh, manifest-entrypoints-test.sh, qml-text-format-test.sh, git diff --check, and manifest JSON validation pass. I also verified the freshness display in the running Omarchy shell. ./test/all was attempted; unrelated checkout/environment checks fail (read-only runtime lock, missing omarchy-pkgs checkout, and system-path tests). No agents-specific test failed.

@llstrk

llstrk commented Sep 25, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Verified: On a single bar instance, the freshness text and the low-allowance state machine behave as described. The age wording, the stale threshold (the larger of 30 minutes or two refresh intervals), the missing-timestamp and future-clock handling, notify-once with rearm after recovery, the stale/error skip and the prepaid-balance path all match the PR description. The collectors' Python isoformat() timestamps (six-digit fractions, +00:00 offsets) parse correctly in the Qt 6.11.2 QML engine. The omarchy-notification-send argument list matches that helper's parser, with no shell involved.

Two issues are worth addressing: duplicate alerts on multi-monitor setups or after widget re-creation, and a freshness line that reports when the record was written rather than when the usage was measured.

Alerts repeat once per monitor and after widget re-creation

The bar builds one surface per screen (shell/plugins/bar/Bar.qml:1197), and the shell's own comment notes that "a widget that appears once in the layout is still live once per screen" (Bar.qml:694-695). Each agents Panel.qml instance has its own Main, its own notifiedProviders map (Panel.qml:49) and its own onProvidersChanged check (Panel.qml:355). Every instance sees the same record write and calls Quickshell.execDetached itself. omarchy-notification-send sends a new notification on every call, and the notification service does not deduplicate by content.

record write (Claude 8% left)
  ├─ Panel on monitor 1: notifiedProviders = {}  → notify
  └─ Panel on monitor 2: notifiedProviders = {}  → notify   (duplicate)

Any re-creation of the widget also starts from an empty map and alerts again while the provider stays low. By source, this happens on a structural layout change, a horizontal/vertical bar switch, a monitor hotplug (for the new screen's copy) and reloadPlugins(). Settings-only changes, including editing lowRemainingPercent, patch the existing instance and do not reset it. Closing and reopening the popup does not reset it either.

Impact: With the agents widget in the default bar layout, a two-monitor desktop gets two identical "allowance low" toasts per crossing. The README's "once per shell session" holds only for a single instance that is never rebuilt.

Suggested change: Keep updating notifiedProviders in every instance, but send only from one owner, for example the first entry of bar.moduleWidgets(moduleName). The Bluetooth panel already coordinates across monitors this way (shell/plugins/panels/bluetooth/Panel.qml:428-429, :573). To survive rebuilds, keep the ledger outside widget instances (a shared singleton or a small runtime-state file), or reword the README to "once per crossing while the widget is loaded".

"Updated" reflects the record write time, not when usage was measured

The new line reads updatedAt, which each collector stamps with the current time on every write (bin/omarchy-agent-usage-claude:889). For Claude, when the live limits probe fails (offline, HTTP 429, 5xx) and a cached window that has not reset still exists, collect_limits returns the cached limits with an empty usageStatusText (omarchy-agent-usage-claude:840-842). The cache has no age bound other than each window's reset time, so it can be up to 5 hours old for the session window or 7 days for the weekly one.

probe fails → limits = cached (fetched hours or days ago), usageStatusText = ""
record.updatedAt = now → panel: "Updated just now", isStale() = false

The alert in this case is normally still accurate: within a window that has not reset, remaining allowance does not grow, so a cached low reading remains low. The freshness line is what misleads, because it does not flag stale data when the endpoint is unreachable or rate limited, the case where a freshness indicator helps most.

Synced-only providers have a related gap. They fall back to aggregateData.updatedAt (shell/plugins/agents/Main.qml:250), which aggregateSnapshots sets to the local merge time (Main.qml:655) rather than any snapshot's own updatedAt (written at Main.qml:697). A remote device that stopped syncing long ago still shows "Updated just now" while the local shell runs. The PR description states that synced-only agents use the aggregate time. The wording can still suggest the remote data is current.

Impact: The freshness line can report "Updated just now" over Claude limits that were not re-measured, and over synced-only data of any age.

Suggested change: Have the Claude collector emit the probe cache's existing fetchedAtMs as a limits timestamp, and use it for the freshness line and alert eligibility when limits are present. Alternatively, set a status when serving cached limits. For synced-only providers, carry the newest snapshot.updatedAt per provider through the merge, or word the line so it covers local limits only.

Optional: Two smaller behaviors, both traced in source:

  • The flag is per provider, not per window. If the session window alerts and then resets while the weekly window is already below threshold, the weekly state is never announced. Keying the flag on provider plus window would cover this.
  • lowRemainingPercent controls only the toast. The bar icon and limit meters still turn urgent at a fixed 90% used / 10% left (Panel.qml:45-47, :769), so at lowRemainingPercent: 25 a toast fires while the bar still looks normal.

Review information

Test scope: Source review of head 51dcb94f, including the agents plugin, the bar and plugin host code, the usage collectors, omarchy-notification-send, and Qt 6.11.2 and Quickshell 0.3.1 source. One sandboxed probe ran the PR's updatedAgeMs, isStale and freshnessText bodies in Qt 6.11.2's non-GUI QML engine. It covered 10 synthetic timestamp cases, including collector-format strings, the 30-minute boundary, future clock skew and a malformed value. All 10 matched their expected results. The repository's node test was not executed. No running shell, multi-monitor session or notification delivery was tested, so the duplicate-alert and re-creation findings rest on source only.

AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments with targeted follow-up questions, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@jandrusk

jandrusk commented Oct 8, 2026

Copy link
Copy Markdown

Part of this has landed separately: #14225 (merged Oct 4) keeps stale usage visible and puts "Last updated … ago" in the tooltip. The branch also conflicts with quattro now. Could you rebase and narrow it to the low-allowance notification, which isn't covered yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants