mirror of
https://github.com/tiennm99/ccstatusline.git
synced 2026-09-02 06:19:56 +00:00
Block windows were staying “active” after multiple hours with no token usage, so the block timer kept counting even though ccusage reported the session closed. Aligning the activity detection with actual token usage prevents those phantom sessions and keeps the timer in sync with the upstream report. Co-authored-by: alexander.buyanov <alexander.buyanov@konux.de>
This commit is contained in:
co-authored by
alexander.buyanov
parent
2842f856e9
commit
3010addb70
+26
-7
@@ -320,13 +320,32 @@ function getAllTimestampsFromFile(filePath: string): Date[] {
|
||||
|
||||
for (const line of lines) {
|
||||
try {
|
||||
const json = JSON.parse(line) as { timestamp?: string };
|
||||
if (json.timestamp && typeof json.timestamp === 'string') {
|
||||
const date = new Date(json.timestamp);
|
||||
if (!Number.isNaN(date.getTime())) {
|
||||
timestamps.push(date);
|
||||
}
|
||||
}
|
||||
const json = JSON.parse(line) as {
|
||||
timestamp?: string;
|
||||
isSidechain?: boolean;
|
||||
message?: { usage?: { input_tokens?: number; output_tokens?: number } };
|
||||
};
|
||||
|
||||
// Only treat entries with real token usage as block activity
|
||||
const usage = json.message?.usage;
|
||||
if (!usage)
|
||||
continue;
|
||||
|
||||
const hasInputTokens = typeof usage.input_tokens === 'number';
|
||||
const hasOutputTokens = typeof usage.output_tokens === 'number';
|
||||
if (!hasInputTokens || !hasOutputTokens)
|
||||
continue;
|
||||
|
||||
if (json.isSidechain === true)
|
||||
continue;
|
||||
|
||||
const timestamp = json.timestamp;
|
||||
if (typeof timestamp !== 'string')
|
||||
continue;
|
||||
|
||||
const date = new Date(timestamp);
|
||||
if (!Number.isNaN(date.getTime()))
|
||||
timestamps.push(date);
|
||||
} catch {
|
||||
// Skip invalid JSON lines
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user