Skip to content

[Bug]: Grok usage tracking ignores configured WSL account runtime #13784

Description

@euclodius

Operating system

Windows 11 with WSL2, Ubuntu-24.04.

Orca version

1.4.180

Summary

Grok CLI is installed, signed in, and working inside WSL, but Orca reports:

Not signed in to Grok CLI
In a terminal, run grok login, then click Refresh usage here.

Clicking Refresh usage does not change the status.

Configuration

Orca is configured to use WSL for local accounts:

localAccountRuntime: wsl
localAccountWslDistro: Ubuntu-24.04

The project and Orca terminals also run inside that WSL distro.

Verified state

Inside WSL:

$ grok models
You are logged in with grok.com.

The Grok session file exists in the WSL home:

/home/<linux-user>/.grok/auth.json

It is accessible from Windows through UNC:

\\wsl.localhost\Ubuntu-24.04\home\<linux-user>\.grok\auth.json

There is no corresponding host-side file:

C:\Users\<windows-user>\.grok\auth.json

Despite the valid WSL session, Orca still reports "Not signed in to Grok CLI".

Reproduction

  1. Install Grok CLI inside WSL only.
  2. In Orca, set the local account runtime to WSL and select the distro.
  3. Run grok login inside WSL.
  4. Confirm that grok models reports a signed-in session.
  5. Open Settings -> AI Provider Accounts -> Grok.
  6. Click Refresh usage.
  7. Observe "Not signed in to Grok CLI".

Actual behavior

When GROK_HOME is not set for the Windows Electron process, Orca resolves the auth location from the Windows host home:

C:\Users\<windows-user>\.grok\auth.json

It does not use localAccountRuntime or localAccountWslDistro.

Expected behavior

When the configured local account runtime is WSL, Orca should resolve the selected distro's home and read:

\\wsl.localhost\<distro>\<linux-home>\.grok\auth.json

Both the Grok account-status handler and usage/rate-limit fetcher should use the same runtime-aware path.

Root cause

In the current implementation, resolveGrokHomeDir() falls back to os.homedir()/.grok when GROK_HOME is unset:

  • src/main/rate-limits/grok-auth.ts
  • src/shared/grok-session-paths.ts

Because Orca's Electron main process runs on Windows, this resolves to the Windows user home. The configured WSL account runtime is not considered for Grok auth/status or usage reads.

This makes the UI guidance misleading in this setup: running grok login in an Orca WSL terminal writes the valid session to WSL, while Orca checks an unrelated Windows path.

Suggested implementation

Please apply the same runtime-aware credential resolution pattern used for Kimi in:

In particular:

  • resolve the credential home from localAccountRuntime and localAccountWslDistro;
  • map the WSL home to its UNC path on Windows;
  • use bounded asynchronous filesystem reads, so an unavailable distro cannot block the Electron main process;
  • use one resolved path consistently for Grok status and usage/rate-limit reads.

Related

#12370 explicitly noted that the same runtime-target gap likely affected the Grok fetcher.

Activity

  1. manuaudio commented on Aug 11, 2026

    @manuaudio
    Contributor

    Confirmed at source, and better than that — every component the fix needs already exists in the tree, in the same directory. There's one real snag, which I'll get to. Verified on upstream/main at 3713dd7376.

    Your root cause, exactly

    src/shared/grok-session-paths.ts:40-46:

    /** Resolve Grok's configured home, falling back to the runtime user's home. */
    export function resolveGrokHomeDir(
      env: GrokSessionPathEnv = process.env,
      homeDir: string = homedir()
    ): string {
      const fromEnv = env.GROK_HOME?.trim()
      return fromEnv || join(homeDir, '.grok')
    }

    and the caller, src/main/rate-limits/grok-auth.ts:5-8:

    // Why: when GROK_HOME is set, auth.json must be the same path Grok CLI uses.
    export function getGrokHome(): string {
      return resolveGrokHomeDir()
    }

    Called with no arguments, so both parameters take their defaults: process.env (the Windows Electron process, where GROK_HOME is unset) and homedir() (the Windows profile). C:\Users\<windows-user>\.grok, precisely as you reported.

    Worth noting the // Why: covers only the GROK_HOME branch — it justifies honouring an explicit override, and says nothing about what the fallback should be. The fallback is where the runtime setting should have entered and simply doesn't.

    Your "both handlers" expectation maps to exactly two call sites, and both have the same shape:

    Call site Purpose
    src/main/rate-limits/grok-auth.ts:7 usage / rate-limit auth
    src/main/grok/hook-service.ts:68 status hook (join(resolveGrokHomeDir(), 'hooks', 'orca-status.json'))

    getGrokHome / getGrokAuthPath have no importers outside grok-auth.ts itself (:11, :86), so the blast radius is those two files.

    The parts that already exist

    The resolver already accepts the override — resolveGrokHomeDir(env, homeDir) — so no signature change is needed. And the rest is in-tree:

    • The runtime target, in the same directory: getInitialAccountRateLimitTarget (src/main/rate-limits/initial-account-rate-limit-target.ts:18-42) reads settings.localAccountRuntime === 'wsl' and returns { runtime: 'wsl', wslDistro }, resolving the distro via resolveLocalAccountRuntimeTarget. It is already computing the exact fact getGrokHome() needs.
    • Distro → Linux home: getWslHomeAsync(distro) (src/main/wsl.ts:306), already used by AI Vault (cached-session-list.ts:124).
    • Linux path → UNC: src/shared/wsl-paths.ts:31 builds \\wsl.localhost\<distro>\<path>.

    So this reads less like "add WSL support to Grok" and more like connecting three things that are already neighbours.

    The snag

    getWslHomeAsync is async (Promise<string | null>), and the Grok path is synchronous end to end — getGrokHome() → getGrokAuthPath() → existsSync / readFileSync at grok-auth.ts:86. So the wiring isn't purely mechanical: either that chain becomes async, or the WSL home is resolved once and cached somewhere the sync path can read.

    That's the design question I'd put to a maintainer rather than guess at, because it decides whether this is a two-line change or a small refactor. It's also the reason I'd expect the fix to look different from the Codex one below.

    Same family as #13697

    The Codex analogue has the identical shape — getCodexHomePath() falls back to codexHomePath ?? process.env.CODEX_HOME ?? join(homedir(), '.codex'). The difference is that Codex's fetcher does have a WSL lane (buildWslCodexCommand, which takes a \\wsl$\… UNC path and runs codex inside the distro) — but only when a caller supplies codexHomePath explicitly. Grok has no equivalent caller at all.

    Two symptoms, one root: a home resolver whose WSL-awareness depends entirely on whoever calls it, in a codebase where the runtime setting is available but not threaded through. Worth fixing them with the same shape if a maintainer picks both up.

    (Also related, different mechanism: #13697 is a concurrency defect in the Codex lock rather than a path one — the WSL probe and spawn lanes key differently, so the lock never engages. Mentioning only so nobody merges the two.)

    What I did not verify

    No Windows/WSL host here, so I haven't reproduced the "Not signed in" state or confirmed that pointing homeDir at the UNC path makes the read succeed. Your UNC-accessibility check (\\wsl.localhost\Ubuntu-24.04\home\<user>\.grok\auth.json readable from Windows) is the load-bearing evidence that it would, and that's your measurement, not mine.

  2. added
    bug
    os:linux
    on Sep 19, 2026
  3. added theissue type on Sep 19, 2026
  4. nwparker commented on Nov 17, 2026

    @nwparker
    Contributor

    Thanks for reporting this! This looks like it comes from Orca's older WSL integration, which reaches into the distro from Windows through \\wsl.localhost paths and wsl.exe. We've since shipped a new WSL bridge, WSL hosts, where Orca's server runs inside the distro itself, so this part of the old path isn't involved.

    Could you give it a try?

    1. Open Settings → Experimental and turn on WSL hosts.
    2. Click Add a project → Add remote host → Add WSL distro and pick your distro.
    3. Open your project on that WSL host and try the same steps again.

    If it still happens there, please let us know here with your Orca version. That helps us a lot.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugos:Windowsos:linux

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions