Repository navigation
Conversation
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryAdds indexes so usage refreshes skip pi/omp history and opencode rows they already read.
|
|
Reviewed at 4f80e51 against What ran there:
Codex Medium reviewed it as a second opinion. It judged the scope reasonable for the problem and raised six edge cases, none of which I am asking you to change. Three of them describe the design the Claude transcript index already uses on I linked #12411 to this PR. What was left of that issue is the pi/omp This is now waiting on the maintainer. |
|
This head (4f80e51) no longer merges into What changed underneath it: #14040 rewrote both collectors as thin wrappers. pi/omp and opencode scanning now live in shared helpers in The problem you're fixing is still there. A port would have to go into those helpers and keep what they now do beyond the old code:
There's also a scope choice. An index in the shared helpers changes all 17 collectors at once, and needs one writer and a lock, like the Claude Code index at What was checked: the PR head against current This is waiting on the author: a version of this change built on the shared helpers in |
|
I've opened #18938, which ports the pi/omp half of this to It doesn't cover the opencode scan, so that half of this PR is still open for you or anyone else to port. On a machine with 9.6 GB of pi sessions, a refresh went from 77 s and 490 CPU-seconds to 6 s and 13 CPU-seconds once the index is built, with identical usage records. The full numbers are in #18938. @Iann29, if you'd rather carry this in your own PR, take whatever is useful from that branch. |
|
Since the last review, #18938 by @OldJobobo has ported the pi/omp half of this to The opencode half of this PR is still the only one anywhere. What was checked: both diffs, read against current This is waiting on the maintainer. Choosing between this and #18938, and whether to close this one or keep it open for the opencode work, is their call. |
The agents panel runs
omarchy-agent-usage-updateevery 15 minutes. Claude transcripts and native Codex rollouts already have per-file indexes, but the pi/omp and opencode scans still read everything on every refresh, and both collectors do it: the Claude collector parses every pi/omp session andjson.loadsevery opencode message row, and the Codex collector runsrgover the pi/omp roots and aLIKEscan over opencode'smessagetable.That gets expensive with real history. On my machine (6.9 GB under
~/.omp/agent/sessions, a 3.6 GBopencode.db) those scans took about 19 s, 19 s and 21 s per refresh. On 4.0.4, which still rescanned Claude transcripts as well, every refresh pinned the NVMe at ~99% for about a minute and the whole desktop stalled with it (/proc/pressure/iofull avg60 around 17%).What changes
resume_point()andindex_entry()come out ofparse_usage_records()so both scans share them.(id, time_updated). Each refresh selects only those two columns, which sit beforedata, so SQLite never reaches the JSON overflow pages, and only new or changed rows are parsed. The Codex collector keeps itsLIKE/json_extractgate on the rows it does read. A table withouttime_updatedfalls back to reading every row.--forcestill rereads everything.One behavior change
rgsearched every file under the pi/omp roots, so omp's*.eval.logfiles that quote session lines were counted as sessions. The Codex collector now reads*.jsonlonly, as the Claude collector already did. On my data that removed 4 phantom sessions (778 → 774); prompts and tokens were unaffected.Verification
rg -g '*.jsonl', given the change above).time_updatedmoves (plus a deleted row on the Claude side). Both suites fail at the new tests against the current scripts.scan_pi_usage/scan_opencode_usagestubs take the newuse_indexargument, and the Codex suite no longer requiresrg.agent-usage-*suites,agents-panel-test.shand the i18n checks pass.Not changed here: several Codex scanner tests run the collector without setting
XDG_CACHE_HOME, so with it exported (as on my machine) they write cache files for their temporary homes into the real~/.cache/omarchy/agent-usage. Happy to send that separately.Fixes #12411