lewtun HF Staff OpenAI Codex commited on
Commit
406122e
·
unverified ·
1 Parent(s): 1a8fb0c

Split usage token rows (#297)

Browse files

* Split usage token rows

Co-authored-by: OpenAI Codex <codex@openai.com>

* Document gh token fallback

Co-authored-by: OpenAI Codex <codex@openai.com>

---------

Co-authored-by: OpenAI Codex <codex@openai.com>

AGENTS.md CHANGED
@@ -23,6 +23,7 @@ Notes:
23
  ## GitHub CLI
24
 
25
  - For multiline PR descriptions, prefer `gh pr edit <number> --body-file <file>` over inline `--body` so shell quoting, `$` env-var names, backticks, and newlines are preserved correctly.
 
26
 
27
  ## GitHub PRs
28
 
 
23
  ## GitHub CLI
24
 
25
  - For multiline PR descriptions, prefer `gh pr edit <number> --body-file <file>` over inline `--body` so shell quoting, `$` env-var names, backticks, and newlines are preserved correctly.
26
+ - If `gh` reports an invalid token or auth failure, retry the command with `GH_TOKEN` and `GITHUB_TOKEN` unset, for example `env -u GH_TOKEN -u GITHUB_TOKEN gh pr create ...`, so `gh` can use the stored login token instead of a stale environment token.
27
 
28
  ## GitHub PRs
29
 
frontend/src/components/UsageMeter.tsx CHANGED
@@ -35,6 +35,18 @@ function formatCount(value: number | undefined): string {
35
  return new Intl.NumberFormat('en-US').format(value ?? 0);
36
  }
37
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  function billingUnavailableMessage(error: string | null | undefined): string | null {
39
  if (!error) return null;
40
  if (error === 'missing_hf_token') return 'Sign in to view HF account billing usage.';
@@ -115,8 +127,12 @@ function AccountUsageSection({
115
  />
116
  <UsageRow label="LLM calls" value={formatCount(telemetry?.llm_calls)} />
117
  <UsageRow
118
- label="Tokens"
119
- value={formatCount(telemetry?.total_tokens)}
 
 
 
 
120
  />
121
  </UsageGrid>
122
  </Box>
 
35
  return new Intl.NumberFormat('en-US').format(value ?? 0);
36
  }
37
 
38
+ function contextTokenCount(telemetry: UsageBucket | null | undefined): number | undefined {
39
+ if (!telemetry) return undefined;
40
+ if (telemetry.total_tokens > 0) {
41
+ return Math.max(0, telemetry.total_tokens - telemetry.completion_tokens);
42
+ }
43
+ return (
44
+ telemetry.prompt_tokens +
45
+ telemetry.cache_read_tokens +
46
+ telemetry.cache_creation_tokens
47
+ );
48
+ }
49
+
50
  function billingUnavailableMessage(error: string | null | undefined): string | null {
51
  if (!error) return null;
52
  if (error === 'missing_hf_token') return 'Sign in to view HF account billing usage.';
 
127
  />
128
  <UsageRow label="LLM calls" value={formatCount(telemetry?.llm_calls)} />
129
  <UsageRow
130
+ label="Context tokens"
131
+ value={formatCount(contextTokenCount(telemetry))}
132
+ />
133
+ <UsageRow
134
+ label="Output tokens"
135
+ value={formatCount(telemetry?.completion_tokens)}
136
  />
137
  </UsageGrid>
138
  </Box>