Repository navigation
Consistent period totals and incremental refresh - #1467
Merged
Merged
Conversation
hasUsage: false means the provider is installed but had no spend in the selected period, which is a reason to grey the row, not to hide a tool the user has. The picker and the Settings provider list now show every provider the CLI detected, active ones first by spend.
polledMemoTimestamp returned the age of a report snapshot restored from localStorage, so right after a renderer restart the footer announced a refresh from the previous day that had never happened, and the streak read 0 because the restored payload had no row for today. The clock now reports only fetches from this renderer and says refreshing while the first one is in flight, and the streak counts from yesterday when today has no spend yet.
Minimum bar width plus gap times the day count overflowed the plot at 6M and Life, so bars drew outside the card and the peak guide pointed at a bar that was not on screen. Bar width and gap now step down until the columns fit the narrowest supported plot, and a history longer than that folds into whole weeks.
A day that has not happened yet is not a broken streak: before the first session of the day the pill read 0 while the heatmap showed an unbroken run.
The two-layer card anatomy clips its inner surface to keep the rounded corners, which cut the By branch project menu off after three rows. Every anchored surface now renders into document.body, opens under its trigger's left edge, flips above when the space below is too short, and keeps the dropdown row height and text size with an internal scroll.
A repository with a dozen review worktrees and benchmark clones filled the picker with identical rows. Checkouts that share an origin remote are now one entry labelled by the repo name with the checkout count beside it, their branch rows summed; throwaway checkouts with no origin collect under one entry at the bottom, and a project with no branch row in the range is left out of the picker entirely.
The pill was derived from the payload's own history, so it changed with the selected period and provider filter and read 21, 32, 38, 55 or 0 for the same machine. The CLI now emits one streak, taken from the hydrated daily cache across every provider and independent of the period, and the app shows that number when the CLI supplies it.
Each period held its own payload fetched at its own time, so switching period mixed snapshots minutes apart: the same six months read 20,770.90 on one refresh and 37,683.63 on the next, and Lifetime came back smaller than the six months it contains. The durable period build now returns cost and calls for all six windows from the one cache and today set it already has, the app reads the headline for the selected period from the newest generation it holds, and the footer clock is that generation's time. Dev builds report a generation whose windows do not nest.
An identity with no recorded working directory is a session title, not a project, and belongs to Sessions only. A checkout whose origin cannot be read is now named by its parent and folder, so it is told apart from the repository group of the same basename instead of appearing as a second identical row.
A window reaching back past the live scan was summed from the cache alone, so it trailed a direct request wherever a cached day had under-read its sources: from a today request week was 194 calls short, lifetime 219. Those windows are no longer emitted and the client falls back to the period's own payload, and a generation stands in only when it is newer than the payload on screen, so a correct headline is never replaced by an estimate of it. The hero and the footer clock now also require this payload to carry the totals, which the CLI emits only for an unscoped, unfiltered request, so a provider or config filter can no longer show the whole machine's number.
The map key held a literal NUL byte, which makes git treat the file as binary.
A v7 snapshot predates both fields, and the file's own rule is that a payload meaning change bumps this or a warm snapshot is served without them.
A durable memo hit is a snapshot from an earlier app run. Painting it is right; reporting it as this run's refresh time is what made the footer say refreshed 14h ago while a fetch was in flight.
Past the fit ceiling the chart folds days into weeks while the chips still read the raw days, so the Peak chip named a date the chart had no bar for and the peak guide pointed somewhere else. The card now buckets once and both read it, and the chip labels say week when that is what they are.
A recorded working directory is usually below the repo root, so reading only <path>/.git resolved an origin for 10 of 1,986 identities and left every other checkout of the same repository as its own picker row. The lookup walks up to the first ancestor that has one.
The prefix test carried a trailing slash, so a session that recorded /private/tmp itself as its working directory missed the bucket.
Every menu and popover is portaled and positioned from its trigger rect, so the absolute offsets they used to grow from no longer apply to anything.
Both persistence paths already refused a payload whose hydration was incomplete, but nothing gated rendering, so after the local-day rollover the resident serve child re-derived the corpus and the partials it served while indexing replaced a complete payload: history.daily came back with about 27 cost-bearing rows instead of 125, and the streak, month-to-date and the medians read off that same array were wrong with it. usePolled now keeps the complete value, offers the partial to the indexing banner and stays marked refreshing until a complete one arrives, the switch memo will not let a partial displace a complete entry, and a partial is never taken as a generation. The serve child's output memo is keyed by the local date so --period today cannot answer for yesterday after midnight.
…aded shards resident A SQLite read rewrites the database's shared-memory index, so opening a provider database under a watched root reported a change and dirtied the memo the same request had just produced. Ignore -shm writes; a real write still lands in the database or its WAL. Scope a change to the days the changed file can hold (creation to last write) so a finalized past range survives a write dated today, and keep parsed cache shards in the process keyed by their write-nonced file name, bounded by bytes and evicted by age and least-recent use, so widening a period reads only the months it has not read yet. No cache format changed, so no cache version bump.
…s with their generation The optimize detectors scan every Claude transcript overlapping the period, separately from the parse, and re-read all of it on every request: six of the seven seconds a warm 30-day period switch cost. Keep each scanned file in the resident process, keyed by its path, size, last write and the range it was scanned for, bounded by bytes and evicted by age and least-recent use. The recency flag is now stamped after the scan instead of during it, so a kept file is not pinned to the cutoff it was first read under, and the whole scan shares one cutoff rather than reading the clock per file. Serve responses gain the generation they were built from: a counter that advances once per derived answer plus the day range it covers, re-served unchanged on a memo hit. No cache format changed, so no cache version bump.
The scan memo re-read a file in full whenever it changed, which for a live transcript is its whole length on every request. Keep the byte offset after the last complete line consumed, the size at that point and a digest of the first 4KB, and when the file has only grown past an unchanged head, read from that offset and merge the new lines into what was already scanned. A file that shrank, one whose offset now sits past its end, or one whose head no longer matches is read from the top. A partial line left by a writer mid-append is never consumed, so it arrives whole on the next read. The parser's Claude reader already resumes this way (reconcileFile), so both readers now do.
…sorting The scan memo counted the text it held, not the objects: measured against a live heap, a scanned file retains about 1.8x its text, so a 192MB budget was really about 350MB and the two memos together pushed a resident process into SERVE_MAX_RSS_BYTES - whose guard then drops every memo and hands the next request a cold parse and a cold scan. Count the retention factor, sample tool inputs instead of serializing every one, and drop the budgets to 160MB of held heap for scanned files and 64MB of shard text (a shard the current scope also holds costs this memo nothing extra). Digest a file's head only when it was written recently enough to grow later, rather than opening the whole corpus a second time per scan. Eviction now walks the map in least-recently-used order - a hit reinserts its entry at the back - instead of sorting every entry on every insertion, which made a scan whose working set does not fit cost more than no memo at all. Peak RSS over 40 requests: 2660MB against main's 2663MB; over a three-period rotation 3109MB against 2813MB.
The published figures came from a harness that only appended to an existing transcript, and from a run short enough that the memos never met the resident-set guard. Replace them with medians measured on the desktop's own argv for both shapes a user produces - appending to a live transcript, and a new session file per request - and say plainly that rotating through every period is roughly unchanged, because three periods of scanned files do not fit the budget at once.
The memo was keyed by argv alone, so a request the desktop repeats across local midnight - every relative period, today most obviously - was served yesterday's answer until the five-minute cap expired. Key it by the local date and the resolved day range as well, so the same words asked on a new day are a new question.
The day range came from the request's own period, which for the desktop's menubar payload describes a fraction of what the answer carries - a today request stamped today..today over a payload whose daily history reaches back a year. Report the derivation's own time instead, which is what a client needs to show one clock per generation. The clock-derived fields in that payload, periodTotals and streak, both change only when the local date does, which the memo key now carries.
…code Covers the day range a request resolves to - explicit day, explicit window, named period, short and inline flags, and the cases where it declines to guess - and the generation stamp as it appears on the wire, including that a memoized answer carries the stamp it was derived under. Removes the string-timestamp isRecent, unused since the recency flag moved to the already-parsed instant, and records next to cachedTurnToClassified why it cannot be memoized yet: the four places that write to a turn after it is built.
The scan memo was keyed by the query range, so the three periods the desktop rotates through held three copies of every file and evicted each other - the rotation ran at parity with no memo at all. Scan each file once into a range-independent record: every call, cwd, user message and opening block with the instant it happened, plus the two pieces of state the line loop carried that a range can change - whether a line marking the file a sidechain survives the range's own skip threshold, and which version a call carries once that threshold has had its way. A period's filter is then applied to that record, and each period's selection is kept as references into it. A file whose version changes partway through is the one case a single record cannot answer for every range; it is read per query, as before. Rotating 7D to 30D to 6M with a session written between every request: 2832 to 1326ms, 7744 to 3349ms, 9097 to 4332ms, peak RSS 2147MB against 2937MB. All 48 desktop payloads byte-identical to main, with and without a line appended between every request.
The projection paired the LAST version seen with the anchor of whichever version line was easiest to qualify. When those came from different lines the pair was wrong: with a version line carrying an earlier timestamp than the one before it, a range starting 2026-08-15 read 2.0.0 where the range-carrying scan read 1.0.0, and that value reaches ApiCallMeta.version and the version note the optimize report prints. Record the version lines in order instead, one event per change of version - a run repeating one version keeps whichever member a range is likeliest to still see - and walk them back per range to the last one its skip threshold leaves in place. For a file that never changes version that is one step, and the multi-version escape hatch, which used the same wrong pairing anyway, is gone: every file is now stored. Selections are held least-recently-used per file and counted in the memo's byte budget.
The 2020ms was one run's median; repeated, the same measurement lands at 2387ms with a wide spread, because how long a warm request takes depends on how much was appended since the last one. Quote the reproducible median and the spread rather than the best of them.
A range that skips every version line in a file made the per-call walk-back scan the whole event list for each of that file's calls. Resolve every position once, forward, and index into it. Rotation figures in the changelog re-measured against the rebased main.
# Conflicts: # CHANGELOG.md # src/serve.ts
iamtoruk
added a commit
to ozymandiashh/codeburn
that referenced
this pull request
Sep 17, 2026
App.tsx footer: keep the leaf RefreshedAt component from this branch and main's getagentseal#1467 loading argument, so the label still shows "refreshing…" for a restored durable snapshot until the first real refresh lands.
iamtoruk
added a commit
that referenced
this pull request
Sep 18, 2026
The hero took its cost from the held generation while the models table always read the on-screen payload, so during a period switch where the generation was newer the two disagreed for a moment. The generation now records the period and models it was captured from; the table stands in with it only when it is for the shown period, and otherwise both the hero and the table fall back to the payload. The provider-filter gate that #1467 added is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Numbers
Every period headline now comes from one aggregation. Each period used to hold its own payload fetched at its own time, so switching period mixed snapshots minutes apart and Lifetime could come back smaller than the six months inside it. The status payload now carries cost and calls for every headline window its live scan covered, and the app reads the selected period from the newest generation it holds. A window the scan did not reach is omitted rather than summed from the cache alone.
Preserved days recovered from expired transcripts now count toward the totals instead of being dropped.
The usage streak is one number for the machine. It used to be derived from the payload's own period- and provider-narrowed history, so the same pill read 21, 32, 38, 55 or 0 depending on which tab was open. The CLI now emits one streak taken from the hydrated daily cache across every provider.
A provider-filtered hero reads the scoped payload, so the headline matches the filter that is applied.
Dropdown menus and popovers render through a portal. The two-layer card anatomy clipped its inner surface to keep the rounded corners, which cut the Spend project menu off after three rows. Anchored surfaces now open under their trigger and flip above it when the space below is too short.
The Spend "By branch" picker groups by git origin. Checkouts that share an origin collapse into one entry with the checkout count beside it and their branch rows summed, instead of a dozen identical rows for review worktrees and benchmark clones.
Performance
Serve invalidation is scoped to the day. SQLite rewrites a database's shared-memory index when it is read, so opening a provider database under a watched root reported a change and CodeBurn invalidated the memo it had just produced.
-shmwrites are now ignored; a real write still lands in the database or its WAL, both watched. A change is scoped to the days the changed file itself can hold, so a finalized past range keeps its result when only today's sessions were written.The optimize detectors keep a range-independent scan record. A file is scanned once into everything the detectors can ask of it, each item carrying the instant it happened, with version events kept in order, and the period filter is applied at query time. One stored scan answers every period instead of each period holding its own copy and evicting the others. An appended transcript is read from the byte after the last complete line the previous read consumed, not from the top.
Memos are bounded by the bytes they really retain, evicted by age and least-recent use, and dropped when the process passes its resident-set guard.
Every
codeburn serve --stdioresponse now carries the generation it was built from, with the moment that derivation happened. A client holding several panels can tell which of them share one reading of the corpus and show a single clock.No cache format changed, so no cache version was bumped.
Numbers verified
Lifetime reads $38,131.55, at or above the 6M figure of $38,090.80. The 143 daily rows sum to $38,131.29.
48 of 48 payloads are byte-identical to the numbers branch. 42 of 48 are byte-identical to main, and the six that differ do so only in
periodTotals,streakandliveSessions, which are what this branch changes.Performance
Measured on a 7GB corpus with the argv the desktop actually sends, medians of 8, with a session written between every request.
Tests
Root suite 4185 passed. Locks 36. App 1107 across 71 files.
tscclean.Screenshots
Today with the Codex filter applied. The hero reads the scoped payload.
Today with all providers. Idle providers are listed and greyed rather than hidden.
The Settings currency menu open, rendered through a portal so the card no longer clips it.
The Spend by-branch picker, one entry per git origin with the checkout count beside it.