From 67448e163fd854fa2a09fb5f5d133a6da41b01e8 Mon Sep 17 00:00:00 2001 From: Xinbeok Date: Wed, 2 Dec 2026 14:52:33 +0000 Subject: [PATCH 1/3] feat(workbench): hint a /v1 base for bare-root OpenAI-compatible endpoints Custom OpenAI-family endpoints (Chat Completions, Responses, New API and Sub2API) had no Base URL example, so a bare host root looked as valid as a versioned base and model discovery failed against relays that serve `/v1/models` (#3320). These providers now advertise `https://api.example.com/v1` as a JSON Schema example derived from their runtime adapter, not their name. The connection form shows it as the placeholder and, when a bare host root is entered, notes that most services expect a base ending in `/v1`. The configured value stays authoritative and is never rewritten. Closes #3320 Generated-by: Claude Code --- plugins/agent/providers/src/api.rs | 21 ++++++- .../providers/tests/integration/api/mod.rs | 27 +++++++++ .../maka/workbench/app/ConnectionForm.tsx | 18 +++--- .../maka/workbench/app/connectionEndpoint.ts | 54 +++++++++++++++++ products/maka/workbench/locales/de.json | 1 + products/maka/workbench/locales/en.json | 1 + products/maka/workbench/locales/es.json | 1 + products/maka/workbench/locales/fr.json | 1 + products/maka/workbench/locales/it.json | 1 + products/maka/workbench/locales/ja.json | 1 + products/maka/workbench/locales/ko.json | 1 + products/maka/workbench/locales/pt-BR.json | 1 + products/maka/workbench/locales/ru.json | 1 + products/maka/workbench/locales/zh-CN.json | 1 + products/maka/workbench/locales/zh-TW.json | 1 + .../tests/connection-endpoint.test.mjs | 60 +++++++++++++++++++ 16 files changed, 182 insertions(+), 9 deletions(-) create mode 100644 products/maka/workbench/app/connectionEndpoint.ts create mode 100644 products/maka/workbench/tests/connection-endpoint.test.mjs diff --git a/plugins/agent/providers/src/api.rs b/plugins/agent/providers/src/api.rs index 9805b4c500..e45c940755 100644 --- a/plugins/agent/providers/src/api.rs +++ b/plugins/agent/providers/src/api.rs @@ -185,8 +185,7 @@ impl ApiProvider { _ => self.facts.label.clone(), }, custom_endpoint: self.facts.base_url.is_empty(), - configuration_schema: serde_json::to_value(schemars::schema_for!(Configuration)) - .map_err(|error| error.to_string())?, + configuration_schema: self.configuration_schema()?, configuration_defaults: if self.facts.base_url.is_empty() { json!({}) } else { @@ -204,6 +203,24 @@ impl ApiProvider { .map_err(|error| error.to_string()) } + /// A custom OpenAI-family endpoint advertises a versioned example base; + /// the configured value stays authoritative and is never rewritten. + fn configuration_schema(&self) -> Result { + let mut schema = serde_json::to_value(schemars::schema_for!(Configuration)) + .map_err(|error| error.to_string())?; + if self.facts.base_url.is_empty() + && matches!( + self.facts.runtime_adapter, + facts::adapter::RuntimeAdapter::OpenaiChat {} + | facts::adapter::RuntimeAdapter::OpenaiResponses { .. } + | facts::adapter::RuntimeAdapter::OpenaiCompatible { .. } + ) + { + schema["properties"]["baseUrl"]["examples"] = json!(["https://api.example.com/v1"]); + } + Ok(schema) + } + fn model_metadata(&self, model: ModelInfo, overrides: Option<&ModelOverride>) -> ModelMetadata { let info = self.snapshot.resolve(self.id, model, overrides); let thinking_levels = overrides diff --git a/plugins/agent/providers/tests/integration/api/mod.rs b/plugins/agent/providers/tests/integration/api/mod.rs index d6d0f13833..b786545cba 100644 --- a/plugins/agent/providers/tests/integration/api/mod.rs +++ b/plugins/agent/providers/tests/integration/api/mod.rs @@ -867,3 +867,30 @@ async fn responses_discovery_and_probe_share_the_configured_base() { ); } } + +#[test] +fn custom_openai_endpoints_advertise_a_versioned_example_base() { + for (provider, example) in [ + ("openai-compatible", Some("https://api.example.com/v1")), + ( + "openai-responses-compatible", + Some("https://api.example.com/v1"), + ), + ("new-api", Some("https://api.example.com/v1")), + ("sub2api", Some("https://api.example.com/v1")), + ("anthropic-compatible", None), + ("openai", None), + ("ollama", None), + ] { + let binding = binding(provider); + let schema = &binding.descriptor().configuration_schema; + assert_eq!( + schema["properties"]["baseUrl"]["examples"][0].as_str(), + example, + "{provider}" + ); + binding + .configure(json!({"baseUrl": "http://relay.test"})) + .unwrap(); + } +} diff --git a/products/maka/workbench/app/ConnectionForm.tsx b/products/maka/workbench/app/ConnectionForm.tsx index 01b25491b4..c7b966e7f2 100644 --- a/products/maka/workbench/app/ConnectionForm.tsx +++ b/products/maka/workbench/app/ConnectionForm.tsx @@ -38,6 +38,7 @@ import type { CredentialStatus } from '../../../../packages/plugin-sdk/src/gener import type { ExternalAgentSettingsOwner } from './externalAgentSettingsState'; import type { ConnectionEditor, ModelSettingsOwner } from './settings'; import { ConnectionLogin } from './ConnectionLogin'; +import { bareRootExample, baseUrlPlaceholder } from './connectionEndpoint'; import { ExternalAgentSection } from './ExternalAgentSettings'; import { InlineCallout } from './Feedback'; import { useHost } from './host'; @@ -84,11 +85,13 @@ const modelViewportHeight = () => const blocked = (o: ModelSettingsOwner) => o.busy() || o.loading() || !!o.openingProvider() || !o.pendingKnown() || o.pending().length > 0; -const baseUrlPlaceholder = (provider: ConnectionEditor['provider']) => { - const defaults = provider.descriptor.configurationDefaults as Record | null; - return typeof defaults?.baseUrl === 'string' && defaults.baseUrl.trim() - ? defaults.baseUrl - : 'https://…'; +const baseUrlNote = (form: ConnectionEditor) => { + const example = bareRootExample(form.provider.descriptor, form.baseUrl); + return example + ? tr('Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.', { + example, + }) + : undefined; }; const submitConnection = (owner: ModelSettingsOwner) => () => { @@ -425,7 +428,8 @@ function ConnectionStandardForm(props: { label={tr('Base URL')} value={form().baseUrl} autoFocus={props.autoFocus() && !keyed()} - placeholder={baseUrlPlaceholder(form().provider)} + placeholder={baseUrlPlaceholder(form().provider.descriptor)} + note={baseUrlNote(form())} change={(text) => owner.edit('baseUrl', text)} onSubmit={submit} disabled={disabled()} @@ -769,7 +773,7 @@ export function ConnectionAdvanced(props: { settings: ModelSettingsOwner }) { owner.edit('baseUrl', text)} onSubmit={submit} disabled={disabled()} diff --git a/products/maka/workbench/app/connectionEndpoint.ts b/products/maka/workbench/app/connectionEndpoint.ts new file mode 100644 index 0000000000..4282975ad7 --- /dev/null +++ b/products/maka/workbench/app/connectionEndpoint.ts @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +type EndpointDescriptor = { configurationSchema: unknown; configurationDefaults: unknown }; + +/** The versioned example base a custom endpoint advertises, if any. */ +export function endpointExample(descriptor: EndpointDescriptor): string | undefined { + const schema = descriptor.configurationSchema as { + properties?: { baseUrl?: { examples?: unknown[] } }; + } | null; + const example = schema?.properties?.baseUrl?.examples?.[0]; + return typeof example === 'string' && example.trim() ? example : undefined; +} + +export function baseUrlPlaceholder(descriptor: EndpointDescriptor): string { + const defaults = descriptor.configurationDefaults as Record | null; + if (typeof defaults?.baseUrl === 'string' && defaults.baseUrl.trim()) return defaults.baseUrl; + return endpointExample(descriptor) ?? 'https://…'; +} + +const apiPath = (value: string) => { + try { + const url = new URL(value.trim()); + return /^https?:$/.test(url.protocol) ? url.pathname.replace(/\/+$/, '') : undefined; + } catch { + return undefined; + } +}; + +/** + * The example to show when a bare host root is entered where the provider's + * example carries an API path. The entered value is never rewritten: some + * services do serve their API at the root. + */ +export function bareRootExample(descriptor: EndpointDescriptor, value: string): string | undefined { + const example = endpointExample(descriptor); + return example && apiPath(example) && apiPath(value) === '' ? example : undefined; +} diff --git a/products/maka/workbench/locales/de.json b/products/maka/workbench/locales/de.json index bd2dae9c33..dc839144cd 100644 --- a/products/maka/workbench/locales/de.json +++ b/products/maka/workbench/locales/de.json @@ -1403,6 +1403,7 @@ "More scheduled tasks are available": "Weitere Automatisierungen verfügbar", "More source available": "Weiterer Quelltext verfügbar", "Mosaic": "Mosaik", + "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "Die meisten OpenAI-kompatiblen Dienste erwarten eine Basis-URL, die auf /v1 endet, z. B. {example}.", "Move left": "Nach links verschieben", "Move right": "Nach rechts verschieben", "Multiple plugins render the same tool presentation: {presentation}": "Mehrere Plugins rendern dieselbe Werkzeugdarstellung: {presentation}", diff --git a/products/maka/workbench/locales/en.json b/products/maka/workbench/locales/en.json index 03d0b73811..51d508d5e4 100644 --- a/products/maka/workbench/locales/en.json +++ b/products/maka/workbench/locales/en.json @@ -1403,6 +1403,7 @@ "More scheduled tasks are available": "More automations are available", "More source available": "More source available", "Mosaic": "Mosaic", + "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.", "Move left": "Move left", "Move right": "Move right", "Multiple plugins render the same tool presentation: {presentation}": "Multiple plugins render the same tool presentation: {presentation}", diff --git a/products/maka/workbench/locales/es.json b/products/maka/workbench/locales/es.json index b94fe7a8c9..4a40a68bcf 100644 --- a/products/maka/workbench/locales/es.json +++ b/products/maka/workbench/locales/es.json @@ -1403,6 +1403,7 @@ "More scheduled tasks are available": "Hay más automatizaciones disponibles", "More source available": "Hay más código fuente disponible", "Mosaic": "Mosaico", + "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "La mayoría de los servicios compatibles con OpenAI esperan una URL base que termine en /v1, por ejemplo {example}.", "Move left": "Mover a la izquierda", "Move right": "Mover a la derecha", "Multiple plugins render the same tool presentation: {presentation}": "Varios plugins muestran la misma presentación de herramienta: {presentation}", diff --git a/products/maka/workbench/locales/fr.json b/products/maka/workbench/locales/fr.json index 02af035da9..d18b30fd97 100644 --- a/products/maka/workbench/locales/fr.json +++ b/products/maka/workbench/locales/fr.json @@ -1403,6 +1403,7 @@ "More scheduled tasks are available": "Plus d’automatisations disponibles", "More source available": "Plus de code source disponible", "Mosaic": "Mosaïque", + "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "La plupart des services compatibles OpenAI attendent une URL de base se terminant par /v1, par exemple {example}.", "Move left": "Déplacer à gauche", "Move right": "Déplacer à droite", "Multiple plugins render the same tool presentation: {presentation}": "Plusieurs plugins affichent la même présentation d’outil : {presentation}", diff --git a/products/maka/workbench/locales/it.json b/products/maka/workbench/locales/it.json index 1a18f1430d..e7cc8bff92 100644 --- a/products/maka/workbench/locales/it.json +++ b/products/maka/workbench/locales/it.json @@ -1403,6 +1403,7 @@ "More scheduled tasks are available": "Sono disponibili altre automazioni", "More source available": "Altro sorgente disponibile", "Mosaic": "Mosaico", + "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "La maggior parte dei servizi compatibili con OpenAI richiede un URL di base che termina con /v1, ad esempio {example}.", "Move left": "Sposta a sinistra", "Move right": "Sposta a destra", "Multiple plugins render the same tool presentation: {presentation}": "Più plugin renderizzano la stessa presentazione dello strumento: {presentation}", diff --git a/products/maka/workbench/locales/ja.json b/products/maka/workbench/locales/ja.json index e7ca26907b..3739cfa9de 100644 --- a/products/maka/workbench/locales/ja.json +++ b/products/maka/workbench/locales/ja.json @@ -1403,6 +1403,7 @@ "More scheduled tasks are available": "さらに自動化があります", "More source available": "さらにソースがあります", "Mosaic": "モザイク", + "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "多くの OpenAI 互換サービスでは、ベース URL は /v1 で終わります(例:{example})。", "Move left": "左へ移動", "Move right": "右へ移動", "Multiple plugins render the same tool presentation: {presentation}": "複数のプラグインが同じツール表示を提供しています:{presentation}", diff --git a/products/maka/workbench/locales/ko.json b/products/maka/workbench/locales/ko.json index 084f5315ca..77c6a3ed8d 100644 --- a/products/maka/workbench/locales/ko.json +++ b/products/maka/workbench/locales/ko.json @@ -1403,6 +1403,7 @@ "More scheduled tasks are available": "추가 자동화가 있습니다", "More source available": "추가 소스 있음", "Mosaic": "모자이크", + "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "대부분의 OpenAI 호환 서비스는 기본 URL이 /v1로 끝납니다(예: {example}).", "Move left": "왼쪽으로 이동", "Move right": "오른쪽으로 이동", "Multiple plugins render the same tool presentation: {presentation}": "여러 플러그인이 동일한 도구 화면을 렌더링합니다: {presentation}", diff --git a/products/maka/workbench/locales/pt-BR.json b/products/maka/workbench/locales/pt-BR.json index 5fc2877e33..b6dda798fa 100644 --- a/products/maka/workbench/locales/pt-BR.json +++ b/products/maka/workbench/locales/pt-BR.json @@ -1403,6 +1403,7 @@ "More scheduled tasks are available": "Há mais automações disponíveis", "More source available": "Há mais código-fonte disponível", "Mosaic": "Mosaico", + "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "A maioria dos serviços compatíveis com a OpenAI espera uma URL base terminada em /v1, por exemplo {example}.", "Move left": "Mover para a esquerda", "Move right": "Mover para a direita", "Multiple plugins render the same tool presentation: {presentation}": "Vários plugins renderizam a mesma apresentação de ferramenta: {presentation}", diff --git a/products/maka/workbench/locales/ru.json b/products/maka/workbench/locales/ru.json index 01d0c34b57..9b1ac8833e 100644 --- a/products/maka/workbench/locales/ru.json +++ b/products/maka/workbench/locales/ru.json @@ -1403,6 +1403,7 @@ "More scheduled tasks are available": "Доступны дополнительные автоматизации", "More source available": "Доступна оставшаяся часть исходника", "Mosaic": "Мозаика", + "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "Большинство OpenAI-совместимых сервисов ожидают базовый URL, оканчивающийся на /v1, например {example}.", "Move left": "Сдвинуть влево", "Move right": "Сдвинуть вправо", "Multiple plugins render the same tool presentation: {presentation}": "Несколько плагинов отображают одно и то же представление инструмента: {presentation}", diff --git a/products/maka/workbench/locales/zh-CN.json b/products/maka/workbench/locales/zh-CN.json index 877e7cee72..2ac371b248 100644 --- a/products/maka/workbench/locales/zh-CN.json +++ b/products/maka/workbench/locales/zh-CN.json @@ -1403,6 +1403,7 @@ "More scheduled tasks are available": "还有更多自动化", "More source available": "还有后续源码", "Mosaic": "马赛克", + "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "大多数 OpenAI 兼容服务的基础 URL 以 /v1 结尾,例如 {example}。", "Move left": "左移", "Move right": "右移", "Multiple plugins render the same tool presentation: {presentation}": "多个插件提供了相同的工具展示:{presentation}", diff --git a/products/maka/workbench/locales/zh-TW.json b/products/maka/workbench/locales/zh-TW.json index 35c59f542a..35a28dda05 100644 --- a/products/maka/workbench/locales/zh-TW.json +++ b/products/maka/workbench/locales/zh-TW.json @@ -1403,6 +1403,7 @@ "More scheduled tasks are available": "還有更多自動化", "More source available": "還有後續原始碼", "Mosaic": "馬賽克", + "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "大多數 OpenAI 相容服務的基礎 URL 以 /v1 結尾,例如 {example}。", "Move left": "左移", "Move right": "右移", "Multiple plugins render the same tool presentation: {presentation}": "多個外掛提供了相同的工具呈現:{presentation}", diff --git a/products/maka/workbench/tests/connection-endpoint.test.mjs b/products/maka/workbench/tests/connection-endpoint.test.mjs new file mode 100644 index 0000000000..648f6e4040 --- /dev/null +++ b/products/maka/workbench/tests/connection-endpoint.test.mjs @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import assert from 'node:assert/strict'; +import test from 'node:test'; + +const { bareRootExample, baseUrlPlaceholder } = await import( + new URL('../app/connectionEndpoint.ts', import.meta.url) +); + +const example = 'https://api.example.com/v1'; +const custom = { + configurationSchema: { properties: { baseUrl: { type: 'string', examples: [example] } } }, + configurationDefaults: {}, +}; +const plain = { + configurationSchema: { properties: { baseUrl: { type: 'string' } } }, + configurationDefaults: {}, +}; +const preset = { ...plain, configurationDefaults: { baseUrl: 'http://127.0.0.1:11434/v1' } }; + +test('the Base URL placeholder prefers defaults, then the advertised example', () => { + assert.equal(baseUrlPlaceholder(preset), 'http://127.0.0.1:11434/v1'); + assert.equal(baseUrlPlaceholder(custom), example); + assert.equal(baseUrlPlaceholder(plain), 'https://…'); +}); + +test('only a bare host root gets the versioned example hint', () => { + for (const value of [ + 'http://relay.example:3000', + 'https://relay.example/', + ' https://relay.example ', + ]) + assert.equal(bareRootExample(custom, value), example, value); + for (const value of [ + '', + 'relay.example', + 'https://relay.example/v1', + 'https://relay.example/api', + 'ftp://relay.example', + ]) + assert.equal(bareRootExample(custom, value), undefined, value); + assert.equal(bareRootExample(plain, 'https://relay.example'), undefined); +}); From 3a2fa5c36296de223109925a64211cf50f70241d Mon Sep 17 00:00:00 2001 From: Xinbeok Date: Thu, 3 Dec 2026 12:09:16 +0800 Subject: [PATCH 2/3] fix(workbench): limit the /v1 hint to OpenAI-protocol endpoints Cloudflare Workers AI needs a base ending in `/ai/v1`, so only providers with protocol model discovery advertise the generic example. The form note now appears only when the advertised example is a `/v1` base. Generated-by: Claude Code --- plugins/agent/providers/src/api.rs | 4 ++++ plugins/agent/providers/tests/integration/api/mod.rs | 1 + products/maka/workbench/app/connectionEndpoint.ts | 4 ++-- products/maka/workbench/tests/connection-endpoint.test.mjs | 6 ++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/agent/providers/src/api.rs b/plugins/agent/providers/src/api.rs index e45c940755..47d1f9efe8 100644 --- a/plugins/agent/providers/src/api.rs +++ b/plugins/agent/providers/src/api.rs @@ -209,6 +209,10 @@ impl ApiProvider { let mut schema = serde_json::to_value(schemars::schema_for!(Configuration)) .map_err(|error| error.to_string())?; if self.facts.base_url.is_empty() + && matches!( + self.facts.model_discovery, + facts::discovery::ModelDiscovery::Protocol { .. } + ) && matches!( self.facts.runtime_adapter, facts::adapter::RuntimeAdapter::OpenaiChat {} diff --git a/plugins/agent/providers/tests/integration/api/mod.rs b/plugins/agent/providers/tests/integration/api/mod.rs index b786545cba..db4f7c49dc 100644 --- a/plugins/agent/providers/tests/integration/api/mod.rs +++ b/plugins/agent/providers/tests/integration/api/mod.rs @@ -878,6 +878,7 @@ fn custom_openai_endpoints_advertise_a_versioned_example_base() { ), ("new-api", Some("https://api.example.com/v1")), ("sub2api", Some("https://api.example.com/v1")), + ("cloudflare-workers-ai", None), ("anthropic-compatible", None), ("openai", None), ("ollama", None), diff --git a/products/maka/workbench/app/connectionEndpoint.ts b/products/maka/workbench/app/connectionEndpoint.ts index 4282975ad7..f377add93c 100644 --- a/products/maka/workbench/app/connectionEndpoint.ts +++ b/products/maka/workbench/app/connectionEndpoint.ts @@ -45,10 +45,10 @@ const apiPath = (value: string) => { /** * The example to show when a bare host root is entered where the provider's - * example carries an API path. The entered value is never rewritten: some + * example is a `/v1` base. The entered value is never rewritten: some * services do serve their API at the root. */ export function bareRootExample(descriptor: EndpointDescriptor, value: string): string | undefined { const example = endpointExample(descriptor); - return example && apiPath(example) && apiPath(value) === '' ? example : undefined; + return example && apiPath(example) === '/v1' && apiPath(value) === '' ? example : undefined; } diff --git a/products/maka/workbench/tests/connection-endpoint.test.mjs b/products/maka/workbench/tests/connection-endpoint.test.mjs index 648f6e4040..3488b142f5 100644 --- a/products/maka/workbench/tests/connection-endpoint.test.mjs +++ b/products/maka/workbench/tests/connection-endpoint.test.mjs @@ -57,4 +57,10 @@ test('only a bare host root gets the versioned example hint', () => { ]) assert.equal(bareRootExample(custom, value), undefined, value); assert.equal(bareRootExample(plain, 'https://relay.example'), undefined); + for (const other of ['https://api.example.com/ai/v1', 'https://api.example.com/v2']) { + const schema = { properties: { baseUrl: { type: 'string', examples: [other] } } }; + const descriptor = { ...custom, configurationSchema: schema }; + assert.equal(baseUrlPlaceholder(descriptor), other); + assert.equal(bareRootExample(descriptor, 'https://relay.example'), undefined, other); + } }); From 852b75af211f640ff27514ac9c16c9c40d38afcb Mon Sep 17 00:00:00 2001 From: Xinbeok Date: Thu, 3 Dec 2026 12:15:39 +0800 Subject: [PATCH 3/3] refactor(workbench): keep only the /v1 Base URL placeholder The live bare-root note appeared and disappeared while a URL was being typed, shifting the form layout, as raised in review. Drop the note, its helper and its locale entries; the versioned placeholder remains. Generated-by: Claude Code --- .../maka/workbench/app/ConnectionForm.tsx | 12 +-------- .../maka/workbench/app/connectionEndpoint.ts | 21 +-------------- products/maka/workbench/locales/de.json | 1 - products/maka/workbench/locales/en.json | 1 - products/maka/workbench/locales/es.json | 1 - products/maka/workbench/locales/fr.json | 1 - products/maka/workbench/locales/it.json | 1 - products/maka/workbench/locales/ja.json | 1 - products/maka/workbench/locales/ko.json | 1 - products/maka/workbench/locales/pt-BR.json | 1 - products/maka/workbench/locales/ru.json | 1 - products/maka/workbench/locales/zh-CN.json | 1 - products/maka/workbench/locales/zh-TW.json | 1 - .../tests/connection-endpoint.test.mjs | 26 +------------------ 14 files changed, 3 insertions(+), 67 deletions(-) diff --git a/products/maka/workbench/app/ConnectionForm.tsx b/products/maka/workbench/app/ConnectionForm.tsx index c7b966e7f2..0451ded572 100644 --- a/products/maka/workbench/app/ConnectionForm.tsx +++ b/products/maka/workbench/app/ConnectionForm.tsx @@ -38,7 +38,7 @@ import type { CredentialStatus } from '../../../../packages/plugin-sdk/src/gener import type { ExternalAgentSettingsOwner } from './externalAgentSettingsState'; import type { ConnectionEditor, ModelSettingsOwner } from './settings'; import { ConnectionLogin } from './ConnectionLogin'; -import { bareRootExample, baseUrlPlaceholder } from './connectionEndpoint'; +import { baseUrlPlaceholder } from './connectionEndpoint'; import { ExternalAgentSection } from './ExternalAgentSettings'; import { InlineCallout } from './Feedback'; import { useHost } from './host'; @@ -85,15 +85,6 @@ const modelViewportHeight = () => const blocked = (o: ModelSettingsOwner) => o.busy() || o.loading() || !!o.openingProvider() || !o.pendingKnown() || o.pending().length > 0; -const baseUrlNote = (form: ConnectionEditor) => { - const example = bareRootExample(form.provider.descriptor, form.baseUrl); - return example - ? tr('Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.', { - example, - }) - : undefined; -}; - const submitConnection = (owner: ModelSettingsOwner) => () => { const form = owner.editor(); if (!form || blocked(owner) || (form.baseline && !owner.dirty())) return; @@ -429,7 +420,6 @@ function ConnectionStandardForm(props: { value={form().baseUrl} autoFocus={props.autoFocus() && !keyed()} placeholder={baseUrlPlaceholder(form().provider.descriptor)} - note={baseUrlNote(form())} change={(text) => owner.edit('baseUrl', text)} onSubmit={submit} disabled={disabled()} diff --git a/products/maka/workbench/app/connectionEndpoint.ts b/products/maka/workbench/app/connectionEndpoint.ts index f377add93c..3f7f89ce67 100644 --- a/products/maka/workbench/app/connectionEndpoint.ts +++ b/products/maka/workbench/app/connectionEndpoint.ts @@ -20,7 +20,7 @@ type EndpointDescriptor = { configurationSchema: unknown; configurationDefaults: unknown }; /** The versioned example base a custom endpoint advertises, if any. */ -export function endpointExample(descriptor: EndpointDescriptor): string | undefined { +function endpointExample(descriptor: EndpointDescriptor): string | undefined { const schema = descriptor.configurationSchema as { properties?: { baseUrl?: { examples?: unknown[] } }; } | null; @@ -33,22 +33,3 @@ export function baseUrlPlaceholder(descriptor: EndpointDescriptor): string { if (typeof defaults?.baseUrl === 'string' && defaults.baseUrl.trim()) return defaults.baseUrl; return endpointExample(descriptor) ?? 'https://…'; } - -const apiPath = (value: string) => { - try { - const url = new URL(value.trim()); - return /^https?:$/.test(url.protocol) ? url.pathname.replace(/\/+$/, '') : undefined; - } catch { - return undefined; - } -}; - -/** - * The example to show when a bare host root is entered where the provider's - * example is a `/v1` base. The entered value is never rewritten: some - * services do serve their API at the root. - */ -export function bareRootExample(descriptor: EndpointDescriptor, value: string): string | undefined { - const example = endpointExample(descriptor); - return example && apiPath(example) === '/v1' && apiPath(value) === '' ? example : undefined; -} diff --git a/products/maka/workbench/locales/de.json b/products/maka/workbench/locales/de.json index dc839144cd..bd2dae9c33 100644 --- a/products/maka/workbench/locales/de.json +++ b/products/maka/workbench/locales/de.json @@ -1403,7 +1403,6 @@ "More scheduled tasks are available": "Weitere Automatisierungen verfügbar", "More source available": "Weiterer Quelltext verfügbar", "Mosaic": "Mosaik", - "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "Die meisten OpenAI-kompatiblen Dienste erwarten eine Basis-URL, die auf /v1 endet, z. B. {example}.", "Move left": "Nach links verschieben", "Move right": "Nach rechts verschieben", "Multiple plugins render the same tool presentation: {presentation}": "Mehrere Plugins rendern dieselbe Werkzeugdarstellung: {presentation}", diff --git a/products/maka/workbench/locales/en.json b/products/maka/workbench/locales/en.json index 51d508d5e4..03d0b73811 100644 --- a/products/maka/workbench/locales/en.json +++ b/products/maka/workbench/locales/en.json @@ -1403,7 +1403,6 @@ "More scheduled tasks are available": "More automations are available", "More source available": "More source available", "Mosaic": "Mosaic", - "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.", "Move left": "Move left", "Move right": "Move right", "Multiple plugins render the same tool presentation: {presentation}": "Multiple plugins render the same tool presentation: {presentation}", diff --git a/products/maka/workbench/locales/es.json b/products/maka/workbench/locales/es.json index 4a40a68bcf..b94fe7a8c9 100644 --- a/products/maka/workbench/locales/es.json +++ b/products/maka/workbench/locales/es.json @@ -1403,7 +1403,6 @@ "More scheduled tasks are available": "Hay más automatizaciones disponibles", "More source available": "Hay más código fuente disponible", "Mosaic": "Mosaico", - "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "La mayoría de los servicios compatibles con OpenAI esperan una URL base que termine en /v1, por ejemplo {example}.", "Move left": "Mover a la izquierda", "Move right": "Mover a la derecha", "Multiple plugins render the same tool presentation: {presentation}": "Varios plugins muestran la misma presentación de herramienta: {presentation}", diff --git a/products/maka/workbench/locales/fr.json b/products/maka/workbench/locales/fr.json index d18b30fd97..02af035da9 100644 --- a/products/maka/workbench/locales/fr.json +++ b/products/maka/workbench/locales/fr.json @@ -1403,7 +1403,6 @@ "More scheduled tasks are available": "Plus d’automatisations disponibles", "More source available": "Plus de code source disponible", "Mosaic": "Mosaïque", - "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "La plupart des services compatibles OpenAI attendent une URL de base se terminant par /v1, par exemple {example}.", "Move left": "Déplacer à gauche", "Move right": "Déplacer à droite", "Multiple plugins render the same tool presentation: {presentation}": "Plusieurs plugins affichent la même présentation d’outil : {presentation}", diff --git a/products/maka/workbench/locales/it.json b/products/maka/workbench/locales/it.json index e7cc8bff92..1a18f1430d 100644 --- a/products/maka/workbench/locales/it.json +++ b/products/maka/workbench/locales/it.json @@ -1403,7 +1403,6 @@ "More scheduled tasks are available": "Sono disponibili altre automazioni", "More source available": "Altro sorgente disponibile", "Mosaic": "Mosaico", - "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "La maggior parte dei servizi compatibili con OpenAI richiede un URL di base che termina con /v1, ad esempio {example}.", "Move left": "Sposta a sinistra", "Move right": "Sposta a destra", "Multiple plugins render the same tool presentation: {presentation}": "Più plugin renderizzano la stessa presentazione dello strumento: {presentation}", diff --git a/products/maka/workbench/locales/ja.json b/products/maka/workbench/locales/ja.json index 3739cfa9de..e7ca26907b 100644 --- a/products/maka/workbench/locales/ja.json +++ b/products/maka/workbench/locales/ja.json @@ -1403,7 +1403,6 @@ "More scheduled tasks are available": "さらに自動化があります", "More source available": "さらにソースがあります", "Mosaic": "モザイク", - "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "多くの OpenAI 互換サービスでは、ベース URL は /v1 で終わります(例:{example})。", "Move left": "左へ移動", "Move right": "右へ移動", "Multiple plugins render the same tool presentation: {presentation}": "複数のプラグインが同じツール表示を提供しています:{presentation}", diff --git a/products/maka/workbench/locales/ko.json b/products/maka/workbench/locales/ko.json index 77c6a3ed8d..084f5315ca 100644 --- a/products/maka/workbench/locales/ko.json +++ b/products/maka/workbench/locales/ko.json @@ -1403,7 +1403,6 @@ "More scheduled tasks are available": "추가 자동화가 있습니다", "More source available": "추가 소스 있음", "Mosaic": "모자이크", - "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "대부분의 OpenAI 호환 서비스는 기본 URL이 /v1로 끝납니다(예: {example}).", "Move left": "왼쪽으로 이동", "Move right": "오른쪽으로 이동", "Multiple plugins render the same tool presentation: {presentation}": "여러 플러그인이 동일한 도구 화면을 렌더링합니다: {presentation}", diff --git a/products/maka/workbench/locales/pt-BR.json b/products/maka/workbench/locales/pt-BR.json index b6dda798fa..5fc2877e33 100644 --- a/products/maka/workbench/locales/pt-BR.json +++ b/products/maka/workbench/locales/pt-BR.json @@ -1403,7 +1403,6 @@ "More scheduled tasks are available": "Há mais automações disponíveis", "More source available": "Há mais código-fonte disponível", "Mosaic": "Mosaico", - "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "A maioria dos serviços compatíveis com a OpenAI espera uma URL base terminada em /v1, por exemplo {example}.", "Move left": "Mover para a esquerda", "Move right": "Mover para a direita", "Multiple plugins render the same tool presentation: {presentation}": "Vários plugins renderizam a mesma apresentação de ferramenta: {presentation}", diff --git a/products/maka/workbench/locales/ru.json b/products/maka/workbench/locales/ru.json index 9b1ac8833e..01d0c34b57 100644 --- a/products/maka/workbench/locales/ru.json +++ b/products/maka/workbench/locales/ru.json @@ -1403,7 +1403,6 @@ "More scheduled tasks are available": "Доступны дополнительные автоматизации", "More source available": "Доступна оставшаяся часть исходника", "Mosaic": "Мозаика", - "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "Большинство OpenAI-совместимых сервисов ожидают базовый URL, оканчивающийся на /v1, например {example}.", "Move left": "Сдвинуть влево", "Move right": "Сдвинуть вправо", "Multiple plugins render the same tool presentation: {presentation}": "Несколько плагинов отображают одно и то же представление инструмента: {presentation}", diff --git a/products/maka/workbench/locales/zh-CN.json b/products/maka/workbench/locales/zh-CN.json index 2ac371b248..877e7cee72 100644 --- a/products/maka/workbench/locales/zh-CN.json +++ b/products/maka/workbench/locales/zh-CN.json @@ -1403,7 +1403,6 @@ "More scheduled tasks are available": "还有更多自动化", "More source available": "还有后续源码", "Mosaic": "马赛克", - "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "大多数 OpenAI 兼容服务的基础 URL 以 /v1 结尾,例如 {example}。", "Move left": "左移", "Move right": "右移", "Multiple plugins render the same tool presentation: {presentation}": "多个插件提供了相同的工具展示:{presentation}", diff --git a/products/maka/workbench/locales/zh-TW.json b/products/maka/workbench/locales/zh-TW.json index 35a28dda05..35c59f542a 100644 --- a/products/maka/workbench/locales/zh-TW.json +++ b/products/maka/workbench/locales/zh-TW.json @@ -1403,7 +1403,6 @@ "More scheduled tasks are available": "還有更多自動化", "More source available": "還有後續原始碼", "Mosaic": "馬賽克", - "Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.": "大多數 OpenAI 相容服務的基礎 URL 以 /v1 結尾,例如 {example}。", "Move left": "左移", "Move right": "右移", "Multiple plugins render the same tool presentation: {presentation}": "多個外掛提供了相同的工具呈現:{presentation}", diff --git a/products/maka/workbench/tests/connection-endpoint.test.mjs b/products/maka/workbench/tests/connection-endpoint.test.mjs index 3488b142f5..355f387ec9 100644 --- a/products/maka/workbench/tests/connection-endpoint.test.mjs +++ b/products/maka/workbench/tests/connection-endpoint.test.mjs @@ -20,7 +20,7 @@ import assert from 'node:assert/strict'; import test from 'node:test'; -const { bareRootExample, baseUrlPlaceholder } = await import( +const { baseUrlPlaceholder } = await import( new URL('../app/connectionEndpoint.ts', import.meta.url) ); @@ -40,27 +40,3 @@ test('the Base URL placeholder prefers defaults, then the advertised example', ( assert.equal(baseUrlPlaceholder(custom), example); assert.equal(baseUrlPlaceholder(plain), 'https://…'); }); - -test('only a bare host root gets the versioned example hint', () => { - for (const value of [ - 'http://relay.example:3000', - 'https://relay.example/', - ' https://relay.example ', - ]) - assert.equal(bareRootExample(custom, value), example, value); - for (const value of [ - '', - 'relay.example', - 'https://relay.example/v1', - 'https://relay.example/api', - 'ftp://relay.example', - ]) - assert.equal(bareRootExample(custom, value), undefined, value); - assert.equal(bareRootExample(plain, 'https://relay.example'), undefined); - for (const other of ['https://api.example.com/ai/v1', 'https://api.example.com/v2']) { - const schema = { properties: { baseUrl: { type: 'string', examples: [other] } } }; - const descriptor = { ...custom, configurationSchema: schema }; - assert.equal(baseUrlPlaceholder(descriptor), other); - assert.equal(bareRootExample(descriptor, 'https://relay.example'), undefined, other); - } -});