Fix CPU/Energy regressions for issue #139#402
Conversation
|
A question before we merge: can you share how you landed on the new timeout values ( |
|
Hi, I wrote answer and let AI format it for easier readability. If you want me to do some precise testing, no problem but you will have to tell me what exactly you need. Also feel free to change the numbers if you can make better guess. Ideally it would be better to get from Peter some better way to get the info without launching the entire CLI. Maybe he can hook you with solution from big token? AI answerHi, I honestly didn’t know the exact “correct” way to pick those timeout values, so I made a practical guess to get the Reason:
What I saw in my logs: Codex RPC (happy path):
OpenAI web refresh (Feb 20, 2026):
No-data / stale behavior:
So from what I collected, failures looked like short blips, not long degraded periods. |
|
Ou btw the loggs are in my private version, I shipped it without and made custom version for myself. That felt like right way to do it. |
Fixes #139
This is my first PR on this codebase, and I tried to be diligent and explicit about what I changed and how I validated it.
What was causing the high CPU/energy usage
The issue was not one single bug; it was three independent performance problems that could stack:
What this PR changes
1) Main culprit: Codex CLI failed-run window is now short and bounded
File:
Sources/CodexBarCore/Providers/Codex/CodexStatusProbe.swift18sto8s..parseFailedand.timedOut.parseFailed4s).Result: bad CLI states fail fast and wait for next scheduled refresh instead of burning CPU for long windows.
2) OpenAI web dashboard fetch timeouts are capped lower
File:
Sources/CodexBar/UsageStore.swift15s8sResult: bad web session/cookie cases stop much sooner.
3) Idle blink loop is now adaptive
File:
Sources/CodexBar/StatusItemController+Animation.swift75mswakeups while idle.75mscadence only during active blink animation.Result: less idle wakeup noise in normal usage.
4) Documentation updates
docs/codex.mddocs/perf-energy-issue-139-simulation-report-2026-02-19.mddocs/perf-energy-issue-139-main-fix-validation-2026-02-19.mdMeasured impact (before vs after)
Main culprit comparison (Codex CLI failed path):
CPU * duration)Validation run
Commands executed:
./Scripts/lint.sh format./Scripts/lint.sh lint(strict swiftlint)swift testpnpm check./Scripts/compile_and_run.shAll passed.
Attachments / transparency
I will upload these to the PR thread:
ai_conversation_full.jsonl(the conversation where I finalized and implemented this fix end-to-end).I had earlier exploration chats too, but this attached one is the conversation where the final implementation was locked in.
AI assistance disclosure
This PR was prepared with AI assistance (analysis, implementation support, and test/report drafting), with manual review and validation by me before submission.