Skip to content

Windows tray autostart Run entry exceeds 260-character limit and does not launch after sign-in #696

Description

@tulb-git

Client or integration

OpenCodex dashboard

Area

Installation or packaging

Summary

On Windows, ocx tray install registers the entire PowerShell tray invocation
directly under:

HKCU\Software\Microsoft\Windows\CurrentVersion\Run

With a normal user-owned global npm prefix, the generated command was 493
characters. Microsoft documents that Run/RunOnce command lines must be no
longer than 260 characters:

https://learn.microsoft.com/windows/win32/setupapi/run-and-runonce-registry-keys

OpenCodex reports the tray as installed and Windows marks the startup entry
enabled, but the tray does not launch after the next Windows sign-in. The proxy
service starts normally; only the tray process/icon is missing.

Expected: ocx tray install creates a Windows startup registration that
reliably starts the tray at sign-in.

Reproduction

  1. Install OpenCodex globally in the standard per-user npm prefix:

    npm install -g @bitkyc08/opencodex@2.7.41
  2. Install the tray:

    ocx tray install
  3. Inspect the generated HKCU Run value. In this environment it was:

    "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -STA -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\Users\[user]\.opencodex\opencodex-tray.ps1" -BunPath "C:\Users\[user]\AppData\Roaming\npm\node_modules\@bitkyc08\opencodex\node_modules\bun\bin\bun.exe" -CliPath "C:\Users\[user]\AppData\Roaming\npm\node_modules\@bitkyc08\opencodex\src\cli\index.ts" -CodexHome "C:\Users\[user]\.codex" -OpenCodexHome "C:\Users\[user]\.opencodex" -Mode Run
    

    Length: 493 characters.

  4. Restart Windows and sign in.

  5. Observe that the OpenCodex proxy service is healthy, but the tray icon is
    absent and ocx tray status --json reports:

    {"supported":true,"installed":true,"running":false,"stale":false,"summary":"installed, not currently running"}
  6. The HKCU Run value still matches tray-state.json, and
    Explorer\StartupApproved\Run contains the enabled value
    020000000000000000000000. No tray PowerShell process exists, and the
    heartbeat is left over from the previous session.

  7. Starting the tray manually works, confirming that the tray script itself is
    functional and the failure is specifically login persistence.

Version

opencodex 2.7.41

Operating system

Windows 10 Pro x64, build 19045

Provider and model

Not provider-specific.

Logs or error output

Tray API: installed=true, running=false, stale=false
Run command length: 493
StartupApproved: 020000000000000000000000
Heartbeat PID: no longer running
Matching opencodex-tray.ps1 process count: 0
Proxy /healthz: healthy

Suggested fix / validated mitigation

Register a short owned launcher instead of the full PowerShell command. For
example:

"C:\WINDOWS\System32\wscript.exe" //B //NoLogo "C:\Users\[user]\.opencodex\opencodex-tray.vbs"

This replacement was 94 characters. The VBS launcher invoked the existing
PowerShell command invisibly. After adding launcherPath and the matching short
runCommand to tray-state.json, launching through the actual registered VBS
path produced a fresh heartbeat and ocx tray status --json reported:

{"supported":true,"installed":true,"running":true,"stale":false,"summary":"installed and running"}

The current tray state schema already supports an optional launcherPath, and
the installer contains cleanup logic for an older owned VBS launcher, so this
may be a regression from an earlier launcher-based design.

It would also be useful for the installer/tests to assert that a generated
HKCU Run command does not exceed 260 characters under long Windows user/npm
paths.

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions