Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(settings): refresh gateway discovery paths

Darren Kattan4e87394b16d2
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index ca4761b7d..04630c7ae 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -1314,6 +1314,7 @@ export function Canvas() {
}, [
settings.modelGateway.baseUrl,
settings.modelGateway.apiKey,
+ settings.modelGateway.discoveryPath,
discoverModels,
clearModels
])
diff --git a/src/renderer/components/settings/sections/ModelGatewaySection.test.tsx b/src/renderer/components/settings/sections/ModelGatewaySection.test.tsx
index 6f48e0348..9ee28cc9f 100644
--- a/src/renderer/components/settings/sections/ModelGatewaySection.test.tsx
+++ b/src/renderer/components/settings/sections/ModelGatewaySection.test.tsx
@@ -77,6 +77,28 @@ describe('ModelGatewaySection credential modes', () => {
expect(useSettings.getState().settings.modelGateway.apiKey).toBe('${env:GATEWAY_KEY}')
})
+ it('persists the selected discovery path and previews its resolved endpoint', async () => {
+ await mount()
+ expect(host.textContent).toContain(
+ 'Discovery: https://gateway.example.test/v1/models'
+ )
+
+ const openAiPath = [...host.querySelectorAll<HTMLInputElement>('input[type="radio"]')].find(
+ (input) => input.parentElement?.textContent?.includes('/openai/v1/models')
+ )!
+ await act(async () => {
+ openAiPath.click()
+ })
+
+ expect(useSettings.getState().settings.modelGateway.discoveryPath).toBe(
+ '/openai/v1/models'
+ )
+ expect(openAiPath.checked).toBe(true)
+ expect(host.textContent).toContain(
+ 'Discovery: https://gateway.example.test/openai/v1/models'
+ )
+ })
+
it('keeps a literal key write-only and stores only the secret sentinel in settings', async () => {
await mount()
const source = host.querySelector<HTMLSelectElement>('#model-gateway-credential-source')!
diff --git a/src/renderer/components/settings/sections/ModelGatewaySection.tsx b/src/renderer/components/settings/sections/ModelGatewaySection.tsx
index 75ecee8f9..0bfcec086 100644
--- a/src/renderer/components/settings/sections/ModelGatewaySection.tsx
+++ b/src/renderer/components/settings/sections/ModelGatewaySection.tsx
@@ -78,7 +78,7 @@ export function ModelGatewaySection({ isActive }: { isActive: boolean }): React.
// hold whether the custom text input is open and what the user is mid-typing into it.
const [customMode, setCustomMode] = useState(false)
const [customPath, setCustomPath] = useState('')
- const routes = modelGatewayRoutes(gateway.baseUrl)
+ const routes = modelGatewayRoutes(gateway.baseUrl, gateway.discoveryPath)
const patchGateway = (patch: Partial<typeof gateway>): void => {
const current = useSettings.getState().settings.modelGateway
@@ -143,7 +143,10 @@ export function ModelGatewaySection({ isActive }: { isActive: boolean }): React.
const current = useSettings.getState().settings.modelGateway
// Replacing a key leaves the settings sentinel unchanged, so Canvas's value-based effect has
// no dependency change to observe. A first save does change it and gets the normal debounce.
- if (replacingStoredKey && modelGatewayRoutes(current.baseUrl)) {
+ if (
+ replacingStoredKey &&
+ modelGatewayRoutes(current.baseUrl, current.discoveryPath)
+ ) {
void discover({ ...current, apiKey: MODEL_GATEWAY_SECRET_REF })
}
setCredentialNotice('API key saved securely.')