Repository navigation
Split agent usage into data files and rename the plugin to omarchy.agents - #6603
Conversation
One omarchy-agent-usage-scan-<agent> collector per AI coding agent prints a complete display-ready usage record — identity, tier, status, rate limits, and today/week/all-time stats. omarchy-agent-usage-update runs every collector it finds and writes the records atomically to ~/.local/state/omarchy/agents/usage/, so anything that displays usage only ever reads JSON from there. The Claude collector absorbs what the shell previously did in-process: transcript scanning, the stats-cache/history fallback, credentials parsing, and the OAuth limits probe, now with a probe throttle and last-good limits kept across network failures. The Codex collector is the existing scanner reshaped to the shared record contract. Co-Authored-By: Claude Fable 5 <[email protected]>
The panel is now strictly a display. It discovers the JSON records that omarchy-agent-usage-update maintains under ~/.local/state/omarchy/agents/usage/, watches them for changes, and draws whatever appears — so adding an agent means shipping a collector, never touching the panel. Marks resolve by convention (assets/<id>.svg with an optional -light twin), the limits meters read a generic limits array, and the per-provider QML adapters and in-plugin scanner scripts are gone. Cross-device sync aggregation stays in the shell and keeps the snapshot field names older versions wrote, so mixed-version fleets still merge in both directions. With the provider fan-out gone, the widget takes its real name: the plugin id becomes omarchy.agents. A migration renames it wherever a user's config mentions it — layout entries keep their settings and position, a disabled widget stays disabled — then primes the data files once and drops the old scanner cache. The migration test also drops a stale assertion that expected migrations to restart the shell themselves, which c992cdf moved to omarchy update. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Renames the model-usage plugin to omarchy.agents and separates agent data collection from QML presentation.
Changes:
- Adds generic agent collectors and atomic usage-record generation.
- Refactors the panel to discover and display agent JSON records.
- Adds migration, configuration, documentation, and test updates.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 20 out of 27 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
bin/omarchy |
Registers the agent command group. |
bin/omarchy-agent-usage-update |
Runs collectors and writes records. |
bin/omarchy-agent-usage-scan-claude |
Adds Claude usage collection. |
bin/omarchy-agent-usage-scan-codex |
Adapts Codex to the shared record format. |
config/omarchy/shell.json |
Uses the renamed widget ID. |
migrations/1785344985.sh |
Updates the default-widget migration. |
migrations/1786099804.sh |
Migrates existing widget configuration. |
shell/README.md |
Documents the renamed directory. |
shell/plugins/README.md |
Updates the plugin registry documentation. |
shell/plugins/bar/README.md |
Updates bar widget references. |
shell/plugins/agents/README.md |
Documents the record-based architecture. |
shell/plugins/agents/Agent.qml |
Watches one agent record. |
shell/plugins/agents/Main.qml |
Discovers, refreshes, and synchronizes records. |
shell/plugins/agents/Panel.qml |
Displays generic limits and marks. |
shell/plugins/agents/manifest.json |
Renames and simplifies plugin settings. |
shell/plugins/agents/assets/claude.svg |
Adds the Claude mark. |
shell/plugins/agents/assets/codex.svg |
Adds the dark-surface Codex mark. |
shell/plugins/agents/assets/codex-light.svg |
Adds the light-surface Codex mark. |
shell/plugins/model-usage/providers/Claude.qml |
Removes provider-specific Claude QML. |
shell/plugins/model-usage/providers/Codex.qml |
Removes provider-specific Codex QML. |
shell/plugins/model-usage/scripts/claude_usage_scanner.py |
Removes the embedded Claude scanner. |
test/shell.d/agent-usage-update-test.sh |
Tests collector orchestration. |
test/shell.d/agent-usage-claude-scanner-test.sh |
Tests Claude records and token totals. |
test/shell.d/agent-usage-codex-scanner-test.sh |
Tests Codex records and token totals. |
test/shell.d/agents-default-migration-test.sh |
Updates default migration expectations. |
test/shell.d/agents-rename-migration-test.sh |
Tests rename migration behavior. |
test/shell.d/fixtures/bar-widget-contract/shell.qml |
Tests convention-based icon resolution. |
Suppressed comments (1)
shell/plugins/agents/Main.qml:163
- This only iterates agents that have a local usage file. If an agent exists solely in a synced device's snapshot, it never reaches
displayProvider, so the documented “on this machine or on a synced one” behavior is lost. Build the display list from the union of local record IDs andaggregateData.providersIDs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Three data-availability gaps from review. An agent whose records only exist in synced snapshots — a collector installed on just one machine — now gets its tab by unioning the synced aggregate into the provider list, with rate limits blank since those never travel. A Claude limits probe that reaches no server at all writes retryAdvised into its record, and the shell honors it with one 30-second retry instead of waiting out the full refresh interval, restoring the old boot-before-DHCP behavior. And a machine with only history.jsonl — no transcripts, no stats-cache — still reports today's prompt and session counts. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 28 changed files in this pull request and generated no new comments.
Suppressed comments (2)
shell/plugins/agents/Main.qml:212
- History-only Claude records have nonzero
todayPrompts/todaySessionsbut zero all-time counters, so this predicate hides the agent entirely despite the collector successfully reporting today's usage. Include current-day values when deciding whether an agent has displayable data.
migrations/1786099804.sh:35 - The removed scanner stored its cache under
${XDG_CACHE_HOME:-$HOME/.cache}, but this only deletes the default location. Users withXDG_CACHE_HOMEconfigured retain the obsolete cache, contrary to the migration's cleanup goal. Remove it from the same resolved cache root the scanner used.
rm -rf "$HOME/.cache/omarchy/model-usage"
Today's prompt and session counts now count toward an agent's presence in the bar, so a machine whose only Claude source is history.jsonl shows up without waiting for limits. And the 30-second limits retry passes the advising agent ids to the updater, so an outage at one provider no longer puts every other collector on a retry treadmill. Co-Authored-By: Claude Fable 5 <[email protected]>
jq ships in the default package set, which makes it a runtime invariant per AGENTS.md — call it directly. The migration tests lose their now-unused omarchy-cmd-present stubs with it. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 28 changed files in this pull request and generated no new comments.
Suppressed comments (2)
shell/plugins/agents/Main.qml:164
- Queued targeted retries lose
agentIds: the exit handler later callsrunUpdate(kind)with no IDs. If the 30-second retry fires while another update is running, the queued--limits-onlyrun invokes every enabled collector, contradicting the targeted-retry behavior and causing unnecessary provider requests. Preserve the queued request's agent list along with its kind.
migrations/1786099804.sh:35 - The retired scanner stored its cache under
XDG_CACHE_HOME, but this only removes the default~/.cachepath. Users with a custom cache home keep the obsolete cache indefinitely, so the migration does not fully perform its advertised cleanup.
rm -rf "$HOME/.cache/omarchy/model-usage"
Collectors are omarchy-agent-usage-<agent>; the updater skips its own name when globbing them, and the update test proves it with a decoy. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 28 changed files in this pull request and generated no new comments.
Suppressed comments (1)
shell/plugins/agents/Main.qml:165
- When the targeted 30-second limits retry fires during another update, only
kindis queued;agentIdsis discarded.onExitedsubsequently callsrunUpdate(kind)without IDs, so every enabled collector runs, contrary to the targeted-retry behavior and potentially putting unrelated collectors on the retry cadence. Preserve the pending ID list alongside the pending kind (while clearing it for a queued full refresh).
The Claude collector now reads .credentials.json once into three scalars — the access token, its expiry, and the plan label — instead of passing the parsed store around. The token reaches nothing but the Authorization header of the limits probe, and only the plan label may travel into the record, which is what CodeQL's clear-text-logging alert on the record print was unable to see when the whole dict flowed through. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 28 changed files in this pull request and generated no new comments.
Suppressed comments (1)
shell/plugins/agents/Main.qml:165
- A targeted limits retry queued while another update is running loses its
agentIds;onExitedlater callsrunUpdate(kind)without them. This reruns every enabled collector, and Codex ignores--limits-onlyand rescans sessions, defeating the stated per-provider retry behavior. Store the pending IDs together with the pending kind and replay both.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 28 changed files in this pull request and generated no new comments.
Suppressed comments (3)
shell/plugins/agents/Main.qml:147
- Invoke this repository command through
OMARCHY_PATH. The runtime convention requires commands inbin/to use$OMARCHY_PATH/Quickshell.env("OMARCHY_PATH")(AGENTS.md:48-51); resolving it only throughPATHcan leave every panel refresh unable to regenerate records in shell sessions without the Omarchy bin directory exported.
shell/plugins/agents/Main.qml:136 - Preserve the targeted agent IDs when queuing a limits retry. If the 30-second retry fires while another update is running, only
pendingUpdateKindis retained and line 136 rerunslimitswithout IDs, so all enabled collectors execute despite the stated targeted-retry behavior. Queue the IDs alongside the kind (or explicitly broaden only when a higher-priority full refresh supersedes it).
shell/plugins/agents/Main.qml:222 - Include token-only activity in the visibility predicate. Under the documented generic contract, a conforming external record may provide
todayTotalTokenswithout prompt/session counters; this predicate then hides the agent even though the panel has usage to display. Treat a positive token total as data.
…ents (omacom#6603) * Add agent usage collectors that write display-ready data files One omarchy-agent-usage-scan-<agent> collector per AI coding agent prints a complete display-ready usage record — identity, tier, status, rate limits, and today/week/all-time stats. omarchy-agent-usage-update runs every collector it finds and writes the records atomically to ~/.local/state/omarchy/agents/usage/, so anything that displays usage only ever reads JSON from there. The Claude collector absorbs what the shell previously did in-process: transcript scanning, the stats-cache/history fallback, credentials parsing, and the OAuth limits probe, now with a probe throttle and last-good limits kept across network failures. The Codex collector is the existing scanner reshaped to the shared record contract. Co-Authored-By: Claude Fable 5 <[email protected]> * Redo the model-usage plugin as omarchy.agents watching usage data files The panel is now strictly a display. It discovers the JSON records that omarchy-agent-usage-update maintains under ~/.local/state/omarchy/agents/usage/, watches them for changes, and draws whatever appears — so adding an agent means shipping a collector, never touching the panel. Marks resolve by convention (assets/<id>.svg with an optional -light twin), the limits meters read a generic limits array, and the per-provider QML adapters and in-plugin scanner scripts are gone. Cross-device sync aggregation stays in the shell and keeps the snapshot field names older versions wrote, so mixed-version fleets still merge in both directions. With the provider fan-out gone, the widget takes its real name: the plugin id becomes omarchy.agents. A migration renames it wherever a user's config mentions it — layout entries keep their settings and position, a disabled widget stays disabled — then primes the data files once and drops the old scanner cache. The migration test also drops a stale assertion that expected migrations to restart the shell themselves, which c992cdf moved to omarchy update. Co-Authored-By: Claude Fable 5 <[email protected]> * Address Codex review: synced-only tabs, limits retry, history fallback Three data-availability gaps from review. An agent whose records only exist in synced snapshots — a collector installed on just one machine — now gets its tab by unioning the synced aggregate into the provider list, with rate limits blank since those never travel. A Claude limits probe that reaches no server at all writes retryAdvised into its record, and the shell honors it with one 30-second retry instead of waiting out the full refresh interval, restoring the old boot-before-DHCP behavior. And a machine with only history.jsonl — no transcripts, no stats-cache — still reports today's prompt and session counts. Co-Authored-By: Claude Fable 5 <[email protected]> * Address second Codex pass: history-only visibility, targeted retries Today's prompt and session counts now count toward an agent's presence in the bar, so a machine whose only Claude source is history.jsonl shows up without waiting for limits. And the 30-second limits retry passes the advising agent ids to the updater, so an outage at one provider no longer puts every other collector on a retry treadmill. Co-Authored-By: Claude Fable 5 <[email protected]> * Drop omarchy-cmd-present jq guards from the agents migrations jq ships in the default package set, which makes it a runtime invariant per AGENTS.md — call it directly. The migration tests lose their now-unused omarchy-cmd-present stubs with it. Co-Authored-By: Claude Fable 5 <[email protected]> * Drop the scan infix from the collector command names Collectors are omarchy-agent-usage-<agent>; the updater skips its own name when globbing them, and the update test proves it with a decoy. Co-Authored-By: Claude Fable 5 <[email protected]> * Keep the credential store out of the printed usage record The Claude collector now reads .credentials.json once into three scalars — the access token, its expiry, and the plan label — instead of passing the parsed store around. The token reaches nothing but the Authorization header of the limits probe, and only the plan label may travel into the record, which is what CodeQL's clear-text-logging alert on the record print was unable to see when the whole dict flowed through. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>
Summary
The model-usage plugin becomes
omarchy.agents, and the data that powers it is separated from how it's extracted. The panel now only watches one JSON record per agent under~/.local/state/omarchy/agents/usage/; a separate process generates those files. Adding an agent never touches the panel again.omarchy-agent-usage-update(omarchy agent usage update): runs everyomarchy-agent-usage-<agent>collector inbin/, validates the JSON, and writes the records atomically.--forcebypasses caches,--limits-onlyreuses recent scans,--except/positional args filter agents.Claude.qmldid in-process — transcript scanning, stats-cache/history fallback, credentials parsing, and the OAuth limits probe (now urllib with a 15s throttle, last-good limits kept across network failures, and a 30-second targeted retry when the endpoint is unreachable at the transport level). The Codex collector is the old scanner reshaped to the shared record contract.CLAUDE_CONFIG_DIR/CODEX_HOMEreplace the per-path settings.Main.qmldiscovers records, instantiates a generic file-watchingAgent.qmlper file, and runs the update command on its refresh timer (--limits-onlyon panel open,--forceon explicit refresh). The per-provider QML adapters and in-plugin scripts are gone. Limits render from a genericlimitsarray; marks resolve by convention (assets/<id>.svg, optional-lighttwin, bar glyph fallback).omarchy.model-usage→omarchy.agentswherever a user's config mentions it — layout entries keep their settings and position, a disabled widget stays disabled — then the data files are primed once and the old scanner cache dropped.Adding an agent
One file: an executable
bin/omarchy-agent-usage-<id>that prints a single JSON record to stdout. The updater globsomarchy-agent-usage-*, so the next refresh writes~/.local/state/omarchy/agents/usage/<id>.json, the panel discovers the file, and the tab appears as soon as the record has data. No manifest change, no QML, no settings, no registration anywhere.{ "schemaVersion": 1, "id": "gemini", "name": "Gemini CLI", "ready": true, "tierLabel": "Pro", "usageStatusText": "", "authHelpText": "Run `gemini auth` to authenticate.", "limits": [{ "label": "Session (5-hour)", "percent": 0.37, "resetsAt": "ISO-8601" }], "todayPrompts": 0, "todaySessions": 0, "todayTotalTokens": 0, "todayTokensByModel": { "gemini-3-pro": 12345 }, "recentDays": [{ "date": "2026-08-07", "messageCount": 12345 }], "totalPrompts": 0, "totalSessions": 0, "activeDays": 0, "activeDates": ["2026-08-07"], "modelUsage": { "gemini-3-pro": { "inputTokens": 0, "outputTokens": 0, "cacheReadInputTokens": 0, "cacheCreationInputTokens": 0 } } }--forceand--limits-only(fine to ignore them, as the Codex collector does). Everything is optional exceptid; the tab shows once any total, today count, active day, or limit is present.shell/plugins/agents/assets/<id>.svg, plus<id>-light.svgif a dark variant is needed on light surfaces. The bar glyph stands in without one.retryAdvised: truewhen the limits endpoint was unreachable at the transport level — the shell reruns just that collector in 30 seconds.providers.<id>.enabled = falsehides the tab and skips the collector. Sync picks the new agent up automatically since snapshots carry the whole record map.Zero-code path: any external process can write a conforming record straight into the usage directory and the panel displays it — the collector route just adds the shared refresh cadence.
🤖 Generated with Claude Code