Skip to content

Commit 7a25767

Browse files
James Mtendamemacursoragent
andcommitted
fix(zoo-gateway): settings UI sign-in button, validation tests, defer auth
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0fc8279 commit 7a25767

3 files changed

Lines changed: 62 additions & 60 deletions

File tree

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { useExtensionState } from "@src/context/ExtensionStateContext"
1010
import { getZooCodeAuthUrl } from "@src/oauth/urls"
1111
import { useAppTranslation } from "@src/i18n/TranslationContext"
12+
import { VSCodeButtonLink } from "@src/components/common/VSCodeButtonLink"
1213

1314
import { ModelPicker } from "../ModelPicker"
1415

@@ -92,11 +93,9 @@ export const ZooGateway = ({
9293
<p className="text-xs text-vscode-descriptionForeground">
9394
{t("settings:providers.zooGateway.signInDescription")}
9495
</p>
95-
<a
96-
href={authUrl}
97-
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">
96+
<VSCodeButtonLink href={authUrl} appearance="primary">
9897
{t("settings:providers.zooGateway.signInButton")}
99-
</a>
98+
</VSCodeButtonLink>
10099
</div>
101100
) : (
102101
<div className="flex items-center gap-1">

webview-ui/src/utils/__tests__/validate.spec.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,54 @@ describe("Model Validation Functions", () => {
211211
expect(result).toBe("settings:validation.modelId")
212212
})
213213
})
214+
215+
describe("Zoo Gateway validation", () => {
216+
it("returns a sign-in error when neither profile token nor Zoo auth is present", () => {
217+
const config: ProviderSettings = {
218+
apiProvider: "zoo-gateway",
219+
zooGatewayModelId: "anthropic/claude-sonnet-4",
220+
}
221+
222+
const result = validateApiConfigurationExcludingModelErrors(
223+
config,
224+
mockRouterModels,
225+
allowAllOrganization,
226+
false,
227+
)
228+
expect(result).toBe("settings:validation.zooGatewaySignIn")
229+
})
230+
231+
it("returns undefined when Zoo Code auth is active without a profile token", () => {
232+
const config: ProviderSettings = {
233+
apiProvider: "zoo-gateway",
234+
zooGatewayModelId: "anthropic/claude-sonnet-4",
235+
}
236+
237+
const result = validateApiConfigurationExcludingModelErrors(
238+
config,
239+
mockRouterModels,
240+
allowAllOrganization,
241+
true,
242+
)
243+
expect(result).toBeUndefined()
244+
})
245+
246+
it("returns undefined when a profile session token is set", () => {
247+
const config: ProviderSettings = {
248+
apiProvider: "zoo-gateway",
249+
zooGatewayModelId: "anthropic/claude-sonnet-4",
250+
zooSessionToken: "zoo_ext_test_token",
251+
}
252+
253+
const result = validateApiConfigurationExcludingModelErrors(
254+
config,
255+
mockRouterModels,
256+
allowAllOrganization,
257+
false,
258+
)
259+
expect(result).toBeUndefined()
260+
})
261+
})
214262
})
215263

216264
describe("validateBedrockArn", () => {

webview-ui/vite.config.ts

Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const persistPortPlugin = (): Plugin => ({
5151
},
5252
})
5353

54-
// https://vitejs.dev/config/
54+
// https://vite.dev/config/
5555
export default defineConfig(({ mode }) => {
5656
let outDir = "../src/webview-ui/build"
5757

@@ -98,79 +98,39 @@ export default defineConfig(({ mode }) => {
9898
return {
9999
plugins,
100100
resolve: {
101-
alias: {
102-
"@": resolve(__dirname, "./src"),
103-
"@src": resolve(__dirname, "./src"),
104-
"@roo": resolve(__dirname, "../src/shared"),
105-
},
101+
tsconfigPaths: true,
106102
},
107103
build: {
108104
outDir,
109105
emptyOutDir: true,
110106
reportCompressedSize: false,
111107
// Generate complete source maps with original TypeScript sources
112108
sourcemap: true,
113-
// Ensure source maps are properly included in the build
114-
minify: mode === "production" ? "esbuild" : false,
109+
// Vite 8 uses Rolldown/Oxc by default; keep non-production modes readable.
110+
minify: mode === "production",
115111
// Use a single combined CSS bundle so all webviews share styles
116112
cssCodeSplit: false,
117-
rollupOptions: {
113+
rolldownOptions: {
118114
// Externalize vscode module - it's imported by file-search.ts which is
119115
// dynamically imported by roo-config/index.ts, but should never be bundled
120116
// in the webview since it's not available in the browser context
121117
external: ["vscode"],
122-
input: {
123-
index: resolve(__dirname, "index.html"),
124-
},
118+
input: resolve(__dirname, "index.html"),
125119
output: {
126-
entryFileNames: `assets/[name].js`,
127-
chunkFileNames: (chunkInfo) => {
128-
if (chunkInfo.name === "mermaid-bundle") {
129-
return `assets/mermaid-bundle.js`
130-
}
131-
// Default naming for other chunks, ensuring uniqueness from entry
132-
return `assets/chunk-[hash].js`
133-
},
120+
entryFileNames: "assets/[name].js",
121+
chunkFileNames: "assets/[name]-[hash].js",
134122
assetFileNames: (assetInfo) => {
135-
const name = assetInfo.name || ""
123+
const name = assetInfo.name ?? ""
136124

137-
// Force all CSS into a single predictable file used by both webviews
138125
if (name.endsWith(".css")) {
139126
return "assets/index.css"
140127
}
141128

142-
if (name.endsWith(".woff2") || name.endsWith(".woff") || name.endsWith(".ttf")) {
129+
if (/\.(woff2?|ttf)$/.test(name)) {
143130
return "assets/fonts/[name][extname]"
144131
}
145-
// Ensure source maps are included in the build
146-
if (name.endsWith(".map")) {
147-
return "assets/[name]"
148-
}
149-
return "assets/[name][extname]"
150-
},
151-
manualChunks: (id, { getModuleInfo }) => {
152-
// Consolidate all mermaid code and its direct large dependencies (like dagre)
153-
// into a single chunk. The 'channel.js' error often points to dagre.
154-
if (
155-
id.includes("node_modules/mermaid") ||
156-
id.includes("node_modules/dagre") || // dagre is a common dep for graph layout
157-
id.includes("node_modules/cytoscape") // another potential graph lib
158-
// Add other known large mermaid dependencies if identified
159-
) {
160-
return "mermaid-bundle"
161-
}
162132

163-
// Check if the module is part of any explicitly defined mermaid-related dynamic import
164-
// This is a more advanced check if simple path matching isn't enough.
165-
const moduleInfo = getModuleInfo(id)
166-
if (moduleInfo?.importers.some((importer) => importer.includes("node_modules/mermaid"))) {
167-
return "mermaid-bundle"
168-
}
169-
if (
170-
moduleInfo?.dynamicImporters.some((importer) => importer.includes("node_modules/mermaid"))
171-
) {
172-
return "mermaid-bundle"
173-
}
133+
return "assets/[name][extname]"
174134
},
175135
},
176136
},
@@ -188,11 +148,6 @@ export default defineConfig(({ mode }) => {
188148
},
189149
define,
190150
optimizeDeps: {
191-
include: [
192-
"mermaid",
193-
"dagre", // Explicitly include dagre for pre-bundling
194-
// Add other known large mermaid dependencies if identified
195-
],
196151
exclude: ["@vscode/codicons", "vscode-oniguruma", "shiki"],
197152
},
198153
assetsInclude: ["**/*.wasm", "**/*.wav"],

0 commit comments

Comments
 (0)