Skip to content

Commit 8f03729

Browse files
author
James Mtendamema
committed
fix auth in settings for zoo gateway
1 parent 48521e6 commit 8f03729

22 files changed

Lines changed: 186 additions & 26 deletions

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const ApiOptions = ({
134134
setErrorMessage,
135135
}: ApiOptionsProps) => {
136136
const { t } = useAppTranslation()
137-
const { organizationAllowList, openAiCodexIsAuthenticated } = useExtensionState()
137+
const { organizationAllowList, openAiCodexIsAuthenticated, zooCodeIsAuthenticated } = useExtensionState()
138138

139139
const [customHeaders, setCustomHeaders] = useState<[string, string][]>(() => {
140140
const headers = apiConfiguration?.openAiHeaders || {}
@@ -273,9 +273,17 @@ const ApiOptions = ({
273273
apiConfiguration,
274274
routerModels,
275275
organizationAllowList,
276+
zooCodeIsAuthenticated,
276277
)
277278
setErrorMessage(apiValidationResult)
278-
}, [apiConfiguration, routerModels, organizationAllowList, setErrorMessage, isRetiredSelectedProvider])
279+
}, [
280+
apiConfiguration,
281+
routerModels,
282+
organizationAllowList,
283+
setErrorMessage,
284+
isRetiredSelectedProvider,
285+
zooCodeIsAuthenticated,
286+
])
279287

280288
const onProviderChange = useCallback(
281289
(value: ProviderName) => {

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

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
2-
31
import {
42
type ProviderSettings,
53
type OrganizationAllowList,
64
type RouterModels,
75
zooGatewayDefaultModelId,
86
} from "@roo-code/types"
97

8+
import { useExtensionState } from "@src/context/ExtensionStateContext"
9+
import { getZooCodeAuthUrl } from "@src/oauth/urls"
1010
import { useAppTranslation } from "@src/i18n/TranslationContext"
1111

1212
import { ModelPicker } from "../ModelPicker"
@@ -29,24 +29,42 @@ export const ZooGateway = ({
2929
simplifySettings,
3030
}: ZooGatewayProps) => {
3131
const { t } = useAppTranslation()
32+
const { zooCodeIsAuthenticated, zooCodeUserEmail, zooCodeUserName, zooCodeBaseUrl, uriScheme, deviceName } =
33+
useExtensionState()
34+
35+
const authUrl = getZooCodeAuthUrl(uriScheme, zooCodeBaseUrl, deviceName)
3236

3337
return (
3438
<>
35-
{/* Zoo Gateway auth is managed exclusively through the "Sign in with Zoo Code"
36-
OAuth flow — the token is set automatically and must not be editable by users.
37-
Showing the field as read-only lets users confirm they are signed in. */}
38-
<VSCodeTextField
39-
value={apiConfiguration?.zooSessionToken ? "••••••••••••••••" : ""}
40-
type="text"
41-
readOnly
42-
placeholder={t("settings:placeholders.sessionToken")}
43-
className="w-full">
44-
<label className="block font-medium mb-1">Zoo Session Token</label>
45-
</VSCodeTextField>
46-
<div className="text-sm text-vscode-descriptionForeground -mt-2">
47-
{apiConfiguration?.zooSessionToken
48-
? "Signed in via Zoo Code"
49-
: "Sign in via the Zoo Code button to authenticate"}
39+
{/* Zoo Code Authentication Section */}
40+
<div className="flex flex-col gap-1 rounded-md border border-vscode-panel-border p-2">
41+
<div className="flex items-center justify-between">
42+
<label className="block text-sm font-medium">{t("settings:providers.zooGateway.account")}</label>
43+
{zooCodeIsAuthenticated && zooCodeUserEmail && (
44+
<span className="text-xs text-vscode-descriptionForeground">{zooCodeUserEmail}</span>
45+
)}
46+
</div>
47+
{!zooCodeIsAuthenticated ? (
48+
<div className="flex flex-col gap-1">
49+
<p className="text-xs text-vscode-descriptionForeground">
50+
{t("settings:providers.zooGateway.signInDescription")}
51+
</p>
52+
<a
53+
href={authUrl}
54+
className="inline-flex w-fit items-center rounded-sm bg-vscode-button-background px-3 py-1 text-xs text-vscode-button-foreground no-underline hover:bg-vscode-button-hoverBackground">
55+
{t("settings:providers.zooGateway.signInButton")}
56+
</a>
57+
</div>
58+
) : (
59+
<div className="flex items-center gap-1">
60+
<span className="codicon codicon-check text-vscode-charts-green" />
61+
<span className="text-xs text-vscode-descriptionForeground">
62+
{zooCodeUserName
63+
? t("settings:providers.zooGateway.authenticatedAs", { name: zooCodeUserName })
64+
: t("settings:providers.zooGateway.authenticated")}
65+
</span>
66+
</div>
67+
)}
5068
</div>
5169
<ModelPicker
5270
apiConfiguration={apiConfiguration}

webview-ui/src/components/welcome/WelcomeViewProvider.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import { Trans } from "react-i18next"
1616
import { ArrowLeft, Brain } from "lucide-react"
1717

1818
const WelcomeViewProvider = () => {
19-
const { apiConfiguration, currentApiConfigName, setApiConfiguration, uriScheme } = useExtensionState()
19+
const { apiConfiguration, currentApiConfigName, setApiConfiguration, uriScheme, zooCodeIsAuthenticated } =
20+
useExtensionState()
2021
const { t } = useAppTranslation()
2122
const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined)
2223
const [showProviderSetup, setShowProviderSetup] = useState(false)
@@ -36,7 +37,9 @@ const WelcomeViewProvider = () => {
3637
return
3738
}
3839

39-
const error = apiConfiguration ? validateApiConfiguration(apiConfiguration) : undefined
40+
const error = apiConfiguration
41+
? validateApiConfiguration(apiConfiguration, undefined, undefined, zooCodeIsAuthenticated)
42+
: undefined
4043

4144
if (error) {
4245
setErrorMessage(error)
@@ -45,7 +48,7 @@ const WelcomeViewProvider = () => {
4548

4649
setErrorMessage(undefined)
4750
vscode.postMessage({ type: "upsertApiConfiguration", text: currentApiConfigName, apiConfiguration })
48-
}, [showProviderSetup, apiConfiguration, currentApiConfigName])
51+
}, [showProviderSetup, apiConfiguration, currentApiConfigName, zooCodeIsAuthenticated])
4952

5053
const handleBackToLanding = useCallback(() => {
5154
setShowProviderSetup(false)

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

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,13 @@
545545
"learnMore": "Learn more about provider routing"
546546
}
547547
},
548+
"zooGateway": {
549+
"account": "Zoo Code Account",
550+
"signInButton": "Sign in to Zoo Code",
551+
"signInDescription": "Sign in to use Zoo Gateway with your account",
552+
"authenticated": "Authenticated",
553+
"authenticatedAs": "Authenticated as {{name}}"
554+
},
548555
"customModel": {
549556
"capabilities": "Configure the capabilities and pricing for your custom OpenAI-compatible model. Be careful when specifying the model capabilities, as they can affect how Zoo Code performs.",
550557
"maxTokens": {

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

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)