Skip to content

fix(agents): surface stale usage from record updatedAt (#12849) - #12986

Open
kvnloo wants to merge 3 commits into
omacom:quattrofrom
kvnloo:fix/12849-agents-usage-freshness
Open

kvnloo wants to merge 3 commits into
omacom:quattrofrom
kvnloo:fix/12849-agents-usage-freshness

Conversation

@kvnloo

@kvnloo kvnloo commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #12849.

What changes

The collectors stamp every usage record with updatedAt, but the panel never read it, so a record left behind by a collector that stopped running looked exactly like a live one.

Rebuilt on the redesigned panel (quattro merged in; the old diff targeted the single-provider hero, which no longer exists):

  • displayProvider in Main.qml carries the record's time as updatedAtMs. An agent with no record on this machine (a synced-only agent, a local model) gets 0 and is never aged.
  • A provider section whose record no refresh has rewritten in two refresh intervals (30 minutes at the default 900 s) dims its limits, balance and spend, and shows Last updated 3h 0m ago above them. The caption reuses the existing agents.lastUpdatedAgo string, so every language already has it.
  • The hero is not dimmed: it now sums every agent, so one agent's age doesn't belong there.

What changed from the earlier version, after the reviews from @llstrk and omarchybot:

  • The syncUpdatedAt fallback is gone. That timestamp is set at aggregation time, so it never showed an offline machine's data as old. Synced-only agents get no section in the new panel anyway; they only feed the hero summary.
  • The age describes the numbers it sits beside. A section shows only per-account data (limits, plan, balance, spend), which comes from the local record. The token and activity numbers that come from other machines stay in the hero and are not dimmed.
  • This is separate from limitsStale. A failed check still rewrites the record and keeps its note and hover age. This caption is for a collector that stopped writing completely, which nothing else shows.
  • The timestamp is parsed once, in Main.qml, and the test runs the real functions instead of matching source text.

Verification

  • bash test/shell.d/agents-panel-test.sh, extended in place: it builds displayProvider from Main.qml and checks that the collector's microsecond ISO stamp becomes updatedAtMs (0 with no stamp). It also checks recordOutdated from Panel.qml at 29 min (current) and 31 min (outdated) with the 900 s interval, at 11 min with a 300 s interval, and that a line with no record is never outdated.
    • quattro cdd18b2 plus the new test: fails (not ok - a line carries when its collector wrote the record).
    • This head f6daae8: passes.
    • Removal controls at this head: dropping the updatedAtMs line from displayProvider fails on the same assertion, and making recordOutdated return false fails on a record two refreshes old is outdated.
  • bash test/shell.d/i18n-test.sh passes (no catalog change).
  • QV4 (Qt 6.12.0 qml, offscreen): recordUpdatedAtMs gives 1795543200123 for 2026-11-24T18:00:00.123456+00:00 (the collectors' isoformat() form), the same as Date.UTC(...) for that instant. It also handles +00:00 without a fraction, and gives 0 for empty and invalid strings.
  • Running UI: the branch's shell (Quickshell 0.3.2, Qt 6.12, Arch) under headless sway, with two records: Claude written 3 hours ago, Codex 2 minutes ago. The collectors were stubbed so they wouldn't overwrite the records. The panel was opened through omarchy-shell shell summon omarchy.agents and captured with grim. The same records on quattro show both agents the same. Not checked: Hyprland itself (sway stood in for it), a real collector stopping, or the sync folder.

Screenshots

Before (quattro cdd18b2): Claude's record is 3 hours old and looks the same as Codex's live one.

Agents panel on quattro

After (f6daae8): Claude's limits are dimmed under Last updated 3h 0m ago; Codex is unchanged.

Agents panel at this head

Credit

Prepared by Claude Opus 5.5 via Hermes Agent; reviewed under kvnloo's account.

Copy per-record updatedAt into the display model and dim/label panels
older than two refresh cycles so frozen collector files are visible.
@llstrk

llstrk commented Sep 23, 2026

Copy link
Copy Markdown

Verified: The local-record freshness path is now connected: displayProvider forwards the collector timestamp, and the panel uses it to select a dimmed hero and an Updated … ago caption after two refresh intervals (30 minutes by default). One gap remains for synced-only providers.

Synced-only freshness measures the local scan, not the remote data

The new fallback in Panel.qml reads syncUpdatedAt. However, aggregateSnapshots() assigns that timestamp from the current local clock, not from the snapshots being merged.

Source-traced case: remote-only provider, remote writer offline
Old remote snapshot + continuing local scans
  -> aggregate timestamp becomes "now" on each scan
  -> synced-only tab uses that timestamp
  -> no stale caption while scans stay within the threshold

Impact: Old remote usage totals still look current in the offline-machine case mentioned in #12849. This is a remaining freshness gap, not a regression in aggregation. Synced-only tabs do not carry account rate limits or balances, so the impact here is limited to synced usage statistics.

Suggested change: Carry source freshness through the sync model and derive the provider's age from contributing snapshots, with an explicit policy for mixed-age contributors. Alternatively, scope this change to local-record freshness and explicitly document that the aggregate-time fallback does not detect an offline remote writer.


Review information

Test scope: Pinned head c44b9d9. Source tracing covered the local and synced-only display paths. Extracted timestamp helpers were also checked in a core-only Qt 6.11.2 QML engine with synthetic timestamps under three timezones. The complete panel, visual layout, live collectors and cross-device sync were not run; the PR's source-regex test was not independently rerun.

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

Automated AI review: Astra Medium performed initial inspection and synthesis; Opus 5.5 High and GPT 6 Sol Xhigh completed separate independent technical assessments. The final claims were checked against pinned source and targeted evidence.

@sanjyay

sanjyay commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested in the Omarchy VM (Omarchy 4.0.4 / Quickshell 0.3.1):

  • Freshness logic verified: Evaluated under Quickshell's QV4 engine with synthetic agent usage records (fresh, 2-hour-old, 2-day-old, and missing timestamps). Confirmed that:
    • Fresh records within the two-cycle threshold (2 * refreshIntervalSec, default 30m) maintain normal 1.0 opacity and no extra caption.
    • Stale records older than the threshold are dimmed (opacity: 0.65) and display the Updated <duration> ago caption (e.g., Updated 2h ago, Updated 2d ago).
    • Both numeric updatedAtMs and ISO string updatedAt stamps parse reliably under QV4.
  • Test suite: bash test/shell.d/agents-panel-test.sh passed all 16 assertions.

Works as expected!

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at c44b9d9 against quattro at d9b970d. #12849 is still real on quattro: displayProvider in shell/plugins/agents/Main.qml never copies the record's updatedAt, and nothing in the panel shows a record's age. The limitsStale / limitsFetchedAt hover added since (#14225) is a different signal: it marks a failed limits probe, so a collector that simply stops writing after a good run still looks current.

This branch no longer merges, though, and the conflict is not mechanical. Since this was opened, quattro redesigned Panel.qml: the hero is now an "Agents" summary across every provider, each provider is its own section, and there is no root.provider at the panel root any more. The dimmed hero and the caption under it have nowhere to go as written, and quattro also states a convention this would cut across: "The age of numbers kept past a failed check is shown only on hover" (Panel.qml, the CompactLimit component, pinned by test/shell.d/agents-panel-test.sh). Where a stale record's age shows up in the new panel (per section, in the hover, always visible or not) is a design choice, so no fix was pushed to this branch.

Two things to carry into whatever shape it takes:

  • Synced-only tabs never go stale. The fallback reads syncUpdatedAt, but aggregateSnapshots() stamps the aggregate with new Date() on every local scan, so an offline machine's old snapshot keeps looking fresh for as long as this machine scans. That is the offline-machine case Agents panel renders an arbitrarily stale usage record identically to a live one (per-record updatedAt is never read) #12849 describes; @llstrk's comment above found the same.
  • The age can describe the wrong data. For a synced provider, the token and activity numbers come from the aggregate while the age comes only from the local record, so a stopped local writer dims numbers that other machines are keeping current.

Smaller points: providerUpdatedAtMs in Panel.qml repeats the parsing recordUpdatedAtMs already did in Main.qml, and the new tests match source text, so they would still pass if providerIsStale always returned false.

What was checked: the diff, quattro's current plugin, and a trial merge, all read on the coordinator. Nothing ran on a worker, because this head cannot land and verifying the UI it targets would prove a panel that no longer exists. The second opinion, Codex Medium, reviewed the same questions separately and agreed on each point. It also contributed the mixed-source point above. Independence is not guaranteed.

Next step: the maintainer decides how a stale record should look in the current panel. After that, this needs porting onto quattro.

displayProvider now carries when the collector last wrote the record
(updatedAtMs). A panel section whose record no refresh has rewritten in
two refresh intervals dims its limits, balance and spend, and shows
"Last updated ... ago" above them.

Fixes omacom#12849
@kvnloo

kvnloo commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

I merged quattro in and rebuilt this on the redesigned panel. It's now at f6daae8: merge commit a4db62a (no rebase), then one port commit.

The age now sits on the provider section, not the hero, because the hero sums every agent. A section whose record no refresh has rewritten in two refresh intervals dims its limits, balance and spend and shows Last updated … ago above them. That string was already in the catalog, so it needed no new translations. The syncUpdatedAt fallback is gone, so the offline-machine and mixed-source points above no longer apply. Synced-only agents get no section, and a section shows only data from the local record.

Checked:

  • agents-panel-test.sh now runs the real displayProvider/recordOutdated code. It fails on quattro cdd18b2, passes at f6daae8, and fails again with either half removed.
  • In Qt 6.12's QV4, the collectors' microsecond ISO stamp parses correctly.
  • The branch's shell ran under headless sway with a 3-hour-old record. Before/after screenshots are in the description.

Prepared by Claude Opus 5.5 via Hermes Agent; reviewed under kvnloo's account.

@greptile-apps

greptile-apps Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were established.

Summary

The panel now reads each local record’s updatedAt and marks records older than two configured refresh intervals.

  • Old agent usage now shows its age in the panel.

Reviews (1) · Last reviewed commit: "Dim an agent's numbers once its usage re..." · Reviewed by Greptile

@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 25, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Checked f6daae8a8655c0e11f8c0ac500ba4ccdeb54f134 against quattro at a3bad0b1b7eb50e9913b4c616cf87cdec6f56931. The port keeps the age beside the local account numbers it describes, and the earlier layout, mixed-source age and duplicate-parser findings are resolved.

On a disposable ISO worker running this branch under Hyprland, a three-hour-old local record gained its age caption and dimmed limits while a fresh record stayed unchanged. Current quattro showed both as current. Reverting the two QML files brought the bug back. The CLI suite passed, and all 87 Agents panel checks passed; the reverted implementation failed the timestamp assertion, and restoring the exact head restored all 87 passes.

GPT-6 High in Codex, Opus 5.5 High and muse-wonder via pi (thinking high) checked this head. Both second opinions found no actionable defect; independence is not guaranteed. They also traced the collector's fresh timestamp through cached scans and checked that account lines inherit it. This verifies local record freshness; live endpoints and cross-device sync were not exercised, and hero/synced statistics remain outside this freshness signal. No branch changes were needed. Waiting on maintainer review.

Before on quattro: old Claude limits appear current beside fresh Codex limits

After at this head: old Claude limits show their age and dim; fresh Codex limits stay unchanged

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

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agents panel renders an arbitrarily stale usage record identically to a live one (per-record updatedAt is never read)

4 participants