Fix for block timer calculation when last activity was in a previous block. Was incorrectly displaying an active block due to the diff of last activity and current block start

This commit is contained in:
Matthew Breedlove committed 2025-08-20 19:10:38 -04:00
1 parent 539be98470
commit f9a113a9d2
3 files changed
+9 -8

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "ccstatusline",
"version": "2.0.5",
"version": "2.0.6",
"description": "A customizable status line formatter for Claude Code CLI",
"module": "src/ccstatusline.ts",
"type": "module",
-1
View File
@@ -1,5 +1,4 @@
export interface BlockMetrics {
startTime: Date;
lastActivity: Date;
isActive: boolean;
}
+8 -6
View File
@@ -294,16 +294,18 @@ function findMostRecentBlockStartTime(
// The current block started after the completed blocks
blockStart = new Date(flooredWorkStart.getTime() + (completedBlocks * sessionDurationMs));
}
const timeSinceActivity = now.getTime() - mostRecentTimestamp.getTime();
const blockEnd = new Date(blockStart.getTime() + sessionDurationMs);
// Check if block is still active
const isActive = timeSinceActivity < sessionDurationMs && now < blockEnd;
const blockEnd = new Date(blockStart.getTime() + sessionDurationMs);
const inBlockWindow = now.getTime() >= blockStart.getTime() && now.getTime() <= blockEnd.getTime();
const activityInThisBlock = mostRecentTimestamp.getTime() >= blockStart.getTime() && mostRecentTimestamp.getTime() <= now.getTime();
const isActive = inBlockWindow && activityInThisBlock;
if (!isActive)
return null;
return {
startTime: blockStart,
lastActivity: mostRecentTimestamp,
isActive
lastActivity: mostRecentTimestamp
};
}