myrlin-workbook 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/web/server.js +14 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myrlin-workbook",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Browser-based project manager for Claude Code sessions - session discovery, multi-terminal, cost tracking, docs, and kanban board",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/web/server.js CHANGED
@@ -2846,10 +2846,21 @@ app.get('/api/cost/dashboard', requireAuth, (req, res) => {
2846
2846
  }
2847
2847
  }
2848
2848
 
2849
- // Check if within period for periodCost
2850
- if (cutoffDate && costData.lastMessage && costData.lastMessage >= cutoffDate) {
2849
+ // Apportion session cost to the period using per-message cost and
2850
+ // message timestamps, not the full session cost. This ensures "Last 24h"
2851
+ // only counts cost from messages sent in the last 24 hours, not the
2852
+ // entire lifetime of any session that was recently active.
2853
+ if (!cutoffDate) {
2851
2854
  periodCost += sessionCost;
2852
- } else if (!cutoffDate) {
2855
+ } else if (samples && samples.length > 0 && costData.messageCount > 0) {
2856
+ const perMsgCost = sessionCost / costData.messageCount;
2857
+ let periodMessages = 0;
2858
+ for (const sample of samples) {
2859
+ if (sample.ts && sample.ts >= cutoffDate) periodMessages++;
2860
+ }
2861
+ periodCost += perMsgCost * periodMessages;
2862
+ } else if (costData.lastMessage && costData.lastMessage >= cutoffDate) {
2863
+ // Fallback: no timestamp samples available, use full cost
2853
2864
  periodCost += sessionCost;
2854
2865
  }
2855
2866