Skip to content

Commit 9aceabf

Browse files
Thibault00requesty-JohnCosta27
authored andcommitted
fix: create new Requesty profile during OAuth (RooCodeInc#8699)
Co-authored-by: John Costa <[email protected]>
1 parent 456b539 commit 9aceabf

File tree

5 files changed

+30
-21
lines changed

5 files changed

+30
-21
lines changed

src/activate/handleUri.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ export const handleUri = async (uri: vscode.Uri) => {
3030
}
3131
case "/requesty": {
3232
const code = query.get("code")
33+
const baseUrl = query.get("baseUrl")
3334
if (code) {
34-
await visibleProvider.handleRequestyCallback(code)
35+
await visibleProvider.handleRequestyCallback(code, baseUrl)
3536
}
3637
break
3738
}

src/core/webview/ClineProvider.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ import type { ClineMessage } from "@roo-code/types"
9595
import { readApiMessages, saveApiMessages, saveTaskMessages } from "../task-persistence"
9696
import { getNonce } from "./getNonce"
9797
import { getUri } from "./getUri"
98+
import { REQUESTY_BASE_URL } from "../../shared/utils/requesty"
9899

99100
/**
100101
* https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
@@ -1470,8 +1471,8 @@ export class ClineProvider
14701471

14711472
// Requesty
14721473

1473-
async handleRequestyCallback(code: string) {
1474-
let { apiConfiguration, currentApiConfigName = "default" } = await this.getState()
1474+
async handleRequestyCallback(code: string, baseUrl: string | null) {
1475+
let { apiConfiguration } = await this.getState()
14751476

14761477
const newConfiguration: ProviderSettings = {
14771478
...apiConfiguration,
@@ -1480,7 +1481,16 @@ export class ClineProvider
14801481
requestyModelId: apiConfiguration?.requestyModelId || requestyDefaultModelId,
14811482
}
14821483

1483-
await this.upsertProviderProfile(currentApiConfigName, newConfiguration)
1484+
// set baseUrl as undefined if we don't provide one
1485+
// or if it is the default requesty url
1486+
if (!baseUrl || baseUrl === REQUESTY_BASE_URL) {
1487+
newConfiguration.requestyBaseUrl = undefined
1488+
} else {
1489+
newConfiguration.requestyBaseUrl = baseUrl
1490+
}
1491+
1492+
const profileName = `Requesty (${new Date().toLocaleString()})`
1493+
await this.upsertProviderProfile(profileName, newConfiguration)
14841494
}
14851495

14861496
// Task history

src/shared/utils/requesty.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const REQUESTY_BASE_URL = "https://router.requesty.ai/v1"
1+
export const REQUESTY_BASE_URL = "https://router.requesty.ai/v1"
22

33
type URLType = "router" | "app" | "api"
44

webview-ui/src/components/settings/providers/Requesty.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,19 @@ export const Requesty = ({
8484
<div className="text-sm text-vscode-descriptionForeground -mt-2">
8585
{t("settings:providers.apiKeyStorageNotice")}
8686
</div>
87-
{!apiConfiguration?.requestyApiKey && (
88-
<a
89-
href={getApiKeyUrl()}
90-
target="_blank"
91-
rel="noopener noreferrer"
92-
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"
93-
style={{
94-
width: "100%",
95-
textDecoration: "none",
96-
color: "var(--vscode-button-foreground)",
97-
backgroundColor: "var(--vscode-button-background)",
98-
}}>
99-
{t("settings:providers.getRequestyApiKey")}
100-
</a>
101-
)}
87+
<a
88+
href={getApiKeyUrl()}
89+
target="_blank"
90+
rel="noopener noreferrer"
91+
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"
92+
style={{
93+
width: "100%",
94+
textDecoration: "none",
95+
color: "var(--vscode-button-foreground)",
96+
backgroundColor: "var(--vscode-button-background)",
97+
}}>
98+
{t("settings:providers.getRequestyApiKey")}
99+
</a>
102100

103101
<VSCodeCheckbox
104102
checked={requestyEndpointSelected}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@
270270
"success": "Models list refreshed successfully!",
271271
"error": "Failed to refresh models list. Please try again."
272272
},
273-
"getRequestyApiKey": "Get Requesty API Key",
273+
"getRequestyApiKey": "Create new Requesty API Key",
274274
"getRequestyBaseUrl": "Base URL",
275275
"requestyUseCustomBaseUrl": "Use custom base URL",
276276
"openRouterTransformsText": "Compress prompts and message chains to the context size (<a>OpenRouter Transforms</a>)",

0 commit comments

Comments
 (0)