Repository navigation
Show the elapsed part of a limit window's cycle on its meter - #13870
dadofsambonzuki wants to merge 5 commits into
Conversation
|
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.
ca5c0a0 to
049eba1
Compare
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.
|
The branch has been re-cut onto current The re-cut drops the account-grouping and rename work: Still applies, fixed in the current branch
No longer applies after the re-cut
Raised against the re-cut, fixed
|
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.
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).
|
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 What it adds:
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
Best, Daniel |
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>

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.
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, andresetMsFor()already gave the time left — butlimitWindow()threw the length away, keeping only the displaytitle, 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 as1 - remaining / span.Meterdraws 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:Opus 5 (1M context) Sessionis a five-hour session whose1Mparsed 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,1mand1Mare 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 windowis still 30 minutes), and30m,90mand120m windowstay cycles at any length.5 hoursmatched 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 atnowMs, 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.shoverscripts/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, andCompactLimit's four pace bindings —elapsed,paceKnown,paceDelta,paceCaption— are compiled into one program, so the caption is driven by the shippedpaceDeltareading the shippedelapsed. A sign error or a changed unknown-state convention fails the test rather than shipping.displayWindows()keeps the cycle on the base row while still attaching a model-scoped allowance to itOpus 5 (1M context) Sessionstates no cycle,Rolling (30m)states 30 minutes,5 hoursstates fiveReverting only the context guard turns the context cases red; reverting only the
s?in the hour pattern turns5 hoursred.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
returnwhile an expression body does not, and the component reaches its own properties ascompact.<name>.The deep-equal assertions in
agent-usage-claude-limits-test.shoverlimitWindows()anddisplayWindows()output now namespanMs; 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 0bash 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 errorsVerification 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
LimitRowthat 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, noaccountsarray and none of theomarchy-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, andqmllintcovers the markup, but the marker inside upstream'sCompactLimit— band, notch, tooltip line — is unverified in a running panel. I would rather say so than describe it as tested.