Skip to content

fix: format cost display with 6 decimal precision in log details#2037

Closed
Radheshg04 wants to merge 1 commit intographite-base/2037from
03-12-fix_round_off_cost_to_6_decimals_in_ui
Closed

fix: format cost display with 6 decimal precision in log details#2037
Radheshg04 wants to merge 1 commit intographite-base/2037from
03-12-fix_round_off_cost_to_6_decimals_in_ui

Conversation

@Radheshg04
Copy link
Copy Markdown
Contributor

@Radheshg04 Radheshg04 commented Mar 12, 2026

Summary

Fixed cost display formatting in the log details sheet to show costs with proper decimal precision and remove trailing zeros.

Changes

  • Modified the cost display logic to format costs using parseFloat(log.cost.toFixed(6)) instead of directly displaying the raw cost value
  • This ensures costs are displayed with up to 6 decimal places while removing unnecessary trailing zeros

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (Next.js)
  • Docs

How to test

  1. Navigate to the workspace logs section
  2. Open a log entry that has cost information
  3. Verify that the cost is displayed with proper decimal formatting (no unnecessary trailing zeros)
  4. Test with various cost values to ensure formatting works correctly
# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build

Screenshots/Recordings

Before: Cost might display with excessive decimal places or formatting issues
After: Cost displays cleanly with appropriate precision

Breaking changes

  • Yes
  • No

Related issues

Security considerations

None - this is a display formatting change only.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 12, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved cost value formatting in the Tokens section of log details. Cost amounts now display with precision up to 6 decimal places, with trailing zeros removed for cleaner presentation and better readability.

Walkthrough

A single line in the log details sheet has been modified to format cost values using parseFloat(log.cost.toFixed(6)), which limits the display to 6 decimal places and removes trailing zeros while preserving the dollar sign prefix.

Changes

Cohort / File(s) Summary
Cost Formatting
ui/app/workspace/logs/sheets/logDetailsSheet.tsx
Modified cost value display in Tokens section to parse float with 6 decimal precision, removing trailing zeros while maintaining currency formatting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A penny appears, all precise and neat,
Six decimals dancing, a decimal treat! 🐰
No trailing zeros to clutter the view,
Currency cleaner, formatted anew! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: formatting cost display with 6 decimal precision in log details.
Description check ✅ Passed The PR description is comprehensive and follows the template well, covering summary, changes, type of change, affected areas, testing instructions, and other required sections.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 03-12-fix_round_off_cost_to_6_decimals_in_ui

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor Author

Radheshg04 commented Mar 12, 2026

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Radheshg04 Radheshg04 changed the title fix: round off cost to 6 decimals in ui fix: format cost display with 6 decimal precision in log details Mar 12, 2026
@Radheshg04 Radheshg04 marked this pull request as ready for review March 12, 2026 11:22
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ui/app/workspace/logs/sheets/logDetailsSheet.tsx`:
- Line 341: The LogEntryDetailsView in logDetailsSheet.tsx currently formats
cost with .toFixed(6) and a manual `$` prefix causing inconsistent precision;
update the cost formatting to use the shared formatCost utility from
ui/app/workspace/dashboard/utils/chartUtils.ts (or change to .toFixed(4) to
match columns.tsx and page.tsx) for consistency, and ensure the `$` prefix is
applied uniformly (fix columns.tsx to include `$` if you choose .toFixed(4)).
Locate the cost usage in LogEntryDetailsView (value={log.cost ...}), the table
in columns.tsx, and the stats card in page.tsx and replace their ad-hoc
formatting with formatCost(log.cost) (or standardize to .toFixed(4) + `$`) so
all views match.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d3a43f9b-76c4-4acb-a684-488dbbe8d118

📥 Commits

Reviewing files that changed from the base of the PR and between 1e98928 and 58006c9.

📒 Files selected for processing (1)
  • ui/app/workspace/logs/sheets/logDetailsSheet.tsx

Comment thread ui/app/workspace/logs/sheets/logDetailsSheet.tsx
@Pratham-Mishra04 Pratham-Mishra04 changed the base branch from 02-26-refactor_pricing_module_refactor to graphite-base/2037 March 12, 2026 11:47
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.

3 participants