Skip to content

Commit 5e5a6a6

Browse files
committed
Add Retry Request button to 'Insufficient balance' error
1 parent 7f5d03c commit 5e5a6a6

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { AutoApprovalSettings, DEFAULT_AUTO_APPROVAL_SETTINGS } from "../../shar
2222
import { BrowserSettings, DEFAULT_BROWSER_SETTINGS } from "../../shared/BrowserSettings"
2323
import { ChatContent } from "../../shared/ChatContent"
2424
import { ChatSettings, DEFAULT_CHAT_SETTINGS } from "../../shared/ChatSettings"
25-
import { ExtensionMessage, ExtensionState, Platform } from "../../shared/ExtensionMessage"
25+
import { ExtensionMessage, ExtensionState, Invoke, Platform } from "../../shared/ExtensionMessage"
2626
import { HistoryItem } from "../../shared/HistoryItem"
2727
import { McpDownloadResponse, McpMarketplaceCatalog, McpServer } from "../../shared/mcp"
2828
import { ClineCheckpointRestore, WebviewMessage } from "../../shared/WebviewMessage"
@@ -956,6 +956,15 @@ export class ClineProvider implements vscode.WebviewViewProvider {
956956
)
957957
break
958958
}
959+
case "invoke": {
960+
if (message.text) {
961+
await this.postMessageToWebview({
962+
type: "invoke",
963+
invoke: message.text as Invoke,
964+
})
965+
}
966+
break
967+
}
959968
// telemetry
960969
case "openSettings": {
961970
await this.postMessageToWebview({

src/shared/ExtensionMessage.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export interface ExtensionMessage {
4242
| "didBecomeVisible"
4343
| "accountLoginClicked"
4444
| "accountLogoutClicked"
45-
invoke?: "sendMessage" | "primaryButtonClick" | "secondaryButtonClick"
45+
invoke?: Invoke
4646
state?: ExtensionState
4747
images?: string[]
4848
ollamaModels?: string[]
@@ -70,6 +70,8 @@ export interface ExtensionMessage {
7070
isImage?: boolean
7171
}
7272

73+
export type Invoke = "sendMessage" | "primaryButtonClick" | "secondaryButtonClick"
74+
7375
export type Platform = "aix" | "darwin" | "freebsd" | "linux" | "openbsd" | "sunos" | "win32" | "unknown"
7476

7577
export const DEFAULT_PLATFORM = "unknown"

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export interface WebviewMessage {
5858
| "updateMcpTimeout"
5959
| "fetchOpenGraphData"
6060
| "checkIsImageUrl"
61+
| "invoke"
6162
// | "relaunchChromeDebugMode"
6263
text?: string
6364
disabled?: boolean

webview-ui/src/components/account/AccountView.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ export const ClineAccountView = () => {
6868
<div
6969
style={{
7070
padding: "12px 16px",
71-
border: "1px solid var(--vscode-widget-border)",
72-
borderRadius: "6px",
73-
backgroundColor: "var(--vscode-editor-background)",
71+
border: "1px solid var(--vscode-input-border)",
72+
borderRadius: "2px",
73+
backgroundColor: "var(--vscode-dropdown-background)",
7474
}}>
7575
<div
7676
style={{

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import React from "react"
22
import VSCodeButtonLink from "../common/VSCodeButtonLink"
3+
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
4+
import { vscode } from "../../utils/vscode"
5+
import { Invoke } from "../../../../src/shared/ExtensionMessage"
36

47
interface CreditLimitErrorProps {
58
currentBalance: number
@@ -30,10 +33,26 @@ const CreditLimitError: React.FC<CreditLimitErrorProps> = ({ currentBalance, tot
3033
href="https://app.cline.bot/credits"
3134
style={{
3235
width: "100%",
36+
marginBottom: "8px",
3337
}}>
3438
<span className="codicon codicon-credit-card" style={{ fontSize: "14px", marginRight: "6px" }} />
3539
Buy Credits
3640
</VSCodeButtonLink>
41+
42+
<VSCodeButton
43+
onClick={() => {
44+
vscode.postMessage({
45+
type: "invoke",
46+
text: "primaryButtonClick" satisfies Invoke,
47+
})
48+
}}
49+
appearance="secondary"
50+
style={{
51+
width: "100%",
52+
}}>
53+
<span className="codicon codicon-refresh" style={{ fontSize: "14px", marginRight: "6px" }} />
54+
Retry Request
55+
</VSCodeButton>
3756
</div>
3857
)
3958
}

0 commit comments

Comments
 (0)