Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Claude: distinguish Max 5x and Max 20x in the plan label instead of a flat "Max". Thanks @kes02!

### Fixed
- Ollama: point missing-session recovery to the current `/signin` page instead of the protected settings page. Thanks @joeVenner!
- Alibaba Token Plan: support International Model Studio while preserving China-mainland upgrades and isolating regional cookie caches. Thanks @harshav167!
- Amp: open the current Usage page from the menu dashboard action. Thanks @3kh0!
- Browser cookies: stop automatic Chromium-family probes after the first Safe Storage denial, while keeping an explicit Refresh retry available (#1952). Thanks @CoreyCole!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ private func hasRecognizedOllamaSessionCookie(in header: String) -> Bool {
}

public enum OllamaUsageError: LocalizedError, Sendable {
private static let signInURL = "https://ollama.com/signin"

case missingAPIKey
case notLoggedIn
case invalidCredentials
Expand All @@ -43,17 +45,17 @@ public enum OllamaUsageError: LocalizedError, Sendable {
case .missingAPIKey:
"Missing Ollama API key. Set apiKey in ~/.codexbar/config.json or OLLAMA_API_KEY."
case .notLoggedIn:
"Not logged in to Ollama. Please log in via ollama.com/settings."
"Not signed in to Ollama. Please sign in at \(Self.signInURL)."
case .invalidCredentials:
"Ollama session cookie expired. Please log in again."
"Ollama session cookie expired. Please sign in again at \(Self.signInURL)."
case .apiUnauthorized:
"Ollama API key is invalid or revoked."
case let .parseFailed(message):
"Could not parse Ollama usage: \(message)"
case let .networkError(message):
"Ollama request failed: \(message)"
case .noSessionCookie:
"No Ollama session cookie found. Please log in to ollama.com in your browser."
"No Ollama session cookie found. Please sign in at \(Self.signInURL) in your browser."
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions Tests/CodexBarTests/OllamaUsageFetcherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import Testing
@testable import CodexBarCore

struct OllamaUsageFetcherTests {
@Test
func `session authentication errors point to current recovery page`() {
#expect(OllamaUsageError.notLoggedIn.errorDescription?.contains("https://ollama.com/signin") == true)
#expect(OllamaUsageError.invalidCredentials.errorDescription?.contains("https://ollama.com/signin") == true)
#expect(OllamaUsageError.noSessionCookie.errorDescription?.contains("https://ollama.com/signin") == true)
}

@Test
func `attaches cookie for ollama hosts`() {
#expect(OllamaUsageFetcher.shouldAttachCookie(to: URL(string: "https://ollama.com/settings")))
Expand Down
4 changes: 2 additions & 2 deletions docs/ollama.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ Ollama API keys currently do not expire, but they can be revoked from the key se

### “No Ollama session cookie found”

Log in to `https://ollama.com/settings` in Chrome, then refresh in CodexBar.
Sign in at `https://ollama.com/signin` in Chrome, then refresh CodexBar.
If your active session is only in Safari (or another browser), use **Cookie source → Manual** and paste a cookie header.

### “Ollama session cookie expired”

Sign out and back in at `https://ollama.com/settings`, then refresh.
Sign out and back in at `https://ollama.com/signin`, then refresh.

### “Could not parse Ollama usage”

Expand Down
Loading