Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 1.1.0 - 2026-07-22

- Added live account usage through the existing signed-in Codex app-server session.
- Kept local session-file snapshots as an offline and low-latency fallback.
- Replaced permanent `N/A` text with a neutral em dash for unreported windows.
- Updated the README and reproduction prompt for the authenticated reader.
- Licensed the project under the MIT License.

## 1.0.0 - 2026-07-22

- Added compact two-row `5H` and `WEEK` taskbar gauges.
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Jun Seok Kim

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 4 additions & 2 deletions PROMPT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ Build a Codex usage widget that sits on the Windows 11 taskbar, immediately to t
- Show the remaining 5-hour and weekly limits as two stacked gauges labeled `5H` and `WEEK`.
- Use a compact, transparent Fluent design approximately 232 px wide.
- Use Arial Bold and the Windows 11 blue accent color.
- Read actual `rate_limits` values from local Codex session files and refresh within 0.5 seconds of a file change.
- Show `N/A` for limits that are not reported, and show reset times in a tooltip.
- Reuse the existing signed-in Codex session through `account/rateLimits/read`; never copy or store OAuth credentials.
- Keep local Codex `rate_limits` session events as an offline fallback and refresh within 0.5 seconds of a file change.
- Keep both rows visible, use an em dash for an unreported window, and replace it automatically when Codex provides a real percentage.
- Show reset times and the latest refresh time in a tooltip.
- Hide automatically over full-screen apps and return when the taskbar is visible.
- Support left-click refresh, a right-click menu, and single-instance execution.
- Include an installer that starts the widget automatically at Windows sign-in.
Expand Down
90 changes: 46 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</p>

<p align="center">
<strong>A compact Windows taskbar gauge for the Codex limits that matter.</strong><br />
See the current 5-hour and weekly allowance without reopening Codex.<br /><br />
No API key. No auth-file access. No cloud service. No usage estimation.
<strong>A compact Windows taskbar gauge for Codex usage.</strong><br />
Keep the 5-hour and weekly windows visible without reopening Codex.<br /><br />
No separate API key. No auth-file access. No usage estimation.
</p>

<p align="center">
Expand All @@ -21,9 +21,12 @@
<a href="https://github.com/Everyseok/codex-usage-widget/releases/tag/v1.0.0">
<img src="https://img.shields.io/badge/Release-v1.0.0-2563EB?style=for-the-badge" alt="Release v1.0.0" />
</a>
<a href="LICENSE">
<img src="https://img.shields.io/badge/License-MIT-F59E0B?style=for-the-badge" alt="MIT License" />
</a>
<img src="https://img.shields.io/badge/Runtime-Windows%2010%2F11-0078D4?style=for-the-badge&logo=windows11&logoColor=white" alt="Windows 10 and 11" />
<img src="https://img.shields.io/badge/App-Taskbar%20Widget-0EA5E9?style=for-the-badge" alt="Taskbar widget" />
<img src="https://img.shields.io/badge/Updates-Local%20Realtime-16A34A?style=for-the-badge" alt="Local real-time updates" />
<img src="https://img.shields.io/badge/Updates-Signed--in%20Live-16A34A?style=for-the-badge" alt="Signed-in live updates" />
<img src="https://img.shields.io/badge/Privacy-No%20Auth%20Reads-E11D48?style=for-the-badge" alt="No authentication-file reads" />
</p>

Expand All @@ -33,45 +36,46 @@

| Usual usage check | Codex Usage Widget |
|---|---|
| Reopen Codex and expand the usage panel | Keeps both limits visible on the taskbar |
| Poll a remote endpoint or store an API key | Reads the rate-limit snapshot Codex already wrote locally |
| Estimate usage from tokens or elapsed time | Displays the reported `used_percent` value directly |
| Refresh on a fixed timer only | Reacts to session-file changes in about 500 ms |
| Looks like a separate desktop overlay | Uses a transparent 232 px Fluent taskbar surface |
| Reopen Codex and expand the usage panel | Keeps both rows visible on the taskbar |
| Store a separate OAuth token or API key | Reuses the existing signed-in Codex session |
| Estimate usage from tokens or elapsed time | Displays the account's reported percentage directly |
| Assume every plan exposes the same limits | Clearly marks windows the account does not provide |
| Use a separate desktop overlay | Fits inside a transparent 232 px Fluent taskbar surface |

The widget is intentionally narrow in scope. It watches Codex `token_count` events, extracts the latest `rate_limits` snapshot, converts usage into remaining percentage, and renders only two taskbar rows: `5H` and `WEEK`.
The primary reader asks the locally installed Codex app server for `account/rateLimits/read`. Codex performs the authenticated request, so the widget never opens, copies, or stores the underlying OAuth credential. Recent local session snapshots remain available as a fast fallback.

---

## Core Properties

- **Reported usage, not guessed usage**: values come from Codex rate-limit snapshots.
- **Two-window glance**: 5-hour and weekly limits stay visible in one compact surface.
- **Event-driven refresh**: a filesystem watcher reacts to JSONL changes with a 500 ms debounce.
- **Taskbar-aware placement**: the widget anchors immediately left of the Windows notification area.
- **Two-row glance**: `5H` and `WEEK` stay in fixed positions for muscle memory.
- **Truthful state**: an unavailable window shows an em dash instead of a fabricated percentage.
- **Signed-in refresh**: the existing Codex login is reused every 15 seconds and on manual refresh.
- **Fast local fallback**: a filesystem watcher reacts to JSONL changes with a 500 ms debounce.
- **Taskbar-aware placement**: the widget anchors immediately left of the notification area.
- **Full-screen friendly**: it hides over full-screen apps and returns with the taskbar.
- **Local privacy boundary**: it does not read `auth.json`, make network requests, or require credentials.
- **Credential boundary**: it never reads `auth.json` or stores an OAuth token, API key, or password.

---

## Local Usage Runtime
## Runtime Architecture

| Layer | Value |
|---|---|
| App type | C# WinForms taskbar widget |
| Runtime | .NET Framework 4.8 |
| Session path | `%USERPROFILE%\.codex\sessions\**\*.jsonl` |
| Event type | `event_msg` → `token_count` |
| Usage payload | `rate_limits.primary` / `rate_limits.secondary` |
| Live update | `FileSystemWatcher` + 500 ms debounce |
| Fallback update | 15-second refresh timer |
| Primary source | Codex `account/rateLimits/read` |
| Authentication | Existing local Codex sign-in |
| Local fallback | `%USERPROFILE%\.codex\sessions\**\*.jsonl` |
| Fallback event | `event_msg` -> `token_count` -> `rate_limits` |
| Refresh | 15-second account read + click-to-refresh |
| Local reaction | `FileSystemWatcher` + 500 ms debounce |
| Taskbar anchor | `Shell_TrayWnd` / `TrayNotifyWnd` |
| Rendering | Per-pixel alpha layered window |
| Privacy boundary | No auth files, clipboard, screenshots, or network calls |

### Usage Model

Codex reports how much of a rate-limit window has been used. The widget converts it into the value shown on the taskbar:
Codex reports how much of a rate-limit window has been used. The widget converts that value into the remaining percentage shown on the taskbar:

```text
remaining_percent = clamp(100 - used_percent, 0, 100)
Expand All @@ -84,20 +88,20 @@ Rate-limit windows are classified by duration:
WEEK = nearest reported window to 10,080 minutes, with a 6-day minimum
```

If a reset timestamp has passed before a new snapshot arrives, the local display returns to `100%`. A limit omitted from the latest snapshot is shown as `N/A` rather than replaced with an estimate.
If the signed-in account returns `null` for a window, its fixed row shows `—`. The widget never derives one limit from the other. If Codex later reports that window, the real percentage appears automatically.

---

## Display States

| Condition | Display | Accent |
|---|---|---|
| Limit not reported | `N/A` | Neutral gray |
| Window not reported by the account | `` | Neutral gray |
| More than 35% remaining | Percentage gauge | Windows blue |
| 16-35% remaining | Percentage gauge | Amber |
| 0-15% remaining | Percentage gauge | Red |

Hovering the widget shows the exact remaining value, reset time, and timestamp of the latest Codex snapshot. Left-click refreshes immediately; right-click opens the native Refresh/Exit menu.
Hovering the widget shows the exact remaining value, reset time, and timestamp. Left-click refreshes immediately; right-click opens the native Refresh/Exit menu.

---

Expand Down Expand Up @@ -147,47 +151,45 @@ The repository workflow builds on `windows-latest` and uploads `CodexUsageWidget
|---|---|
| Windows | Windows 10 or Windows 11 |
| Runtime | .NET Framework 4.8 |
| Codex data | Desktop or CLI sessions under `%USERPROFILE%\.codex\sessions` |
| Network | Required only for clone, Actions, and release download |
| Codex | Signed-in Codex CLI recommended; Desktop/CLI session data is the fallback |
| Network | Required for live account refresh; local fallback remains available offline |
| Installed location | `%LOCALAPPDATA%\CodexUsageWidget` |
| Taskbar footprint | 232 × 42 px at 100% scaling |
| Taskbar footprint | 232 x 42 px at 100% scaling |

---

## Troubleshooting

| Symptom | Fix |
| Symptom | Explanation / Fix |
|---|---|
| `5H` shows `N/A` | The latest Codex snapshot may not report a separate 5-hour window for this plan. |
| Both rows show `N/A` | Use Codex once, then confirm that `.codex\sessions` contains recent JSONL files. |
| Values look stale | Left-click the widget; the 15-second fallback refresh will also re-read the latest snapshot. |
| `5H` shows `` | The signed-in account does not currently report a separate 5-hour window. This is expected for some plans. |
| Both rows show `` | Confirm `codex --version` works and Codex is signed in, or use Codex once to create local session data. |
| Values look stale | Left-click the widget; the 15-second account refresh also updates it automatically. |
| Widget is not visible | Exit the full-screen app or confirm that the Windows taskbar is visible. |
| Widget starts twice | Re-run `install.ps1`; the single-instance mutex keeps only one runtime active. |
| Build fails | Confirm that .NET Framework 4.8 and its C# compiler are available. |

---

## Distribution Notes

`build.ps1` produces a single WinForms executable with no third-party runtime packages. `install.ps1` copies it to the local app-data directory, replaces older widget Startup shortcuts that target the same executable, and launches the installed copy.
## Privacy Contract

The `v1.0.0` GitHub release contains the same executable verified by the local build flow. The repository remains source-first: generated files under `dist/` are ignored by Git and published through releases or Actions artifacts instead.
Codex Usage Widget treats rate-limit metadata as display telemetry, not user content.

---
The primary reader starts the local Codex app server and requests `account/rateLimits/read`. Codex owns the authenticated network request; the widget never opens or copies the credential. The fallback reader scans recent session-file tails in memory, but parses only lines that match `event_msg` -> `token_count` and contain `rate_limits`. Prompt and response payloads are not interpreted, retained, or transmitted.

## Runtime Contract
The widget does not access the clipboard, screenshots, focused-app content, URLs, or browser history. If the Codex app-server method is unavailable, it keeps using the last reported value and the local fallback.

Codex Usage Widget treats local rate-limit metadata as display telemetry, not user content.
---

The runtime scans the tail of recent session files in memory, but parses only lines that match `event_msg` → `token_count` and contain `rate_limits`. All other event types are ignored; prompt and response payloads are not interpreted, retained, or transmitted. The widget does not access authentication files, clipboard data, screenshots, focused-app content, URLs, or browser history, and it makes no network requests.
## Reproduction Prompt

The current parser depends on Codex's local JSONL session shape rather than a public usage API. A future Codex format change may require an update to `UsageReader`.
The concise English build prompt is available in [PROMPT.md](PROMPT.md).

---

## Reproduction Prompt
## License

The concise English build prompt is available in [PROMPT.md](PROMPT.md).
Released under the [MIT License](LICENSE). You may use, modify, and distribute this project subject to the license terms.

---

Expand Down
1 change: 1 addition & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
/reference:System.dll `
/reference:System.Core.dll `
/reference:System.Drawing.dll `
/reference:System.Web.Extensions.dll `
/reference:System.Windows.Forms.dll `
$sources

Expand Down
6 changes: 3 additions & 3 deletions docs/assets/readme/taskbar-preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 deletions docs/assets/readme/widget-hero.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Get-ChildItem -LiteralPath $startupDirectory -File -Filter '*.lnk' | ForEach-Obj
$shortcut = $shell.CreateShortcut($shortcutPath)
$shortcut.TargetPath = $target
$shortcut.WorkingDirectory = $installDirectory
$shortcut.Description = 'Codex 5-hour and weekly usage widget'
$shortcut.Description = 'Codex usage widget'
$shortcut.Save()

Start-Process -FilePath $target -WindowStyle Hidden
Expand Down
Loading