@@ -8,12 +8,13 @@ import type { RouterModels } from "@roo/api"
88
99import { vscode } from "@src/utils/vscode"
1010import { useAppTranslation } from "@src/i18n/TranslationContext"
11- import { VSCodeButtonLink } from "@src/components/common/VSCodeButtonLink"
1211import { Button } from "@src/components/ui"
1312
1413import { inputEventTransform } from "../transforms"
1514import { ModelPicker } from "../ModelPicker"
1615import { RequestyBalanceDisplay } from "./RequestyBalanceDisplay"
16+ import { getCallbackUrl } from "@/oauth/urls"
17+ import { toRequestyServiceUrl } from "@roo/utils/requesty"
1718
1819type RequestyProps = {
1920 apiConfiguration : ProviderSettings
@@ -22,6 +23,7 @@ type RequestyProps = {
2223 refetchRouterModels : ( ) => void
2324 organizationAllowList : OrganizationAllowList
2425 modelValidationError ?: string
26+ uriScheme ?: string
2527}
2628
2729export const Requesty = ( {
@@ -31,6 +33,7 @@ export const Requesty = ({
3133 refetchRouterModels,
3234 organizationAllowList,
3335 modelValidationError,
36+ uriScheme,
3437} : RequestyProps ) => {
3538 const { t } = useAppTranslation ( )
3639
@@ -54,6 +57,15 @@ export const Requesty = ({
5457 [ setApiConfigurationField ] ,
5558 )
5659
60+ const getApiKeyUrl = ( ) => {
61+ const callbackUrl = getCallbackUrl ( "requesty" , uriScheme )
62+ const baseUrl = toRequestyServiceUrl ( apiConfiguration . requestyBaseUrl , "app" )
63+
64+ const authUrl = new URL ( `oauth/authorize?callback_url=${ callbackUrl } ` , baseUrl )
65+
66+ return authUrl . toString ( )
67+ }
68+
5769 return (
5870 < >
5971 < VSCodeTextField
@@ -65,20 +77,30 @@ export const Requesty = ({
6577 < div className = "flex justify-between items-center mb-1" >
6678 < label className = "block font-medium" > { t ( "settings:providers.requestyApiKey" ) } </ label >
6779 { apiConfiguration ?. requestyApiKey && (
68- < RequestyBalanceDisplay apiKey = { apiConfiguration . requestyApiKey } />
80+ < RequestyBalanceDisplay
81+ baseUrl = { apiConfiguration . requestyBaseUrl }
82+ apiKey = { apiConfiguration . requestyApiKey }
83+ />
6984 ) }
7085 </ div >
7186 </ VSCodeTextField >
7287 < div className = "text-sm text-vscode-descriptionForeground -mt-2" >
7388 { t ( "settings:providers.apiKeyStorageNotice" ) }
7489 </ div >
7590 { ! apiConfiguration ?. requestyApiKey && (
76- < VSCodeButtonLink
77- href = "https://app.requesty.ai/api-keys"
78- style = { { width : "100%" } }
79- appearance = "primary" >
91+ < a
92+ href = { getApiKeyUrl ( ) }
93+ target = "_blank"
94+ rel = "noopener noreferrer"
95+ className = "inline-flex items-center justify-center whitespace-nowrap text-sm font-medium focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground shadow hover:bg-primary/90 h-9 rounded-md px-3 w-full"
96+ style = { {
97+ width : "100%" ,
98+ textDecoration : "none" ,
99+ color : "var(--vscode-button-foreground)" ,
100+ backgroundColor : "var(--vscode-button-background)" ,
101+ } } >
80102 { t ( "settings:providers.getRequestyApiKey" ) }
81- </ VSCodeButtonLink >
103+ </ a >
82104 ) }
83105
84106 < VSCodeCheckbox
0 commit comments