Skip to content

Refresh usage footer on turn end and stop rotating Claude's OAuth token - #26

Open
emircan-sahin wants to merge 1 commit into
hardbeat920:mainfrom
emircan-sahin:fix/usage-footer-refresh
Open

Refresh usage footer on turn end and stop rotating Claude's OAuth token#26
emircan-sahin wants to merge 1 commit into
hardbeat920:mainfrom
emircan-sahin:fix/usage-footer-refresh

Conversation

@emircan-sahin

Copy link
Copy Markdown
Contributor

What changed

The usage footer refreshes when a turn ends and polls on a cadence that can actually deliver a fresh snapshot, plus four related fixes.

Addresses #20.

Why

#20 is right that the data was already on hand: the fetch floor was five minutes but the UI timer ticked every fifteen, so a snapshot could sit unused for ten minutes. The timer now ticks every minute and a snapshot lands as soon as it is eligible, and a finished Claude or Codex turn marks the provider stale so the number moves when the user has just spent some. Both providers keep the five-minute floor between reads.

Also in #20's list, a provider that was not signed in at launch stayed "not connected" for the life of the process; it is now retried every 15 minutes so signing in later recovers on its own. Clicking refresh during a background poll did nothing at all — the click is now queued and runs right after. A 429 backs off for 30 minutes rather than retrying on the normal cadence, with the reason in the chip's tooltip.

The footer no longer refreshes Claude Code's OAuth token. Those credentials belong to the claude CLI, which MonoCode already spawns for every turn and which rotates them itself. Writing to its keychain entry meant a rotation MonoCode could not save left the CLI holding a dead refresh token. The footer is now a read-only view: an expired token shows expired until the next Claude turn renews it.

One unrelated-looking line rides along because it is the same polling story: an idle terminal forked a ps every second per pane to name its foreground process, and now bails before the fork when the foreground pid is the shell itself.

UI

The footer's number updates sooner. A throttled provider shows the reason in the chip tooltip; an expired token shows expired.

Checklist

  • I ran npm run check
  • This PR is small and focused
  • I did not mix unrelated changes

The 15-minute poll timer beat against the 5-minute staleness floor, so a
snapshot could sit unrefreshed for a quarter hour. The timer now ticks
every minute while both providers keep the 5-minute floor, and a finished
Claude or Codex turn refreshes its own chip within two minutes.

MonoCode no longer refreshes Claude Code's OAuth token. Those credentials
belong to the claude CLI, which MonoCode spawns for every turn and which
refreshes them itself; a rotation MonoCode could not persist left the CLI
holding a dead refresh token. The footer now only reads, and an expired
token shows as expired until the next turn renews it.

The usage endpoint 429s at 30-60s polling without sending Retry-After, so
a throttle backs off for 30 minutes and the chip falls back to a dash with
the reason in its tooltip.

Also:
- a provider that was not signed in at launch is retried every 15 minutes
  instead of never
- clicking refresh mid-poll is queued instead of swallowed
- an idle terminal no longer forks a ps every second to name its
  foreground process, since the check that makes that pointless ran after
  the spawn rather than before
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