Skip to content

fix: stop background Ollama refresh from spuriously requiring re-sign-in - #2814

Merged
steipete merged 4 commits into
steipete:mainfrom
axisrow:fix/ollama-background-cookie-flicker
Aug 13, 2026
Merged

fix: stop background Ollama refresh from spuriously requiring re-sign-in#2814
steipete merged 4 commits into
steipete:mainfrom
axisrow:fix/ollama-background-cookie-flicker

Conversation

@axisrow

@axisrow axisrow commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #2072.

ollama.com rotates its session cookie independently of the user's signed-in state. When a background refresh (the 5-minute timer) sees the cached cookie fail with an auth error, OllamaStatusFetchStrategy.fetchAutomatic cleared the cache and unconditionally fell through to a browser cookie read to recover — but BrowserCookieAccessGate denies that read in a background context (no interactive Keychain prompt outside a user-initiated action). The browser read then returned no candidates, surfacing as the misleading "No Ollama session cookie found. Please sign in at https://ollama.com/signin in your browser." error, even though the user was still signed in and the cache had simply been cleared a moment earlier by this same call. The cache stayed empty, so every subsequent background tick repeated the same failure until the next manual refresh repopulated it — this is the reported flicker (also matches SuperSalsa20's repro in the issue thread: background fails → interactive refresh recovers → next background refresh fails again).

fetchAutomatic still attempts browser-cookie recovery after clearing the stale cache, even in a background context — BrowserCookieAccessGate already gates that read on its own no-UI preflight (Safari never needs Keychain decryption, and a Chromium browser with a prior "Always Allow" Keychain grant is read without a prompt), so a background attempt is not unconditionally blocked. Only if that recovery attempt itself fails does the strategy fall back to surfacing an error: a generic, non-actionable browser failure (e.g. no candidates found) is swapped for the original, more informative cached-auth error, while a specific actionable browser-access diagnosis (Safari needs Full Disk Access, a Chromium Keychain prompt was declined/disabled) is preserved and re-thrown as-is, since that is always more useful than the stale cached error it would otherwise replace.

Root-cause writeup with the full execution chain: #2072 (comment)

Note: ClaudeWebAPIFetcher.fetchUsageSerialized uses a similar cache-invalidate-then-fallback-to-browser pattern; not touched in this PR to keep the change scoped to the reported Ollama issue, but worth a follow-up if an equivalent gap is independently confirmed there.

Test plan

  • swift test --filter OllamaUsageFetcherRetryMappingTests (33/33 passing) — covers background recovery after cache invalidation, preserving actionable browser-access errors, and the pre-existing user-initiated cached-cookie-replacement behavior.
  • make lint (0 violations)
  • Full swift test suite passing

Verification

Live-verified against this repo's own signed-in ollama.com session, run through a locally packaged, adhoc-signed CodexBar.app built from this branch (Scripts/package_app.sh release) so the CLI gets real Keychain persistence (an unsigned/unbundled swift build binary intentionally falls back to an in-memory-only cache — see KeychainCacheStore.swift, "Unbundled processes ... must never touch the shared cache item"). Full trace kept locally, redacted excerpts below (cookie names only ever appear in these logs — never values; usernames/emails scrubbed).

1. Cold background fetch after a forced cache miss — the background path honors its no-UI boundary: with no prior "Always Allow" Keychain grant for Chrome/Chromium on this machine, it correctly declines to prompt and surfaces the actionable sign-in message rather than silently hanging or crashing:

debug cookie-cache: provider=ollama Cookie cache miss
info  keychain-preflight: service=Chrome Safe Storage — requires interaction for the current process
info  browser-cookie-gate: browser=Chrome — Skipping background Chromium cookie import to avoid a Keychain prompt
info  keychain-preflight: service=Chromium Safe Storage — requires interaction for the current process
info  browser-cookie-gate: browser=Chromium — Skipping background Chromium cookie import to avoid a Keychain prompt
Error: No Ollama session cookie found. Please sign in at https://ollama.com/signin in your browser.

2. User-initiated recovery (cookie refresh --provider ollama --allow-keychain-prompt) — real browser-cookie import against the live session, cache populated:

info  browser-cookie-gate: browser=Chrome — Explicit browser cookie retry allowed
info  browser-cookie-gate: browser=Chrome — Explicit browser cookie retry succeeded
debug cookie-cache: provider=ollama source=Chrome Default — Cookie cache refresh staged
ollama: ✅ Browser cookie refreshed.

3. Warm-cache reuse in a separate process invocation — proves the cookie from (2) persisted to the real Keychain (not just in-process memory) and is reused without re-hitting the browser:

debug keychain-preflight: service=com.steipete.codexbar.cache — Keychain preflight allowed
debug cookie-cache: provider=ollama Cookie cache hit
== Ollama (web) ==
Session: 100% left ...

fetchAutomatic's recovery and error-classification logic does not read ProviderInteractionContext — only BrowserCookieAccessGate's no-UI preflight does — so the background and user-initiated code paths exercised above run the identical classification code covered by the stale-cached-cookie and actionable-browser-error unit tests. The one branch not live-exercised here is recovery from a stale-but-present cached cookie (vs. the cache-miss case (1) actually hit): reproducing that live would require writing a crafted expired value into this machine's real login-Keychain entry, which isn't a step I'm willing to script against real credentials — it's covered instead by OllamaUsageFetcherRetryMappingTests' injected-failure tests, which exercise the exact same code path with a controlled input.

🤖 Generated with Claude Code

Fixes steipete#2072.

ollama.com rotates its session cookie independently of the user's
signed-in state. When a background refresh (5-minute timer) sees the
cached cookie fail with an auth error, fetchAutomatic cleared the
cache and unconditionally fell through to a browser cookie read to
recover — but BrowserCookieAccessGate denies that read in a
background context (no interactive Keychain prompt outside a
user-initiated action). The browser read then returned no candidates,
surfacing as the misleading 'No Ollama session cookie found. Please
sign in...' error, even though the user was still signed in and the
cache had simply been cleared a moment earlier by this same call. The
cache stayed empty, so every subsequent background tick repeated the
same failure until the next manual refresh repopulated it — the
reported flicker.

fetchAutomatic now re-throws the original auth error instead of
falling through to a browser read when the interaction context is
.background, deferring recovery to the next user-initiated refresh
(which already has the explicit-retry path from steipete#2249/steipete#2595).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqBGFKF9M8etkRpgz2bk2Z
@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8928a4bdb9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// outside a user-initiated action), so falling through to `fetchBrowser` here would only
// trade this accurate auth error for a misleading "no session cookie" one. Defer recovery
// to the next user-initiated refresh, which already has the explicit-retry path.
guard ProviderInteractionContext.current == .userInitiated else { throw error }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve prompt-free background cookie recovery

When the cached Ollama cookie expires but the browser contains its rotated replacement, this guard now forces the refresh to fail instead of importing the fresh cookie. Background browser reads are not categorically denied: BrowserCookieAccessGate.shouldAttemptInBackground permits Chromium reads after a no-UI Keychain preflight, and non-Keychain sources can also be read safely; moreover, CLIUsageCommand deliberately performs normal usage fetches under .background, so the first CLI invocation after cookie rotation now reports invalidCredentials and only a second invocation can recover after the cache was cleared. Attempt fetchBrowser here and rethrow the cached authentication error only if that prompt-free recovery fails.

Useful? React with 👍 / 👎.

…cked

Round-1 review (Codex adversarial-review) found that the prior fix's
blanket 'skip browser recovery in the background' guard was wrong:
BrowserCookieAccessGate does not always deny a background browser
read — Safari never needs Keychain decryption at all, and a Chromium
browser with a prior 'Always Allow' Keychain grant is also read
without a prompt. The unconditional re-throw discarded those working
recovery paths, turning a real self-heal into a permanent background
failure whenever the cached-cookie clear also silently failed
(clearIfCurrent's boolean result is already discarded upstream).

fetchAutomatic now still attempts fetchBrowser() after an auth
failure in the background, exactly as it already does for the
parse-failure recovery branch below it, relying on
BrowserCookieAccessGate's own no-UI preflight to naturally deny a
prompt-requiring attempt. Only when that attempt itself fails does it
surface the original, accurate auth error instead of a misleading
'no session cookie' one.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqBGFKF9M8etkRpgz2bk2Z
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. labels Aug 9, 2026
@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed August 12, 2026, 11:58 AM ET / 15:58 UTC.

ClawSweeper review

What this changes

This PR lets automatic Ollama usage refresh retry browser-cookie import after a cached cookie fails, while preserving specific browser-access errors.

Merge readiness

Blocked until stronger real behavior proof is added - 5 items remain

Keep open: the changed recovery path still converts a deliberately suppressed background browser import into a “sign in again” error, and the submitted live trace does not exercise the stale cached-cookie branch.

Priority: P1
Reviewed head: a13c0d4f4664bec5017ccce3a22f2880a8d24410

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch and tests are useful, but one P1 recovery-diagnosis defect and missing direct runtime proof keep it from merge readiness.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The redacted packaged-app logs are credible for cache miss and manual recovery, but they do not show an after-fix stale cached-cookie failure reaching the changed recovery branch; add a redacted trace of that branch and outcome. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The redacted packaged-app logs are credible for cache miss and manual recovery, but they do not show an after-fix stale cached-cookie failure reaching the changed recovery branch; add a redacted trace of that branch and outcome. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items PR recovery mapping: The PR catches every non-actionable browser recovery failure and rethrows the original cached authentication error.
Background access behavior: The current access gate deliberately skips Chromium cookie reads in background unless its no-UI Keychain preflight is already allowed.
User-facing error remains misleading: The original invalid-credentials error tells the user to sign in again, although a suppressed background import can be recovered by a user-initiated refresh without signing in.
Findings 1 actionable finding [P1] Preserve manual recovery guidance after a suppressed import
Security None None.

How this fits together

CodexBar refreshes Ollama usage with a cached browser session cookie and falls back to browser-cookie import when that cache fails. The browser access gate permits only prompt-free background imports, then the resulting usage or error is presented by the provider UI.

flowchart LR
A[Scheduled Ollama refresh] --> B[Cached browser cookie]
B --> C{Cached request succeeds?}
C -->|yes| D[Usage snapshot]
C -->|auth failure| E[Clear stale cache]
E --> F[Prompt-free browser access gate]
F --> G[Browser cookie recovery]
G --> H[Usage snapshot or recovery guidance]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The redacted packaged-app logs are credible for cache miss and manual recovery, but they do not show an after-fix stale cached-cookie failure reaching the changed recovery branch; add a redacted trace of that branch and outcome. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve manual recovery guidance after a suppressed import (P1) - When the no-UI background gate yields no browser candidate, this catch rethrows invalidCredentials. That error still says “Please sign in again,” although the cache was cleared and a user-initiated Refresh can import the existing browser session. Propagate a distinct suppressed-background recovery result, or map this condition to Refresh guidance, while retaining the real sign-in path for an actually absent session.
  • Resolve merge risk (P1) - When the no-UI gate suppresses a background Chromium import, users still receive an instruction to sign in again despite a manual refresh being the appropriate recovery path.
  • Resolve merge risk (P1) - The submitted packaged-app logs demonstrate cache miss, interactive recovery, and warm-cache reuse, but not the stale cached-cookie recovery branch changed by this PR.
  • Complete next step (P2) - A narrow repair can preserve a manual-refresh diagnosis for background recovery suppression; contributor-supplied live proof is still required before merge.

Findings

  • [P1] Preserve manual recovery guidance after a suppressed import — Sources/CodexBarCore/Providers/Ollama/OllamaProviderDescriptor.swift:218-219
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test delta production +49/-8; tests +183/-16 The change is narrowly concentrated in one recovery path with substantial focused regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #2072
Summary: This PR is a partial candidate fix for the reported Ollama cookie-refresh behavior, but its remaining recovery diagnosis is still incorrect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Preserve manual recovery guidance (recommended)
    Add a distinct diagnosis for stale-cache recovery when a background browser import cannot proceed, then cover it with a focused regression test and live trace.
  2. Pause for direct evidence
    Do not merge until the contributor shows a redacted after-fix packaged-app trace for a stale cached cookie and the resulting recovery guidance or successful refresh.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Add a stale-cache background-recovery diagnosis that directs users to Refresh rather than sign in again; preserve actionable browser-access errors and add focused regression coverage.

Technical review

Best possible solution:

Return a distinct background stale-cache recovery diagnosis that directs the user to refresh the provider, preserve actionable browser-access errors, and attach a redacted packaged-app trace of the repaired branch.

Do we have a high-confidence way to reproduce the issue?

No high-confidence live reproduction of the changed branch is supplied: the PR explicitly says stale-but-present cached-cookie recovery was not live-exercised. The failure is high-confidence source-reproducible through the background access gate and error mapping.

Is this the best way to solve the issue?

No. Retaining the cached-auth error still instructs a signed-in user to sign in again; the recovery path needs a distinct manual-refresh diagnosis before merge.

Full review comments:

  • [P1] Preserve manual recovery guidance after a suppressed import — Sources/CodexBarCore/Providers/Ollama/OllamaProviderDescriptor.swift:218-219
    When the no-UI background gate yields no browser candidate, this catch rethrows invalidCredentials. That error still says “Please sign in again,” although the cache was cleared and a user-initiated Refresh can import the existing browser session. Propagate a distinct suppressed-background recovery result, or map this condition to Refresh guidance, while retaining the real sign-in path for an actually absent session.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c4ed34d0e44a.

Labels

Label justifications:

  • P1: The PR addresses a recurring provider-auth refresh failure that gives users incorrect recovery instructions.
  • merge-risk: 🚨 auth-provider: It changes browser-cookie authentication recovery and which credential diagnosis users receive.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The redacted packaged-app logs are credible for cache miss and manual recovery, but they do not show an after-fix stale cached-cookie failure reaching the changed recovery branch; add a redacted trace of that branch and outcome. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Acceptance criteria:

  • [P1] swift test --filter OllamaUsageFetcherRetryMappingTests.
  • [P1] make check.
  • [P1] make test.

What I checked:

Likely related people:

  • steipete: Recent history repeatedly updates the Ollama descriptor, and this person merged the earlier cookie-access diagnostic work. (role: recent provider-architecture contributor; confidence: high; commits: 7f2c5965cd4a, 777107a2bbb8, b2589aceb0c3; files: Sources/CodexBarCore/Providers/Ollama/OllamaProviderDescriptor.swift, Tests/CodexBarTests/OllamaUsageFetcherRetryMappingTests.swift)
  • masonxhuang: Introduced the cached Ollama browser-session validation behavior that this recovery path extends. (role: introduced cached-session validation; confidence: medium; commits: 667beb1bfd8b; files: Sources/CodexBarCore/Providers/Ollama/OllamaProviderDescriptor.swift, Tests/CodexBarTests/OllamaUsageFetcherRetryMappingTests.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Return manual-refresh guidance for the gate-suppressed stale-cache path while preserving actual sign-in and actionable access errors.
  • Add focused coverage for that diagnosis.
  • Attach a redacted packaged-app trace of stale cached-cookie recovery; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (6 earlier review cycles)
  • reviewed 2026-08-09T13:44:34.379Z sha 61ce42c :: needs real behavior proof before merge. :: [P1] Preserve browser access errors on user-initiated refresh
  • reviewed 2026-08-09T13:58:58.557Z sha 169b084 :: needs real behavior proof before merge. :: [P1] Preserve browser access errors on user-initiated refresh
  • reviewed 2026-08-09T14:16:21.039Z sha 169b084 :: needs real behavior proof before merge. :: [P1] Preserve browser access errors on interactive refresh
  • reviewed 2026-08-09T14:43:48.456Z sha a13c0d4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-09T15:29:03.453Z sha a13c0d4 :: needs real behavior proof before merge. :: [P1] Surface a manual-refresh instruction when background import is suppressed
  • reviewed 2026-08-09T15:34:57.395Z sha a13c0d4 :: needs real behavior proof before merge. :: [P1] Preserve a manual-recovery diagnosis for suppressed background imports

Round-2 review (built-in /review) flagged that round 1's fix made the
auth-failure branch's recovery logic byte-for-byte identical to the
adjacent shouldTryBrowserCandidates branch. Extract the shared
'attempt fetchBrowser, surface the original error if that also fails'
pattern into fetchBrowserOrRethrow so both branches call one helper
instead of duplicating the do/catch.

No behavior change; swift test --filter OllamaUsageFetcherRetryMappingTests
stays 30/30 green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqBGFKF9M8etkRpgz2bk2Z
@axisrow

axisrow commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

🔍 Local review (cycle 3/3, final) — round 9284d2d6-d87e-4e30-a172-67877e4caf36

Reviewed locally (/review + Codex companion), no bots pinged.

Verdict Reviewer Finding Location
SKIP codex The shared browser-recovery helper masks any browser-side error under the original cached-auth error, but this catch-and-preserve pattern predates this PR and was only extended to one more call site as intended. OllamaProviderDescriptor.swift:206
Confirmed, no defect claude Re-verified that the background browser-cookie retry this PR relies on cannot trigger an interactive Keychain prompt in any code path. OllamaProviderDescriptor.swift

No FIX or UNVERIFIED findings this round. Cycle complete.

@axisrow

axisrow commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

📋 Review summary — all cycles

Cycle Reviewer Finding Verdict Resolution
1 codex Background auth-failure recovery unconditionally re-threw instead of ever attempting a browser-cookie read, even when that read would have succeeded without a prompt. FIX Fixed in 61ce42c
1 claude (no issues found)
2 claude The new recovery branch duplicated an adjacent branch nearly verbatim; extracted into one shared helper. FIX Fixed in 169b084
2 codex Cross-account cookie mixing on a passive refresh is a real gap in the cache, but it predates this PR and already existed via other reachable code paths. SKIP Pre-existing, out of scope
2 codex An in-flight background browser fetch can overwrite a cache entry the user cleared moments earlier, but this race already existed in the pre-existing recovery paths this PR reuses. SKIP Pre-existing, out of scope
2 codex A background access failure can extend an existing multi-hour cooldown on further browser attempts, but the cooldown mechanism itself is unchanged by this PR. SKIP Pre-existing, out of scope
3 codex The shared recovery helper always re-surfaces the original cached-auth error over any browser-side error, but that masking behavior predates this PR by many commits. SKIP Pre-existing, out of scope
3 claude Re-confirmed that the background browser-cookie retry this PR relies on cannot trigger an interactive Keychain prompt in any reachable code path. Confirmed, no defect Re-verified

Totals: 2 FIX (both resolved), 4 SKIP (pre-existing architectural properties, out of scope for this issue), 0 UNVERIFIED.

Review complete after 3 cycles — no FIX or UNVERIFIED findings remain. Per the review-only-on-merge policy, merging is a manual step for the PR author. The SKIPped findings (cross-account cookie binding, unconditional cache overwrite race, background cooldown lockout) describe a real, broader architectural gap in the automatic cookie-resolution system worth a follow-up issue, independent of this PR.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. P1 Urgent regression or broken agent/channel workflow affecting real users now. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. P2 Normal priority bug or improvement with limited blast radius. labels Aug 9, 2026
ClawSweeper (P1) and Codex both flagged that fetchBrowserOrRethrow
swallows every fetchBrowser failure — including the specific,
actionable diagnoses (safariCookieAccessDenied,
browserCookieDecryptionDenied, browserCookieDecryptionDisabled) — and
always substitutes the generic stale cached-cookie auth error. On a
user-initiated refresh this replaces a fixable diagnosis (grant Full
Disk Access, retry a declined Keychain prompt) with a misleading
'please sign in again', undoing the explicit-retry guidance shipped in
steipete#2249/steipete#2595.

fetchBrowserOrRethrow now re-throws an actionable browser-access error
as-is instead of substituting the original cached error; a non-
actionable recovery failure (no candidates found, network error, etc.)
still falls back to the original error as before.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqBGFKF9M8etkRpgz2bk2Z
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 9, 2026
@axisrow

axisrow commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

axisrow added a commit to axisrow/CodexBar that referenced this pull request Aug 9, 2026
ClaudeWebAPIFetcher.fetchUsageSerialized cleared a stale cached session
cookie on an auth failure and unconditionally fell through to a browser
cookie read to recover, exactly the pattern fixed for Ollama in PR steipete#2814.
In a background context BrowserCookieAccessGate typically denies that
read (no interactive Keychain prompt outside a user-initiated action),
so extractSessionKeyInfo finds no session key and the generic 'no
session key found' error replaces the original, more informative
cached-auth error (e.g. the OAuth-absence message) — surfacing as the
same intermittent flicker already reported for Claude.

Still attempt browser-cookie recovery after clearing the stale cache,
even in a background context — BrowserCookieAccessGate already gates
that read on its own no-UI preflight (Safari never needs Keychain
decryption, and a Chromium browser with a prior 'Always Allow' Keychain
grant is read without a prompt) — so a background attempt is not
unconditionally blocked. Only when that attempt also fails do we now
surface the original cached-auth error instead of the misleading
generic one.

Adds ClaudeWebBackgroundRecoveryTests covering: background recovery
that finds nothing (original error surfaces), background recovery that
succeeds without a prompt (still works), and the equivalent
user-initiated case.
@steipete
steipete merged commit 58b894d into steipete:main Aug 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No Ollama session cookie found. Please sign in at https://ollama.com/signin in your browser.

2 participants