Session usage: remaining follow-ups from #7862

Abierto
#7,886 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
28/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript
Área
full-stack

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
TypeScript
Estrellas
2.1k
Forks
139
Merge medio
5 h 5 min
PR fusionados (30 d)
923

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de coder/xum

Todos los issues de coder/xum

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.