Repository navigation
Count pi usage from PI_CODING_AGENT_DIR and PI_CODING_AGENT_SESSION_DIR - #14550
omarchybot wants to merge 1 commit into
Conversation
Both collectors scanned only ~/.pi and ~/.omp, so a pi whose agent tree or sessions were moved by its documented overrides had its Codex and Claude usage dropped from the Agents panel. Roots are canonicalised, with Codex session and parentSession paths through realpath, so an override aliasing a default root through a symlink is counted once and forks still find their parent. Fixes #7194 Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-Authored-By: Codex Medium <[email protected]>
|
|
Heads up: #8345 ("Fix Pi Codex session discovery") is still open for the same issue (#7194) and was updated yesterday. This PR also covers the Claude collector and the symlink/realpath dedupe, so it looks like the more complete of the two. It probably makes sense to consolidate on one, and fold anything from #8345 worth keeping into it. |
The Claude and Codex collectors scanned only ~/.pi and ~/.omp, so a pi whose agent tree or sessions were moved by its documented overrides had its usage dropped from the panel. Roots are canonicalised, with Codex session and parentSession paths through realpath, so an override aliasing a default root through a symlink is counted once and forks still find their parent. A root nested inside another is dropped, since the outer one already reads it, and the Codex scan cache is keyed by the overrides too. Builds on #14550. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: Omarchybot <[email protected]>
|
Reviewed at 6773da1, and found nothing wrong. Checked on a disposable Omarchy worker: the new override tests in Codex Medium reviewed it as a second opinion, alongside Claude Opus 5.5, and found no defects. It checked overlapping and nested roots, symlinked aliases and fork-parent matching through The fix closes #7194. It is labelled |
|
Re-checked after What changed on
Checked on a disposable Omarchy worker. I ran this pull request's two scenarios through both collectors on current Second opinion. Codex Medium and muse-wonder via pi (thinking high) both reviewed this from the code. Both agreed that This waits on the maintainer. My recommendation is to close it as already fixed by #14040, and to close #7194 with it. #8345, which fixes the same issue, carries the same recommendation. |
The Agents panel drops Codex and Claude usage from pi whenever pi keeps its sessions anywhere but
~/.pi/agent/sessions.pi_session_roots()in bothbin/omarchy-agent-usage-codexandbin/omarchy-agent-usage-claudebuilds its roots from~/.piand~/.ompalone, so it never looks where pi actually writes oncePI_CODING_AGENT_DIR(pi's agent directory, sessions under<dir>/sessions) orPI_CODING_AGENT_SESSION_DIR(the session directory itself) is set. The Fireworks collector already honoursPI_CODING_AGENT_DIRfor pi'sauth.json; the two session scanners did not.Both collectors now add those two roots, expanding a leading
~as pi does. Every root is canonicalised before scanning, and the Codex collector resolves session paths andparentSessionthroughrealpath, so an override that reaches a default root through a symlink is scanned under one spelling: its usage is counted once, and a fork whose parent is spelled through the symlink still inherits from it rather than counting as a session of its own.The collectors read the environment they are started with, which for the panel is the desktop session's. A variable exported only in a shell rc reaches
omarchy-agent-usage-updaterun from a terminal but not the panel; set it in a file under~/.config/uwsm/env.d/to reach both. pi'ssessionDirsetting insettings.jsonis not read here: it can live in project settings and take relative paths, which needs its own discovery rules.The scanner tests now unset both variables so a developer's own pi sessions never leak into a run, and cover both overrides, a literal
~, and a symlinked override reaching the default root, for each collector.Fixes #7194
Reviewed by Claude Opus 5.5 and Codex Medium.