Skip to content

feat(desktop): add switchyard-desktop --print for recorded costs and savings - #1086

Open
elyasmnvidian wants to merge 1 commit into
emehtabuddin/desktop-gui-first-windowfrom
emehtabuddin/s05-desktop-usage-print
Open

elyasmnvidian wants to merge 1 commit into
emehtabuddin/desktop-gui-first-windowfrom
emehtabuddin/s05-desktop-usage-print

Conversation

@elyasmnvidian

@elyasmnvidian elyasmnvidian commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds optional switchyard-desktop --print [FILE] output after the basic desktop window in #1137. Running without a mode flag opens the graphical app on macOS and Windows. Linux users select --print explicitly.

The summary shows today's usage and the seven local calendar days ending today, with calls, tokens, recorded spending, and estimated savings. Savings compare recorded spending on all calls with the cost of the same answers at baseline_model's rates. Missing costs, missing answer token counts, or missing baseline rates hide savings. Known spending remains visible, including a known zero cost. An invalid explicit pricing_file returns an error.

The print test fixture records a $0.10 charge, 1,000,000 input tokens, and 100,000 output tokens. With the bundled gpt-6-sol baseline, it prints Saved $2.90 (97% of $3.00).

@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 57630fd and 53b8f63.

📒 Files selected for processing: 5
  • crates/switchyard-desktop/src/main.rs
  • crates/switchyard-desktop/src/pricing.rs
  • crates/switchyard-desktop/src/rollup.rs
  • crates/switchyard-desktop/src/summary.rs
  • crates/switchyard-desktop/tests/print.rs

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

Walkthrough

The desktop app loads bundled or configured pricing rates, estimates actual and baseline costs, and adds spending and savings rows to daily and weekly summaries. It reports when pricing or usage data prevents savings estimates. Print tests cover pricing overrides, malformed logs, and path selection.

Changes

Desktop pricing and spend summaries

Layer / File(s) Summary
Pricing and usage inputs
crates/switchyard-desktop/src/main.rs, crates/switchyard-desktop/src/pricing.rs, crates/switchyard-desktop/src/rollup.rs
The app loads bundled rates or rates from the configured file and passes them to the summary builder. ModelTokens::usage includes input, output, and available cache token counts.
Cost and savings estimates
crates/switchyard-desktop/src/pricing.rs
Estimate calculates recorded costs across calls and baseline costs for routed answers. Savings require actual and baseline costs and token counts for all answers. Tests cover missing data, routing overhead, and cache-write pricing.
Summary rows and print behavior
crates/switchyard-desktop/src/summary.rs, crates/switchyard-desktop/tests/print.rs
Daily and weekly summaries show total or known spending and available savings. Messages describe missing rates or data that prevent savings estimates. Print tests cover price overrides, malformed logs, and path selection.

Priority: ➖ Normal

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

Merge Risk: ⚪ Minimal · up to 53b8f

The print summary and pricing overrides are ready for normal merge checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.87% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(desktop): add switchyard-desktop --print for recorded costs and savings" matches the main change. The PR adds a --print mode to switchyard-desktop that shows today's and this week's …
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): add switchyard-desktop --print for recorded costs and savings" matches the main change. The PR adds a --print mode to switchyard-desktop that shows today's and this week's calls, tokens, recorded spending, and estimated savings against a baseline model. The changeset adds pricing.rs (rate loading and Estimate/Savings), rollup.rs (ModelTokens::usage), summary.rs (cost rows and savings output), main.rs (loads rates before summary), and integration tests in tests/print.rs. The title names the feature, the command flag, and the two output concepts, so it is specific and accurate. It is slightly long at 76 characters, and it omits the pricing-file override, but that detail is secondary.

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

I, a rabbit, nibble rates at dawn,
Baseline carrots count and carry on,
Known costs sit beside the sum,
Saved-hop rows appear when numbers come,
I thump my paws: the printout's done!

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

@elyasmnvidian
elyasmnvidian force-pushed the emehtabuddin/s05-desktop-usage-print branch from 53b8f63 to 3ad22de Compare October 22, 2026 23:25
@ayushag-nv
ayushag-nv force-pushed the emehtabuddin/s05-desktop-usage-print branch from 3ad22de to 7d4bec3 Compare October 23, 2026 05:44
@elyasmnvidian
elyasmnvidian force-pushed the emehtabuddin/s05-desktop-usage-print branch from 7d4bec3 to 18b0152 Compare October 23, 2026 18:13
@elyasmnvidian
elyasmnvidian force-pushed the emehtabuddin/s05-desktop-usage-print branch from 18b0152 to 954c69e Compare October 23, 2026 20:42
@ayushag-nv

Copy link
Copy Markdown
Contributor

@elyasmnvidian do we need switchyard-desktop -- print functionality in the first pass ?? Who will use that as cli ???

@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1

🚀 View preview at
https://NVIDIA-NeMo.github.io/Switchyard/pr-preview/pr-1086/

Built to branch gh-pages at 2026-10-23 22:04 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@elyasmnvidian
elyasmnvidian removed this pull request from stack #1121 October 23, 2026 22:12
@elyasmnvidian
elyasmnvidian changed the base branch from emehtabuddin/s04-desktop-usage-rollup to emehtabuddin/desktop-gui-first-window October 23, 2026 22:12
@elyasmnvidian
elyasmnvidian added this pull request to stack #1140 October 23, 2026 22:12
@elyasmnvidian

Copy link
Copy Markdown
Contributor Author

Moved this after the basic graphical app in #1137. #1085 now adds the shared usage reader. #1137 opens a window with server status and usage, plus buttons to refresh, open the server config, open the routing log, and quit. This PR adds --print and savings afterward, and the TUI follows in #1087. Running without a mode flag opens the graphical app on macOS and Windows.

@elyasmnvidian
elyasmnvidian force-pushed the emehtabuddin/s05-desktop-usage-print branch from a6d93ef to 494929f Compare October 23, 2026 22:17
…savings

Signed-off-by: Elyas Mehtabuddin <emehtabuddin@nvidia.com>
@ayushag-nv
ayushag-nv force-pushed the emehtabuddin/s05-desktop-usage-print branch from 494929f to 945f2ff Compare October 24, 2026 18:50

This branch has not been deployed

No deployments
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