Skip to content

Show the elapsed part of a limit window's cycle on its meter - #13870

Open
dadofsambonzuki wants to merge 5 commits into
omacom:quattrofrom
dadofsambonzuki:agents-panel-pace
Open

dadofsambonzuki wants to merge 5 commits into
omacom:quattrofrom
dadofsambonzuki:agents-panel-pace

Conversation

@dadofsambonzuki

@dadofsambonzuki dadofsambonzuki commented Sep 30, 2026 •

Copy link
Copy Markdown

A limit meter says how much of an allowance is spent, but not where in its cycle the spend is: 5% used in the first hour of a five-hour window reads exactly like 5% used in its last, and the countdown beside it does not answer the question either.

The LIMITS section of the agents panel with the pace marker: Session 5% and Weekly 26%, each meter carrying a dim elapsed band that runs to a notch at the clock's position in the window, captioned "45% behind" and "11% behind".

Session 5% used with the clock 45% through the window puts the notch at the midpoint of the bar; Weekly 26% with the clock at 37% puts it at 37%. The words sit beside the countdown in that shot, which is where the earlier cut of this change put them; this cut puts them in the row's tooltip instead, because upstream's row is one line and the exact percentage already lives there. The band and the notch are the marker itself, and they are what the image is showing.

The mechanism

windowSpanMs() already parsed a cycle out of a collector's label, and resetMsFor() already gave the time left — but limitWindow() threw the length away, keeping only the display title, and "Session" (which is what a five-hour window is called on screen) carries no duration. The length is now kept on the window, read from the raw label before the title is derived from it, and the row derives the elapsed fraction as 1 - remaining / span.

Meter draws that dimly behind the fill, with a notch at the clock's edge: fill past the notch is ahead of the cycle, short of it is behind. The row is one line by design, so the comparison in words lives in its tooltip beside the exact percentage — 42% of the cycle elapsed · 12% behind. That is the same place the exact percentage already lives, and it keeps the row the height it is.

Because both a provider's own limit rows and each account's rows are CompactLimit, every meter gets it — including a machine with several accounts on one subscription, which is where reading the clock matters most.

What counts as a cycle

Making windowSpanMs() load-bearing rather than a hint for the title exposed two ways it read a cycle where there is none:

  • A context size sits exactly where a duration does. Opus 5 (1M context) Session is a five-hour session whose 1M parsed as one minute, which would put the notch in the wrong place and report the row as ahead when it is on pace. After lowercasing, 1m and 1M are indistinguishable, so the word "context" is the tell: a number is dropped only where that word says it is a context size. A real cycle stated beside one survives (Opus 5 (1M context) 30m window is still 30 minutes), and 30m, 90m and 120m window stay cycles at any length.
  • A spelled-out 5 hours matched no hour pattern at all, since the unit required a word boundary after "hour".

The caveat

A window whose label states no cycle is drawn exactly as before: no band, no notch, no tooltip line. That is deliberate — a wrong marker would be worse than none. The same applies to a window whose reset has already passed, which keeps no position because it is not 100% through its cycle, it is over.

A monthly window is paced against a 30-day cycle, since that is what the label says; a calendar month runs 28–31 days, so its marker drifts a few percent at the edges while the countdown beside it stays exact. Deriving the true cycle would mean the collector putting the window's length in the record instead of the label, which is a record-contract change rather than a panel one.

A reading kept from an earlier check holds its position rather than drifting. The percentage is frozen when a check fails, so the clock it is compared with is read at the same instant — fetchedAt — instead of at nowMs, which advances every 30 seconds regardless. Without that, a dimmed row's notch and caption creep while its fill stands still, and the row reads as though it were being measured. Its countdown still advances, because a reset time is a fact rather than a reading.

The one exception is a window rolled forward into a new cycle, and the collector declares that rather than the panel inferring it. Grok serves its cached limits when the access token lapses — routine, since the token lives six hours — and rolls an expired Weekly window to the next whole week; collect_limits() now stamps the record with that roll, because it is when the numbers it serves became true. The panel reads the clock at whatever instant the record names.

Inferring the roll in the panel was tried first and abandoned. A month is 28–31 days and its label says only "Monthly", so a reading taken at the start of a 31-day month sits before a 30-day assumed start and looks exactly like a window that rolled — which switched that reading to the live clock and let it drift, the defect the paragraph above exists to prevent. The panel has only the reset, the assumed span and the reading; the span's uncertainty is the same order as the signal, so no version of that test is right.

Tests

test/shell.d/agents-panel-pace-test.sh over scripts/agents-pace-harness.js: a QML runtime is not available in the shell suite, so the panel's own code is run instead of a copy of it. The window helpers are brace-extracted and evaluated together, since they call one another, and CompactLimit's four pace bindings — elapsed, paceKnown, paceDelta, paceCaption — are compiled into one program, so the caption is driven by the shipped paceDelta reading the shipped elapsed. A sign error or a changed unknown-state convention fails the test rather than shipping.

  • a 5h window with 47 minutes left reads as ~84% elapsed, 68 points behind
  • a 7d window with 4d10h left reads as ~37% elapsed, 11 points behind
  • a window ahead of the clock says so; a level window reads as on pace
  • a window of unknown length, and a model-scoped window, are left unpaced
  • a window past its reset keeps no position; one before its cycle clamps to zero
  • a reading kept past a failed check holds its caption and its position while the clock advances, and its countdown still advances
  • a Weekly window rolled to four days out with a ten-day-old timestamp reads 43% elapsed and "43% behind" rather than 0% and "on pace"
  • a month read at its start sits at the start of its cycle and reads "on pace" rather than 17% behind — the case the abandoned in-panel inference got wrong
  • displayWindows() keeps the cycle on the base row while still attaching a model-scoped allowance to it
  • Opus 5 (1M context) Session states no cycle, Rolling (30m) states 30 minutes, 5 hours states five

Reverting only the context guard turns the context cases red; reverting only the s? in the hour pattern turns 5 hours red.

Three extractor traps the harness has to survive, each of which fakes a result rather than crashing: a single-line binding has no brace to match, a block body already ends in return while an expression body does not, and the component reaches its own properties as compact.<name>.

The deep-equal assertions in agent-usage-claude-limits-test.sh over limitWindows() and displayWindows() output now name spanMs; the model-scoped row in that test makes the split explicit, since its collector-stated title reads like a model name while its label names a week.

What I ran

  • bash test/shell.d/agents-panel-pace-test.sh → 62 ok, 0 not ok, exit 0 (36 from the harness, the rest assertions over its output)
  • bash test/shell.d/agent-usage-grok-test.sh → 14 ok, 0 not ok, exit 0 (the roll stamp stays, and moves when a week rolls)
  • bash test/shell.d/agents-panel-test.sh → 31 ok, 0 not ok, exit 0
  • bash test/shell.d/agent-usage-claude-limits-test.sh → 31 ok, 0 not ok, exit 0
  • /usr/lib/qt6/bin/qmllint shell/plugins/agents/Panel.qml → no errors

Verification gap, stated plainly

The screenshot above is from the earlier cut of this change: the same marker, on the same meters, but drawn by a LimitRow that no longer exists. It shows the band and the notch; it does not show this cut's row.

I have not seen this cut render. The machine I developed on runs Omarchy 4.0.0.alpha, whose installed agents panel predates the account work in this branch's base — it has no CompactLimit, no accounts array and none of the omarchy-agent-account-* commands, so the panel this change targets cannot be run there as it stands. The harness covers the arithmetic the marker depends on, and qmllint covers the markup, but the marker inside upstream's CompactLimit — band, notch, tooltip line — is unverified in a running panel. I would rather say so than describe it as tested.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no outstanding finding or new actionable defect was established.

Summary

The PR adds an elapsed-cycle band and notch to limit meters when a label supplies a duration, with the pace comparison in the row tooltip. Since the previous review, Grok stamps a rolled cached window at the time of the roll, and the panel no longer infers a roll from an approximate cycle length. Tests and documentation were updated for that division of responsibility.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Collector limit and timestamp] --> B[Panel window and cycle span]
  B --> C{Known span and valid reset?}
  C -- Yes --> D[Elapsed band, notch, and tooltip pace]
  C -- No --> E[Plain meter]
  F[Grok cached window rolls] --> G[Stamp rolled reading at current time]
  G --> A
Loading

Reviews (10) · Last reviewed commit: "Let the collector declare a roll rather ..." · Reviewed by Greptile

Comment thread shell/plugins/agents/Panel.qml Resolved
Comment thread scripts/agents-pace-harness.js Resolved
Comment thread shell/plugins/agents/README.md Resolved
Comment thread shell/plugins/agents/Panel.qml Resolved
Comment thread shell/plugins/agents/Panel.qml Resolved
Comment thread shell/plugins/agents/Panel.qml Resolved
@omarchybot omarchybot added the enhancement New feature or request label Oct 1, 2026
@dadofsambonzuki dadofsambonzuki changed the title Show elapsed time beside each usage meter in the agents panel Agents panel: pace on each usage meter, and a provider's accounts nested under it Oct 9, 2026
Comment thread shell/plugins/agents/Panel.qml Resolved
Comment thread shell/plugins/agents/Panel.qml Resolved
Comment thread shell/plugins/agents/Panel.qml Resolved
Comment thread shell/plugins/agents/Panel.qml Resolved
A meter says how much of an allowance is spent, but not where in its cycle the
spend is: 5% used in the first hour of a five-hour window reads the same as 5%
in its last, and the countdown beside it does not answer the question either.

windowSpanMs() already parsed a cycle out of a collector's label, and resetMsFor()
already gave the time left, but limitWindow() threw the length away — keeping only
the display title, and "Session" (which is what a five-hour window is called on
screen) carries no duration. The length is now kept on the window, read from the
raw label before the title is derived from it, and the row derives the elapsed
fraction as 1 - remaining / span.

The meter draws that dimly behind the fill, with a notch at the clock's edge:
fill past the notch is ahead of the cycle, short of it is behind. The row is one
line by design, so the comparison in words lives in its tooltip beside the exact
percentage — "42% of the cycle elapsed · 12% behind". Both a provider's own rows
and each account's rows are CompactLimit, so every meter gets it.

A window whose label states no cycle is drawn exactly as before: no band, no
notch, no tooltip line. A wrong marker would be worse than none.

That makes windowSpanMs() load-bearing rather than a hint for the title, which
exposes two ways it read a cycle where there is none. A context size sits exactly
where a duration does — "Opus 5 (1M context) Session" is a five-hour session whose
"1M" parsed as one minute — and after lowercasing "1m" is indistinguishable from
it, so a number is dropped only where the word "context" says it is a context
size. That keeps a real cycle stated beside one, and keeps "30m", "90m" and
"120m window" as cycles at any length. A spelled-out "5 hours" also matched no
hour pattern at all, since the unit required a word boundary after "hour".
A QML runtime is not available in the shell suite, so the harness brace-extracts
the window helpers and CompactLimit's pace bindings out of Panel.qml and compiles
them into one program: the caption is driven by the shipped paceDelta reading the
shipped elapsed, so a sign error or a changed unknown-state convention fails the
test instead of shipping. Three extractor traps it has to survive, each of which
fakes a result rather than crashing — a single-line binding has no brace to match,
a block body already ends in `return` while an expression body does not, and the
component reaches its own properties as `compact.<name>`.

The cases only the shipped code can pass: a 5h window with 47 minutes left reads
as ~84% elapsed and 68 points behind, a 7d window with 4d10h left as ~37% and 11
behind, a window ahead of the clock and a level one say so, a window of unknown
length and a model-scoped window are left unpaced, a window past its reset keeps
no position, one before its cycle clamps to zero, and displayWindows() keeps the
cycle on the base row while still attaching a scoped allowance to it.

The deep-equal assertions in agent-usage-claude-limits-test.sh over limitWindows()
and displayWindows() output now name spanMs.
@dadofsambonzuki dadofsambonzuki changed the title Agents panel: pace on each usage meter, and a provider's accounts nested under it Show the elapsed part of a limit window's cycle on its meter Oct 9, 2026
Comment thread shell/plugins/agents/Panel.qml Resolved
A limit check that fails leaves the last reading in place, dimmed, with its age in
the tooltip. The pace marker compared that reading's percentage with root.nowMs,
which advances every 30 seconds regardless — so a stale row's notch and caption
crept while the fill stood still, and the row read as though it were being
measured. The dimming is the only signal that it is not.

resetMsFor() now takes the instant to measure from, and the elapsed fraction is
read at fetchedAt when the collector states one: the clock is read at the same
moment as the percentage it is compared with. A fresh reading is unaffected, since
its fetchedAt is the moment it was taken; a kept one holds its position, and its
countdown still advances, because a reset time is a fact rather than a reading.
@dadofsambonzuki

Copy link
Copy Markdown
Author

The branch has been re-cut onto current quattro and force-pushed (8c2c6fe2), so the commit SHAs in my earlier replies are orphaned — those commits are no longer in the branch. Re-stating where each finding stands, since the review comments still point at the old diff.

The re-cut drops the account-grouping and rename work: upstream/quattro shipped its own account support while this was open (accounts listed per agent, each with its own limits, Use/Autoswitch, add and rename in place), so mine was both superseded and a competing record contract. This PR is now pace-only — a +365/−13 diff over five files.

Still applies, fixed in the current branch

Finding State
4145674356 context size read as a cycle Fixed — a number is dropped only where "context" says it is a context size, so Opus 5 (1M context) Session states no cycle while Opus 5 (1M context) 30m window still states 30 minutes
4145674366 harness tested a copy of the logic Fixed — the harness brace-extracts CompactLimit's four pace bindings out of Panel.qml and compiles them, so the shipped paceDelta drives the shipped elapsed
4145674374 README described every meter as paced Fixed — the README now says a window whose label states no cycle keeps the plain meter
4145948377 bare minutes dropped by the context guard Fixed — Rolling (30m) states 30 minutes
4146141262 60-minute cap on minute cycles Fixed — 90m window and 120m window are cycles
4146141294 blunt /context/ guard discarded a real cycle Fixed — only context tokens are dropped

No longer applies after the re-cut

Finding State
4230814751 ShellIpc replaced with a bare IpcHandler Moot — the branch keeps upstream's ShellIpc and the diff does not touch the IPC; shell-ipc-socket-test.sh and shell-shortcuts-test.sh are 14 ok each
4230814780 meters ignore reduced motion Moot — those Style.duration(160) lines are upstream's own; the re-cut adds no NumberAnimation
4230814794 first step repeats the provider Moot — stepProvider() was part of the dropped account work; grep -c is 0
4230814809 concurrent renames lose names Moot — names.json, renameScript and beginRename are all gone with the same work

Raised against the re-cut, fixed

4231088970 — a kept reading's pace drifted with the clock. The percentage is frozen when a check fails, but elapsed compared it against nowMs, which advances every 30 seconds regardless, so a dimmed row's notch crept while its fill stood still. resetMsFor() now takes the instant to measure from and the elapsed fraction is read at fetchedAt; a kept reading holds its position while its countdown still advances. Fixed in 8c2c6fe2, with three harness cases RED before it and green after.

Comment thread shell/plugins/agents/Panel.qml Resolved
Grok serves its cached limits when the access token lapses — routine, since the
token lives six hours and is minted again whenever Grok starts — and rolls any
window whose reset has passed into the next one. A Weekly window is rolled to the
next whole week, so the record comes back holding 0% against a reset that is now in
the future, while collect_limits() keeps the cached fetchedAtMs it read before the
roll.

Reading the clock at that timestamp then puts the notch at the start of a cycle
that has been running for days, and since the percentage is 0 too, the row reports
itself as on pace. The reading predates the window it now describes, so the instant
it was taken is not the instant to compare against.

A window whose cycle began after the reading is now measured against the clock as
it stands: nothing spends the allowance while the agent is not running, so the
collector's zero still stands, and the comparison belongs at now. The kept-reading
case is unaffected — there the cycle began before the reading, which is exactly
what makes its position worth holding.
Comment thread shell/plugins/agents/Panel.qml Resolved
A window rolled into a new cycle is current as of the roll — nothing spends the
allowance while the agent is idle, which is why Grok serves its cached numbers at
all — but the record kept the timestamp of the fetch those numbers were cached
from. The panel read the clock there and put the notch at the start of a week that
had already been running for days, reporting a 0% window as on pace.

The first attempt inferred the roll in the panel, from the cycle the label names
measured back from the reset. That cannot work for a month: it is 28-31 days and
the label says only "Monthly", so a reading taken at the start of a 31-day month
sits before the assumed start and looked exactly like a window that had rolled —
switching that reading to the live clock and letting it drift again, which is the
defect the measurement-time reading exists to prevent.

Only the collector knows. rolled_forward() now reports whether anything rolled,
and collect_limits() stamps the record with the roll when it did, so the panel
reads the clock at whatever instant the record names and infers nothing. The
record still keeps the cached timestamp when no window reset, which is what the
kept-reading case rests on.

Both directions are covered: the Grok suite asserts the stamp stays on a window
that has not reset and moves to now when a week rolls (RED without the collector
change), and the pace harness asserts a month read at its start sits at the start
of its cycle rather than 17% into it (RED against the inference).
@xsi-dbachmann

Copy link
Copy Markdown

Hi @dadofsambonzuki, thanks for this one. The notch answers "where am I in the cycle", and that's exactly what I was missing.

Went one step further locally and would like to send it as a follow-up PR once this lands, since it builds on the spanMs you keep on the window. It answers the next question: will the week last, and how much can I still use.

What it adds:

  • Under each limit, a forecast line: Pace 1.38× · 100% Sat 00:09, 1d 21h early · 13%/day left, or ~20% left at reset when you're under pace. The line turns urgent when the forecast runs out before the reset.
  • Active hours per day from the transcripts the Claude collector already reads. Agent time (any session or subagent working, gaps over 10 min don't count) and your own time around prompts.
  • An hours budget on the weekly row: Safe 8.5h/day of agent time until Sun 21:00 · so far 14h/day. The rate is % per agent hour, from a small history of weekly % readings the collector keeps. Below it the balance: At your pace: -30h over by Sun 21:00, or +12h to spare.
  • Past weeks: final %, hours and %/h each, so a new week starts with a sensible rate.
  • The bar icon stays as it is, it only turns urgent when the week runs out before the reset, and its tooltip carries the forecast.

Hours from several machines add up through the existing sync mode, no new mechanism.

It's running on my bar since today, on 4.0.5 as a cloned plugin. I'll add a screenshot.

Two questions before I port it to quattro:

  1. Is this welcome as a follow-up, or too much for the agents panel?
  2. Keeping the % history in ~/.local/state/omarchy/agents/ next to the usage records OK, or would you rather have it inside the Claude record?

Best, Daniel

@dadofsambonzuki

Copy link
Copy Markdown
Author

I think UI should remain simple - people intuitively have an idea on 'hitting target' based on their plans for the next periods (holidays, non-coding days, etc.) and relative intensity recently - extrapolating too much would likely be inaccurate.

Roughly correct > precisely wrong 😄

I do think that some additional info could be useful though and it should probably be in a revised hover over pane, which also needs a redesign to make it clearer as it's currently a wall of text.

This is what we currently have.

image

lbssousa added a commit to lbssousa/omarchy-setup that referenced this pull request Nov 28, 2026
The clone is now Omarchy 4.6's omarchy.agents verbatim plus two
additions: the pace marker of omacom/omarchy#13870 (elapsed band, accent
cursor, tooltip translated through the plugin's own i18n/ catalogs) and
Gemini's weekly limit, read from AICode's quota summary because Cloud
Code's leaves it out for AICode-routed accounts (omacom/omarchy#16906).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants