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

@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.

Copy link

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.

Copy link

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.

Copy link

github-actions bot commented Oct 1, 2025

🚀 Preview deployed!

Your changes have been deployed to Vercel:

Preview URL: https://roo-code-website-gvmlsyrvx-roo-code.vercel.app

This preview will be updated automatically when you push new commits to this PR.

brunobergher and others added 7 commits October 1, 2025 10:44
* origin/main:
  fix: Addresses overeager 'there are unsaved changes' dialog in settings (#8410)
  Add structured data to the homepage (#8427)
  fix: show send button when only images are selected in chat textarea (#8423)
  Include reasoning messages in cloud tasks (#8401)
  chore: Remove unsupported Gemini 2.5 Flash Image Preview free model (#8359)
  A couple more sonnet 4.5 fixes (#8421)
  Changeset version bump (#8414)
  chore: add changeset for v3.28.14 (#8413)
  feat: add GLM-4.6 model support for z.ai provider (#8408)
…into bb/experiment-stats

* 'bb/experiment-stats' of github.com:RooCodeInc/Roo-Code:
Copy link

@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.

<div className="p-4">
{/* Chart with daily usage bars */}
<div className="h-24 min-[450px]:h-40 rounded mb-3 flex items-end gap-1 pb-2">
{data &&
Copy link

Choose a reason for hiding this comment

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

P2: Add accessible name/role for the chart container so assistive tech announces the widget meaningfully.

Suggested change
{data &&
<div
className="h-24 min-[450px]:h-40 rounded mb-3 flex items-end gap-1 pb-2"
role="img"
aria-label={t("cloud:usagePreview.costPastDays", { count: data.days.length })}>

Copy link

@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. Focused on new, deduped findings only.

}

return (
<div className="cursor-pointer group rounded-lg bg-vscode-editor-background relative" onClick={onViewDetails}>
Copy link

Choose a reason for hiding this comment

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

[P2] Interactive container is not keyboard-accessible. Add role, tabIndex, and Enter/Space key handling so users can activate the chart via keyboard.

Suggested change
<div className="cursor-pointer group rounded-lg bg-vscode-editor-background relative" onClick={onViewDetails}>
<div
className="cursor-pointer group rounded-lg bg-vscode-editor-background relative"
role="button"
tabIndex={0}
onClick={onViewDetails}
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onViewDetails(); } }}>

// Loading state
if (isLoading) {
return (
<div
Copy link

Choose a reason for hiding this comment

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

[P2] Loading state container is clickable but not keyboard-accessible. Mirror the same a11y affordances as the main chart.

Suggested change
<div
<div
className="cursor-pointer group rounded-lg bg-vscode-editor-background hover:bg-vscode-list-hoverBackground transition-colors relative"
role="button"
tabIndex={0}
onClick={onViewDetails}
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onViewDetails(); } }}>

// Error state
if (error || !data) {
return (
<div
Copy link

Choose a reason for hiding this comment

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

[P2] Error state is also a clickable retry affordance; add keyboard support (role, tabIndex, Enter/Space handler).

Suggested change
<div
<div
className="cursor-pointer group rounded-lg bg-vscode-editor-background hover:bg-vscode-list-hoverBackground transition-colors relative"
role="button"
tabIndex={0}
onClick={handleRetry}
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); handleRetry(); } }}>

cloudIsAuthenticated &&
"cursor-pointer hover:bg-vscode-dropdown-background hover:border-vscode-dropdown-border transition-colors",
)}
style={{ opacity: cost !== null && cost !== undefined && cost > 0 ? 1 : 0 }}
Copy link

Choose a reason for hiding this comment

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

[P2] Invisible cost pill still intercepts clicks (opacity: 0 retains pointer events). This can trigger a navigation when the pill is visually hidden. Disable pointer events and hide from a11y when not visible.

Suggested change
style={{ opacity: cost !== null && cost !== undefined && cost > 0 ? 1 : 0 }}
style={{
opacity: cost !== null && cost !== undefined && cost > 0 ? 1 : 0,
pointerEvents: cost !== null && cost !== undefined && cost > 0 ? 'auto' : 'none'
}}
aria-hidden={!(cost !== null && cost !== undefined && cost > 0)}

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. size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
Status: Triage
Development

Successfully merging this pull request may close these issues.

6 participants