Session usage: remaining follow-ups from #7862

Aperta
#7,886 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
28/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
full-stack

Direzione di ricerca

Three separate deferred items. Start from getSessionUsage and the ledger repair path, where recordUsage (its messageId option) and settledInFlightKeys decide whether a settle double-counts. Item 2 is WorkspaceStore.refreshUsageAfterChange, which logs a failed refetch and stops. Item 3 is refreshSessionUsage, which is latest-wins rather than single flight. Each item needs its own test and its own definition of done; item 1 needs a new persisted ledger field.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Open items left from #7862 after #7865, #7866, #7867 and #7868 merged. Each one is rare, and none was seen in the 6,714 real ledgers checked for #7868.

  1. A settle counts a message twice after a locked repair, for a stream without an in-flight key. The stream has no key only when every one of its in-flight writes failed. Then getSessionUsage (or a token-stats cache update) can rebuild an unusable ledger from history, which already holds the final message, and the later settle adds that message again. #7868 covers this window when recordUsage does the repair itself (its messageId option) and when the stream has an in-flight key (settledInFlightKeys). A fix must persist which messages the repair counted, so it needs a new ledger field. (Item 9 of #7862, deferred from #7868 review round 5.)
  2. A failed usage-changed refetch is not retried. When a transient getSessionUsage or ancestor getSubagentUsage error fails the refetch, WorkspaceStore.refreshUsageAfterChange logs it and stops. The Costs tab stays stale until the next usage change, an activation, a Costs tab open or an activity resubscribe. Fix: retry with bounded backoff, or keep a per-workspace "refresh pending" flag until a fetch succeeds. (Deferred from #7867.)
  3. refreshSessionUsage is latest-wins, not single flight. A burst of usage writes on one shown workspace whose chat is not subscribed (for example headless records) costs one getSessionUsage each. Act on it when a profile shows getSessionUsage bursts. (Deferred from #7867. #7870 tracks the projection side.)

Related: #7870 (projection refetch throttle), #7883 (removal loses a sub-agent's spend when the roll-up fails), #7884 (rebuild drops an in-flight settled marker when the scan fails).


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

Lingua principale
TypeScript
Stelle
2.1k
Fork
139
Merge medio
5h 5m
PR unite (30g)
923

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di coder/xum

Tutte le issue di coder/xum

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.