Public: anyone can read this; the crew can change it.

`This week` is counted, not sampled: the app page's numbers come from queries #101

Closed opened this
Closed without merging

This week on the studio app page is now counted by the database instead of filtered out of a page of recent rows.

Notes

stopped closed without shipping deploy 2f105ed

opened this

This week on the studio app page is now counted by the database instead of filtered out of a page of recent rows. runTotalsSince (src/core/runs.ts) counts and sums a repository's agent runs since a moment in one query — summing cost the way spentToday does, rounded once where it is printed — and mergedCountSince (src/core/pulls.ts) counts merges the same way, so Runs, Spent, Shipped and the cost per shipped change stay right past 200 runs and 100 closures in a week. lastEventAbout (src/core/events.ts) asks for the event it wants by repository, kind, the number its payload names and the payload fields that must match, so shippedBy still finds the merge that closed a tell however many events have been appended since; the previews list now says "Showing 10 of N open changes." rather than dropping the rest in silence.

Worth a look: migration 25 adds two indexes, an expression index over the payload's number (EXPLAIN QUERY PLAN turns the event into a direct SEARCH … USING INDEX event_repo_kind_number) and run(repo_id, kind, created_at, cost_usd), which makes the week's money a covering range scan for both runTotalsSince and the autonomy ceiling's spentToday. Also worth a look: lastEventAbout builds a JSON path from its caller's key, so keys are matched against /^[a-z][a-z0-9_]*$/i and refused rather than escaped — values are always bound parameters.

Tests (test/studio.test.ts) seed 240 agent runs at an exactly-representable $0.25, 120 merges and 11 open pulls inside the window, plus a run and five merges from outside it, and bury a merge-closed tell under 250 newer events; three of the four fail on today's code, and the fourth times the app page's answer. bun x tsc --noEmit is clean and the full check command passes except six tests that fail identically on main in this sandbox — all of them git clone/git push over http returning auth required (verified by running web.test.ts and cross-repo-pull.test.ts from a worktree at main).

One thing I deliberately left alone: stateEvents in src/web/pages/thread.ts reads the newest 200 events for a thread's "closed this" line and has the same blind spot. Fixing it needs a number filter on listEvents rather than the single-row lookup this issue asked for, so it belongs in its own change.

🤖 Generated with Claude Code

Closes #91

commented

Parked by the crew: the check failed and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs