Skip to content

Commit c33cc29

Browse files
committed
Adds links to CloudView from mentions of cost elsewhere if the user is authenticated
1 parent eda8cae commit c33cc29

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

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

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

135-
const { mcpServers, alwaysAllowMcp, currentCheckpoint, mode, apiConfiguration } = useExtensionState()
135+
const { mcpServers, alwaysAllowMcp, currentCheckpoint, mode, apiConfiguration, cloudIsAuthenticated } =
136+
useExtensionState()
136137
const { info: model } = useSelectedModel(apiConfiguration)
137138
const [isEditing, setIsEditing] = useState(false)
138139
const [editedContent, setEditedContent] = useState("")
@@ -1074,8 +1075,21 @@ export const ChatRowContent = ({
10741075
{title}
10751076
</div>
10761077
<div
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 }}>
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={
1085+
cloudIsAuthenticated
1086+
? (e) => {
1087+
e.stopPropagation() // Prevent parent onClick from firing
1088+
vscode.postMessage({ type: "switchTab", tab: "cloud" })
1089+
}
1090+
: undefined
1091+
}
1092+
title={cloudIsAuthenticated ? t("chat:apiRequest.viewTokenUsage") : undefined}>
10791093
${Number(cost || 0)?.toFixed(4)}
10801094
</div>
10811095
</div>

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ 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 } from "lucide-react"
6+
import { FoldVertical, ChevronUp, ChevronDown, ChartColumn } from "lucide-react"
77
import prettyBytes from "pretty-bytes"
88

99
import type { ClineMessage } from "@roo-code/types"
@@ -50,7 +50,7 @@ const TaskHeader = ({
5050
todos,
5151
}: TaskHeaderProps) => {
5252
const { t } = useTranslation()
53-
const { apiConfiguration, currentTaskItem, clineMessages } = useExtensionState()
53+
const { apiConfiguration, currentTaskItem, clineMessages, cloudIsAuthenticated } = useExtensionState()
5454
const { id: modelId, info: model } = useSelectedModel(apiConfiguration)
5555
const [isTaskExpanded, setIsTaskExpanded] = useState(false)
5656
const [showLongRunningTaskMessage, setShowLongRunningTaskMessage] = useState(false)
@@ -302,6 +302,24 @@ const TaskHeader = ({
302302
</th>
303303
<td className="align-top">
304304
<span>${totalCost?.toFixed(2)}</span>
305+
{cloudIsAuthenticated ? (
306+
<StandardTooltip content={t("chat:apiRequest.viewTokenUsage")}>
307+
<ChartColumn
308+
className="inline size-3.5 -mt-0.5 ml-2 text-vscode-textLink-foreground cursor-pointer hover:text-vscode-textLink-activeForeground transition-colors"
309+
onClick={(e) => {
310+
e.stopPropagation()
311+
import("@src/utils/vscode").then(({ vscode }) => {
312+
vscode.postMessage({
313+
type: "switchTab",
314+
tab: "cloud",
315+
})
316+
})
317+
}}
318+
/>
319+
</StandardTooltip>
320+
) : (
321+
<ChartColumn className="inline size-3.5 -mt-0.5 ml-2 text-vscode-textLink-foreground" />
322+
)}
305323
</td>
306324
</tr>
307325
)}

webview-ui/src/i18n/locales/en/chat.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@
147147
"failed": "API Request Failed",
148148
"streaming": "API Request...",
149149
"cancelled": "API Request Cancelled",
150-
"streamingFailed": "API Streaming Failed"
150+
"streamingFailed": "API Streaming Failed",
151+
"viewTokenUsage": "View token usage"
151152
},
152153
"checkpoint": {
153154
"regular": "Checkpoint",

0 commit comments

Comments
 (0)