Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

opencodego: background refresh reports 100% free quota, manual refresh shows real quota

Closed
#4,805 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

@egigoka is already working on this.

Since Oct 27, 2026.

  • #4806 by @egigoka — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
swift
Domain
backend, devtools

Research direction

Read Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoProviderDescriptor.swift and the refresh pipeline’s applyProviderRefreshSuccess behavior to understand how a local estimate can replace an authoritative snapshot. Then inspect Tests/CodexBarTests/OpenCodeGoWebOverlayTests.swift and run the named regression test; done means background refresh preserves the prior snapshot when the web overlay is transiently unavailable, while the documented exemptions retain their fallback behavior. A linked open pull request (#4806) is already pursuing this fix.

Written by the indexing model from the issue text.

Description

clawsweeper:linked-pr-open clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster P2

Symptom

With the opencode-go provider in auto mode, every background (timer) refresh shows 100% free quota. A manual Refresh Now immediately loads the real quota. The next background tick clobbers it back to 100% free.

Root cause

OpenCodeGoLocalUsageFetchStrategy.snapshot(context:) (Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoProviderDescriptor.swift) unconditionally returns its local-only fallback (quotaIsAuthoritative=false, published as .estimated) when the web overlay is unavailable. The pipeline (applyProviderRefreshSuccess) then publishes that estimate over the last good authoritative snapshot.

Background ticks run under ProviderInteractionContext.background, where BrowserCookieAccessGate skips browser import (no-UI Keychain preflight) and CookieHeaderCache.observeForConditionalMutation can report .keychainTemporarilyUnavailable. So in the background there is usually no cookie, the web overlay resolves to nil, and the strategy publishes a pure-local estimate. A local DB with no recent costs yields 0% used percents, i.e. "100% free". Manual refresh runs as .userInitiated, the cookie import succeeds, and the real quota loads.

Deterministic repro (no UI screenshots possible — needs a real account plus a timed background tick)

New regression test background refresh preserves prior snapshot when cached web overlay is transiently unavailable (Tests/CodexBarTests/OpenCodeGoWebOverlayTests.swift) run against base 5f93dc306 fails exactly the buggy way — old code returns a local estimate with rollingUsagePercent: 0.0 instead of failing so the prior snapshot is preserved:

Expectation failed: an error was expected but none was thrown ...
  sourceLabel: "local", ... rollingUsagePercent: 0.0 ...
  dataConfidence: estimated

Fix (PR to follow)

In background auto-mode refreshes, throw instead of publishing a non-authoritative local-only result when a web overlay may still be reachable (cached session exists or Keychain read was gated). The failure path preserves the prior authoritative snapshot; the next manual refresh retries the overlay with interaction allowed. Exempt when the cookie cache is definitively empty (first-run/logged-out users keep the local estimate), when cookieSource is manual/off, and manual refreshes (unchanged fallback UX).

Dominant language
Swift
Stars
22.8k
Forks
2.2k
Avg merge
22h 20m
Merged PRs (30d)
380

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from steipete/CodexBar

All issues in steipete/CodexBar

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.