Skip to content

Extension for Windows - #12

Open
bhavsarpratik wants to merge 5 commits into
mainfrom
windows-arm
Open

Extension for Windows #12
bhavsarpratik wants to merge 5 commits into
mainfrom
windows-arm

Conversation

@bhavsarpratik

@bhavsarpratik bhavsarpratik commented Aug 3, 2026

Copy link
Copy Markdown
Member

Extending support for Windows

The claude auth-status and codex app-server quota refreshes (every QUOTA_REFRESH_S=60s)
shelled out to the provider CLIs without CREATE_NO_WINDOW, so on Windows a cmd/console
window flashed once a minute. Add a shared _NO_WINDOW creationflag (matching the updater)
and apply it to both calls.
@bhavsarpratik

Copy link
Copy Markdown
Member Author

Thanks Paul! Here is the feedback on the PR. We need to find someone on Windows.


Thanks for adding Windows support. I reviewed commit a1295c0, including the installer, updater, tray application, server changes, and tests. The general direction looks good, but a few Windows-specific reliability issues should be addressed before merge.

Must fix

  1. Recent-session selection does not work

    scripts/run-tray.ps1:352 requests /menubar?id=..., while meter.py:10075 only reads the session query parameter. Selecting a recent session therefore continues displaying the latest session.

    Please change this to ?session=... and add a behavioral test for the tray/backend contract.

  2. Network calls block the WinForms UI thread

    Invoke-TrayRefresh performs Invoke-RestMethod -TimeoutSec 4 synchronously. It runs when the menu opens and from the ten-second UI timer. If the server is restarting, indexing, or unavailable, the entire tray menu can freeze for four seconds—or eight seconds when it retries.

    Please perform HTTP work in a background task/runspace, coalesce overlapping refreshes, and marshal only the resulting UI update onto the WinForms thread.

  3. There is no crash recovery after login

    The installer creates one HKCU\...\Run entry. start-token-meter.ps1 starts the server and tray once and then exits. If either process crashes afterward, nothing restarts it.

    Consider separate per-user Scheduled Tasks with restart-on-failure, or a small supervisor process. The server and tray should have independent lifecycle management.

  4. Failed installation rollback leaves Token Meter offline

    The installer stops the existing processes and restores the previous runtime directory and registry value on failure, but it does not restart the restored version.

    After rollback, please start the restored server/tray and verify /health. If that fails, report that rollback itself was incomplete.

  5. The Codex quota subprocess reader is not Windows-portable

    meter.py:9059-9095 registers process.stdout with selectors.DefaultSelector. Windows’ select-based selector does not support anonymous subprocess pipes. CREATE_NO_WINDOW hides the console but does not make this pipe mechanism portable.

    A reader thread plus a bounded queue would work across platforms. This should have a Windows subprocess test.

  6. The documented and installed PowerShell runtimes are inconsistent

    The README tells users to run pwsh, although PowerShell 7 is not installed on a clean Windows machine. The installer then registers powershell.exe at login, without the same execution-policy arguments used during installation.

    Please either consistently support built-in Windows PowerShell:

    powershell.exe -NoProfile -ExecutionPolicy Bypass -File ...

    or detect and persist the shell used during installation.

Cross-platform maintainability

The PR currently implements platform behavior as Windows versus “everything else,” while the Linux PR adds a separate XDG branch. These changes will conflict and make future OS support harder.

I suggest centralizing platform detection and paths in something such as:

platform_paths.py
desktop/
  windows/
    TokenMeterTray.ps1

Use explicit windows, macos, linux, and unsupported cases. Also, run-tray.ps1 is too generic once Linux has a tray implementation; windows_tray.ps1 or desktop/windows/TokenMeterTray.ps1 would be clearer.

The 477-line tray script would also be easier to maintain if formatting/view-model logic were separated from the WinForms host.

Testing needed

The existing Windows tests are mainly source-string checks. Please add a windows-latest CI job that exercises:

  • PowerShell parsing
  • The Python test suite
  • Tray smoke startup
  • Recent-session selection
  • Install and clean reinstall
  • Failed-install rollback
  • Update and uninstall
  • Server/tray restart behavior

Because the PR specifically claims Windows ARM support, please also attach native ARM64 validation evidence: architecture output, installation, tray startup, login restart, update, and uninstall.

Local cross-platform checks passed: 233 tests passed with one Windows-only smoke test skipped, Python compilation passed, embedded JavaScript parsing passed, and git diff --check passed. I could not run PowerShell or perform native Windows/ARM64 validation from macOS.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants