Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/i18n/locales/en/kilocode.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"message_updated": "Message updated successfully"
},
"lowCreditWarning": {
"title": "Low Credit Warning!",
"message": "Check to see if you can top up with free credits or purchase some more!"
"title": "Insufficient Credit Warning!",
"message": "Your monthly credit limit has been reached. Purchase/Upgrade to the paid plan to continue using the service."
},
"task": {
"noAssistantMessages": "Encountered an error while generating a response. Trying auto-repair, if I'm unable to repair the error, please send a 'Continue' message.",
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "%extension.displayName%",
"description": "%extension.description%",
"publisher": "matterai",
"version": "4.120.0",
"version": "4.122.0",
"icon": "assets/icons/matterai-ic.png",
"galleryBanner": {
"color": "#FFFFFF",
Expand Down
30 changes: 30 additions & 0 deletions src/shared/kilocode/__tests__/errorUtils.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { isPaymentRequiredError } from "../errorUtils"

describe("isPaymentRequiredError", () => {
test("returns true for HTTP 402 payment required errors", () => {
expect(
isPaymentRequiredError({
status: 402,
message: "Payment required",
}),
).toBe(true)
})

test("returns true for insufficient credits throttling responses", () => {
expect(
isPaymentRequiredError({
status: 429,
error: "Insufficient credits",
}),
).toBe(true)
})

test("returns false for generic rate limit responses", () => {
expect(
isPaymentRequiredError({
status: 429,
error: "Rate limit exceeded",
}),
).toBe(false)
})
})
31 changes: 30 additions & 1 deletion src/shared/kilocode/errorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,37 @@ export function stringifyError(error: unknown) {
return error instanceof Error ? error.stack || error.message : String(error)
}

function getErrorMessage(error: any): string | undefined {
if (!error) {
return undefined
}

if (typeof error.error === "string") {
return error.error
}

if (typeof error.error?.message === "string") {
return error.error.message
}

if (typeof error.message === "string") {
return error.message
}

return undefined
}

function isInsufficientCreditsThrottle(error: any) {
if (!error || error.status !== 429) {
return false
}

const message = getErrorMessage(error)
return typeof message === "string" && message.toLowerCase().includes("insufficient credit")
}

export function isPaymentRequiredError(error: any) {
return !!(error && error.status === 402)
return !!(error && error.status === 402) || isInsufficientCreditsThrottle(error)
}

export function isAlphaPeriodEndedError(error: any) {
Expand Down
31 changes: 16 additions & 15 deletions webview-ui/src/components/kilocode/chat/LowCreditWarning.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { ClineMessage, getAppUrl, TelemetryEventName } from "@roo-code/types"
import { ClineMessage } from "@roo-code/types"
import { vscode } from "@src/utils/vscode"
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
import { RetryIconButton } from "../common/RetryIconButton"
import styled from "styled-components"
import { useTranslation } from "react-i18next"
import { VSCodeButtonLink } from "@/components/common/VSCodeButtonLink"
import { telemetryClient } from "@/utils/TelemetryClient"
import styled from "styled-components"

type LowCreditWarningProps = {
message: ClineMessage
Expand All @@ -26,7 +23,10 @@ const Description = styled.div`
overflow-wrap: anywhere;
`

export const LowCreditWarning = ({ message, isOrganization }: LowCreditWarningProps) => {
export const LowCreditWarning = ({
message,
// , isOrganization
}: LowCreditWarningProps) => {
const { t } = useTranslation()
let data = { title: "Error", message: "Payment required.", balance: "-?.??", buyCreditsUrl: "" }

Expand All @@ -39,23 +39,23 @@ export const LowCreditWarning = ({ message, isOrganization }: LowCreditWarningPr
return (
<>
<HeaderContainer>
<span className="text-blue-400" style={{ marginBottom: "-1.5px" }}>
<span className="text-red-400" style={{}}>
$
</span>
<span style={{ fontWeight: "bold" }}>{data.title}</span>
</HeaderContainer>
<Description>{data.message}</Description>

<div
className="bg-vscode-panel-border flex flex-col gap-3"
className="flex flex-col gap-3"
style={{
borderRadius: "4px",
display: "flex",
marginTop: "15px",
padding: "14px 16px 22px",
// padding: "14px 16px 22px",
justifyContent: "center",
}}>
<div className="flex justify-between items-center">
{/* <div className="flex justify-between items-center">
{t("kilocode:lowCreditWarning.lowBalance")}
<RetryIconButton
onClick={() => {
Expand All @@ -66,20 +66,21 @@ export const LowCreditWarning = ({ message, isOrganization }: LowCreditWarningPr
})
}}
/>
</div>
</div> */}
<VSCodeButton
className="p-1 w-full rounded"
appearance="secondary"
className="flex-[2] rounded-lg border border-green-400 outline-none bg-vscode-input-background max-w-fit"
onClick={(e) => {
e.preventDefault()

vscode.postMessage({
type: "openInBrowser",
url: data.buyCreditsUrl,
url: "https://app.matterai.so/usage",
})
}}>
{t("kilocode:lowCreditWarning.addCredit")}
</VSCodeButton>
{!isOrganization && (
{/* {!isOrganization && (
<VSCodeButtonLink
onClick={() => {
telemetryClient.capture(TelemetryEventName.CREATE_ORGANIZATION_LINK_CLICKED, {
Expand All @@ -91,7 +92,7 @@ export const LowCreditWarning = ({ message, isOrganization }: LowCreditWarningPr
className="p-1 w-full rounded">
{t("kilocode:lowCreditWarning.newOrganization")}
</VSCodeButtonLink>
)}
)} */}
</div>
</>
)
Expand Down
4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/en/kilocode.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"loginText": "Log in here"
},
"lowCreditWarning": {
"addCredit": "Add Credit",
"lowBalance": "Your Axon Code balance is low",
"addCredit": "Upgrade Plan",
"lowBalance": "Your Axon Code balance is empty",
"newOrganization": "Using Axon for work?"
},
"memoryWarning": {
Expand Down
Loading