Skip to content

Commit eeaafef

Browse files
authored
Revert "feat: Experiment: Show a bit of stats in Cloud tab to help users discover there's more in Cloud" (#8559)
1 parent cd8036d commit eeaafef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+142
-691
lines changed

packages/cloud/src/CloudAPI.ts

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import { z } from "zod"
22

3-
import {
4-
type AuthService,
5-
type ShareVisibility,
6-
type ShareResponse,
7-
shareResponseSchema,
8-
type UsageStats,
9-
usageStatsSchema,
10-
} from "@roo-code/types"
3+
import { type AuthService, type ShareVisibility, type ShareResponse, shareResponseSchema } from "@roo-code/types"
114

125
import { getRooCodeApiUrl } from "./config.js"
136
import { getUserAgent } from "./utils.js"
@@ -60,11 +53,9 @@ export class CloudAPI {
6053
})
6154

6255
if (!response.ok) {
63-
this.log(`[CloudAPI] Request to ${endpoint} failed with status ${response.status}`)
6456
await this.handleErrorResponse(response, endpoint)
6557
}
6658

67-
// Log before attempting to read the body
6859
const data = await response.json()
6960

7061
if (parseResponse) {
@@ -95,15 +86,9 @@ export class CloudAPI {
9586
let responseBody: unknown
9687

9788
try {
98-
const bodyText = await response.text()
99-
100-
try {
101-
responseBody = JSON.parse(bodyText)
102-
} catch {
103-
responseBody = bodyText
104-
}
105-
} catch (_error) {
106-
responseBody = "Failed to read error response"
89+
responseBody = await response.json()
90+
} catch {
91+
responseBody = await response.text()
10792
}
10893

10994
switch (response.status) {
@@ -124,12 +109,15 @@ export class CloudAPI {
124109
}
125110

126111
async shareTask(taskId: string, visibility: ShareVisibility = "organization"): Promise<ShareResponse> {
112+
this.log(`[CloudAPI] Sharing task ${taskId} with visibility: ${visibility}`)
113+
127114
const response = await this.request("/api/extension/share", {
128115
method: "POST",
129116
body: JSON.stringify({ taskId, visibility }),
130117
parseResponse: (data) => shareResponseSchema.parse(data),
131118
})
132119

120+
this.log("[CloudAPI] Share response:", response)
133121
return response
134122
}
135123

@@ -146,14 +134,4 @@ export class CloudAPI {
146134
.parse(data),
147135
})
148136
}
149-
150-
async getUsagePreview(): Promise<UsageStats> {
151-
const response = await this.request("/api/analytics/usage/daily?period=7", {
152-
method: "GET",
153-
parseResponse: (data) => {
154-
return usageStatsSchema.parse(data)
155-
},
156-
})
157-
return response
158-
}
159137
}

src/core/webview/webviewMessageHandler.ts

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3110,68 +3110,5 @@ export const webviewMessageHandler = async (
31103110
})
31113111
break
31123112
}
3113-
case "getUsagePreview": {
3114-
try {
3115-
// Get the CloudAPI instance and fetch usage preview
3116-
const cloudApi = CloudService.instance.cloudAPI
3117-
if (!cloudApi) {
3118-
// User is not authenticated
3119-
provider.log("[webviewMessageHandler] User not authenticated for usage preview")
3120-
await provider.postMessageToWebview({
3121-
type: "usagePreviewData",
3122-
error: "Authentication required",
3123-
data: null,
3124-
})
3125-
break
3126-
}
3127-
3128-
// Fetch usage preview data
3129-
const rawUsageData = await cloudApi.getUsagePreview()
3130-
3131-
// Transform the data to match UI expectations
3132-
// The API returns data with separate arrays, but UI expects an array of day objects
3133-
const dates = rawUsageData.data?.dates ?? []
3134-
const tasks = rawUsageData.data?.tasks ?? []
3135-
const tokens = rawUsageData.data?.tokens ?? []
3136-
const costs = rawUsageData.data?.costs ?? []
3137-
const len = Math.min(dates.length, tasks.length, tokens.length, costs.length)
3138-
3139-
const transformedData = {
3140-
days: Array.from({ length: len }).map((_, index) => ({
3141-
date: dates[index] ?? "",
3142-
taskCount: tasks[index] ?? 0,
3143-
tokenCount: tokens[index] ?? 0,
3144-
cost: costs[index] ?? 0,
3145-
})),
3146-
totals: rawUsageData.data?.totals || {
3147-
tasks: 0,
3148-
tokens: 0,
3149-
cost: 0,
3150-
},
3151-
}
3152-
3153-
// Send the transformed data back to the webview
3154-
await provider.postMessageToWebview({
3155-
type: "usagePreviewData",
3156-
data: transformedData,
3157-
error: undefined,
3158-
})
3159-
} catch (error) {
3160-
provider.log(
3161-
`[webviewMessageHandler] Failed to fetch usage preview: ${error instanceof Error ? error.message : String(error)}`,
3162-
)
3163-
provider.log(
3164-
`[webviewMessageHandler] Error stack trace: ${error instanceof Error ? error.stack : "No stack trace"}`,
3165-
)
3166-
3167-
// Send error back to webview
3168-
await provider.postMessageToWebview({
3169-
type: "usagePreviewData",
3170-
error: error instanceof Error ? error.message : "Failed to load usage data",
3171-
data: null,
3172-
})
3173-
}
3174-
break
3175-
}
31763113
}
31773114
}

src/shared/ExtensionMessage.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ export interface ExtensionMessage {
126126
| "insertTextIntoTextarea"
127127
| "dismissedUpsells"
128128
| "organizationSwitchResult"
129-
| "usagePreviewData"
130129
text?: string
131130
payload?: any // Add a generic payload for now, can refine later
132131
action?:
@@ -206,7 +205,6 @@ export interface ExtensionMessage {
206205
queuedMessages?: QueuedMessage[]
207206
list?: string[] // For dismissedUpsells
208207
organizationId?: string | null // For organizationSwitchResult
209-
data?: any // For usagePreviewData
210208
}
211209

212210
export type ExtensionState = Pick<

src/shared/WebviewMessage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ export interface WebviewMessage {
229229
| "editQueuedMessage"
230230
| "dismissUpsell"
231231
| "getDismissedUpsells"
232-
| "getUsagePreview"
233232
text?: string
234233
editedMessageContent?: string
235234
tab?: "settings" | "history" | "mcp" | "modes" | "chat" | "marketplace" | "cloud"

webview-ui/src/__tests__/ContextWindowProgress.spec.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import TaskHeader from "@src/components/chat/TaskHeader"
88
// Mock formatLargeNumber function
99
vi.mock("@/utils/format", () => ({
1010
formatLargeNumber: vi.fn((num) => num.toString()),
11-
formatCost: (cost: number) => `$${cost.toFixed(2)}`,
1211
}))
1312

1413
// Mock VSCodeBadge component for all tests
@@ -129,7 +128,12 @@ describe("ContextWindowProgress", () => {
129128
expect(windowSize).toBeInTheDocument()
130129
expect(windowSize).toHaveTextContent("4000")
131130

132-
const progressBarContainer = screen.getByTestId("context-progress-bar-container").parentElement
131+
// The progress bar is now wrapped in tooltips, but we can verify the structure exists
132+
// by checking for the progress bar container
133+
const progressBarContainer = screen.getByTestId("context-tokens-count").parentElement
133134
expect(progressBarContainer).toBeInTheDocument()
135+
136+
// Verify the flex container has the expected structure
137+
expect(progressBarContainer?.querySelector(".flex-1.relative")).toBeInTheDocument()
134138
})
135139
})

webview-ui/src/components/chat/ChatRow.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ export const ChatRowContent = ({
132132
}: ChatRowContentProps) => {
133133
const { t } = useTranslation()
134134

135-
const { mcpServers, alwaysAllowMcp, currentCheckpoint, mode, apiConfiguration, cloudIsAuthenticated } =
136-
useExtensionState()
135+
const { mcpServers, alwaysAllowMcp, currentCheckpoint, mode, apiConfiguration } = useExtensionState()
137136
const { info: model } = useSelectedModel(apiConfiguration)
138137
const [isEditing, setIsEditing] = useState(false)
139138
const [editedContent, setEditedContent] = useState("")
@@ -1075,17 +1074,8 @@ export const ChatRowContent = ({
10751074
{title}
10761075
</div>
10771076
<div
1078-
className={cn(
1079-
"text-xs text-vscode-dropdown-foreground border-vscode-dropdown-border/50 border px-1.5 py-0.5 rounded-lg",
1080-
cloudIsAuthenticated &&
1081-
"cursor-pointer hover:bg-vscode-dropdown-background hover:border-vscode-dropdown-border transition-colors",
1082-
)}
1083-
style={{ opacity: cost !== null && cost !== undefined && cost > 0 ? 1 : 0 }}
1084-
onClick={(e) => {
1085-
e.stopPropagation() // Prevent parent onClick from firing
1086-
vscode.postMessage({ type: "switchTab", tab: "cloud" })
1087-
}}
1088-
title={t("chat:apiRequest.viewTokenUsage")}>
1077+
className="text-xs text-vscode-dropdown-foreground border-vscode-dropdown-border/50 border px-1.5 py-0.5 rounded-lg"
1078+
style={{ opacity: cost !== null && cost !== undefined && cost > 0 ? 1 : 0 }}>
10891079
${Number(cost || 0)?.toFixed(4)}
10901080
</div>
10911081
</div>

webview-ui/src/components/chat/ContextWindowProgress.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ export const ContextWindowProgress = ({ contextWindow, contextTokens, maxTokens
6060
<StandardTooltip content={tooltipContent} side="top" sideOffset={8}>
6161
<div className="flex-1 relative">
6262
{/* Main progress bar container */}
63-
<div
64-
data-testid="context-progress-bar-container"
65-
className="flex items-center h-1 rounded-[2px] overflow-hidden w-full bg-[color-mix(in_srgb,var(--vscode-foreground)_20%,transparent)]">
63+
<div className="flex items-center h-1 rounded-[2px] overflow-hidden w-full bg-[color-mix(in_srgb,var(--vscode-foreground)_20%,transparent)]">
6664
{/* Current tokens container */}
6765
<div
6866
className="relative h-full"

webview-ui/src/components/chat/TaskHeader.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import { useTranslation } from "react-i18next"
33
import { useCloudUpsell } from "@src/hooks/useCloudUpsell"
44
import { CloudUpsellDialog } from "@src/components/cloud/CloudUpsellDialog"
55
import DismissibleUpsell from "@src/components/common/DismissibleUpsell"
6-
import { FoldVertical, ChevronUp, ChevronDown, ChartColumn } from "lucide-react"
6+
import { FoldVertical, ChevronUp, ChevronDown } from "lucide-react"
77
import prettyBytes from "pretty-bytes"
88

99
import type { ClineMessage } from "@roo-code/types"
1010

1111
import { getModelMaxOutputTokens } from "@roo/api"
1212
import { findLastIndex } from "@roo/array"
1313

14-
import { formatCost, formatLargeNumber } from "@src/utils/format"
14+
import { formatLargeNumber } from "@src/utils/format"
1515
import { cn } from "@src/lib/utils"
1616
import { StandardTooltip } from "@src/components/ui"
1717
import { useExtensionState } from "@src/context/ExtensionStateContext"
@@ -24,8 +24,6 @@ import { ContextWindowProgress } from "./ContextWindowProgress"
2424
import { Mention } from "./Mention"
2525
import { TodoListDisplay } from "./TodoListDisplay"
2626

27-
import { vscode } from "@src/utils/vscode"
28-
2927
export interface TaskHeaderProps {
3028
task: ClineMessage
3129
tokensIn: number
@@ -303,19 +301,7 @@ const TaskHeader = ({
303301
{t("chat:task.apiCost")}
304302
</th>
305303
<td className="align-top">
306-
<span>{formatCost(totalCost)}</span>
307-
<StandardTooltip content={t("chat:apiRequest.viewTokenUsage")}>
308-
<ChartColumn
309-
className="inline size-3.5 -mt-0.5 ml-2 text-vscode-textLink-foreground cursor-pointer hover:text-vscode-textLink-activeForeground transition-colors"
310-
onClick={(e) => {
311-
e.stopPropagation()
312-
vscode.postMessage({
313-
type: "switchTab",
314-
tab: "cloud",
315-
})
316-
}}
317-
/>
318-
</StandardTooltip>
304+
<span>${totalCost?.toFixed(2)}</span>
319305
</td>
320306
</tr>
321307
)}

webview-ui/src/components/chat/__tests__/TaskHeader.spec.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,6 @@ vi.mock("@roo/array", () => ({
8888
},
8989
}))
9090

91-
// Mock the format utilities
92-
vi.mock("@/utils/format", async (importOriginal) => {
93-
const actual = await importOriginal<typeof import("@/utils/format")>()
94-
return {
95-
...actual,
96-
formatCost: (cost: number) => `$${cost.toFixed(2)}`,
97-
}
98-
})
99-
10091
describe("TaskHeader", () => {
10192
const defaultProps: TaskHeaderProps = {
10293
task: { type: "say", ts: Date.now(), text: "Test task", images: [] },

0 commit comments

Comments
 (0)