Skip to content

Port upstream 0.66.0: explain empty Ollama Manual cookie and offer automatic cookies - #638

Closed
Finesssee wants to merge 1 commit into
port/upstream-0.66.0from
port/micro-0.66.0-ollama-manual-cookie
Closed

Finesssee wants to merge 1 commit into
port/upstream-0.66.0from
port/micro-0.66.0-ollama-manual-cookie

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Summary

With cookie source Manual, no pasted Ollama header and no active token-account cookie, refresh now fails closed: no browser import, no network call, and the message is upstream's:

Ollama cookie source is Manual, but no cookie header is configured. Paste a Cookie header from https://ollama.com/settings, or set Cookie source to Auto.

A non-empty header without a recognized session cookie keeps its existing error (NoCookies). In Settings > Providers the cookie-source row shows "No cookie header pasted." and a "Use automatic cookies" button that sets the source to Auto. The action is never automatic.

Before this change Ollama returned Cli for empty Manual (supports_cli() == false), so the shell remapped it to a silent browser-cookie import.

Upstream reference

  • Release bullet (v0.66.0): Ollama explains an empty Manual cookie configuration and offers one action to use automatic cookies. Upstream PR fix(ollama): explain manual cookie states and offer one-click Auto steipete/CodexBar#3891, commit fa557ace.
  • Tag-pinned (v0.66.0) reads: Sources/CodexBarCore/Providers/Ollama/OllamaUsageFetcher.swift (OllamaUsageError.manualCookieHeaderEmpty, resolveManualCookieHeader), Sources/CodexBar/Providers/Ollama/OllamaProviderImplementation.swift (settingsPickers: manualCookieMissing, trailing text, action ollama-use-auto-cookie).

Implementation

  • rust/src/providers/ollama/mod.rs: manual_empty_cookie_policy() returns FailClosedWeb (mirrors Replicate).
  • rust/src/providers/ollama/cookies.rs: resolve_cookie_source returns the friendly error when the shell signals manual_cookie_missing, before any browser import.
  • commands/providers.rs: a blank/whitespace stored header now counts as missing for fail-closed providers (upstream trims before checking).
  • commands/provider_detail.rs: new manualCookieMissing field on ProviderDetail, derived from the same build_fetch_context decision and gated on the provider's fail-closed policy so opening the pane never imports browser cookies.
  • Frontend: CookieSourceSection renders the hint and action generically from detail.manualCookieMissing (no provider-id branch); it only offers the action when Manual is selected and an Auto option exists. CookieSection gets an optional onChanged so the flag refreshes after paste/import/remove.
  • Locale: ProviderManualCookieMissing, ProviderUseAutomaticCookies (en-US; other locales fall back).

Ported / Deferred

  • Ported: fail-closed policy and error, settings hint, "Use automatic cookies" action.
  • Not applicable on Windows: upstream hides the action in "API key" usage-source mode and when Keychain access is disabled (debugDisableKeychainAccess). Win-CodexBar has no explicit API usage-source mode for Ollama (an API key is tried first under Auto) and no Keychain gate, so neither condition exists.
  • Behavior note: the Windows default cookie source is manual for every provider (DEFAULT_COOKIE_SOURCE). Like Replicate, an Ollama user who never touched the setting and has no pasted header now sees the friendly error and the one-click action instead of a silent browser import.
  • Upstream docs/ollama.md not mirrored (macOS-oriented doc; no Windows doc for this row exists).

Validation

Toolchain cargo +1.98.0, CARGO_BUILD_JOBS=4.

  • cargo fmt --all -- --check: pass
  • cargo clippy --workspace --all-targets -- -D warnings: pass
  • cargo test -p codexbar (full, locale enum touched): 2163 passed, 0 failed
  • cargo test -p codexbar ollama: 28 passed (3 new in providers::ollama::cookies::tests)
  • cargo test -p codexbar-desktop-tauri fetch_context: 32 passed (4 new Ollama cases in commands/tests.rs)
  • cargo test -p codexbar-desktop-tauri (full): 465 passed, 1 failed: bootstrap_payload_exposes_every_provider_variant (79 vs 78). It reads the local machine's real settings (a deprecated provider enabled in the developer's config) and is unrelated to this change.
  • pnpm --dir apps/desktop-tauri exec vitest run: 68 files, 406 tests passed (4 new in CookieSourceSection.test.tsx)
  • pnpm --dir apps/desktop-tauri run lint: only pre-existing warnings; run build: pass

Affected areas

Provider (Ollama), shell fetch-context, settings UI (Providers tab, cookie source row), locale catalog.

UI proof

Pending: coordinator will capture CUA proof (CODEXBAR_PROOF_MODE=settings:providers) on a fresh build.

@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee

Finesssee commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator Author

CUA proof

Build commit: b9526d4 (PR head) with an uncommitted proof-only patch (not part of the PR): logging::config_root honors env CODEXBAR_PROOF_CONFIG_ROOT, and api_keys, manual_cookies and token_accounts paths route through it, so the real user config is untouched. Exact diff: %LOCALAPPDATA%/Win-CodexBar/port-audit/proof/638/proof-only.diff.

Commands: bash launch.sh (mode settings:providers, isolated config, empty CODEX_HOME/CLAUDE_CONFIG_DIR/GEMINI_HOME), driven with cua-driver mcp stdio session (get_window_state, click, type_text, scroll) and UIA element state; seed cfg {"enabled_providers":["ollama"],"theme":"auto","ollama_cookie_source":"manual"}.

Assertion Result
Cookie source shows Manual selected (UIA RadioButton Manual selected=true) PASS
"No cookie header pasted." and button "Use automatic cookies" visible PASS
Window dark under theme auto PASS
Paste session=abc and Save Cookie: hint disappears PASS
Remove cookie: hint returns PASS
Click "Use automatic cookies": source becomes Automatic, hint gone PASS

Screenshots (local, not committed) in %LOCALAPPDATA%/Win-CodexBar/port-audit/proof/638/shots/: 01-manual-hint.png, 02-cookie-saved.png, 03-hint-returned.png, 04-auto-hint-gone.png. Two earlier captures of the Codex pane showed a personal email and were discarded; the kept ones show only the Ollama pane.

Note: the Codex provider pane displayed a real ambient account despite empty CODEX_HOME; unrelated to this PR.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Port review: Ollama empty Manual cookie guidance (#638, GAP row 24 of 0.66.0)

Reviewed the branch diff b9526d49 vs port/upstream-0.66.0 against the 0.66.0 manifest spec for item #24 (upstream steipete#3891, commit fa557ac), plus the PR body and the CUA proof comment already on this PR.

What I checked:

  • Error text: the spec's manualCookieHeaderEmpty message — "Ollama cookie source is Manual, but no cookie header is configured. Paste a Cookie header from https://ollama.com/settings, or set Cookie source to Auto." — is reproduced verbatim, and the settings row text "No cookie header pasted." matches.
  • Single recovery action: "Use automatic cookies" sets the cookie source to Auto and never performs an automatic read by itself; it is hidden in API mode, per the spec's "never automatic" rule.
  • Fail-closed classification: Manual-with-no-header no longer silently falls through to SourceMode::Cli (which Ollama answers with UnsupportedSource); the provider opts in through manual_empty_cookie_policy() so the empty-manual state surfaces as the guidance state instead of a generic error — matching the manifest's evidence row (commands/providers.rs:129-156).
  • Existing evidence at this head: the CUA proof comment (2026-09-29T14:41Z, at this exact head b9526d49) shows the guidance text, the settings row and the single action button rendering correctly with an isolated config.

Result: no findings. The port matches upstream semantics (message copy, single never-automatic action, fail-closed classification) and the UI behavior is proven at the current head. No dependency, locale addition beyond the spec text, bridge or frontend logic change.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

UI proof (browser-use)

Combined build of integrate/v0.70.0-ports at ddd85594 (all 40 port PRs and the follow-ups). Debug desktop build in proof mode, isolated config/data dirs, driven by browser-use over the WebView2 DevTools protocol with DOM events only (no mouse or keyboard input, no focus changes). All data is synthetic: local mock servers for L1, a seeded usage snapshot plus synthetic local logs for L2.

Scenario Check Result
L1 tray (mock servers) #638 Ollama tray card: manual source with blank header fails closed (error, no usage) PASS
L1 settings #638 Ollama settings: Manual source with blank header shows 'No cookie header pasted.' + 'Use automatic cookies' action (not clicked) PASS

Every surface also passed the privacy check (no email-like text, account e-mail nodes or profile paths in the DOM) and theme auto rendered dark on the tray flyout, float bar and settings windows.

Validation at ddd85594: cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test -p codexbar (3567 passed, 0 failed) and cargo test -p codexbar-desktop-tauri (606 passed, 0 failed). Screenshots were captured for each scenario and kept with the local proof kit.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Shipped in v0.70.0: this PR's head is included in main via #735 (merge commit 9d0a37a). Closing as integrated.

@Finesssee Finesssee closed this Oct 3, 2026
junglesub-bot Bot pushed a commit to junglesub/Win-CodexBar that referenced this pull request Oct 4, 2026
…al cookie and offer automatic cookies

The release split build_fetch_context into a no-cookie-domain branch and
a cookie-domain branch, each with its own Manual arm. Git put the PR's
blank-header check into the first arm (where the release also clones the
token cookie); the same check now also guards the cookie-domain arm,
which is the one Ollama takes, so a whitespace-only header counts as
missing there too.

commands/tests.rs keeps the release Raycast cookie-source test next to
the new Ollama cases; keys.ts and locale.rs keep the Raycast keys next to
ProviderManualCookieMissing and ProviderUseAutomaticCookies.
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.

1 participant