Add a Codex Usage tab to Settings, shown when a Codex login is detected; fix main-repo header branch and session-lookup sequencing - #398
Conversation
Handle protocol pipe failures and wrapper process-tree cleanup, preserve WSL working directories, and clear stale renderer state. Consolidate the persisted widget preference and extend focused coverage. Applied-by: Pane refactor pass
|
Applied refactor pass AppliedMain process
Renderer
Regression coverage
Skipped / left for decision
Checks
|
Use the repository's Bash quoting helper for WSL working directories and key main-repository branch state to the active project and worktree. Replace the branch regression test with a valid-to-invalid repository transition. Applied-by: Pane refactor pass (fix round)
|
Fix round The adversarial review caught two reproduced regressions from
Checks (Node 22): Windows |
Render main-repository details only from a session owned by the active project and worktree. Exercise production-shaped base branches across the full delayed repository transition window. Applied-by: Pane refactor pass (fix round 3)
|
Final fix round The round-2 adversary correctly found that
Verification: the rewritten test failed on Windows |
|
Hi @Styrse — nice first contribution, and thank you. Heads up that we pushed some fixes straight to your branch (maintainer edits were enabled) instead of a request-changes round. Three commits, all scoped to review findings:
One thing left for you to know: the Windows Typecheck, lint, focused tests all pass on the current head. Please pull before pushing again. The rest of your PR is untouched. |
Discard stale async session responses and keep the active target in its loading state until its own session arrives. Cover ordinary delayed switches and rapid A-to-B-to-A sequencing with production-shaped sessions. Applied-by: Pane refactor pass (fix round 4, root cause)
|
Root-cause fix applied in
Both regression tests were proven against Checks: Windows |
Stop showing the loading skeleton after the active project's lookup settles without a session, and guard the asynchronous session activation boundary. Cover the rejected lookup path with a browser regression test. Applied-by: Pane refactor pass (follow-up)
|
Follow-up applied in
Checks: |
Subscription usage is account-level, so the widget leaves the per-pane detail panel (toolbar toggle, persisted preference, auto-open) and becomes a Settings tab shown only when the probe detects a Codex login. The probe now targets the daemon host instead of a pane; service, hardening, hook, widget, and the ProjectView fixes are kept. DetailPanel, PanelTabBar and SessionView return to identical with main.
|
@Styrse — thanks for this, and for the follow-up hardening rounds; the probe, the IPC plumbing, the widget, and your unit tests are all in as you wrote them. I've pushed one more change to your branch, a placement move rather than a code-quality one. When I ran the PR, the sidebar design asked the user to discover three things — a gauge toggle on every panel's tab bar (including plain terminals), a persisted preference, and an auto-opening detail panel — to see one number, and that number is account-level, not per-pane. So the widget now lives in Settings → Usage, right after "AI & Agents", and the tab appears only when the probe detects a Codex login (nothing to enable; absent otherwise). That also gives #383's Usage & Limits work a natural home to converge into. What changed:
Title/body updated to describe the result. Shout if anything in the move looks off to you. |
A Codex login can live only inside WSL, so after the host probe the handler tries each distinct WSL distribution Pane knows from its projects and returns the first available snapshot; every target keeps its own cache.
Description
Adds a Usage tab to Settings (right after "AI & Agents") that shows the Codex subscription plan, remaining usage, and reset time for every Codex rate-limit bucket. The tab exists only when a Codex login is detected on the machine running Pane; otherwise Settings is unchanged. Nothing to enable, no preference to persist.
How it works
codex app-server(JSON-RPC over stdio:initialize→account/readwithrefreshToken: false→account/rateLimits/read), not from terminal-output parsing.main/src/services/agentUsageService.ts) targets the host that runs Pane's daemon (local machine, or the remote host when connected remotely), with a 60 s cache and manual refresh. On Windows, if the host has no Codex login, every distinct WSL distribution Pane knows from its projects is probed next and the first available login wins. It is hardened against a missing/hungcodexbinary (12 s timeout, Windows process-tree kill, stdin EPIPE guards, WSL cwd quoting).codexreportsavailable→ tab shown; otherwise the tab is absent (a logged-out or missing Codex never adds chrome).Also fixes (independent, kept from the earlier iteration of this PR)
unknownwhen the synthetic main-repo session has no base branch — the branch is resolved through the existing project branch-detection IPC and keyed to the active project.Type of Change
Checklist
pnpm typecheckandpnpm lintlocallypnpm electron-devCritical Areas Modified
Tests
main):agentUsageService.test.ts(normalization, cache, WSL spawn shape, stdin-close safety, Windows tree kill),agentUsage.test.ts(host target, Windows WSL fallback order, refresh flag validation).tests/agent-usage.spec.ts— Usage tab present and populated when Codex is available (desktop nav + 640 px selector); absent when unavailable; refresh failure clears the snapshot; plus the three main-repository sequencing/skeleton tests.tests/settings.spec.tsunchanged and green.Screenshots
Settings → Usage (Codex login detected) — see
codex-usage-settings.pngattached to the Playwright report; a screenshot from the running app will be added by the maintainer.Additional Notes
DetailPanel.tsx,PanelTabBar.tsx, andSessionView.tsxare byte-identical tomain.