Skip to content

feat(desktop): aggregate routing logs into daily and weekly token rollups - #1085

Merged
ayushag-nv merged 1 commit into
mainfrom
emehtabuddin/s04-desktop-usage-rollup
Oct 24, 2026
Merged

ayushag-nv merged 1 commit into
mainfrom
emehtabuddin/s04-desktop-usage-rollup

Conversation

@elyasmnvidian

@elyasmnvidian elyasmnvidian commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds the shared routing-log reader for the desktop app.

rollup::Reader reads newly completed lines from routing.jsonl and totals usage for today and the seven local calendar days ending today. It keeps answer calls separate from classifier calls. It starts over when the log is replaced or truncated. An invalid complete record returns an error instead of showing incomplete usage.

The reader and record types live in the desktop library so the graphical and terminal apps can share them. The basic window follows in #1137. Printed summaries and savings follow in #1086.

@elyasmnvidian
elyasmnvidian requested a review from a team as a code owner October 22, 2026 22:05
@elyasmnvidian
elyasmnvidian added this pull request to stack #1121 October 22, 2026 22:17
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between b2e9386 and 4ef061b.

📒 Files selected for processing: 5
  • crates/switchyard-desktop/Cargo.toml
  • crates/switchyard-desktop/src/history.rs
  • crates/switchyard-desktop/src/main.rs
  • crates/switchyard-desktop/src/rollup.rs
  • crates/switchyard-desktop/src/summary.rs

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Walkthrough

The desktop package adds routing-log usage aggregation, summary formatting, and a command-line app. The app supports help, TOML validation, and printing a summary using configured settings, current usage, and server status.

Changes

Desktop usage summary

Layer / File(s) Summary
Log entry and usage aggregation
crates/switchyard-desktop/src/history.rs, crates/switchyard-desktop/src/rollup.rs
Adds a serializable routing-log entry type and aggregation for token, cost, and request totals. The reader handles appended and partial records, file truncation or replacement, and period totals. Tests cover token accounting and reader behavior.
Summary formatting
crates/switchyard-desktop/src/summary.rs
Formats server status, period totals, weekly model shares, and incomplete-cost or uncounted-answer indicators.
Command-line flow
crates/switchyard-desktop/src/main.rs, crates/switchyard-desktop/Cargo.toml
Adds help, print, and TOML-validation options. The app loads settings, reads usage, probes the configured server, and prints summary rows. The package selects its default executable.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 4ef06

The usage summary appears ready to merge after normal checks; no actionable issue was established in the current changes.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(desktop): aggregate routing logs into daily and weekly token rollups" matches the main change. The PR adds rollup.rs, which aggregates routing-log records into daily, weekly, and all-t…
Docstring Coverage Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 4 files. (1 skipped: 1 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(desktop): aggregate routing logs into daily and weekly token rollups" matches the main change. The PR adds rollup.rs, which aggregates routing-log records into daily, weekly, and all-time totals, and the summary.rs and main.rs files that display those totals. The title is concise and specific, and it names the primary feature. The title follows a conventional-commit style and does not mention unrelated files or changes.

Full details: Docstring Coverage

Explanation

Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 4 files. (1 skipped: 1 unsupported.)

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the log at night
Counts tokens by the lantern light
Seven days roll into view
Costs and routes are tallied too
The desktop prints a summary, neat

Comment @coderabbitai help to get the list of available commands.

@elyasmnvidian
elyasmnvidian force-pushed the emehtabuddin/s04-desktop-usage-rollup branch from 57630fd to 3811425 Compare October 22, 2026 23:25
@ayushag-nv
ayushag-nv force-pushed the emehtabuddin/s04-desktop-usage-rollup branch from 3811425 to 788ccbf Compare October 23, 2026 05:44
Comment thread crates/switchyard-desktop/src/summary.rs Outdated
@elyasmnvidian
elyasmnvidian force-pushed the emehtabuddin/s04-desktop-usage-rollup branch from 788ccbf to 4ef353f Compare October 23, 2026 18:13
@elyasmnvidian

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

I added documentation for the rollup and summary helpers and updated the summary to show known spending when some calls have no recorded cost. Please review the current head and rerun the docstring coverage check.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

Base automatically changed from emehtabuddin/s03-desktop-settings-health to main October 23, 2026 19:45
@elyasmnvidian
elyasmnvidian force-pushed the emehtabuddin/s04-desktop-usage-rollup branch from 4ef061b to 28cbb74 Compare October 23, 2026 20:05
Comment thread crates/switchyard-desktop/src/summary.rs Outdated
Comment thread crates/switchyard-desktop/src/summary.rs Outdated
Comment thread crates/switchyard-desktop/src/main.rs Outdated
…lups

Signed-off-by: Elyas Mehtabuddin <emehtabuddin@nvidia.com>
@elyasmnvidian
elyasmnvidian force-pushed the emehtabuddin/s04-desktop-usage-rollup branch from cb926d4 to d449f33 Compare October 23, 2026 22:15
@ayushag-nv
ayushag-nv merged commit 9ddd487 into main Oct 24, 2026
16 checks passed
@ayushag-nv
ayushag-nv deleted the emehtabuddin/s04-desktop-usage-rollup branch October 24, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants