Skip to content

Conversation

@brunobergher
Copy link
Collaborator

@brunobergher brunobergher commented Sep 30, 2025

Description

  • Adds a basic bar chart in CloudView when logged in
  • Tweaks overall CloudView layout to accomodate it
  • When clicked, users are taken to /usage in the Cloud app
  • Clicking on costs in the message feed takes the user to CloudView
  • Adds basic instrumentation via utm params (utm_source=extension&utm_medium=stats_preview&utm_campaign=stats_preview)

Screenshots / Videos

image image

Important

Adds a bar chart in CloudView to display usage stats, with API and UI updates for enhanced user interaction with the Cloud app.

  • Behavior:
    • Adds a bar chart in CloudView to display usage stats when logged in.
    • Clicking the chart redirects to /usage in the Cloud app.
    • Clicking costs in the message feed redirects to CloudView.
    • Adds UTM parameters for tracking: utm_source=extension&utm_medium=stats_preview&utm_campaign=stats_preview.
  • API:
    • Adds getUsagePreview() in CloudAPI.ts to fetch usage data.
    • Handles JSON parsing errors in CloudAPI.ts.
  • UI Components:
    • Updates webviewMessageHandler.ts to handle getUsagePreview messages.
    • Adds UsagePreview component in CloudView.tsx.
    • Updates ChatRow.tsx to handle cost click events.
  • Localization:
    • Updates multiple locale files to include new strings for usage preview and related messages.
  • Utilities:
    • Adds formatCost() in format.ts for consistent cost formatting.

This description was created by Ellipsis for 35154ef. You can customize this summary. It will automatically update as commits are pushed.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 30, 2025
Copy link
Contributor

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

I found some issues that need attention. See inline comments for concrete suggestions.

@brunobergher
Copy link
Collaborator Author

@roomote-agent implement the feedback I responded to.

@roomote
Copy link
Contributor

roomote bot commented Sep 30, 2025

Acknowledged. I will implement the feedback you responded to: clear the 10s timeout when usagePreviewData arrives to prevent a stale error; and compute bar height as Math.round((cost / maxCost) * 100) with a minimum of 1. I will push changes to bb/experiment-stats shortly.

@roomote
Copy link
Contributor

roomote bot commented Sep 30, 2025

Implemented the feedback. Summary:

  • Cloud UsagePreview: clear the 10s timeout when usagePreviewData arrives and manage cleanup via timeoutId; bar height now uses Math.round((cost / maxCost) * 100) with a minimum of 1 and guards for non positive max.
  • webviewMessageHandler: transform usage preview data defensively by bounding to the shortest of the dates, tasks, tokens, and costs arrays.

Local vitest suites for src and webview-ui passed. Changes pushed to bb/experiment-stats. CI checks are green.

@brunobergher brunobergher marked this pull request as ready for review September 30, 2025 14:26
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. Enhancement New feature or request labels Sep 30, 2025
import { AuthenticationError, CloudAPIError, NetworkError, TaskNotFoundError } from "./errors.js"

// Usage stats schemas
const usageStatsSchema = z.object({
Copy link
Collaborator

@mrubens mrubens Sep 30, 2025

Choose a reason for hiding this comment

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

Maybe this should go in packages/types/src/cloud.ts? I think we could then share it with the cloud side.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This usually ends up being easiest (arguably...) to sequence as

  1. Add the types to packages/types.
  2. Update @roo-code/types
  3. Update @roo-code/types in cloud + ship the cloud functionality.
  4. Finally actually use the cloud functionality back here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants