Hmbown/CodeWhale · error · Error

This browser session is not authenticated. Restart…

Error message

This browser session is not authenticated. Restart `codewhale web` to open a fresh one-time session.

What it means

The web client's api() wrapper replaces the error message with this text when the Runtime answers HTTP 401, because browser sessions are one-time tokens minted by `codewhale web` at startup. A 401 means that token is no longer valid and the page cannot authenticate itself to the Runtime.

Solutions

  1. Stop and rerun `codewhale web`, then open the freshly printed one-time URL in the same tab
  2. Reload only from the new URL emitted by the latest `codewhale web` invocation
  3. Close stale tabs pointing at old sessions and use one tab per session
  4. Check that no proxy strips the session credentials/cookies on the way to the Runtime

Example fix

// before: retrying requests against a dead session
await api('/v1/providers');
// after: detect 401 and prompt the user to re-open a fresh session URL
try { await api('/v1/providers'); }
catch (e) {
  if (String(e.message).includes('not authenticated')) location.href = await promptForFreshSessionUrl();
}
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try { await api(path); } catch (e) { if (String(e.message).includes('not authenticated')) { showToast('Restart `codewhale web` and open the new URL.'); } }

Prevention

When it happens

Trigger: Any api() call returns response.status === 401: the one-time session token expired or was invalidated, the Runtime restarted (issuing new tokens), or the request was made from a page whose token was never issued.

Common situations: Keeping the browser tab open across a `codewhale web` restart; copying the URL to a second browser/device (one-time session); long-lived tab outliving the token lifetime; sharing the URL in chat after the token was consumed.

Understand the failure class

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/b5c2881c8e23e59c. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/runtime_web/app.mjs:956

    }
    const response = await fetch(path, {
      ...options,
      headers,
      credentials: "same-origin",
      cache: "no-store",
    });
    if (!response.ok) {
      let message = `${response.status} ${response.statusText}`.trim();
      try {
        const body = await response.json();
        message = body?.error?.message || body?.message || message;
      } catch (_error) {
        // The status line is enough when the response is not JSON.
      }
      if (response.status === 401) {
        message = "This browser session is not authenticated. Restart `codewhale web` to open a fresh one-time session.";
      }
      throw new Error(message);
    }
    if (response.status === 204) return null;
    const contentType = response.headers.get("content-type") || "";
    return contentType.includes("application/json") ? response.json() : response.text();
  }

  function renderThreadList() {
    dom.threadList.replaceChildren();
    if (app.summaries.length === 0) {
      const empty = element("p", "thread-preview", "No matching threads");
      empty.style.padding = "8px 10px";
      dom.threadList.append(empty);
      return;
    }

    const groups = groupThreadSummaries(app.summaries);
    if (groups.needsYou.length > 0) {
      appendThreadGroup("Needs you", "needs-you", groups.needsYou);

View on GitHub (pinned to 73e0f67d83)