You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Orca shows usage meters for many AI subscriptions, but not for Ollama's cloud plans. This change adds Ollama as a tenth usage provider: save the API key from ollama.com once and Orca shows your remaining included credits and your 30-day cloud spend in the status bar, refreshed with the same cycle as every other provider.
What Changed
src/main/rate-limits/ollama-usage-fetcher.ts — new fetcher against the documented cloud endpoints (GET https://ollama.com/api/balance, GET https://ollama.com/api/usage?range=30d, Authorization: Bearer <OLLAMA_API_KEY>, 15s timeout, documented 10 req/min rate limit respected by the shared poll cadence). Both documented balance shapes parse via zod at the boundary: modern plans spend down a USD allowance (balance_usd/allowance_usd), legacy plans expose session/weekly remaining_percent. The 30d usage response (request count, USD spend, token counts) is carried as a named ollamaUsageTotals field instead of being forced into a quota window — no invented percents.
src/main/ollama/ollama-cloud-api-key-store.ts + ollama-cloud-credential-commands.ts — async sealed API-key storage mirroring the GLM Coding Plan path: OS-encrypted envelope when available, owner-only plaintext fallback on POSIX, and fail-closed saves on Windows if encryption is unavailable; explicit save/clear/status with sealed-elsewhere refusal.
Wiring: ollama joins ProviderRateLimits['provider'], RateLimitState, service state/generation/backoff maps, sibling fetch cycle (prepared alongside zcode, applied with the same generation guard), accounts.ollamaCloud* RPC methods, preload bridge window.api.ollamaCloudCredentials, status-bar letter L, and settings-target mapping to accounts-ollama.
src/renderer/src/components/settings/OllamaCloudAccountsSection.tsx — Settings ▸ Accounts section: key entry (password input, Save/Replace/Forget), subscription usage block with included credits and 30-day spend across requests.
36 en.json catalog entries; zh untranslated falls back to English per repo policy.
Why
Ollama's ollama launch integrations (claude, codex, droid, …) already work inside Orca terminals, so cloud subscribers hit usage limits Orca cannot see. Reusing the existing rate-limit provider architecture (zod parse once at the boundary, sibling promise cycles, sealed key files) gives Ollama the same treatment as Codex credits or GLM Coding Plan with no new polling code paths.
Linked Issue
Fixes#21476 (Ollama Cloud portion; OpenRouter and TokenRouter remain open in that issue)
Visual Proof
These screenshots compare the same synthetic Ollama Cloud usage state on the original PR head and after the feedback fix. They do not show live account data.
Before
After
Both screenshots were captured in hidden Electron runs with synthetic usage data; they do not show a live Ollama account. I manually tested the Ollama usage flow locally. The screenshots are visual evidence of the before/after UI state, while the manual test was performed separately.
Testing
I manually tested the Ollama usage flow locally. Cross-platform UI verification was not performed.
Automated tests added/updated. The fetcher tests cover an omitted optional spend total. The orchestration tests cover Codex queued during Grok, modern Ollama usage after transient failure, and a repeated Ollama refresh queued during a full refresh.
The added tests cover the reported failures and avoid the repository test anti-patterns.
Validation:
pnpm check:changed -- --maxWorkers=4 --timeout=45: all 40 checks passed on the rebased branch against base 6b1e12d2 (17m 45s).
Focused Vitest run: 5 files, 35/35 tests passed.
git diff --check passed.
Full pnpm lint, pnpm test, and pnpm build were not run as separate commands; the changed-file gate does not replace the full suite or build.
Notes
Usage endpoints are cloud-only (https://ollama.com); local servers (http://localhost:11434) expose no usage API, so the provider reports unavailable: missing-credentials semantics instead of pretending.
Keys are sent only to ollama.com; no token analytics are computed locally.
Credential storage uses OS encryption when available. If it is unavailable, POSIX stores plaintext with owner-only file and directory permissions; Windows saves fail closed instead of writing plaintext. Cross-platform UI verification was not performed.
Risk
Level: Medium. Recent Ollama balance and totals stay visible through transient failures for the normal stale window. Full refreshes reuse the provider-cycle drain, so repeated queued refreshes run before waiters resolve. Generation checks still discard results from an invalidated key. Reverting the follow-up restores the prior behavior.
AI Disclosure
OpenAI Codex assisted with review-feedback analysis, code changes, and validation.
Review
Earlier review feedback and follow-up findings are addressed in the current branch. All existing review threads are resolved.
Agent skill upstream boundary
Not applicable. This change does not copy or translate upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Checklist
This PR remains focused on Ollama usage feedback.
The ELI5, user-facing change, and reason are explained above.
The risk and rollback path are stated above.
Before/after screenshots are included above. The captures use synthetic data; manual Ollama usage-flow verification was performed separately by the author.
Self-reviewed the changed files for correctness, security, and performance.
Considered cross-platform and SSH/remote behavior. Credential storage fails closed on Windows if safeStorage encryption is unavailable; UI verification across platforms was not performed.
Full pnpm lint, pnpm typecheck, pnpm test, and pnpm build commands pass or are covered by CI. The changed-file gate passed; full lint, full test, and build remain unverified separately.
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Scope note: this covers the Ollama Cloud portion of #21476 (status-bar usage bar + Settings ▸ Accounts section). OpenRouter and TokenRouter remain open there — same architecture applies if this lands. Visual proof (before/after screenshots) coming in a follow-up once I capture the running app.
Pushed 1c4c90cb: review pass closing two data-completeness gaps — purchased balance_usd is now kept distinct from the included allowance end-to-end (parser → ollamaUsageTotals.purchasedBalanceUsd → Accounts row) and the documented input/cached/output token counters render as a 30-day token row. Fetcher tests 7/7; pnpm lint (41/41), tc:node, tc:web clean. Visual proof screenshots still pending — attaching when I can run the app.
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
This change adds Ollama Cloud API-key storage and credential operations through local IPC and environment RPC. It adds balance and usage parsing and fetching to the rate-limit cycle, with Ollama state included in refresh and configuration reporting. The Accounts interface supports credential management and displays available subscription usage. Ollama is also added to status-bar provider mapping and settings navigation.
Merge Risk: Moderate · up to b2338
The Ollama status-bar entry currently shows no balance or usage, displays as "ollama" with the wrong icon, and does not show a loading state. A forced Codex or Claude refresh can stall behind an Ollama refresh. Fix these, and the misleading labels and error visibility in Accounts and Stats, before merging.
Pre-merge checks: 3 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Out of Scope Changes check
The PR changes unrelated queue behavior in src/main/rate-limits/service/service-fetch-queue.ts. fetchGrokOnly now uses runSingleProviderDrain, which no longer drains queued `codexOnlyFetchQueued…
Restore the Codex-only and Claude-only queue drains in fetchGrokOnly with their original force settings. Keep the shared drain limited to behavior that preserves those requests, or retain the original Grok loop and use the helper only for…
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title clearly and concisely identifies the main change: tracking Ollama Cloud subscription usage in the status bar and Accounts settings.
Linked Issues check
Issue #21476 is open and directly linked. This PR implements the Ollama Cloud slice only, which is the stated first implementation slice. It adds user-pasted API-key storage, Accounts UI, rate-limit f…
Description check
The description follows the repository template and covers the main sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Risk, AI Disclosure, and Checklist. It explains the new Olla…
Full details: Linked Issues check
Explanation
Issue #21476 is open and directly linked. This PR implements the Ollama Cloud slice only, which is the stated first implementation slice. It adds user-pasted API-key storage, Accounts UI, rate-limit fetch and refresh wiring, the L status-bar item, visibility settings, missing-credential unavailable state, configured exhausted-balance display, and focused fetcher tests. It supports legacy session and weekly percentages and modern currency allowances without inventing money-based percentage windows. The 30-day usage totals preserve request and token counts. OpenRouter and TokenRouter remain outside this slice.
Full details: Description check
Explanation
The description follows the repository template and covers the main sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Risk, AI Disclosure, and Checklist. It explains the new Ollama Cloud usage provider, its fetcher, sealed API-key storage, wiring, and settings UI. It links issue #21476 and says the PR covers only the Ollama Cloud portion. Visual proof is attached as before and after screenshots, with a note that they use synthetic data. Testing lists the focused Vitest run, the changed-file gate, and the checks that were not run. Risk gives a level, the riskiest areas, and a rollback note. Remaining gaps: the Risk section's rollback guidance is thin, since it says only that reverting the follow-up restores prior behavior and does not describe the full revert path. The Review section is brief. The Testing checkbox for anti-pattern avoidance is ticked without evidence beyond the author's statement. The 'Full lint/test/build' checklist item is unchecked, which is accurate but leaves verification incomplete. The 'Visual Proof' section does not clearly show a tabbed or switchable before and after comparison.
Full details: Out of Scope Changes check
Explanation
The PR changes unrelated queue behavior in src/main/rate-limits/service/service-fetch-queue.ts. fetchGrokOnly now uses runSingleProviderDrain, which no longer drains queued codexOnlyFetchQueued and claudeOnlyFetchQueued requests. This changes existing Codex and Claude scheduling and is not required for issue #21476. The incremental diff from the previous reviewed head is empty for this file, so this issue remains unresolved.
Resolution
Restore the Codex-only and Claude-only queue drains in fetchGrokOnly with their original force settings. Keep the shared drain limited to behavior that preserves those requests, or retain the original Grok loop and use the helper only for Ollama. Add a queue test that verifies a Codex-only or Claude-only request queued during a Grok-only cycle still runs.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Re-check fullFetchQueued after the provider-only sub-cycles in fetchAll.
A forced refresh that arrives during the codex, claude, or grok sub-cycle in fetchAll can be left queued. fetchAll checks fullFetchQueued only before those sub-cycles (service-fetch-queue.ts:27). The loop then exits, resolveFetchIdleWaiters() returns early while the flag is set, and the queued full cycle runs only at a later unforced fetchAll.
Ollama save and clear now reach this path. invalidateOllamaCredentialState() sets Ollama to a fetching status, then the helper calls refresh(), which calls fetchAll({ force: true }). Ollama is not refreshed by the provider-only cycles, so it can stay in fetching status until the next background poll. With the default 15-minute poll interval, that can be up to 15 minutes. Without background polling, it stays until another full cycle starts.
Suggested fix
if (grokSignal.aborted) {
break
}
}
+ if (this.fullFetchQueued) {+ this.fullFetchQueued = false+ shouldContinue = true+ }
}
Files skipped from review as they are similar to previous changes: 1
src/renderer/src/i18n/locales/en.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (4)
Minor · Drain queued Ollama refreshes before resolving idle waiters. · service-fetch-control.ts:4-35
src/main/rate-limits/service/service-fetch-control.ts:4-35 Minor · Functional Correctness · Quick win
Drain queued Ollama refreshes before resolving idle waiters.
When refreshOllama() runs during fetchGrokOnly(), the Grok finally block can resolve the refresh promise while ollamaOnlyFetchQueued remains set. The IPC caller then receives stale usage, and the pane stops showing its refresh state before the Ollama fetch runs.
Include the Ollama flag in both idle predicates, then start the queued Ollama drain from the Grok-only completion path. Adding only the flag checks would leave this waiter pending because the Grok drain does not otherwise consume the Ollama queue.
Minor · Discard Ollama-only results after credential invalidation. · service-provider-cycles.ts:185-217
src/main/rate-limits/service/service-provider-cycles.ts:185-217 Minor · Functional Correctness · Quick win
Discard Ollama-only results after credential invalidation.
When a save or clear advances ollamaFetchGeneration, an active runFetchOllamaOnlyCycle can still apply usage fetched with the old key. This briefly restores stale usage after the credential state was cleared, until the queued refresh replaces it. Capture the generation before the fetch and ignore the result when it changes.
Minor · Make usage_usd nullable so one omitted field does not discard… · ollama-usage-fetcher.ts:23-29
src/main/rate-limits/ollama-usage-fetcher.ts:23-29 Minor · Data Integrity & Integration · Quick win
Make usage_usd nullable so one omitted field does not discard all usage totals.
The documented UsageMetrics schema lists only request_count as required. usage_usd is optional there. This schema requires usage_usd. A valid usage response without that field fails the parse. parseOllamaUsageResponse then returns every usage total as null, including requestCount and the token counters. fetchOllamaCloudRateLimits still returns status: 'ok', and the UI shows — for each value.
Minor · Do not map legacy purchased credits to extraUsage.balance. · ollama-usage-fetcher.ts:98-125
src/main/rate-limits/ollama-usage-fetcher.ts:98-125 Minor · Functional Correctness · Quick win
Do not map legacy purchased credits to extraUsage.balance.
extraUsage.balance is consumed as included credits by Stats and Accounts and as a generic balance by the status bar. The legacy branch currently assigns purchased.balance_usd to that field. Keep the value in purchasedBalanceUsd and set the legacy extraUsage.balance to null. The existing consumers already handle that value: Stats and Accounts retain the separate purchased-credit display, while the status bar and tooltip suppress the extra balance output.
Files skipped from review as they are similar to previous changes: 1
src/renderer/src/i18n/locales/en.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Minor · Include Ollama in anyFetching. · use-status-bar-controller.ts:224
src/renderer/src/components/status-bar/use-status-bar-controller.ts:224 Minor · Functional Correctness · Quick win
Include Ollama in anyFetching.
The aggregate still omits ollama. When the Ollama refresh is fetching, this hook returns false, so consumers of anyFetching do not show the loading state. Add the Ollama status check. (raw.githubusercontent.com)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
The outside-diff findings are also addressed in commit 3ddb622: fetchAll rechecks queued full refreshes after provider-only cycles; the provider drain handles queued Ollama, Codex, Claude, Grok, and full refreshes before resolving waiters; Ollama-only results are discarded after credential invalidation; usage_usd is optional; and legacy purchased balance stays separate from extraUsage.balance.
Ollama's cloud usage API (ollama.com/api/balance and /api/usage?range=30d,
Bearer OLLAMA_API_KEY, 10 req/min) becomes a tenth rate-limit provider:
- ollama-usage-fetcher.ts parses both balance shapes (modern USD allowance,
legacy session/weekly percents) via zod at the boundary; 30d totals ride a
named ollamaUsageTotals field instead of a fake quota window
- sealed API-key store + credential commands mirror the GLM Coding Plan path;
explicit save/clear/status over IPC and RPC (accounts.ollamaCloud*)
- fetch cycles prepare the sibling promise alongside zcode and apply with a
generation guard; failures track the shared backoff streaks
- OllamaCloudAccountsSection in Settings > Accounts: key entry with sealed
storage, included credits, and 30-day spend labels; status bar letter L
Review pass over fetcher contract: the modern balance branch dropped
purchased.balance_usd and the 30d totals dropped input/cached/output token
counts. Both now survive into the shared ollamaUsageTotals field; the
Accounts section renders purchased credits and token rows beside the
included allowance.
StatsPane gains an Ollama tab backed by the same cloud snapshot as the
status bar (no fake per-worktree attribution): included/purchased credits,
30-day spend, tokens, plus an empty state that opens Accounts. Refresh
rides a dedicated rateLimits:refreshOllama IPC -> refreshOllama() ->
ollamaOnlyFetch queue drain, deduped with Grok's loop into
runSingleProviderDrain. Key-read failures settle as Ollama-only
unavailable (non-retryable) so an undecryptable envelope cannot spend
every activation window on a doomed refetch.
The compact/detailed Usage popup filtered providers at
use-status-bar-controller; ollama was missing from the roster, the
visibility settings contract and the empty-state check, so the panel in
the screenshot never listed it. Wire it like zcode: key-presence flag
(ollamaApiKeyConfigured), default status-bar item, roster/empty-state
coverage, plus an ollama unavailable-row expectation in the visibility
suite. Restore the zcode pending clause the first edit clobbered.
ProviderIcon's unmatched-provider fallback rendered Claude's mark for
Ollama. Add OllamaIcon (theme-foreground llama silhouette) and route the
provider, the Stats Usage tab icon, and the windowless roster row to it.
Fetch the 64px icon from ollama.com/public/icon-64x64.png into
src/shared/agent-icons/ollama.png and render it from OllamaIcon
(offline-bundled like the other agent favicons, stablyai#8451), replacing the
guessed silhouette SVG. Import depth fixed to match
agent-favicon-assets (../../../../shared/...).
…I schema
StatusBarItem parity caught the drift: the shared PersistedUIState and
defaults gained 'ollama' while the z.enum in UiUpdateFieldsSchema had
not, so AssertNoMissingValues rejected every desktop payload.
Upstream moved AccountsPane into accounts/, helpers into
accounts/usage/, section primitives into section-layout/, and split
visibility tests; re-point Ollama section imports, pane wiring, and the
lifetime-test imports accordingly. Provide the ollama display name in
usage-provider-windows (satisfies exhaustiveness).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Orca shows usage meters for many AI subscriptions, but not for Ollama's cloud plans. This change adds Ollama as a tenth usage provider: save the API key from ollama.com once and Orca shows your remaining included credits and your 30-day cloud spend in the status bar, refreshed with the same cycle as every other provider.
What Changed
src/main/rate-limits/ollama-usage-fetcher.ts— new fetcher against the documented cloud endpoints (GET https://ollama.com/api/balance,GET https://ollama.com/api/usage?range=30d,Authorization: Bearer <OLLAMA_API_KEY>, 15s timeout, documented 10 req/min rate limit respected by the shared poll cadence). Both documented balance shapes parse via zod at the boundary: modern plans spend down a USD allowance (balance_usd/allowance_usd), legacy plans expose session/weeklyremaining_percent. The 30d usage response (request count, USD spend, token counts) is carried as a namedollamaUsageTotalsfield instead of being forced into a quota window — no invented percents.src/main/ollama/ollama-cloud-api-key-store.ts+ollama-cloud-credential-commands.ts— async sealed API-key storage mirroring the GLM Coding Plan path: OS-encrypted envelope when available, owner-only plaintext fallback on POSIX, and fail-closed saves on Windows if encryption is unavailable; explicitsave/clear/statuswith sealed-elsewhere refusal.ollamajoinsProviderRateLimits['provider'],RateLimitState, service state/generation/backoff maps, sibling fetch cycle (prepared alongside zcode, applied with the same generation guard),accounts.ollamaCloud*RPC methods, preload bridgewindow.api.ollamaCloudCredentials, status-bar letterL, and settings-target mapping toaccounts-ollama.src/renderer/src/components/settings/OllamaCloudAccountsSection.tsx— Settings ▸ Accounts section: key entry (password input, Save/Replace/Forget), subscription usage block with included credits and 30-day spend across requests.Why
Ollama's
ollama launchintegrations (claude, codex, droid, …) already work inside Orca terminals, so cloud subscribers hit usage limits Orca cannot see. Reusing the existing rate-limit provider architecture (zod parse once at the boundary, sibling promise cycles, sealed key files) gives Ollama the same treatment as Codex credits or GLM Coding Plan with no new polling code paths.Linked Issue
Fixes #21476 (Ollama Cloud portion; OpenRouter and TokenRouter remain open in that issue)
Visual Proof
These screenshots compare the same synthetic Ollama Cloud usage state on the original PR head and after the feedback fix. They do not show live account data.
Before
After
Both screenshots were captured in hidden Electron runs with synthetic usage data; they do not show a live Ollama account. I manually tested the Ollama usage flow locally. The screenshots are visual evidence of the before/after UI state, while the manual test was performed separately.
Testing
Validation:
pnpm check:changed -- --maxWorkers=4 --timeout=45: all 40 checks passed on the rebased branch against base6b1e12d2(17m 45s).git diff --checkpassed.pnpm lint,pnpm test, andpnpm buildwere not run as separate commands; the changed-file gate does not replace the full suite or build.Notes
https://ollama.com); local servers (http://localhost:11434) expose no usage API, so the provider reportsunavailable: missing-credentialssemantics instead of pretending.Risk
Level: Medium. Recent Ollama balance and totals stay visible through transient failures for the normal stale window. Full refreshes reuse the provider-cycle drain, so repeated queued refreshes run before waiters resolve. Generation checks still discard results from an invalidated key. Reverting the follow-up restores the prior behavior.
AI Disclosure
OpenAI Codex assisted with review-feedback analysis, code changes, and validation.
Review
Earlier review feedback and follow-up findings are addressed in the current branch. All existing review threads are resolved.
Agent skill upstream boundary
Checklist
pnpm lint,pnpm typecheck,pnpm test, andpnpm buildcommands pass or are covered by CI. The changed-file gate passed; full lint, full test, and build remain unverified separately.