提交

提交图

113 次代码提交

作者 SHA1 备注 提交日期
Matthew Breedlove 36054e6b0b Version bump v2.0.18 2025-09-24 10:10:15 -04:00
Alexander Buyanov 7140c3faa5 Fix #88: Fix Block Timer showing incorrect elapsed time due to flawed block calculation (#90)
* revert 798b637

* Fix #88: Fix Block Timer showing incorrect elapsed time due to flawed block calculation

\## Problem

The Block Timer widget was displaying incorrect elapsed times when multiple work sessions occurred on the same day with gaps between them. For example, with work sessions at:
- Morning: 11:00-16:00 (first message at 11:42, last at 14:52)
- Evening: 17:00-22:00 (first message at 17:44)

At 20:10, the Block Timer showed **4hr 10m** instead of the expected **3hr 10m**.

\## Root Cause

The existing algorithm in `findMostRecentBlockStartTime()` had a fundamental flaw in how it calculated block start times:

1. It correctly identified continuous work by finding gaps ≥ 5 hours
2. It floored the continuous work start to the hour
3. **But then it used `Math.floor(totalWorkTime / sessionDurationMs)` to calculate the current block**

This division-based approach assumed continuous 5-hour blocks without gaps:
```
[Block 0: 11:00-16:00][Block 1: 16:00-21:00]...
```

In reality, blocks have gaps between them:
```
[Block 0: 11:00-16:00]--gap--[Block 1: 17:00-22:00]...
```

\### Incorrectly Identified Cases

The algorithm failed in scenarios where:
- **Multiple work sessions with small gaps** (< 5 hours): Treated them as one continuous session and calculated wrong block boundaries
- **Current time in a gap**: Could incorrectly show elapsed time from a previous block
- **Messages spanning multiple days**: Division logic ignored actual message timestamps and gaps

\### Example of the Bug

With messages at 11:42 and 17:44, gap of ~2h 52m:
1. No 5-hour gap found → continuous work from 11:00
2. At 20:10: `totalWorkTime = 9h 10m`
3. `completedBlocks = floor(9.17 / 5) = 1`
4. `blockStart = 11:00 + (1 × 5h) = 16:00`
5. Elapsed = 20:10 - 16:00 = **4h 10m** (wrong!)

Correct calculation should be:
- Block 1: 11:00-16:00 (ended)
- Gap: 16:00-17:44
- Block 2: 17:00-22:00 (current)
- Elapsed = 20:10 - 17:00 = **3h 10m** ✓

\## Solution

Replaced the flawed division-based calculation with a proper block-building algorithm:

1. **Find definitive boundary**: Look back for 5+ hour gap (or start of data)
2. **Build blocks forward from timestamps**:
- Sort timestamps chronologically
- For each timestamp after the boundary:
   - If no current block OR timestamp is after current block end: start new block (floor to hour, add 5h for end)
   - Otherwise: timestamp is within current block
3. **Find current block**: Check if `now` falls within any constructed block's timespan
4. **Return block start** if found and has activity, otherwise null

This correctly handles gaps of any size and builds the actual block structure from message timestamps.

\## Tests Added

Created comprehensive unit tests in `src/utils/__tests__/jsonl.test.ts` covering:

\### Real Scenarios
- **Morning and evening blocks with gap**: Messages at 11:42 and 17:44 → correctly identifies 17:00 block start at 20:10
- **Multiple messages in single block**: Messages within 5 hours → single block with floored start time
- **Multi-block scenario**: Messages at 00:13, 05:56, 06:01, 14:33, 20:01 → correctly identifies 20:00 block at 22:43

\### Edge Cases
- **Current time in gap between blocks**: Returns null (no active block)
- **No messages within 5 hours**: Returns null (session expired)
- **Block boundary timing**: Correctly handles time exactly at 5-hour boundary
- **5+ hour gap detection**: Properly detects boundary when gap ≥ 5 hours
- **Messages at exact hour boundaries**: Handles flooring when message is already at :00

\### Invalid Inputs
- **Empty content**: Returns null
- **Invalid JSON**: Returns null gracefully

All tests pass with the corrected algorithm, ensuring the Block Timer and Five Hour Moons widgets now display accurate elapsed times.

---------

Co-authored-by: alexander.buyanov <alexander.buyanov@konux.de>
2025-09-24 10:07:16 -04:00
Matthew Breedlove 5c4521d014 Version bump v2.0.17 2025-09-19 12:19:21 -04:00
Alexander Buyanov 798b637c58 Fix #86 Adjust block metrics gap threshold for short breaks (#87)
Detect block boundaries after 60 minutes of inactivity instead of requiring a 5-hour gap.
This prevents block start times from carrying over into short midday breaks and ensures elapsed time matches ccusage.

Co-authored-by: alexander.buyanov <alexander.buyanov@konux.de>
2025-09-19 12:18:48 -04:00
Matthew Breedlove d9ee110fc7 Version bump and README update v2.0.16 2025-09-19 01:30:23 -04:00
MIAO Jishuai d23af975b2 feat: Add fish-style path abbreviation to CurrentWorkingDir widget (#80)
* feat: Add fish-style path abbreviation to CurrentWorkingDir widget

- Added new toggle option for fish-style path abbreviation
- Keeps home directory as ~, first and last directories complete
- Abbreviates middle directories to first letter only
- Preserves dot for hidden directories (e.g. .config → .c)
- Maintains backward compatibility with segments feature
- Both options are mutually exclusive (fish-style takes precedence)

Example: ~/Documents/Projects/my-project → ~/D/P/my-project

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Modify cwd widget fish-style code to use handleEditorAction instead of renderEditor, misc lint fixes

---------

Co-authored-by: Jishuai <aqianlikuaizaifeng@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
2025-09-19 01:25:16 -04:00
Matthew Breedlove 0a5f0e58b9 Fix for menu item description text on main menu 2025-09-18 21:31:46 -04:00
Matthew Breedlove bf269e1f63 Version bump and README update v2.0.15 2025-09-18 21:27:21 -04:00
Alexander Buyanov 3010addb70 Fix #84: Block timer should reset after idle gap (#85)
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>
2025-09-18 21:25:53 -04:00
Matthew Breedlove 2842f856e9 Version bump and README update v2.0.14 2025-09-17 22:38:54 -04:00
Jake Nelson 2ecaf023b7 feat: add remaining mode to context % widgets (#83) 2025-09-17 22:34:41 -04:00
Nuno Salvação 3bc8e225f4 Update documentation with Windows-specific details (#82) 2025-09-16 01:41:49 -04:00
Alex Newman 7bb53d11e5 TypeDoc Docs (#75)
* Initial plan

* Add TypeDoc documentation generation system

Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com>
2025-09-11 17:12:34 -04:00
Matthew Breedlove b36ac6c202 Fix SessionClock to show '0m' if we don't have a calculated session duration (empty jsonl) 2025-09-11 12:49:10 -04:00
Matthew Breedlove 5942afe563 Version bump v2.0.13 2025-09-09 00:00:50 -04:00
Matthew Breedlove c52e4d7042 Merge branch 'heromantf-fix/fix-win-cwd-segment' 2025-09-08 23:51:27 -04:00
Matthew Breedlove ab198be3c0 Merge branch 'MuserQuantity-fix/separator-rendering-logic' 2025-09-08 23:49:22 -04:00
Her0mAn 5b351548a4 Fix cwd segment setting not working as expected on Windows 2025-09-08 22:47:02 +08:00
muserquantity 66214c950c fix: improve separator rendering logic to look backwards for content
- Enhanced separator rendering to check all previous widgets for actual content
- Prevents separators from being skipped when there are widgets that don't render but others before them do
- Improves status line layout consistency by properly detecting content presence
2025-09-07 18:50:01 +08:00
Matthew Breedlove c106958f36 License fix file 2025-09-01 17:14:29 -04:00
Matthew Breedlove 679bdac86e Version bump and README update v2.0.12 2025-08-31 03:04:15 -04:00
Matthew Breedlove 0ee9f7f7e2 Fix for merged items when powerline mode is active with auto-alignment toggled on 2025-08-31 03:00:44 -04:00
Matthew Breedlove 17b2576cca Support emoji input for custom text 2025-08-31 02:47:02 -04:00
Matthew Breedlove dade396de1 Version bump and README update v2.0.11 2025-08-28 09:37:13 -04:00
Jack Allen d5b2da2a47 chore(settings): support more than 3 lines (#53)
* chore(settings): support more than 3 lines
* chore: add confirm dialog
* chore: update example script
* chore: rm config override
* Fix spacing issues, disallow deletion of last line, fix issue where deleting lines 2 and 3 would keep them in the list, cleanup onDelete and onAppend method locations
* Initialize default settings with two empty lines

---------

Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
2025-08-28 09:30:26 -04:00
Matthew Breedlove 9e97e003d3 Merge commit '6cd32a5b82cd5ed27e698860f5ca8421a94548d9'. Closes #52 2025-08-27 14:35:02 -04:00
Jack Allen 6cd32a5b82 chore(no-git): Hide separators where the previous widget returns null 2025-08-27 17:19:32 +01:00
Matthew Breedlove 698bdb7f1a Updating version and README for 2.0.10 v2.0.10 2025-08-27 11:08:48 -04:00
Matthew Breedlove 0a81688010 Added toggle to hide 'no git' message if not in a git repository. Fixes #48 2025-08-27 11:03:05 -04:00
Matthew Breedlove 8b5f6c7fb6 Fix for unicode characters messing with powerline auto-alignment width calculation 2025-08-27 10:45:51 -04:00
Jack Allen 7886e1f376 feat(git-worktree): Add git worktree widget (#49)
* feat(git-worktree): Add git worktree widget

* Minor cleanup

---------

Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
2025-08-27 10:22:43 -04:00
Matthew Breedlove 8c89b0271e Merge branch 'jackall3n-chore/use-bun-patch' 2025-08-27 09:10:21 -04:00
Jack Allen 9354dbc9a3 chore(patch-package): Migrate to using bun patch, instead of patch-package 2025-08-27 13:16:47 +01:00
Matthew Breedlove 9767fc6399 Gracefully handle unknown widgets in the settings.json in both the TUI and statusline rendering 2025-08-27 01:03:09 -04:00
Matthew Breedlove 077dc0f5eb Imports cleanup 2025-08-26 23:32:47 -04:00
Matthew Breedlove 19d739c7fd Add ClaudeLog badge to README 2025-08-25 03:52:37 -04:00
Matthew Breedlove c5d9243174 Merge pull request #46 from ProCreations-Official/patch-1
Update README.md to add username in setup command
2025-08-24 14:11:56 -04:00
ProCreations-Official 015c1f0b1c Update README.md 2025-08-24 14:07:46 -04:00
Matthew Breedlove ad85f951a4 Fixes for inefficient rendering in auto-alignment mode v2.0.9 2025-08-24 02:45:38 -04:00
Matthew Breedlove 174dba2832 Better screenshot showing off auto-align feature 2025-08-24 00:28:31 -04:00
Matthew Breedlove b46319c4e2 Adding powerline widget auto-alignment toggle v2.0.8 2025-08-24 00:22:22 -04:00
Matthew Breedlove bbf50be1b0 Standardize naming convention -> status items and items are now widgets 2025-08-21 02:56:10 -04:00
Matthew Breedlove 8e6b1013a1 Update readme and bump version to 2.0.7 v2.0.7 2025-08-21 02:02:19 -04:00
Matthew Breedlove ce768e541a Add session cost widget 2025-08-21 01:41:05 -04:00
Matthew Breedlove f218a6a445 Enable raw mode for Current Working Dir widget 2025-08-21 01:40:30 -04:00
Matthew Breedlove 3aea75403f Add Current Working Dir component 2025-08-21 01:28:17 -04:00
Matthew Breedlove f9a113a9d2 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 v2.0.6 2025-08-20 19:10:38 -04:00
Matthew Breedlove 539be98470 Adding NOTICE 2025-08-20 15:22:45 -04:00
Matthew Breedlove dfaea8b6aa Updating LICENSE with copyright and author information 2025-08-20 15:20:33 -04:00
Matthew Breedlove 39dbc2b70b Update ccusage link in readme 2025-08-20 14:27:55 -04:00