-
Notifications
You must be signed in to change notification settings - Fork 5
feat: add sessions usage tab #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f4f6c9c
feat(web-ui): add sessions usage tab
awsl233777 6c0c345
fix(web-ui): align sessions usage tab with existing theme
awsl233777 590a8ee
fix(web-ui): prevent sessions usage charts and paths overflow
awsl233777 3f3f01a
docs(readme): document sessions usage analytics view
awsl233777 c9cb504
docs(readme): keep sessions usage docs feature-focused
awsl233777 13f5556
docs(readme): expand comparison and architecture for sessions usage
awsl233777 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import assert from 'assert'; | ||
| import path from 'path'; | ||
| import { fileURLToPath, pathToFileURL } from 'url'; | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = path.dirname(__filename); | ||
| const logic = await import(pathToFileURL(path.join(__dirname, '..', '..', 'web-ui', 'logic.mjs'))); | ||
| const { buildUsageChartGroups } = logic; | ||
|
|
||
| test('buildUsageChartGroups aggregates codex and claude sessions into day buckets', () => { | ||
| const now = Date.UTC(2026, 3, 6, 12, 0, 0); | ||
| const result = buildUsageChartGroups([ | ||
| { source: 'codex', updatedAt: '2026-04-06T08:00:00.000Z', messageCount: 5, cwd: '/a' }, | ||
| { source: 'claude', updatedAt: '2026-04-06T09:00:00.000Z', messageCount: 7, cwd: '/a' }, | ||
| { source: 'codex', updatedAt: '2026-04-05T09:00:00.000Z', messageCount: 3, cwd: '/b' } | ||
| ], { range: '7d', now }); | ||
|
|
||
| assert.strictEqual(result.summary.totalSessions, 3); | ||
| assert.strictEqual(result.summary.totalMessages, 15); | ||
| assert.strictEqual(result.summary.codexTotal, 2); | ||
| assert.strictEqual(result.summary.claudeTotal, 1); | ||
| assert.strictEqual(result.sourceShare.find(item => item.key === 'codex').percent, 67); | ||
| assert.strictEqual(result.topPaths[0].path, '/a'); | ||
| assert.strictEqual(result.topPaths[0].count, 2); | ||
| const lastBucket = result.buckets[result.buckets.length - 1]; | ||
| assert.strictEqual(lastBucket.codex, 1); | ||
| assert.strictEqual(lastBucket.claude, 1); | ||
| assert.strictEqual(lastBucket.totalMessages, 12); | ||
| }); | ||
|
|
||
| test('buildUsageChartGroups ignores invalid sessions and keeps empty buckets stable', () => { | ||
| const now = Date.UTC(2026, 3, 6, 12, 0, 0); | ||
| const result = buildUsageChartGroups([ | ||
| null, | ||
| { source: 'other', updatedAt: '2026-04-06T08:00:00.000Z', messageCount: 9 }, | ||
| { source: 'codex', updatedAt: 'bad-date', messageCount: 2 } | ||
| ], { range: '7d', now }); | ||
|
|
||
| assert.strictEqual(result.summary.totalSessions, 0); | ||
| assert.strictEqual(result.summary.totalMessages, 0); | ||
| assert.strictEqual(result.buckets.length, 7); | ||
| assert.ok(result.buckets.every((item) => item.totalSessions === 0)); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normalize unsupported
rangevalues to a canonical output ('7d'/'30d').At Line [93] and Line [163], invalid inputs currently produce 7-day buckets but return the original invalid
rangestring. This can desync metadata from actual aggregation.💡 Proposed fix
Also applies to: 163-163
🤖 Prompt for AI Agents