Skip to content

Commit ddde8cd

Browse files
fix: changed optional fields to nullable, printing 0 instead of N/A
1 parent 34c5c86 commit ddde8cd

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎apps/ccusage/src/_types.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,16 @@ export const statuslineHookJsonSchema = v.object({
184184
total_input_tokens: v.number(),
185185
total_output_tokens: v.optional(v.number()),
186186
context_window_size: v.number(),
187-
current_usage: v.optional(
187+
current_usage: v.nullable(
188188
v.object({
189189
input_tokens: v.number(),
190190
output_tokens: v.number(),
191191
cache_creation_input_tokens: v.number(),
192192
cache_read_input_tokens: v.number(),
193193
}),
194194
),
195-
used_percentage: v.optional(v.number()),
196-
remaining_percentage: v.optional(v.number()),
195+
used_percentage: v.nullable(v.number()),
196+
remaining_percentage: v.nullable(v.number()),
197197
}),
198198
),
199199
});

‎apps/ccusage/src/commands/statusline.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,10 @@ export const statuslineCommand = define({
501501
),
502502
Result.map((contextResult) => {
503503
if (contextResult == null) {
504+
// If transcript calculation failed but we have context_window_size, show 0 tokens
505+
if (hookData.context_window?.context_window_size != null) {
506+
return formatContextInfo(0, hookData.context_window.context_window_size);
507+
}
504508
return undefined;
505509
}
506510
return formatContextInfo(contextResult.inputTokens, contextResult.contextLimit);

0 commit comments

Comments
 (0)