Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

feat(settings): service chooser with recommended model selection

vastsa1041c0788c2d
diff --git a/apps/desktop/src/components/settings/ChosenModelsSummary.tsx b/apps/desktop/src/components/settings/ChosenModelsSummary.tsx
new file mode 100644
index 000000000..82718c545
--- /dev/null
+++ b/apps/desktop/src/components/settings/ChosenModelsSummary.tsx
@@ -0,0 +1,110 @@
+/**
+ * The chosen models of a service or account, as a short list (D623).
+ *
+ * Most people keep the models a service starts with, so the form shows what
+ * is chosen and leaves the two-pane picker one click away instead of opening
+ * on it. Rows reuse the picker's row classes so removing a model reads and
+ * behaves the same in both places.
+ */
+import { useTranslation } from "react-i18next";
+import { formatTokenCount, type ModelBinding } from "@pi-desktop/shared";
+import { TooltipButton } from "../ui";
+import { IconClose } from "../icons";
+import type { ProviderModelsState } from "./useProviderModels";
+
+export type ChosenModelsSummaryProps = {
+ models: ModelBinding[];
+ discoveryStatus: ProviderModelsState["status"];
+ busy?: boolean;
+ /** The list is exactly what the recommendation picked. */
+ autoPicked?: boolean;
+ onRemove: (id: string) => void;
+ onManage: () => void;
+ /** Open the picker on its hand-typed id field. */
+ onAddManually: () => void;
+};
+
+export function ChosenModelsSummary({
+ models,
+ discoveryStatus,
+ busy = false,
+ autoPicked = false,
+ onRemove,
+ onManage,
+ onAddManually,
+}: ChosenModelsSummaryProps) {
+ const { t } = useTranslation();
+
+ let empty: string;
+ if (discoveryStatus === "error") empty = t("settings.modelsSummaryFailed");
+ else if (discoveryStatus === "loading") empty = t("settings.modelsSummaryLoading");
+ else if (discoveryStatus === "ready") empty = t("settings.noModelsChosen");
+ else empty = t("settings.modelsEmptyHint");
+
+ return (
+ <div className="provider-models-summary">
+ <div className="provider-models-summary-head">
+ <h4 className="provider-chosen-title">{t("settings.modelsSummaryTitle")}</h4>
+ <span className="provider-chosen-count">{models.length}</span>
+ <button
+ type="button"
+ className="provider-models-summary-manage"
+ disabled={busy}
+ aria-expanded={false}
+ onClick={onManage}
+ >
+ {t("settings.manageModels")}
+ </button>
+ </div>
+
+ {models.length === 0 ? (
+ <div className="provider-chosen-empty">
+ <span>{empty}</span>
+ {discoveryStatus === "error" || discoveryStatus === "ready" ? (
+ <button
+ type="button"
+ className="provider-models-summary-action"
+ disabled={busy}
+ onClick={onAddManually}
+ >
+ {t("settings.addModelManually")}
+ </button>
+ ) : null}
+ </div>
+ ) : (
+ <ul className="provider-chosen-list">
+ {models.map((binding) => (
+ <li className="provider-chosen-row" key={binding.id}>
+ <div className="provider-chosen-row-head">
+ <span className="provider-chosen-row-id font-mono selectable">{binding.id}</span>
+ {binding.alias?.trim() ? (
+ <span className="provider-chosen-row-alias">{binding.alias.trim()}</span>
+ ) : null}
+ {binding.thinkingLevels.length > 0 ? (
+ <span className="provider-chosen-row-alias">{t("settings.modelReasoningTag")}</span>
+ ) : null}
+ <span className="provider-chosen-row-limits">
+ {formatTokenCount(binding.contextWindow)} · {formatTokenCount(binding.maxTokens)}
+ </span>
+ <TooltipButton
+ type="button"
+ className="provider-chosen-remove"
+ ariaLabel={t("settings.removeModel")}
+ tooltip={t("settings.removeModel")}
+ disabled={busy}
+ onClick={() => onRemove(binding.id)}
+ >
+ <IconClose size={12} />
+ </TooltipButton>
+ </div>
+ </li>
+ ))}
+ </ul>
+ )}
+
+ {autoPicked && models.length > 0 ? (
+ <div className="provider-models-summary-hint">{t("settings.modelsAutoPicked")}</div>
+ ) : null}
+ </div>
+ );
+}
diff --git a/apps/desktop/src/components/settings/ModelConfigPage.tsx b/apps/desktop/src/components/settings/ModelConfigPage.tsx
index fd0dd1925..467f26c77 100644
--- a/apps/desktop/src/components/settings/ModelConfigPage.tsx
+++ b/apps/desktop/src/components/settings/ModelConfigPage.tsx
@@ -29,7 +29,6 @@ import {
IconCheck,
IconChevronDown,
IconConfig,
- IconKey,
IconPlus,
IconServer,
IconSearch,
@@ -50,7 +49,6 @@ import { ServiceList } from "./ServiceList";
import { serviceRowKind } from "./service-row-status";
import { useVendorAccounts } from "./useVendorAccounts";
import { VendorAccountDialog, type VendorAccountForm } from "./VendorAccountDialog";
-import { VendorPickerDialog } from "./VendorPickerDialog";
type CatalogStatus = {
loaded: boolean;
@@ -91,7 +89,6 @@ export function ModelConfigPage() {
removeAccount,
saveAccount,
} = useVendorAccounts();
- const [pickingVendor, setPickingVendor] = useState(false);
const [editingAccountId, setEditingAccountId] = useState<string | null>(null);
useEffect(() => {
@@ -515,18 +512,6 @@ export function ModelConfigPage() {
) : null}
</div>
<div className="provider-section-head-actions">
- {vendors?.length ? (
- <Button
- variant="secondary"
- disabled={login !== null}
- onClick={() => setPickingVendor(true)}
- >
- <span className="model-config-btn-inner">
- <IconKey size={14} />
- <span>{t("settings.vendorAddAccount")}</span>
- </span>
- </Button>
- ) : null}
<Button
variant="primary"
className="model-provider-add"
@@ -568,8 +553,7 @@ export function ModelConfigPage() {
editingAccountId !== null ||
busyAccountId !== null ||
savingAccount ||
- login !== null ||
- pickingVendor
+ login !== null
}
isRowBusy={(id) => busyId === id || testingId === id || busyAccountId === id}
testingId={testingId}
@@ -648,19 +632,14 @@ export function ModelConfigPage() {
.map((binding) => binding.modelId)
: undefined}
onSaved={afterSaved}
- />
- ) : null}
-
- {pickingVendor && vendors ? (
- <VendorPickerDialog
vendors={vendors}
- onPick={(vendor) => {
- setPickingVendor(false);
+ onPickSubscription={(vendor) => {
+ setSetupFor(null);
+ setCopyDraft(null);
// Started here, not in the dialog: a click happens once, where
// StrictMode would run a mount effect twice and open two browsers.
startLogin(vendor);
}}
- onClose={() => setPickingVendor(false)}
/>
) : null}
diff --git a/apps/desktop/src/components/settings/ModelSelectionPanes.tsx b/apps/desktop/src/components/settings/ModelSelectionPanes.tsx
index 3cfb24627..df2d8b5d5 100644
--- a/apps/desktop/src/components/settings/ModelSelectionPanes.tsx
+++ b/apps/desktop/src/components/settings/ModelSelectionPanes.tsx
@@ -8,7 +8,7 @@
* guarantee lives here once instead of in a convention two files had to
* remember.
*/
-import { useEffect, useMemo, useState } from "react";
+import { useEffect, useMemo, useState, type Ref } from "react";
import { useTranslation } from "react-i18next";
import {
THINKING_LEVELS,
@@ -209,6 +209,10 @@ export type ModelSelectionPanesProps = {
* limits; absent fields only widen the catalog search.
*/
lookupContext?: CustomModelLookupContext;
+ /** Attached to the hand-typed id field, so a caller can focus it. */
+ customModelInputRef?: Ref<HTMLInputElement>;
+ /** Folds the picker back into the chosen-models summary (D623). */
+ onCollapse?: () => void;
};
/**
@@ -226,6 +230,8 @@ export function ModelSelectionPanes({
imageModelIds,
lookupContext,
onImageModelChange,
+ customModelInputRef,
+ onCollapse,
}: ModelSelectionPanesProps) {
const { t } = useTranslation();
const { rows, models, publishedLevelsById, setModels } = selection;
@@ -233,9 +239,9 @@ export function ModelSelectionPanes({
const [chosenQuery, setChosenQuery] = useState("");
const [customModelId, setCustomModelId] = useState("");
const [customModelError, setCustomModelError] = useState("");
- const [expandedModelId, setExpandedModelId] = useState<string | null>(
- () => models[0]?.id ?? null,
- );
+ // Nothing opens on its own: the advanced settings of one model are not
+ // what the picker is opened for.
+ const [expandedModelId, setExpandedModelId] = useState<string | null>(null);
// The returned list is short and already local, so filtering is client-side:
// no host search and no debounced IPC round trip.
@@ -556,6 +562,16 @@ export function ModelSelectionPanes({
onChange={(event) => setChosenQuery(event.target.value)}
/>
</div>
+ {onCollapse ? (
+ <button
+ type="button"
+ className="provider-models-summary-manage"
+ aria-expanded
+ onClick={onCollapse}
+ >
+ {t("settings.collapseModels")}
+ </button>
+ ) : null}
</div>
{models.length === 0 ? (
<div className="provider-chosen-empty">{t("settings.noModelsChosen")}</div>
@@ -971,6 +987,7 @@ export function ModelSelectionPanes({
>
<div className="provider-custom-model-row">
<Input
+ ref={customModelInputRef}
value={customModelId}
placeholder={t("settings.customModelPlaceholder")}
className="font-mono text-sm"
diff --git a/apps/desktop/src/components/settings/ModelsFetchErrorMessage.tsx b/apps/desktop/src/components/settings/ModelsFetchErrorMessage.tsx
index 5cf2598f5..6cc3c2a5b 100644
--- a/apps/desktop/src/components/settings/ModelsFetchErrorMessage.tsx
+++ b/apps/desktop/src/components/settings/ModelsFetchErrorMessage.tsx
@@ -13,7 +13,8 @@ export function ModelsFetchErrorMessage({
variant,
}: {
error?: string;
- variant: "banner" | "placeholder";
+ /** `status` is the one-line connection status under a service's key. */
+ variant: "banner" | "placeholder" | "status";
}) {
const { t } = useTranslation();
const view = describeModelsFetchError(error);
@@ -46,7 +47,9 @@ export function ModelsFetchErrorMessage({
const className =
variant === "placeholder"
? "provider-models-placeholder is-error"
- : "provider-models-note is-error";
+ : variant === "status"
+ ? "provider-connection-status is-error"
+ : "provider-models-note is-error";
return (
<div className={className} role="alert">
<span className="provider-models-error-summary">{summary}</span>
diff --git a/apps/desktop/src/components/settings/ProviderConnectionFields.tsx b/apps/desktop/src/components/settings/ProviderConnectionFields.tsx
new file mode 100644
index 000000000..68f7a193b
--- /dev/null
+++ b/apps/desktop/src/components/settings/ProviderConnectionFields.tsx
@@ -0,0 +1,254 @@
+/**
+ * The connection half of the AI service form: which service, its key, and for
+ * a custom endpoint the name, URL and API format (D310, D623).
+ *
+ * The chosen service reads as a settled fact with a Change action rather than
+ * an open menu, and a status line under the key says whether the service
+ * answered, so pasting a key is visibly the whole job on a named service.
+ */
+import type { ReactNode, RefObject } from "react";
+import { useTranslation } from "react-i18next";
+import type { CatalogApiStyle } from "@pi-desktop/shared";
+import { Field, Input } from "../ui";
+import { IconCheck } from "../icons";
+import { SettingsMenuSelect } from "./SettingsMenuSelect";
+import { ServiceMonogram } from "./ServiceMonogram";
+import { ModelsFetchErrorMessage } from "./ModelsFetchErrorMessage";
+import { canRecommendFrom } from "./recommended-models";
+import { hostOf } from "./service-catalog";
+import type { ProviderModelsState } from "./useProviderModels";
+import { API_STYLE_LABEL_KEYS, CUSTOM_PROVIDER_API_STYLES } from "./provider-api-style";
+
+/**
+ * One line that answers "did it work?" for the credentials above it. Silent
+ * while nothing can be asked yet, then connecting, connected with a count, or
+ * the classified failure the model picker would show.
+ */
+export function ConnectionStatus({
+ active,
+ discovery,
+ named,
+}: {
+ /** Whether the form holds enough to contact the service. */
+ active: boolean;
+ discovery: ProviderModelsState;
+ named: boolean;
+}) {
+ const { t } = useTranslation();
+ let content: ReactNode;
+ let tone: "hint" | "ok" | "error" = "hint";
+ if (!active) {
+ content = t(named ? "settings.connectionKeyHint" : "settings.connectionUrlHint");
+ } else if (
+ discovery.status === "idle" ||
+ discovery.status === "loading" ||
+ discovery.source === "cache"
+ ) {
+ content = t("settings.connectionChecking");
+ } else if (discovery.status === "ready" && !discovery.error) {
+ tone = "ok";
+ content = t(
+ discovery.source === "remote" ? "settings.connectionReady" : "settings.connectionCatalog",
+ { count: discovery.models.length },
+ );
+ } else if (canRecommendFrom(discovery, named)) {
+ // A named vendor without a model-list route: the key was not refused.
+ tone = "ok";
+ content = t("settings.connectionNoModelList", { count: discovery.models.length });
+ } else {
+ return <ModelsFetchErrorMessage error={discovery.error} variant="status" />;
+ }
+ return (
+ <div className={`provider-connection-status is-${tone}`} aria-live="polite">
+ {tone === "ok" ? <IconCheck size={12} aria-hidden /> : null}
+ <span>{content}</span>
+ </div>
+ );
+}
+
+export type ProviderConnectionFieldsProps = {
+ named: boolean;
+ custom: boolean;
+ editing: boolean;
+ saving: boolean;
+ serviceLabel: string;
+ /** Endpoint the named preset talks to; empty on a custom endpoint. */
+ serviceBaseUrl: string;
+ onChangeService: () => void;
+ apiKeyRef: RefObject<HTMLInputElement | null>;
+ nameRef: RefObject<HTMLInputElement | null>;
+ apiKey: string;
+ onApiKeyChange: (value: string) => void;
+ name: string;
+ onNameChange: (value: string) => void;
+ baseUrl: string;
+ onBaseUrlChange: (value: string) => void;
+ commitBaseUrl: () => void;
+ baseUrlError?: string;
+ apiStyle: CatalogApiStyle;
+ onApiStyleChange: (value: CatalogApiStyle) => void;
+ accountOnlyApiStyle: boolean;
+ requiresApiStyleChoice: boolean;
+ status: ReactNode;
+};
+
+export function ProviderConnectionFields({
+ named,
+ custom,
+ editing,
+ saving,
+ serviceLabel,
+ serviceBaseUrl,
+ onChangeService,
+ apiKeyRef,
+ nameRef,
+ apiKey,
+ onApiKeyChange,
+ name,
+ onNameChange,
+ baseUrl,
+ onBaseUrlChange,
+ commitBaseUrl,
+ baseUrlError,
+ apiStyle,
+ onApiStyleChange,
+ accountOnlyApiStyle,
+ requiresApiStyleChoice,
+ status,
+}: ProviderConnectionFieldsProps) {
+ const { t } = useTranslation();
+ const keyHint = editing ? t("settings.apiKeyKeepHint") : undefined;
+
+ return (
+ <div className={named ? "provider-setup-fields is-named" : "provider-setup-fields is-custom"}>
+ <div
+ className={`provider-setup-field-row provider-setup-service-row ${
+ named ? "is-named" : "is-single"
+ }`}
+ >
+ {/* Not a Field: its <label> would forward clicks to the Change button. */}
+ <div className="block space-y-1.5">
+ <div className="text-sm text-text-secondary">{t("settings.service")}</div>
+ <div className="provider-service-chip">
+ <ServiceMonogram name={serviceLabel} />
+ <span className="provider-service-chip-copy">
+ <span className="provider-service-chip-name">{serviceLabel}</span>
+ {serviceBaseUrl ? (
+ <span className="provider-service-chip-host" title={serviceBaseUrl}>
+ {hostOf(serviceBaseUrl)}
+ </span>
+ ) : null}
+ </span>
+ <button
+ type="button"
+ className="provider-service-chip-change"
+ disabled={saving}
+ onClick={onChangeService}
+ >
+ {t("settings.changeService")}
+ </button>
+ </div>
+ </div>
+
+ {named ? (
+ <div className="provider-setup-key">
+ <Field label={t("settings.apiKey")} hint={keyHint}>
+ <Input
+ ref={apiKeyRef}
+ type="password"
+ value={apiKey}
+ placeholder="sk-…"
+ className="font-mono text-sm-plus"
+ autoComplete="off"
+ autoFocus
+ onChange={(event) => onApiKeyChange(event.target.value)}
+ />
+ </Field>
+ {status}
+ </div>
+ ) : null}
+ </div>
+
+ {custom ? (
+ <>
+ <div className="provider-setup-field-row provider-setup-custom-identity-row">
+ <Field label={t("settings.name")}>
+ <Input
+ ref={nameRef}
+ value={name}
+ autoFocus
+ onChange={(event) => onNameChange(event.target.value)}
+ />
+ </Field>
+ <div className="provider-setup-base-url">
+ <Field label={t("settings.baseUrl")}>
+ <Input
+ value={baseUrl}
+ type="url"
+ inputMode="url"
+ autoComplete="url"
+ className="font-mono text-sm-plus"
+ placeholder="https://api.example.com/v1"
+ aria-invalid={Boolean(baseUrlError)}
+ aria-describedby={baseUrlError ? "provider-base-url-error" : undefined}
+ onChange={(event) => onBaseUrlChange(event.target.value)}
+ onBlur={commitBaseUrl}
+ />
+ {baseUrlError ? (
+ <div
+ id="provider-base-url-error"
+ className="provider-setup-field-error"
+ role="alert"
+ >
+ {baseUrlError}
+ </div>
+ ) : null}
+ </Field>
+ </div>
+ </div>
+ <div className="provider-setup-field-row provider-setup-custom-auth-row">
+ <Field label={t("settings.apiKey")} hint={keyHint}>
+ <Input
+ ref={apiKeyRef}
+ type="password"
+ value={apiKey}
+ placeholder="sk-…"
+ className="font-mono text-sm-plus"
+ autoComplete="off"
+ onChange={(event) => onApiKeyChange(event.target.value)}
+ />
+ </Field>
+ <Field
+ label={t("settings.apiStyle")}
+ hint={accountOnlyApiStyle ? t(requiresApiStyleChoice
+ ? "settings.apiStyleChooseCustom"
+ : "settings.apiStyleLegacyAccount") : undefined}
+ >
+ <SettingsMenuSelect
+ fullWidth
+ label={t("settings.apiStyle")}
+ value={apiStyle}
+ disabled={saving}
+ onChange={(id) => onApiStyleChange(id as CatalogApiStyle)}
+ options={[
+ ...(accountOnlyApiStyle
+ ? [{
+ id: apiStyle,
+ label: t(API_STYLE_LABEL_KEYS[apiStyle]),
+ disabled: true,
+ }]
+ : []),
+ ...CUSTOM_PROVIDER_API_STYLES.map((style) => ({
+ id: style,
+ label: t(API_STYLE_LABEL_KEYS[style]),
+ })),
+ ]}
+ />
+ </Field>
+ </div>
+ {status}
+ </>
+ ) : null}
+ </div>
+ );
+}
diff --git a/apps/desktop/src/components/settings/ProviderSetupDialog.tsx b/apps/desktop/src/components/settings/ProviderSetupDialog.tsx
index 4be61202d..a39823491 100644
--- a/apps/desktop/src/components/settings/ProviderSetupDialog.tsx
+++ b/apps/desktop/src/components/settings/ProviderSetupDialog.tsx
@@ -1,8 +1,11 @@
/**
- * One form to add or edit an AI service.
+ * One dialog to add or edit an AI service, in two views (D623).
*
- * Named services: pick a vendor and paste a key. Custom: name, URL, key and
- * API format on the common path. Models come from the service endpoint.
+ * A new service opens on the service chooser; picking a tile moves to the
+ * form. Named services: paste a key and the recommended models are chosen as
+ * soon as the service answers. Custom: name, URL, key and API format on the
+ * common path. Models come from the service endpoint; the full picker stays
+ * one click away behind the chosen-models summary.
*/
import { useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
@@ -13,18 +16,22 @@ import {
normalizeApiStyle,
type CatalogApiStyle,
type ModelBinding,
+ type OAuthVendor,
type ProviderPublic,
} from "@pi-desktop/shared";
import { api } from "../../lib/api";
import { pairsToRecord, recordToPairs } from "../extensions/KeyValueRows";
import { Button, Field, HelpIcon, Input, portalOverlay } from "../ui";
import { ProviderHeadersEditor } from "./ProviderHeadersEditor";
-import { SettingsMenuSelect } from "./SettingsMenuSelect";
import { useProviderModels } from "./useProviderModels";
import { ModelSelectionPanes, useModelSelection } from "./ModelSelectionPanes";
-import { CUSTOM_SERVICE, ServicePicker } from "./ServicePicker";
+import { ChosenModelsSummary } from "./ChosenModelsSummary";
+import { ConnectionStatus, ProviderConnectionFields } from "./ProviderConnectionFields";
+import { ServiceChooser } from "./ServiceChooser";
+import { CUSTOM_SERVICE } from "./service-catalog";
+import { useRecommendedModelSelection } from "./useRecommendedModelSelection";
import type { ProviderCopyDraft } from "./provider-copy";
-import { API_STYLE_LABEL_KEYS, CUSTOM_PROVIDER_API_STYLES, isAccountOnlyApiStyle, needsCustomApiStyleChoice, providerSetupPreset } from "./provider-api-style";
+import { isAccountOnlyApiStyle, needsCustomApiStyleChoice, providerSetupPreset } from "./provider-api-style";
type BaseUrlIssue = "invalid";
@@ -98,21 +105,16 @@ function initialBaseUrl(provider?: ProviderPublic | null): string {
return providerSetupPreset(provider)?.baseUrl ?? provider?.baseUrl ?? "";
}
-function endpointHost(url: string): string {
- try {
- const parsed = new URL(url);
- return `${parsed.host}${parsed.pathname.replace(/\/+$/, "")}`;
- } catch {
- return url;
- }
-}
-
export type ProviderSetupDialogProps = {
provider?: ProviderPublic | null;
initialDraft?: ProviderCopyDraft | null;
onClose: () => void;
imageModelIds?: string[];
onSaved: (provider: ProviderPublic, models: ModelBinding[], imageModelIds?: string[]) => void | Promise<void>;
+ /** Vendors a new row can sign in to instead of pasting a key. */
+ vendors?: OAuthVendor[] | null;
+ /** Leaves this dialog for the vendor's browser sign-in. */
+ onPickSubscription?: (vendor: OAuthVendor) => void;
};
export function ProviderSetupDialog({
@@ -121,6 +123,8 @@ export function ProviderSetupDialog({
onClose,
onSaved,
imageModelIds,
+ vendors,
+ onPickSubscription,
}: ProviderSetupDialogProps) {
const { t } = useTranslation();
const [imageModelDraft, setImageModelDraft] = useState<string[] | undefined>();
@@ -145,6 +149,10 @@ export function ProviderSetupDialog({
const [error, setError] = useState("");
const [testResult, setTestResult] = useState("");
const [baseUrlTouched, setBaseUrlTouched] = useState(false);
+ const [choosing, setChoosing] = useState(false);
+ const [managing, setManaging] = useState(false);
+ const customModelRef = useRef<HTMLInputElement>(null);
+ const chooserOpen = choosing || !service;
const namedPreset = NAMED_ENDPOINT_PRESETS.find((preset) => preset.id === service);
const named = Boolean(namedPreset);
@@ -176,7 +184,22 @@ export function ProviderSetupDialog({
},
provider,
);
- const selection = useModelSelection(discovery, models, setModels);
+ const recommended = useRecommendedModelSelection({
+ // A copy keeps the models it was copied with.
+ enabled: !provider && !initialDraft?.models?.length,
+ serviceKey: `${service}|${requestBaseUrl}|${resolvedApiStyle}`,
+ discovery,
+ setModels,
+ namedService: named,
+ });
+ // Every edit made through the picker or the summary ends preselection.
+ const selection = useModelSelection(discovery, models, recommended.setModels);
+
+ // A list with nothing to recommend leaves the choice to the user, so the
+ // picker opens instead of an empty summary.
+ useEffect(() => {
+ if (recommended.noRecommendation) setManaging(true);
+ }, [recommended.noRecommendation]);
useEffect(() => {
const onKeyDown = (event: KeyboardEvent) => {
@@ -185,11 +208,16 @@ export function ProviderSetupDialog({
setAdvancedOpen(false);
return;
}
+ // Changing an existing row's service backs out to its form.
+ if (choosing && service) {
+ setChoosing(false);
+ return;
+ }
onClose();
};
window.addEventListener("keydown", onKeyDown);
return () => window.removeEventListener("keydown", onKeyDown);
- }, [advancedOpen, onClose, saving]);
+ }, [advancedOpen, choosing, onClose, saving, service]);
const nameRef = useRef<HTMLInputElement>(null);
const focusAfterServiceChange = (next: string) => {
@@ -218,6 +246,22 @@ export function ProviderSetupDialog({
focusAfterServiceChange(next);
};
+ const pickService = (next: string) => {
+ setChoosing(false);
+ if (next === service) {
+ focusAfterServiceChange(next);
+ return;
+ }
+ // A key belongs to the service it was pasted for.
+ if (!provider) setApiKey("");
+ onServiceChange(next);
+ };
+
+ const addModelManually = () => {
+ setManaging(true);
+ window.setTimeout(() => customModelRef.current?.focus(), 0);
+ };
+
const commitBaseUrl = () => {
setBaseUrlTouched(true);
const normalized = normalizeBaseUrlInput(baseUrl, resolvedApiStyle);
@@ -332,211 +376,89 @@ export function ProviderSetupDialog({
!baseUrlIssue &&
models.length > 0;
- return portalOverlay(
- <div
- className="overlay provider-setup-overlay"
- role="presentation"
- onClick={() => {
- if (saving) return;
- onClose();
- }}
- >
- <div
- className="dialog provider-setup-dialog"
- role="dialog"
- aria-modal="true"
- aria-labelledby="provider-setup-title"
- onClick={(event) => event.stopPropagation()}
- >
- <div className="provider-setup-head">
- <h3 id="provider-setup-title" className="provider-setup-title">
- {initialDraft ? t("settings.copyProviderTitle") : editing ? t("settings.editProviderTitle") : t("settings.addProviderTitle")}
- {/* What a copy does and does not take is the title's own promise. */}
- {initialDraft ? <HelpIcon label={t("settings.copyProviderHint")} /> : null}
- </h3>
- <div className="provider-setup-head-actions">
- {named || custom ? (
- <Button
- variant="ghost"
- size="sm"
- disabled={saving}
- onClick={() => setAdvancedOpen(true)}
- >
- {t("settings.advancedSettings")}
- </Button>
- ) : null}
- {provider ? (
- <Button
- variant="ghost"
- size="sm"
- disabled={testing || saving}
- onClick={() => void testConnection()}
- >
- {testing ? t("settings.testing") : t("settings.testConnection")}
- </Button>
- ) : null}
- <Button variant="ghost" size="sm" disabled={saving} onClick={onClose}>
- {t("settings.cancel")}
+ const formView = (
+ <>
+ <div className="provider-setup-head">
+ <h3 id="provider-setup-title" className="provider-setup-title">
+ {initialDraft ? t("settings.copyProviderTitle") : editing ? t("settings.editProviderTitle") : t("settings.addProviderTitle")}
+ {/* What a copy does and does not take is the title's own promise. */}
+ {initialDraft ? <HelpIcon label={t("settings.copyProviderHint")} /> : null}
+ </h3>
+ <div className="provider-setup-head-actions">
+ {named || custom ? (
+ <Button
+ variant="ghost"
+ size="sm"
+ disabled={saving}
+ onClick={() => setAdvancedOpen(true)}
+ >
+ {t("settings.advancedSettings")}
</Button>
+ ) : null}
+ {provider ? (
<Button
- variant="primary"
+ variant="ghost"
size="sm"
- disabled={!canSave}
- onClick={() => void save()}
+ disabled={testing || saving}
+ onClick={() => void testConnection()}
>
- {saving ? t("settings.saving") : t("settings.saveProvider")}
+ {testing ? t("settings.testing") : t("settings.testConnection")}
</Button>
- </div>
+ ) : null}
+ <Button variant="ghost" size="sm" disabled={saving} onClick={onClose}>
+ {t("settings.cancel")}
+ </Button>
+ <Button
+ variant="primary"
+ size="sm"
+ disabled={!canSave}
+ onClick={() => void save()}
+ >
+ {saving ? t("settings.saving") : t("settings.saveProvider")}
+ </Button>
</div>
+ </div>
- <div className="provider-setup-body">
- {error ? <div className="provider-setup-error">{error}</div> : null}
-
- <div className="provider-setup-credentials">
- <div
- className={
- named
- ? "provider-setup-fields is-named"
- : custom
- ? "provider-setup-fields is-custom"
- : "provider-setup-fields is-empty"
- }
- >
- <div
- className={`provider-setup-field-row provider-setup-service-row ${
- named ? "is-named" : "is-single"
- }`}
- >
- <div className="provider-setup-service">
- <Field label={t("settings.service")}>
- <ServicePicker
- value={service}
- autoFocus={!named && !custom}
- disabled={saving}
- onChange={onServiceChange}
- />
- </Field>
- </div>
-
- {named ? (
- <Field
- label={t("settings.apiKey")}
- hint={editing ? t("settings.apiKeyKeepHint") : undefined}
- >
- <Input
- ref={apiKeyRef}
- type="password"
- value={apiKey}
- placeholder="sk-…"
- className="font-mono text-sm-plus"
- autoComplete="off"
- autoFocus
- onChange={(event) => setApiKey(event.target.value)}
- />
- </Field>
- ) : null}
- </div>
+ <div className="provider-setup-body">
+ {error ? <div className="provider-setup-error">{error}</div> : null}
- {named && resolvedBaseUrl ? (
- <div className="provider-setup-host" title={resolvedBaseUrl}>
- {endpointHost(resolvedBaseUrl)}
- </div>
- ) : null}
+ <div className="provider-setup-credentials">
+ <ProviderConnectionFields
+ named={named}
+ custom={custom}
+ editing={editing}
+ saving={saving}
+ serviceLabel={namedPreset ? t(namedPreset.labelKey) : t("settings.presetCustomEndpoint")}
+ serviceBaseUrl={namedPreset?.baseUrl ?? ""}
+ onChangeService={() => setChoosing(true)}
+ apiKeyRef={apiKeyRef}
+ nameRef={nameRef}
+ apiKey={apiKey}
+ onApiKeyChange={setApiKey}
+ name={name}
+ onNameChange={setName}
+ baseUrl={baseUrl}
+ onBaseUrlChange={(value) => {
+ setBaseUrl(value);
+ setError("");
+ }}
+ commitBaseUrl={commitBaseUrl}
+ baseUrlError={baseUrlError}
+ apiStyle={apiStyle}
+ onApiStyleChange={setApiStyle}
+ accountOnlyApiStyle={accountOnlyApiStyle}
+ requiresApiStyleChoice={requiresApiStyleChoice}
+ status={<ConnectionStatus active={discoveryActive} discovery={discovery} named={named} />}
+ />
- {custom ? (
- <>
- <div className="provider-setup-field-row provider-setup-custom-identity-row">
- <Field label={t("settings.name")}>
- <Input
- ref={nameRef}
- value={name}
- autoFocus
- onChange={(event) => setName(event.target.value)}
- />
- </Field>
- <div className="provider-setup-base-url">
- <Field label={t("settings.baseUrl")}>
- <Input
- value={baseUrl}
- type="url"
- inputMode="url"
- autoComplete="url"
- className="font-mono text-sm-plus"
- placeholder="https://api.example.com/v1"
- aria-invalid={Boolean(baseUrlError)}
- aria-describedby={baseUrlError ? "provider-base-url-error" : undefined}
- onChange={(event) => {
- setBaseUrl(event.target.value);
- setError("");
- }}
- onBlur={commitBaseUrl}
- />
- {baseUrlError ? (
- <div
- id="provider-base-url-error"
- className="provider-setup-field-error"
- role="alert"
- >
- {baseUrlError}
- </div>
- ) : null}
- </Field>
- </div>
- </div>
- <div className="provider-setup-field-row provider-setup-custom-auth-row">
- <Field
- label={t("settings.apiKey")}
- hint={editing ? t("settings.apiKeyKeepHint") : undefined}
- >
- <Input
- ref={apiKeyRef}
- type="password"
- value={apiKey}
- placeholder="sk-…"
- className="font-mono text-sm-plus"
- autoComplete="off"
- onChange={(event) => setApiKey(event.target.value)}
- />
- </Field>
- <Field
- label={t("settings.apiStyle")}
- hint={accountOnlyApiStyle ? t(requiresApiStyleChoice
- ? "settings.apiStyleChooseCustom"
- : "settings.apiStyleLegacyAccount") : undefined}
- >
- <SettingsMenuSelect
- fullWidth
- label={t("settings.apiStyle")}
- value={apiStyle}
- disabled={saving}
- onChange={(id) => setApiStyle(id as CatalogApiStyle)}
- options={[
- ...(accountOnlyApiStyle
- ? [{
- id: apiStyle,
- label: t(API_STYLE_LABEL_KEYS[apiStyle]),
- disabled: true,
- }]
- : []),
- ...CUSTOM_PROVIDER_API_STYLES.map((style) => ({
- id: style,
- label: t(API_STYLE_LABEL_KEYS[style]),
- })),
- ]}
- />
- </Field>
- </div>
- </>
- ) : null}
+ {testResult ? (
+ <div className="provider-credential-test">
+ <span className="provider-credential-test-result">{testResult}</span>
</div>
+ ) : null}
+ </div>
- {testResult ? (
- <div className="provider-credential-test">
- <span className="provider-credential-test-result">{testResult}</span>
- </div>
- ) : null}
- </div>
-
+ {managing ? (
<ModelSelectionPanes
discovery={discovery}
selection={selection}
@@ -546,13 +468,71 @@ export function ProviderSetupDialog({
apiStyle={resolvedApiStyle}
imageModelIds={imageModelDraft ?? imageModelIds}
onImageModelChange={updateImageModelDraft}
+ customModelInputRef={customModelRef}
+ onCollapse={() => setManaging(false)}
lookupContext={{
baseUrl: requestBaseUrl,
vendorKey: namedPreset?.vendorKey ?? "custom",
providerId: provider?.id,
}}
/>
- </div>
+ ) : (
+ <ChosenModelsSummary
+ models={models}
+ discoveryStatus={discoveryActive ? discovery.status : "idle"}
+ busy={saving}
+ autoPicked={recommended.autoPicked}
+ onRemove={(id) =>
+ selection.setModels((current) => current.filter((entry) => entry.id !== id))
+ }
+ onManage={() => setManaging(true)}
+ onAddManually={addModelManually}
+ />
+ )}
+ </div>
+ </>
+ );
+
+ const chooserView = (
+ <>
+ <div className="provider-setup-head">
+ <h3 id="provider-setup-title" className="provider-setup-title">
+ {editing ? t("settings.changeServiceTitle") : t("settings.addProviderTitle")}
+ </h3>
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={service ? () => setChoosing(false) : onClose}
+ >
+ {t("settings.cancel")}
+ </Button>
+ </div>
+ <ServiceChooser
+ vendors={editing ? null : vendors}
+ current={service}
+ onPickService={pickService}
+ onPickSubscription={editing ? undefined : onPickSubscription}
+ />
+ </>
+ );
+
+ return portalOverlay(
+ <div
+ className="overlay provider-setup-overlay"
+ role="presentation"
+ onClick={() => {
+ if (saving) return;
+ onClose();
+ }}
+ >
+ <div
+ className="dialog provider-setup-dialog"
+ role="dialog"
+ aria-modal="true"
+ aria-labelledby="provider-setup-title"
+ onClick={(event) => event.stopPropagation()}
+ >
+ {chooserOpen ? chooserView : formView}
</div>
{advancedOpen && (named || custom) ? (
diff --git a/apps/desktop/src/components/settings/ServiceChooser.tsx b/apps/desktop/src/components/settings/ServiceChooser.tsx
new file mode 100644
index 000000000..a1fb919a3
--- /dev/null
+++ b/apps/desktop/src/components/settings/ServiceChooser.tsx
@@ -0,0 +1,270 @@
+/**
+ * Where a new AI service starts: every way to connect, on one searchable page
+ * (D623).
+ *
+ * The old form opened on a closed Service menu, and subscriptions had their
+ * own button and dialog further down the page, so the first decision was
+ * where to look rather than what to connect. Subscriptions and API-key
+ * services now sit side by side as tiles; the custom endpoint comes last,
+ * because it is the one choice that asks for more than a key. Filtering never
+ * talks to the host.
+ */
+import { useMemo, useRef, useState, type KeyboardEvent } from "react";
+import { useTranslation } from "react-i18next";
+import type { OAuthVendor } from "@pi-desktop/shared";
+import { cx, Input } from "../ui";
+import { IconPlus, IconSearch } from "../icons";
+import { ServiceMonogram } from "./ServiceMonogram";
+import {
+ CUSTOM_SERVICE,
+ customServiceOption,
+ filterServiceOptions,
+ namedServiceOptions,
+} from "./service-catalog";
+
+export type ServiceChooserProps = {
+ /** Vendors that sign in with an account; absent or empty hides the group. */
+ vendors?: readonly OAuthVendor[] | null;
+ /** The service the form was showing, marked when the user comes back. */
+ current?: string;
+ disabled?: boolean;
+ onPickService: (id: string) => void;
+ onPickSubscription?: (vendor: OAuthVendor) => void;
+};
+
+type SubscriptionOption = { vendor: OAuthVendor; haystack: string };
+
+const TILE_SELECTOR = "[data-service-tile]";
+
+export function ServiceChooser({
+ vendors,
+ current,
+ disabled = false,
+ onPickService,
+ onPickSubscription,
+}: ServiceChooserProps) {
+ const { t } = useTranslation();
+ const [query, setQuery] = useState("");
+ const searchRef = useRef<HTMLInputElement>(null);
+ const gridRef = useRef<HTMLDivElement>(null);
+
+ const serviceOptions = useMemo(
+ () => [...namedServiceOptions(t), customServiceOption(t)],
+ [t],
+ );
+ const subscriptionOptions = useMemo<SubscriptionOption[]>(
+ () =>
+ onPickSubscription && vendors
+ ? vendors.map((vendor) => ({
+ vendor,
+ haystack:
+ `${vendor.name} ${vendor.loginLabel ?? ""} ${vendor.vendorId}`.toLowerCase(),
+ }))
+ : [],
+ [onPickSubscription, vendors],
+ );
+
+ const visibleServices = useMemo(
+ () => filterServiceOptions(serviceOptions, query),
+ [query, serviceOptions],
+ );
+ const visibleSubscriptions = useMemo(
+ () => filterServiceOptions(subscriptionOptions, query),
+ [query, subscriptionOptions],
+ );
+ const nothingMatches = visibleServices.length === 0 && visibleSubscriptions.length === 0;
+
+ // Enter prefers an API service over a subscription: a pick there only moves
+ // to the key field, while a subscription opens the browser.
+ const enterTarget = query.trim()
+ ? visibleServices[0]
+ ? `service:${visibleServices[0].id}`
+ : visibleSubscriptions[0]
+ ? `subscription:${visibleSubscriptions[0].vendor.vendorId}`
+ : ""
+ : "";
+
+ const pickService = (id: string) => {
+ if (!disabled) onPickService(id);
+ };
+ const pickSubscription = (vendor: OAuthVendor) => {
+ if (!disabled) onPickSubscription?.(vendor);
+ };
+
+ const pickEnterTarget = () => {
+ if (visibleServices[0]) pickService(visibleServices[0].id);
+ else if (visibleSubscriptions[0]) pickSubscription(visibleSubscriptions[0].vendor);
+ else pickService(CUSTOM_SERVICE);
+ };
+
+ const tiles = () => [
+ ...(gridRef.current?.querySelectorAll<HTMLButtonElement>(TILE_SELECTOR) ?? []),
+ ];
+
+ /**
+ * Left and right walk the tiles in reading order; up and down go to the
+ * nearest tile in the row above or below, so the grid keeps its columns at
+ * any width. Up from the first row returns to the search field.
+ */
+ const onTileKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {
+ const all = tiles();
+ const index = all.indexOf(event.currentTarget);
+ if (index === -1) return;
+ let next: HTMLButtonElement | undefined;
+ if (event.key === "ArrowRight") next = all[index + 1];
+ else if (event.key === "ArrowLeft") next = all[index - 1];
+ else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
+ const down = event.key === "ArrowDown";
+ const origin = event.currentTarget.getBoundingClientRect();
+ const originX = origin.left + origin.width / 2;
+ let bestScore = Number.POSITIVE_INFINITY;
+ for (const tile of all) {
+ const box = tile.getBoundingClientRect();
+ const rowGap = down ? box.top - origin.bottom : origin.top - box.bottom;
+ if (rowGap < -1) continue;
+ const score = rowGap * 1000 + Math.abs(box.left + box.width / 2 - originX);
+ if (score < bestScore) {
+ bestScore = score;
+ next = tile;
+ }
+ }
+ if (!next && !down) {
+ event.preventDefault();
+ searchRef.current?.focus();
+ return;
+ }
+ } else return;
+ if (!next) return;
+ event.preventDefault();
+ next.focus();
+ };
+
+ return (
+ <div className="service-chooser">
+ <div className="service-chooser-search">
+ <IconSearch size={14} aria-hidden />
+ <Input
+ ref={searchRef}
+ value={query}
+ autoFocus
+ autoComplete="off"
+ disabled={disabled}
+ placeholder={t("settings.searchService")}
+ aria-label={t("settings.searchService")}
+ onChange={(event) => setQuery(event.target.value)}
+ onKeyDown={(event) => {
+ if (event.key === "Enter") {
+ event.preventDefault();
+ pickEnterTarget();
+ } else if (event.key === "ArrowDown") {
+ event.preventDefault();
+ tiles()[0]?.focus();
+ }
+ }}
+ />
+ </div>
+
+ <div className="service-chooser-groups" ref={gridRef}>
+ {nothingMatches ? (
+ <div className="service-chooser-empty">
+ <span>{t("settings.noServiceMatches")}</span>
+ <button
+ type="button"
+ className="service-chooser-empty-action"
+ disabled={disabled}
+ onClick={() => pickService(CUSTOM_SERVICE)}
+ >
+ {t("settings.useCustomEndpoint")}
+ </button>
+ </div>
+ ) : null}
+
+ {visibleSubscriptions.length > 0 ? (
+ <section className="service-chooser-group" aria-labelledby="service-chooser-subscriptions">
+ <h4 id="service-chooser-subscriptions" className="service-chooser-group-title">
+ {t("settings.chooserSubscriptions")}
+ </h4>
+ <div className="service-chooser-grid">
+ {/* Every OAuth-capable vendor; existing accounts do not disable a
+ vendor, because one vendor can hold several accounts. */}
+ {visibleSubscriptions.map(({ vendor }) => {
+ const detail = vendor.loginLabel ||
+ (vendor.isSubscription ? t("settings.vendorSubscription") : "");
+ const existing = vendor.accounts.length > 0
+ ? t("settings.vendorExistingAccounts", { count: vendor.accounts.length })
+ : "";
+ return (
+ <button
+ key={vendor.vendorId}
+ type="button"
+ data-service-tile
+ className={cx(
+ "service-chooser-tile",
+ enterTarget === `subscription:${vendor.vendorId}` && "is-active",
+ )}
+ disabled={disabled}
+ onKeyDown={onTileKeyDown}
+ onClick={() => pickSubscription(vendor)}
+ >
+ <ServiceMonogram name={vendor.name} />
+ <span className="service-chooser-tile-copy">
+ <span className="service-chooser-tile-name">{vendor.name}</span>
+ {detail || existing ? (
+ <span className="service-chooser-tile-detail">
+ {[detail, existing].filter(Boolean).join(" · ")}
+ </span>
+ ) : null}
+ </span>
+ </button>
+ );
+ })}
+ </div>
+ </section>
+ ) : null}
+
+ {visibleServices.length > 0 ? (
+ <section className="service-chooser-group" aria-labelledby="service-chooser-api-keys">
+ <h4 id="service-chooser-api-keys" className="service-chooser-group-title">
+ {t("settings.chooserApiKeys")}
+ </h4>
+ <div className="service-chooser-grid">
+ {visibleServices.map((option) => {
+ const isCustom = option.id === CUSTOM_SERVICE;
+ return (
+ <button
+ key={option.id}
+ type="button"
+ data-service-tile
+ data-service-id={option.id}
+ className={cx(
+ "service-chooser-tile",
+ enterTarget === `service:${option.id}` && "is-active",
+ )}
+ aria-current={option.id === current ? "true" : undefined}
+ disabled={disabled}
+ onKeyDown={onTileKeyDown}
+ onClick={() => pickService(option.id)}
+ >
+ {isCustom ? (
+ <span className="service-monogram" aria-hidden>
+ <IconPlus size={14} />
+ </span>
+ ) : (
+ <ServiceMonogram name={option.label} />
+ )}
+ <span className="service-chooser-tile-copy">
+ <span className="service-chooser-tile-name">{option.label}</span>
+ <span className="service-chooser-tile-detail">
+ {isCustom ? t("settings.customEndpointDesc") : option.host}
+ </span>
+ </span>
+ </button>
+ );
+ })}
+ </div>
+ </section>
+ ) : null}
+ </div>
+ </div>
+ );
+}
diff --git a/apps/desktop/src/components/settings/ServicePicker.tsx b/apps/desktop/src/components/settings/ServicePicker.tsx
deleted file mode 100644
index e72bdb464..000000000
--- a/apps/desktop/src/components/settings/ServicePicker.tsx
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- * Searchable Service menu for the add/edit provider dialog.
- *
- * Native <select> is sluggish in this overlay and cannot filter. This follows
- * the default-model picker: an anchored menu, a local search field, and a
- * flat vendor list. Filtering never talks to the host.
- */
-import { useEffect, useMemo, useRef, useState } from "react";
-import { useTranslation } from "react-i18next";
-import { cx, Input } from "../ui";
-import { IconCheck, IconChevronDown, IconSearch } from "../icons";
-import { AnchoredMenu } from "./AnchoredMenu";
-import {
- CUSTOM_SERVICE,
- customServiceOption,
- filterServiceOptions,
- namedServiceOptions,
- type ServiceOption,
-} from "./service-catalog";
-
-export { CUSTOM_SERVICE };
-
-export type ServicePickerProps = {
- value: string;
- autoFocus?: boolean;
- disabled?: boolean;
- onChange: (next: string) => void;
-};
-
-export function ServicePicker({
- value,
- autoFocus = false,
- disabled = false,
- onChange,
-}: ServicePickerProps) {
- const { t } = useTranslation();
- const [open, setOpen] = useState(false);
- const [query, setQuery] = useState("");
- const [activeId, setActiveId] = useState(value || CUSTOM_SERVICE);
- const [restoreFocus, setRestoreFocus] = useState(true);
- const optionRefs = useRef(new Map<string, HTMLButtonElement>());
-
- const options = useMemo<ServiceOption[]>(
- () => [customServiceOption(t), ...namedServiceOptions(t)],
- [t],
- );
-
- const visible = useMemo(() => filterServiceOptions(options, query), [options, query]);
-
- const visibleIds = useMemo(() => visible.map((option) => option.id), [visible]);
-
- useEffect(() => {
- setActiveId((current) =>
- visibleIds.includes(current) ? current : (visibleIds[0] ?? ""),
- );
- }, [visibleIds]);
-
- useEffect(() => {
- if (!open) return;
- optionRefs.current.get(activeId)?.scrollIntoView({ block: "nearest" });
- }, [activeId, open]);
-
- const selected = options.find((option) => option.id === value);
- const triggerLabel = selected?.label ?? t("settings.chooseService");
-
- const close = () => {
- setOpen(false);
- setQuery("");
- };
-
- const choose = (id: string) => {
- // The next field (API key or Name) takes focus; do not bounce to the trigger.
- setRestoreFocus(false);
- onChange(id);
- close();
- };
-
- const moveActive = (delta: number) => {
- if (visibleIds.length === 0) return;
- const index = visibleIds.indexOf(activeId);
- const next =
- index === -1
- ? delta > 0
- ? 0
- : visibleIds.length - 1
- : (index + delta + visibleIds.length) % visibleIds.length;
- setActiveId(visibleIds[next] ?? "");
- };
-
- return (
- <AnchoredMenu
- className="provider-service-anchor"
- open={open}
- onClose={close}
- menuClassName="provider-service-menu"
- label={t("settings.service")}
- initialFocus="input"
- restoreFocus={restoreFocus}
- trigger={(ref) => (
- <button
- ref={ref}
- type="button"
- className={cx(
- "field-select provider-service-trigger",
- !selected && "is-placeholder",
- )}
- disabled={disabled}
- autoFocus={autoFocus}
- aria-haspopup="listbox"
- aria-expanded={open}
- onClick={() => {
- if (disabled) return;
- setRestoreFocus(true);
- setQuery("");
- setActiveId(value || CUSTOM_SERVICE);
- setOpen((current) => !current);
- }}
- >
- <span className="provider-service-trigger-label">{triggerLabel}</span>
- <IconChevronDown
- className="provider-service-trigger-chevron"
- size={14}
- aria-hidden
- />
- </button>
- )}
- >
- <div className="provider-service-search">
- <IconSearch size={14} aria-hidden />
- <Input
- value={query}
- onChange={(event) => setQuery(event.target.value)}
- placeholder={t("settings.searchService")}
- aria-label={t("settings.searchService")}
- autoComplete="off"
- onKeyDown={(event) => {
- if (event.key === "ArrowDown") {
- event.preventDefault();
- moveActive(1);
- } else if (event.key === "ArrowUp") {
- event.preventDefault();
- moveActive(-1);
- } else if (event.key === "Enter") {
- event.preventDefault();
- if (activeId) choose(activeId);
- }
- }}
- />
- </div>
- <div className="provider-service-results" role="presentation">
- {visible.length === 0 ? (
- <div className="provider-service-no-results">
- {t("settings.noServiceMatches")}
- </div>
- ) : (
- <ul className="provider-service-list">
- {visible.map((option) => {
- const isCurrent = option.id === value;
- const isActive = option.id === activeId;
- return (
- <li key={option.id}>
- <button
- ref={(node) => {
- if (node) optionRefs.current.set(option.id, node);
- else optionRefs.current.delete(option.id);
- }}
- type="button"
- role="option"
- tabIndex={-1}
- aria-selected={isCurrent}
- className={cx(
- "provider-service-option",
- isCurrent && "is-current",
- isActive && "is-active",
- )}
- onMouseEnter={() => setActiveId(option.id)}
- onClick={() => choose(option.id)}
- >
- <span className="provider-service-option-check" aria-hidden>
- {isCurrent ? <IconCheck size={12} /> : null}
- </span>
- <span className="provider-service-option-label">
- {option.label}
- </span>
- </button>
- </li>
- );
- })}
- </ul>
- )}
- </div>
- </AnchoredMenu>
- );
-}
diff --git a/apps/desktop/src/components/settings/VendorAccountDialog.tsx b/apps/desktop/src/components/settings/VendorAccountDialog.tsx
index 82a590000..88dbf0fdb 100644
--- a/apps/desktop/src/components/settings/VendorAccountDialog.tsx
+++ b/apps/desktop/src/components/settings/VendorAccountDialog.tsx
@@ -6,9 +6,10 @@
* entitlements, so this dialog shows what the account can actually run rather
* than every model the vendor publishes. Choosing among those rows is
* `ModelSelectionPanes`, the same picker the AI service dialog renders, so an
- * account is not a reduced version of a service.
+ * account is not a reduced version of a service. Like a service, the dialog
+ * opens on the chosen-models summary and the picker is one click away (D623).
*/
-import { useEffect, useState } from "react";
+import { useEffect, useRef, useState } from "react";
import {
bindingForCustomModel,
type ModelBinding,
@@ -20,6 +21,7 @@ import { Button, Field, Input, portalOverlay } from "../ui";
import { ProviderHeadersEditor } from "./ProviderHeadersEditor";
import { useProviderModels } from "./useProviderModels";
import { ModelSelectionPanes, useModelSelection } from "./ModelSelectionPanes";
+import { ChosenModelsSummary } from "./ChosenModelsSummary";
export type VendorAccountForm = {
name: string;
@@ -46,6 +48,8 @@ export function VendorAccountDialog({
const [name, setName] = useState(initialName);
const [headerPairs, setHeaderPairs] = useState(() => recordToPairs(provider.headers));
const [advancedOpen, setAdvancedOpen] = useState(false);
+ const [managing, setManaging] = useState(false);
+ const customModelRef = useRef<HTMLInputElement>(null);
const [models, setModels] = useState<ModelBinding[]>(
provider.models.length > 0
? provider.models
@@ -132,19 +136,37 @@ export function VendorAccountDialog({
/>
</Field>
- <ModelSelectionPanes
- discovery={discovery}
- selection={selection}
- listTitle={t("settings.accountModels")}
- busy={saving}
- onReload={discovery.reload}
- lookupContext={{
- baseUrl: provider.baseUrl,
- vendorKey: provider.vendorKey,
- providerId: provider.id,
- }}
- apiStyle={provider.apiStyle ?? ""}
- />
+ {managing ? (
+ <ModelSelectionPanes
+ discovery={discovery}
+ selection={selection}
+ listTitle={t("settings.accountModels")}
+ busy={saving}
+ onReload={discovery.reload}
+ lookupContext={{
+ baseUrl: provider.baseUrl,
+ vendorKey: provider.vendorKey,
+ providerId: provider.id,
+ }}
+ apiStyle={provider.apiStyle ?? ""}
+ customModelInputRef={customModelRef}
+ onCollapse={() => setManaging(false)}
+ />
+ ) : (
+ <ChosenModelsSummary
+ models={models}
+ discoveryStatus={discovery.status}
+ busy={saving}
+ onRemove={(id) =>
+ selection.setModels((current) => current.filter((entry) => entry.id !== id))
+ }
+ onManage={() => setManaging(true)}
+ onAddManually={() => {
+ setManaging(true);
+ window.setTimeout(() => customModelRef.current?.focus(), 0);
+ }}
+ />
+ )}
</div>
<div className="vendor-account-actions">
diff --git a/apps/desktop/src/components/settings/VendorPickerDialog.tsx b/apps/desktop/src/components/settings/VendorPickerDialog.tsx
deleted file mode 100644
index 5e180f74f..000000000
--- a/apps/desktop/src/components/settings/VendorPickerDialog.tsx
+++ /dev/null
@@ -1,77 +0,0 @@
-/** Pick which vendor to sign in to; the same vendor can be picked repeatedly. */
-import { useEffect } from "react";
-import { useTranslation } from "react-i18next";
-import type { OAuthVendor } from "@pi-desktop/shared";
-import { Button, portalOverlay } from "../ui";
-
-export function VendorPickerDialog({
- vendors,
- onPick,
- onClose,
-}: {
- /** Every OAuth-capable vendor; existing accounts do not disable a vendor. */
- vendors: OAuthVendor[];
- onPick: (vendor: OAuthVendor) => void;
- onClose: () => void;
-}) {
- const { t } = useTranslation();
-
- useEffect(() => {
- const onKeyDown = (event: KeyboardEvent) => {
- if (event.key === "Escape") onClose();
- };
- window.addEventListener("keydown", onKeyDown);
- return () => window.removeEventListener("keydown", onKeyDown);
- }, [onClose]);
-
- return portalOverlay(
- <div className="overlay provider-dialog-overlay" role="presentation">
- <div
- className="dialog oauth-dialog"
- role="dialog"
- aria-modal="true"
- aria-labelledby="vendor-picker-title"
- >
- <h3 id="vendor-picker-title" className="provider-dialog-title">
- {t("settings.vendorPickTitle")}
- </h3>
- <div className="oauth-status">{t("settings.vendorPickDesc")}</div>
- <div className="oauth-options">
- {vendors.map((vendor) => (
- <button
- key={vendor.vendorId}
- type="button"
- className="oauth-option"
- onClick={() => onPick(vendor)}
- >
- <span className="oauth-option-label">{vendor.name}</span>
- {/* The vendor's own call to action when it has one; otherwise
- say whether this is a subscription rather than pay-per-use. */}
- {vendor.loginLabel || vendor.isSubscription ? (
- <span className="oauth-option-desc">
- {vendor.loginLabel || t("settings.vendorSubscription")}
- {vendor.accounts.length > 0
- ? ` · ${t("settings.vendorExistingAccounts", {
- count: vendor.accounts.length,
- })}`
- : ""}
- </span>
- ) : vendor.accounts.length > 0 ? (
- <span className="oauth-option-desc">
- {t("settings.vendorExistingAccounts", {
- count: vendor.accounts.length,
- })}
- </span>
- ) : null}
- </button>
- ))}
- </div>
- <div className="provider-dialog-actions">
- <Button variant="ghost" onClick={onClose}>
- {t("settings.cancel")}
- </Button>
- </div>
- </div>
- </div>
- );
-}
diff --git a/apps/desktop/src/components/settings/recommended-models.ts b/apps/desktop/src/components/settings/recommended-models.ts
new file mode 100644
index 000000000..3e2acf2be
--- /dev/null
+++ b/apps/desktop/src/components/settings/recommended-models.ts
@@ -0,0 +1,146 @@
+/**
+ * The models a new AI service starts with, so saving a key is enough to chat.
+ *
+ * Only chat models that can call tools are candidates: an agent turn needs
+ * both, and embedding, speech, image, moderation and research endpoints show
+ * up in most `/models` answers next to them. When the list carries models.dev
+ * metadata, the newest stable models win, one per family, so the picks cover
+ * different lines instead of three snapshots of one; the first pick becomes
+ * the service's default model. Without metadata (a local server or a private
+ * gateway) nothing says which id is the chat model, so only the first
+ * candidate is picked and the user adds the rest.
+ */
+import {
+ MODEL_VENDOR_PREFIXES,
+ bindingFromModelInfo,
+ type ModelBinding,
+ type ModelInfo,
+} from "@pi-desktop/shared";
+import { describeModelsFetchError } from "./model-fetch-error";
+import type { ProviderModelsState } from "./useProviderModels";
+
+export const RECOMMENDED_MODEL_LIMIT = 3;
+
+/**
+ * Whether a discovery answer is trustworthy enough to preselect from.
+ *
+ * The service's own list always is. The models.dev fallback is only when the
+ * service did not refuse: a named vendor that simply has no `/models` route
+ * (404) still accepted the key, but a rejected key, a timeout or a network
+ * failure says nothing about whether the key works, and a preselection there
+ * would make a broken service look ready to save.
+ */
+export function canRecommendFrom(
+ discovery: Pick<ProviderModelsState, "status" | "source" | "error">,
+ namedService: boolean,
+): boolean {
+ if (discovery.status !== "ready") return false;
+ if (discovery.source === "remote") return true;
+ if (discovery.source !== "catalog") return false;
+ if (!discovery.error) return true;
+ return namedService && describeModelsFetchError(discovery.error).kind === "notFound";
+}
+
+/**
+ * Published output price, in USD per million tokens, above which a model is
+ * only picked when nothing cheaper qualifies. Flagship chat models sit well
+ * below it; the premium reasoning tiers a vendor ships next to them sit above,
+ * and one of those must not become a new service's default by accident.
+ */
+export const PREMIUM_OUTPUT_COST_PER_MILLION = 100;
+
+const NON_CHAT_MODEL_ID =
+ /(embed|rerank|moderation|whisper|tts|transcri|audio|realtime|\blive\b|speech|image|dall-e|imagen|ocr|guard|deep-research|computer-use)/i;
+
+function isCandidate(model: ModelInfo): boolean {
+ if (model.status === "deprecated") return false;
+ const output = model.modalities?.output;
+ if (output && !output.includes("text")) return false;
+ if (model.toolCall === false) return false;
+ return !NON_CHAT_MODEL_ID.test(model.modelId);
+}
+
+/**
+ * An aggregator addresses models as `vendor/model`. A path that names none of
+ * the known vendors is a community fine-tune or a private route, which should
+ * not outrank the mainstream models listed next to it.
+ */
+function routedThroughUnknownVendor(modelId: string): boolean {
+ const segments = modelId.split("/");
+ if (segments.length === 1) return false;
+ return !segments
+ .slice(0, -1)
+ .some((segment) => MODEL_VENDOR_PREFIXES.has(segment.toLowerCase()));
+}
+
+function isUnstable(model: ModelInfo): boolean {
+ return model.experimental === true || model.status === "beta" || model.status === "alpha";
+}
+
+function isPremium(model: ModelInfo): boolean {
+ return (model.cost?.output ?? 0) > PREMIUM_OUTPUT_COST_PER_MILLION;
+}
+
+function publishedDate(model: ModelInfo): string {
+ return model.releaseDate ?? model.lastUpdated ?? "";
+}
+
+/**
+ * Keys compared in order; lower sorts first. A premium tier ranks below a
+ * pre-release model: an unexpected bill is worse than an unexpected beta.
+ */
+function demotions(model: ModelInfo): number[] {
+ return [
+ routedThroughUnknownVendor(model.modelId) ? 1 : 0,
+ model.toolCall === true ? 0 : 1,
+ isPremium(model) ? 1 : 0,
+ isUnstable(model) ? 1 : 0,
+ ];
+}
+
+function compareCandidates(
+ left: { model: ModelInfo; index: number },
+ right: { model: ModelInfo; index: number },
+): number {
+ const leftKeys = demotions(left.model);
+ const rightKeys = demotions(right.model);
+ for (let key = 0; key < leftKeys.length; key += 1) {
+ if (leftKeys[key] !== rightKeys[key]) return leftKeys[key] - rightKeys[key];
+ }
+ // ISO dates compare as strings; an undated model sorts after every dated one.
+ const leftDate = publishedDate(left.model);
+ const rightDate = publishedDate(right.model);
+ if (leftDate !== rightDate) return leftDate < rightDate ? 1 : -1;
+ // A vendor releases a line together; the pricier sibling is its flagship.
+ const leftCost = left.model.cost?.output ?? -1;
+ const rightCost = right.model.cost?.output ?? -1;
+ if (leftCost !== rightCost) return rightCost - leftCost;
+ return left.index - right.index;
+}
+
+/**
+ * Bindings to preselect for a service whose model list just arrived, best
+ * first. Empty when the list holds no chat model that can call tools.
+ */
+export function recommendModels(
+ models: readonly ModelInfo[],
+ limit = RECOMMENDED_MODEL_LIMIT,
+): ModelBinding[] {
+ const candidates = models
+ .map((model, index) => ({ model, index }))
+ .filter(({ model }) => isCandidate(model));
+ if (candidates.length === 0 || limit <= 0) return [];
+ if (!candidates.some(({ model }) => model.catalogSource === "models.dev")) {
+ return [bindingFromModelInfo(candidates[0].model)];
+ }
+ const picked: ModelBinding[] = [];
+ const families = new Set<string>();
+ for (const { model } of [...candidates].sort(compareCandidates)) {
+ const family = (model.family ?? model.modelId).toLowerCase();
+ if (families.has(family)) continue;
+ families.add(family);
+ picked.push(bindingFromModelInfo(model));
+ if (picked.length === limit) break;
+ }
+ return picked;
+}
diff --git a/apps/desktop/src/components/settings/useRecommendedModelSelection.ts b/apps/desktop/src/components/settings/useRecommendedModelSelection.ts
new file mode 100644
index 000000000..91dbfa461
--- /dev/null
+++ b/apps/desktop/src/components/settings/useRecommendedModelSelection.ts
@@ -0,0 +1,78 @@
+/**
+ * Preselect recommended models on a new AI service (D623).
+ *
+ * The add form used to open with nothing chosen, so saving a key was never
+ * enough: every user had to find a chat model in a list of dozens. This hook
+ * fills the empty selection from `recommendModels` as soon as a trustworthy
+ * list arrives, and steps aside for good the first time the user changes the
+ * selection themselves. Until then a service change drops the previous picks,
+ * so a list meant for one vendor never rides along to the next.
+ */
+import { useCallback, useEffect, useRef, useState } from "react";
+import type { ModelBinding } from "@pi-desktop/shared";
+import { canRecommendFrom, recommendModels } from "./recommended-models";
+import type { ProviderModelsState } from "./useProviderModels";
+
+type SetModels = (update: (current: ModelBinding[]) => ModelBinding[]) => void;
+
+export type RecommendedModelSelection = {
+ /** The setter every user-driven edit goes through; it ends preselection. */
+ setModels: SetModels;
+ /** True while the chosen list is exactly what the recommendation picked. */
+ autoPicked: boolean;
+ /** A trustworthy list arrived but held no chat model that can call tools. */
+ noRecommendation: boolean;
+};
+
+export function useRecommendedModelSelection({
+ enabled,
+ serviceKey,
+ discovery,
+ setModels: setModelsState,
+ namedService,
+}: {
+ /** Only a new service with an empty selection is preselected. */
+ enabled: boolean;
+ /** Service, endpoint and API format; a change restarts preselection. */
+ serviceKey: string;
+ discovery: ProviderModelsState;
+ setModels: (next: ModelBinding[] | ((current: ModelBinding[]) => ModelBinding[])) => void;
+ namedService: boolean;
+}): RecommendedModelSelection {
+ const touchedRef = useRef(false);
+ const serviceKeyRef = useRef(serviceKey);
+ const [autoPicked, setAutoPicked] = useState(false);
+ const [noRecommendation, setNoRecommendation] = useState(false);
+
+ const setModels = useCallback<SetModels>(
+ (update) => {
+ touchedRef.current = true;
+ setAutoPicked(false);
+ setNoRecommendation(false);
+ setModelsState(update);
+ },
+ [setModelsState],
+ );
+
+ useEffect(() => {
+ if (serviceKeyRef.current === serviceKey) return;
+ serviceKeyRef.current = serviceKey;
+ if (!enabled || touchedRef.current) return;
+ setModelsState([]);
+ setAutoPicked(false);
+ setNoRecommendation(false);
+ }, [enabled, serviceKey, setModelsState]);
+
+ const recommendable = canRecommendFrom(discovery, namedService);
+ useEffect(() => {
+ // A later failure (say a mistyped key after a good one) keeps the picks:
+ // they came from a list the service did answer with.
+ if (!enabled || touchedRef.current || !recommendable) return;
+ const picks = recommendModels(discovery.models);
+ setModelsState(picks);
+ setAutoPicked(picks.length > 0);
+ setNoRecommendation(picks.length === 0);
+ }, [discovery.models, enabled, recommendable, setModelsState]);
+
+ return { setModels, autoPicked, noRecommendation };
+}
diff --git a/apps/desktop/src/styles/globals.css b/apps/desktop/src/styles/globals.css
index 74b5ad231..19e24e98f 100644
--- a/apps/desktop/src/styles/globals.css
+++ b/apps/desktop/src/styles/globals.css
@@ -30,6 +30,7 @@
@import "./work-panel.css";
@import "./providers.css";
@import "./model-config.css";
+@import "./service-setup.css";
@import "./chat-links.css";
@import "./composer-autocomplete.css";
@import "./plugins.css";
diff --git a/apps/desktop/src/styles/model-config.css b/apps/desktop/src/styles/model-config.css
index 718294419..0b5ee6159 100644
--- a/apps/desktop/src/styles/model-config.css
+++ b/apps/desktop/src/styles/model-config.css
@@ -160,16 +160,132 @@
overflow-wrap: anywhere;
}
-.provider-setup-host {
- grid-column: 1 / -1;
+/*
+ The chosen service is a settled fact, not an open menu: its letter tile,
+ name and host on the field tone, with Change leading back to the chooser.
+*/
+.provider-service-chip {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ min-width: 0;
+ min-height: var(--ds-field-height);
+ padding: 4px 6px 4px 5px;
+ border-radius: var(--radius-sm);
+ background: var(--ds-tile);
+}
+
+.provider-service-chip .service-monogram {
+ width: 24px;
+ height: 24px;
+ border-radius: var(--radius-xs);
+ font-size: var(--text-xs);
+}
+
+.provider-service-chip-copy {
+ display: flex;
+ flex: 1;
+ align-items: baseline;
+ gap: 8px;
+ min-width: 0;
+ overflow: hidden;
+ white-space: nowrap;
+}
+
+.provider-service-chip-name {
+ flex: none;
+ color: var(--ds-text-primary);
+ font-size: var(--text-md);
+ font-weight: var(--font-weight-medium);
+ line-height: var(--leading-tight);
+}
+
+.provider-service-chip-host {
min-width: 0;
overflow: hidden;
color: var(--ds-text-muted);
font-family: var(--font-mono);
font-size: var(--text-2xs);
- line-height: var(--leading-relaxed);
+ line-height: var(--leading-tight);
text-overflow: ellipsis;
- white-space: nowrap;
+}
+
+.provider-service-chip-change,
+.provider-models-summary-manage,
+.provider-models-summary-action,
+.service-chooser-empty-action {
+ flex: none;
+ margin: 0;
+ padding: 0 8px;
+ min-height: 24px;
+ border: 0;
+ border-radius: var(--radius-2xs);
+ background: var(--ds-bg-chip);
+ color: var(--ds-text-secondary);
+ font-size: var(--text-2xs);
+ line-height: var(--leading-normal);
+ cursor: pointer;
+}
+
+.provider-service-chip-change:hover:not(:disabled),
+.provider-models-summary-manage:hover:not(:disabled),
+.provider-models-summary-action:hover:not(:disabled),
+.service-chooser-empty-action:hover:not(:disabled) {
+ background: var(--ds-bg-hover);
+ color: var(--ds-text-primary);
+}
+
+.provider-service-chip-change:focus-visible,
+.provider-models-summary-manage:focus-visible,
+.provider-models-summary-action:focus-visible,
+.service-chooser-empty-action:focus-visible {
+ outline: none;
+ box-shadow: 0 0 0 2px color-mix(in oklab, var(--ds-accent) 24%, transparent);
+}
+
+.provider-service-chip-change:disabled,
+.provider-models-summary-manage:disabled,
+.provider-models-summary-action:disabled {
+ cursor: default;
+ color: var(--ds-text-faint);
+}
+
+.provider-setup-key {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ min-width: 0;
+}
+
+/* One quiet line under the key: connecting, connected, or why not. */
+.provider-connection-status {
+ display: flex;
+ align-items: center;
+ gap: 5px;
+ min-width: 0;
+ color: var(--ds-text-muted);
+ font-size: var(--text-2xs);
+ line-height: var(--leading-relaxed);
+ overflow-wrap: anywhere;
+}
+
+.provider-connection-status.is-ok {
+ color: var(--ds-text-secondary);
+}
+
+.provider-connection-status.is-ok svg {
+ flex: none;
+ color: var(--ds-success);
+}
+
+.provider-connection-status.is-error {
+ flex-wrap: wrap;
+ column-gap: 6px;
+ color: var(--ds-warning);
+}
+
+.provider-connection-status.is-error .provider-models-error-detail {
+ max-width: none;
}
.provider-service-anchor {
diff --git a/apps/desktop/src/styles/service-setup.css b/apps/desktop/src/styles/service-setup.css
new file mode 100644
index 000000000..ca840dda7
--- /dev/null
+++ b/apps/desktop/src/styles/service-setup.css
@@ -0,0 +1,205 @@
+/*
+ The AI service dialog's chooser view and chosen-models summary (D623).
+ In-flow tiles only (D297): tone and spacing separate them, never a stroke.
+*/
+
+/* ------------------------------------------------------- service chooser */
+
+.service-chooser {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ min-height: 0;
+}
+
+.service-chooser-search {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ flex: none;
+ margin: 2px;
+ padding: 0 11px;
+ border-radius: var(--radius-sm);
+ background: var(--ds-tile-hover);
+ color: var(--ds-text-faint);
+ transition:
+ background var(--motion-duration-fast) var(--motion-ease-out),
+ box-shadow var(--motion-duration-fast) var(--motion-ease-out);
+}
+
+.service-chooser-search:focus-within {
+ background: var(--ds-raised);
+ box-shadow: 0 0 0 2px color-mix(in oklab, var(--ds-accent) 22%, transparent);
+}
+
+/* The wrapper owns the field tone and ring; the input is only the text. */
+.service-chooser-search input,
+.service-chooser-search input:focus {
+ min-width: 0;
+ padding-right: 0;
+ padding-left: 0;
+ background: transparent;
+ box-shadow: none;
+}
+
+.service-chooser-groups {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+ min-height: 0;
+ overflow-x: hidden;
+ overflow-y: auto;
+ padding: 2px;
+ overscroll-behavior: contain;
+}
+
+.service-chooser-group {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+}
+
+.service-chooser-group-title {
+ margin: 0;
+ color: var(--ds-text-secondary);
+ font-size: var(--text-2xs);
+ font-weight: var(--font-weight-semibold);
+ letter-spacing: var(--tracking-wide);
+ line-height: var(--leading-tight);
+ text-transform: uppercase;
+}
+
+.service-chooser-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
+ gap: 6px;
+}
+
+.service-chooser-tile {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ min-width: 0;
+ margin: 0;
+ padding: 9px 10px;
+ border: 0;
+ border-radius: var(--radius-md);
+ background: var(--ds-tile);
+ color: var(--ds-text-primary);
+ text-align: left;
+ cursor: pointer;
+ transition:
+ background var(--motion-duration-fast) var(--motion-ease-out),
+ box-shadow var(--motion-duration-fast) var(--motion-ease-out);
+}
+
+.service-chooser-tile:hover:not(:disabled),
+.service-chooser-tile.is-active {
+ background: var(--ds-tile-hover);
+}
+
+.service-chooser-tile:focus-visible {
+ outline: none;
+ background: var(--ds-tile-hover);
+ box-shadow: 0 0 0 2px color-mix(in oklab, var(--ds-accent) 24%, transparent);
+}
+
+.service-chooser-tile[aria-current="true"] {
+ background: var(--ds-tile-deep);
+}
+
+.service-chooser-tile:disabled {
+ cursor: default;
+ opacity: 0.55;
+}
+
+.service-chooser-tile-copy {
+ display: flex;
+ flex: 1;
+ flex-direction: column;
+ gap: 2px;
+ min-width: 0;
+}
+
+.service-chooser-tile-name,
+.service-chooser-tile-detail {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.service-chooser-tile-name {
+ font-size: var(--text-md);
+ font-weight: var(--font-weight-medium);
+ line-height: var(--leading-tight);
+}
+
+.service-chooser-tile-detail {
+ color: var(--ds-text-muted);
+ font-size: var(--text-2xs);
+ line-height: var(--leading-tight);
+}
+
+.service-chooser-empty {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 10px;
+ padding: 28px 12px;
+ border-radius: var(--radius-md);
+ background: var(--ds-tile);
+ color: var(--ds-text-faint);
+ font-size: var(--text-sm);
+ line-height: var(--leading-relaxed);
+ text-align: center;
+}
+
+/* ------------------------------------------------ chosen models summary */
+
+/* The same inset tray as the picker panes, so folding one into the other
+ keeps the dialog's shape. */
+.provider-models-summary {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ min-height: 0;
+ border-radius: var(--radius-sm);
+ background: var(--ds-bg-inset);
+}
+
+.provider-models-summary-head {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ flex: none;
+ padding: 9px 8px 4px;
+}
+
+.provider-models-summary-head .provider-models-summary-manage,
+.provider-chosen-head .provider-models-summary-manage {
+ margin-left: auto;
+}
+
+.provider-chosen-search-wrap + .provider-models-summary-manage {
+ margin-left: 0;
+}
+
+.provider-models-summary .provider-chosen-row-head {
+ min-height: 30px;
+}
+
+.provider-models-summary .provider-chosen-empty {
+ flex-direction: column;
+ gap: 10px;
+}
+
+.provider-models-summary-hint {
+ flex: none;
+ padding: 4px 10px 9px;
+ color: var(--ds-text-muted);
+ font-size: var(--text-2xs);
+ line-height: var(--leading-relaxed);
+}
diff --git a/apps/desktop/test/model-advanced-capabilities.test.mjs b/apps/desktop/test/model-advanced-capabilities.test.mjs
index ba386e252..c5d9a8122 100644
--- a/apps/desktop/test/model-advanced-capabilities.test.mjs
+++ b/apps/desktop/test/model-advanced-capabilities.test.mjs
@@ -236,7 +236,9 @@ test("the advanced body is a compact sheet without helper paragraphs", () => {
);
assert.doesNotMatch(pickerSource, /hint=\{t\("settings\.modelAliasHint"\)\}/);
assert.match(pickerSource, /aria-controls=\{advancedId\}/);
- assert.match(pickerSource, /models\[0\]\?\.id \?\? null/);
+ // Every row starts folded (D623); the chosen list is for review first.
+ assert.match(pickerSource, /useState<string \| null>\(null\)/);
+ assert.doesNotMatch(pickerSource, /models\[0\]\?\.id \?\? null/);
assert.match(
pickerSource,
/className="provider-chosen-thinking-head">[\s\S]*?provider-chosen-thinking-default[\s\S]*?provider-chosen-thinking-chips/,
diff --git a/apps/desktop/test/provider-form-layout.test.mjs b/apps/desktop/test/provider-form-layout.test.mjs
index 3de94f9bf..505183f04 100644
--- a/apps/desktop/test/provider-form-layout.test.mjs
+++ b/apps/desktop/test/provider-form-layout.test.mjs
@@ -20,6 +20,9 @@ const vendorDialogSource = await read("../src/components/settings/VendorAccountD
// The panes themselves live in the picker both dialogs render (D269).
const pickerSource = await read("../src/components/settings/ModelSelectionPanes.tsx");
const fetchErrorSource = await read("../src/components/settings/ModelsFetchErrorMessage.tsx");
+// The credential rows live in their own component since D623.
+const fieldsSource = await read("../src/components/settings/ProviderConnectionFields.tsx");
+const summarySource = await read("../src/components/settings/ChosenModelsSummary.tsx");
const styles = await loadStyles();
/** Declaration block for exactly one selector, so matches cannot span rules. */
@@ -51,10 +54,11 @@ test("the scrolling body keeps the credential focus ring inside the dialog", ()
test("credentials use explicit rows for predictable field alignment", () => {
assert.match(setupSource, /className="provider-setup-credentials"/);
- assert.match(setupSource, /provider-setup-fields/);
- assert.match(setupSource, /provider-setup-service-row/);
- assert.match(setupSource, /provider-setup-custom-identity-row/);
- assert.match(setupSource, /provider-setup-custom-auth-row/);
+ assert.match(setupSource, /<ProviderConnectionFields/);
+ assert.match(fieldsSource, /provider-setup-fields/);
+ assert.match(fieldsSource, /provider-setup-service-row/);
+ assert.match(fieldsSource, /provider-setup-custom-identity-row/);
+ assert.match(fieldsSource, /provider-setup-custom-auth-row/);
const fields = block(".provider-setup-fields");
assert.ok(fields.includes("display: flex"));
assert.ok(fields.includes("flex-direction: column"));
@@ -71,28 +75,30 @@ test("custom API format sits beside the key, not in a disclosure", () => {
assert.doesNotMatch(setupSource, /provider-setup-advanced-toggle/);
assert.match(setupSource, /provider-advanced-dialog/);
assert.match(setupSource, /settings\.advancedSettings/);
- const fieldsBlock = setupSource.slice(
- setupSource.indexOf("provider-setup-fields"),
- setupSource.indexOf("<ModelSelectionPanes"),
+ assert.match(fieldsSource, /settings\.apiStyle"/);
+ assert.match(fieldsSource, /CUSTOM_PROVIDER_API_STYLES\.map/);
+ assert.doesNotMatch(fieldsSource, /settings\.apiStyleDerived/);
+ assert.match(fieldsSource, /provider-service-chip/);
+ // The format choice belongs to the custom rows only.
+ assert.ok(
+ fieldsSource.indexOf("{custom ? (") < fieldsSource.indexOf("settings.apiStyle\""),
+ "API format must sit inside the custom rows",
);
- assert.match(fieldsBlock, /settings\.apiStyle"/);
- assert.match(fieldsBlock, /CUSTOM_PROVIDER_API_STYLES\.map/);
- assert.doesNotMatch(fieldsBlock, /settings\.apiStyleDerived/);
- assert.match(fieldsBlock, /<ServicePicker/);
assert.match(pickerSource, /provider-chosen-advanced-toggle/);
});
test("custom Name and Base URL sit on one row without helper copy", () => {
- assert.match(setupSource, /type="url"/);
- assert.match(setupSource, /inputMode="url"/);
- assert.match(setupSource, /autoComplete="url"/);
+ assert.match(fieldsSource, /type="url"/);
+ assert.match(fieldsSource, /inputMode="url"/);
+ assert.match(fieldsSource, /autoComplete="url"/);
// Placeholder is enough; a hint under the URL would un-align the name field.
- assert.doesNotMatch(setupSource, /settings\.baseUrlHint/);
- assert.match(setupSource, /onBlur={commitBaseUrl}/);
+ assert.doesNotMatch(fieldsSource, /settings\.baseUrlHint/);
+ assert.match(fieldsSource, /onBlur={commitBaseUrl}/);
+ assert.match(setupSource, /commitBaseUrl=\{commitBaseUrl\}/);
assert.match(setupSource, /normalizeBaseUrlInput\(resolvedBaseUrl, resolvedApiStyle\)/);
assert.match(setupSource, /!baseUrlIssue/);
- assert.match(setupSource, /aria-invalid={Boolean\(baseUrlError\)}/);
- assert.match(setupSource, /provider-base-url-error/);
+ assert.match(fieldsSource, /aria-invalid={Boolean\(baseUrlError\)}/);
+ assert.match(fieldsSource, /provider-base-url-error/);
const customIdentity = block(".provider-setup-custom-identity-row");
assert.ok(customIdentity.includes("grid-template-columns: minmax(180px, 0.8fr)"));
@@ -104,10 +110,7 @@ test("custom Name and Base URL sit on one row without helper copy", () => {
assert.match(styles, /\.provider-setup-base-url \.field-input\[aria-invalid="true"\]/);
assert.match(styles, /\.provider-setup-field-error\s*\{[\s\S]*overflow-wrap: anywhere/);
- const customBlock = setupSource.slice(
- setupSource.indexOf("{custom ? ("),
- setupSource.indexOf("<ModelSelectionPanes"),
- );
+ const customBlock = fieldsSource.slice(fieldsSource.indexOf("{custom ? ("));
assert.ok(
customBlock.indexOf("settings.name") < customBlock.indexOf("provider-setup-base-url"),
"Name must precede Base URL so they occupy the same 2-column row",
@@ -336,12 +339,8 @@ test("Advanced offers presets plus JSON import and copy without redundant helper
assert.match(headersViewport, /overflow-y: auto/);
assert.match(headersViewport, /overscroll-behavior: contain/);
// Named and custom both expose Advanced; API format stays beside the key.
- const fieldsBlock = setupSource.slice(
- setupSource.indexOf("provider-setup-fields"),
- setupSource.indexOf("<ModelSelectionPanes"),
- );
assert.match(setupSource, /named \|\| custom/);
- assert.match(fieldsBlock, /settings\.apiStyle"/);
+ assert.match(fieldsSource, /settings\.apiStyle"/);
});
test("the vendor account dialog hosts the same panes in the same shell", () => {
@@ -353,6 +352,7 @@ test("the vendor account dialog hosts the same panes in the same shell", () => {
assert.match(dialog, /min-width: 0/);
assert.match(dialog, /height: min\(720px, calc\(100vh - 64px\)\)/);
assert.match(vendorDialogSource, /<ModelSelectionPanes/);
+ assert.match(vendorDialogSource, /<ChosenModelsSummary/);
// The duplicated chosen-pane and custom-model rules are retired with it.
assert.doesNotMatch(styles, /\.vendor-account-chosen/);
assert.doesNotMatch(styles, /\.vendor-account-custom-model/);
@@ -376,3 +376,23 @@ test("Advanced says a fullwidth value folds and a non-Latin-1 value is refused",
assert.match(headerEditorSource, /settings\.headersValueNotLatin1/);
assert.match(block(".provider-setup-header-note"), /color: var\(--ds-text-muted\)/);
});
+
+test("models open as a summary with the full picker one click away (D623)", () => {
+ for (const source of [setupSource, vendorDialogSource]) {
+ assert.match(source, /managing \?/);
+ assert.match(source, /<ChosenModelsSummary/);
+ assert.match(source, /onCollapse=\{\(\) => setManaging\(false\)\}/);
+ assert.match(source, /customModelInputRef=\{customModelRef\}/);
+ }
+ // Summary rows reuse the picker's row classes so both read the same.
+ assert.match(summarySource, /provider-chosen-row-id/);
+ assert.match(summarySource, /provider-chosen-remove/);
+ assert.match(summarySource, /settings\.manageModels/);
+ assert.match(summarySource, /settings\.addModelManually/);
+ assert.match(pickerSource, /settings\.collapseModels/);
+ // No model opens its advanced settings on its own any more.
+ assert.match(pickerSource, /useState<string \| null>\(null\)/);
+ const summary = block(".provider-models-summary");
+ assert.match(summary, /background: var\(--ds-bg-inset\)/);
+ assert.doesNotMatch(summary, /border:|border-top|box-shadow/);
+});
diff --git a/apps/desktop/test/provider-model-config.test.mjs b/apps/desktop/test/provider-model-config.test.mjs
index 5e52d3bbe..d766fb70c 100644
--- a/apps/desktop/test/provider-model-config.test.mjs
+++ b/apps/desktop/test/provider-model-config.test.mjs
@@ -19,6 +19,7 @@ const hookSource = await read("../src/components/settings/useProviderModels.ts")
const pageSource = await read("../src/components/settings/ModelConfigPage.tsx");
const vendorDialogSource = await read("../src/components/settings/VendorAccountDialog.tsx");
const pickerSource = await read("../src/components/settings/ModelSelectionPanes.tsx");
+const fieldsSource = await read("../src/components/settings/ProviderConnectionFields.tsx");
const filterSource = await read("../src/components/settings/model-chosen-filter.ts");
const vendorAccountsSource = await read("../src/components/settings/useVendorAccounts.ts");
const apiSource = await read("../src/lib/api.ts");
@@ -40,10 +41,13 @@ test("adding an AI service is a single form, not a staged wizard", () => {
assert.doesNotMatch(setupSource, /provider-preset-grid/);
assert.doesNotMatch(setupSource, /settings\.setupStage/);
assert.doesNotMatch(setupSource, /settings\.next"/);
- // Name, base URL and key are all reachable without navigating a step.
- assert.match(setupSource, /settings\.name/);
- assert.match(setupSource, /settings\.baseUrl/);
- assert.match(setupSource, /settings\.apiKey/);
+ assert.doesNotMatch(setupSource, /settings\.back"/);
+ // Picking a service is the only step before the form, and it is a tile
+ // click, not a Next button: name, base URL and key share one view.
+ assert.match(setupSource, /<ProviderConnectionFields/);
+ assert.match(fieldsSource, /settings\.name/);
+ assert.match(fieldsSource, /settings\.baseUrl/);
+ assert.match(fieldsSource, /settings\.apiKey/);
assert.match(setupSource, /settings\.saveProvider/);
});
@@ -89,9 +93,9 @@ test("token limits are adopted from the published record, never typed by default
});
test("custom API format is a common-path choice, named services skip it", () => {
- assert.match(setupSource, /settings\.apiStyle/);
- assert.match(setupSource, /API_STYLES/);
- assert.match(setupSource, /custom \? \(/);
+ assert.match(fieldsSource, /settings\.apiStyle/);
+ assert.match(fieldsSource, /API_STYLES/);
+ assert.match(fieldsSource, /custom \? \(/);
assert.match(setupSource, /provider-advanced-dialog/);
assert.doesNotMatch(setupSource, /provider-setup-advanced-toggle/);
});
diff --git a/apps/desktop/test/recommended-models.test.mjs b/apps/desktop/test/recommended-models.test.mjs
new file mode 100644
index 000000000..417a71f59
--- /dev/null
+++ b/apps/desktop/test/recommended-models.test.mjs
@@ -0,0 +1,192 @@
+/**
+ * The models a new AI service starts with. A service is usable once its key is
+ * saved only when the preselection is a chat model that can call tools; the
+ * first pick becomes the service's default, so it must be a current model and
+ * never a premium tier or a community route that happens to be newer.
+ */
+import assert from "node:assert/strict";
+import { register } from "node:module";
+import { dirname, join } from "node:path";
+import test from "node:test";
+import { fileURLToPath, pathToFileURL } from "node:url";
+
+const here = dirname(fileURLToPath(import.meta.url));
+register(pathToFileURL(join(here, "helpers/ts-import-hooks.mjs")));
+const { PREMIUM_OUTPUT_COST_PER_MILLION, canRecommendFrom, recommendModels } = await import(
+ "../src/components/settings/recommended-models.ts"
+);
+
+const model = (modelId, over = {}) => ({
+ modelId,
+ displayName: modelId,
+ providerId: "p1",
+ capabilities: ["text", "tools"],
+ source: "discovered",
+ catalogSource: "models.dev",
+ toolCall: true,
+ modalities: { input: ["text"], output: ["text"] },
+ ...over,
+});
+
+const ids = (models) => recommendModels(models).map((binding) => binding.id);
+
+test("only tool-capable chat models are candidates", () => {
+ assert.deepEqual(
+ ids([
+ model("text-embedding-3-large", { family: "embed", releaseDate: "2026-09-01" }),
+ model("gpt-4o-mini-tts", { family: "tts", releaseDate: "2026-09-01" }),
+ model("whisper-1", { family: "whisper", releaseDate: "2026-09-01" }),
+ model("gpt-realtime", { family: "realtime", releaseDate: "2026-09-01" }),
+ model("gemini-flash-live-preview", { family: "live", releaseDate: "2026-09-01" }),
+ model("gpt-image-2", { family: "image", releaseDate: "2026-09-01" }),
+ model("omni-moderation-latest", { family: "moderation", releaseDate: "2026-09-01" }),
+ model("o3-deep-research", { family: "research", releaseDate: "2026-09-01" }),
+ model("computer-use-preview", { family: "cua", releaseDate: "2026-09-01" }),
+ model("sora-2", {
+ family: "video",
+ releaseDate: "2026-09-01",
+ modalities: { input: ["text"], output: ["video"] },
+ }),
+ model("sonar", { family: "sonar", releaseDate: "2026-09-01", toolCall: false }),
+ model("gpt-4-legacy", { family: "legacy", releaseDate: "2026-09-01", status: "deprecated" }),
+ model("gpt-chat", { family: "gpt", releaseDate: "2026-01-01" }),
+ ]),
+ ["gpt-chat"],
+ );
+});
+
+test("a model without published modalities still qualifies", () => {
+ assert.deepEqual(ids([model("gateway-model", { modalities: undefined })]), ["gateway-model"]);
+});
+
+test("the newest model of each family wins, up to three", () => {
+ const picked = ids([
+ model("gpt-5", { family: "gpt", releaseDate: "2025-08-07", cost: { output: 10 } }),
+ model("gpt-6-sol", { family: "gpt-sol", releaseDate: "2026-09-22", cost: { output: 10 } }),
+ model("gpt-5.6-sol", { family: "gpt-sol", releaseDate: "2026-07-09", cost: { output: 20 } }),
+ model("gpt-6-luna", { family: "gpt-luna", releaseDate: "2026-09-22", cost: { output: 0.5 } }),
+ model("gpt-6-astra", { family: "gpt-astra", releaseDate: "2026-09-04", cost: { output: 50 } }),
+ ]);
+ // Same-day siblings put the pricier flagship first; older snapshots of a
+ // picked family never take a slot.
+ assert.deepEqual(picked, ["gpt-6-sol", "gpt-6-luna", "gpt-6-astra"]);
+});
+
+test("a model without a family is its own family", () => {
+ assert.deepEqual(
+ ids([
+ model("alpha-1", { releaseDate: "2026-01-03" }),
+ model("alpha-2", { releaseDate: "2026-01-02" }),
+ ]),
+ ["alpha-1", "alpha-2"],
+ );
+});
+
+test("premium tiers and pre-release models only fill leftover slots", () => {
+ const premium = PREMIUM_OUTPUT_COST_PER_MILLION + 80;
+ assert.deepEqual(
+ ids([
+ model("gpt-6-pro", { family: "gpt-pro", releaseDate: "2026-09-23", cost: { output: premium } }),
+ model("glm-next", { family: "glm-next", releaseDate: "2026-09-23", status: "beta" }),
+ model("gpt-6-sol", { family: "gpt-sol", releaseDate: "2026-09-22", cost: { output: 10 } }),
+ ]),
+ ["gpt-6-sol", "glm-next", "gpt-6-pro"],
+ );
+ // models.dev uses `experimental` for extra request modes, not for maturity.
+ assert.deepEqual(
+ ids([
+ model("claude-opus-5-5", {
+ family: "claude-opus",
+ releaseDate: "2026-09-22",
+ experimental: { modes: { fast: {} } },
+ }),
+ model("claude-sonnet-5", { family: "claude-sonnet", releaseDate: "2026-06-29" }),
+ ]),
+ ["claude-opus-5-5", "claude-sonnet-5"],
+ );
+});
+
+test("an aggregator prefers known vendors over community routes", () => {
+ assert.deepEqual(
+ ids([
+ model("thedrummer/cydonia-24b", { family: "cydonia", releaseDate: "2026-09-23" }),
+ model("nousresearch/hermes-5", { family: "hermes", releaseDate: "2026-09-23" }),
+ model("anthropic/claude-opus-5.5", {
+ family: "claude-opus",
+ releaseDate: "2026-09-22",
+ cost: { output: 20 },
+ }),
+ model("openai/gpt-6-sol", { family: "gpt-sol", releaseDate: "2026-09-22", cost: { output: 10 } }),
+ model("Qwen/Qwen3.8-27B", { family: "qwen", releaseDate: "2026-08-14" }),
+ ]),
+ ["anthropic/claude-opus-5.5", "openai/gpt-6-sol", "Qwen/Qwen3.8-27B"],
+ );
+ // Unprefixed ids on a direct vendor are not routes and keep their place.
+ assert.deepEqual(
+ ids([
+ model("MiniMax/MiniMax-M2.7", { family: "minimax", releaseDate: "2026-03-18" }),
+ model("qwen3.8-flash", { family: "qwen", releaseDate: "2026-08-26" }),
+ ]),
+ ["qwen3.8-flash", "MiniMax/MiniMax-M2.7"],
+ );
+});
+
+test("models.dev-described models outrank ones it does not know", () => {
+ assert.deepEqual(
+ ids([
+ model("private-tuned", { catalogSource: undefined, toolCall: undefined, family: undefined }),
+ model("gpt-6-sol", { family: "gpt-sol", releaseDate: "2026-09-22" }),
+ ]).slice(0, 1),
+ ["gpt-6-sol"],
+ );
+});
+
+test("an undescribed list picks only its first chat model", () => {
+ const unknown = (modelId) =>
+ model(modelId, { catalogSource: undefined, toolCall: undefined, modalities: undefined });
+ assert.deepEqual(
+ ids([unknown("nomic-embed-text"), unknown("llama3.3:70b"), unknown("qwen3:32b")]),
+ ["llama3.3:70b"],
+ );
+});
+
+test("nothing qualifies, nothing is picked", () => {
+ assert.deepEqual(recommendModels([]), []);
+ assert.deepEqual(ids([model("text-embedding-3-small")]), []);
+ assert.deepEqual(recommendModels([model("gpt-6-sol")], 0), []);
+});
+
+test("only a list the service did not refuse is recommended from", () => {
+ const ready = (source, error) => ({ status: "ready", source, ...(error ? { error } : {}) });
+ assert.equal(canRecommendFrom(ready("remote"), false), true);
+ assert.equal(canRecommendFrom(ready("catalog"), false), true);
+ // A named vendor without a /models route still accepted the key.
+ assert.equal(canRecommendFrom(ready("catalog", "HTTP 404 Not Found"), true), true);
+ assert.equal(canRecommendFrom(ready("catalog", "HTTP 404 Not Found"), false), false);
+ // A refused key or an unreachable host says nothing about the key.
+ assert.equal(canRecommendFrom(ready("catalog", "HTTP 401 Unauthorized"), true), false);
+ assert.equal(canRecommendFrom(ready("catalog", "fetch failed"), true), false);
+ assert.equal(canRecommendFrom(ready("fallback"), true), false);
+ assert.equal(canRecommendFrom(ready("cache"), true), false);
+ assert.equal(canRecommendFrom({ status: "loading", source: "remote" }, true), false);
+ assert.equal(canRecommendFrom({ status: "error", source: "remote" }, true), false);
+});
+
+test("picks are the same bindings a manual pick creates", () => {
+ const [binding] = recommendModels([
+ model("gpt-6-sol", {
+ family: "gpt-sol",
+ releaseDate: "2026-09-22",
+ contextWindow: 400000,
+ maxTokens: 128000,
+ reasoning: true,
+ supportedThinkingLevels: ["low", "medium", "high"],
+ }),
+ ]);
+ assert.equal(binding.id, "gpt-6-sol");
+ assert.equal(binding.contextWindow, 400000);
+ assert.equal(binding.maxTokens, 128000);
+ assert.equal(binding.contextWindowSource, "catalog");
+ assert.equal(binding.defaultThinkingLevel, "medium");
+ assert.equal(binding.supportsImages, null);
+});
diff --git a/apps/desktop/test/service-chooser.test.mjs b/apps/desktop/test/service-chooser.test.mjs
new file mode 100644
index 000000000..6f61076e5
--- /dev/null
+++ b/apps/desktop/test/service-chooser.test.mjs
@@ -0,0 +1,138 @@
+import assert from "node:assert/strict";
+import { readFile } from "node:fs/promises";
+import test from "node:test";
+import { loadStyles } from "./helpers/styles.mjs";
+
+const read = (rel) => readFile(new URL(rel, import.meta.url), "utf8");
+
+const setupSource = await read("../src/components/settings/ProviderSetupDialog.tsx");
+const chooserSource = await read("../src/components/settings/ServiceChooser.tsx");
+const fieldsSource = await read("../src/components/settings/ProviderConnectionFields.tsx");
+const catalogSource = await read("../src/components/settings/service-catalog.ts");
+const hookSource = await read("../src/components/settings/useProviderModels.ts");
+const subagentPickerSource = await read("../src/components/settings/SubagentModelPicker.tsx");
+const menuSource = await read("../src/components/settings/AnchoredMenu.tsx");
+const styles = await loadStyles();
+
+const rule = (selector) => {
+ const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+ const match = styles.match(new RegExp(`(?:^|\\n)${escaped} \\{([^}]*)\\}`));
+ assert.ok(match, `${selector} rule is missing`);
+ return match[1];
+};
+
+test("a new service starts on a searchable chooser, not a closed menu (D623)", () => {
+ assert.match(setupSource, /<ServiceChooser/);
+ assert.match(setupSource, /const chooserOpen = choosing \|\| !service/);
+ assert.match(setupSource, /\{chooserOpen \? chooserView : formView\}/);
+ assert.doesNotMatch(setupSource, /<ServicePicker/);
+ assert.doesNotMatch(setupSource, /<optgroup/);
+ assert.match(chooserSource, /settings\.searchService/);
+ assert.match(chooserSource, /autoFocus/);
+ // Matching itself is covered behaviorally in service-catalog.test.mjs.
+ assert.match(chooserSource, /filterServiceOptions\(serviceOptions, query\)/);
+ assert.match(chooserSource, /filterServiceOptions\(subscriptionOptions, query\)/);
+ // Filtering stays in the renderer; a keystroke must not IPC.
+ assert.doesNotMatch(chooserSource, /\bapi\./);
+ assert.doesNotMatch(catalogSource, /\bapi\.\w+\(/);
+});
+
+test("subscriptions and API services share the chooser, custom endpoint last", () => {
+ assert.match(chooserSource, /\[\.\.\.namedServiceOptions\(t\), customServiceOption\(t\)\]/);
+ assert.match(chooserSource, /settings\.chooserSubscriptions/);
+ assert.match(chooserSource, /settings\.chooserApiKeys/);
+ const subscriptionsAt = chooserSource.indexOf("settings.chooserSubscriptions");
+ const apiKeysAt = chooserSource.indexOf("settings.chooserApiKeys");
+ assert.ok(subscriptionsAt < apiKeysAt, "subscriptions render above API services");
+ // One vendor can hold several accounts, so existing ones never disable it.
+ assert.match(chooserSource, /existing accounts do not disable a\s+vendor/);
+ assert.match(chooserSource, /vendors\.map/);
+ // Editing only changes the API service; subscriptions are not offered.
+ assert.match(setupSource, /vendors=\{editing \? null : vendors\}/);
+ assert.match(setupSource, /onPickSubscription=\{editing \? undefined : onPickSubscription\}/);
+ assert.doesNotMatch(chooserSource, /presetGroupInternational|presetGroupChina/);
+ assert.doesNotMatch(chooserSource, /NAMED_PRESET_GROUPS/);
+ assert.doesNotMatch(catalogSource, /NAMED_PRESET_GROUPS/);
+});
+
+test("the chooser answers the keyboard and never dead-ends", () => {
+ // Enter picks the first match, preferring a service over a browser sign-in.
+ assert.match(chooserSource, /event\.key === "Enter"/);
+ assert.match(chooserSource, /pickEnterTarget/);
+ assert.match(chooserSource, /is-active/);
+ assert.match(chooserSource, /ArrowDown/);
+ assert.match(chooserSource, /ArrowUp/);
+ assert.match(chooserSource, /searchRef\.current\?\.focus\(\)/);
+ // No match still offers the custom endpoint.
+ assert.match(chooserSource, /settings\.noServiceMatches/);
+ assert.match(chooserSource, /settings\.useCustomEndpoint/);
+ assert.match(chooserSource, /pickService\(CUSTOM_SERVICE\)/);
+ assert.match(chooserSource, /data-service-id=\{option\.id\}/);
+});
+
+test("chooser tiles are toned in-flow surfaces without strokes (D297)", () => {
+ const tile = rule(".service-chooser-tile");
+ assert.match(tile, /border: 0;/);
+ assert.match(tile, /background: var\(--ds-tile\);/);
+ assert.doesNotMatch(tile, /border: (?!0;)/);
+ assert.match(rule(".service-chooser-grid"), /repeat\(auto-fill, minmax\(200px, 1fr\)\)/);
+ assert.match(rule(".service-chooser-groups"), /overflow-y: auto;/);
+ for (const selector of [
+ ".service-chooser-search",
+ ".service-chooser-empty",
+ ".provider-models-summary",
+ ".provider-service-chip",
+ ]) {
+ assert.doesNotMatch(rule(selector), /\bborder(-(top|right|bottom|left|color|width|style))?:/, selector);
+ }
+});
+
+test("the chosen service is a settled chip with a Change action", () => {
+ assert.match(fieldsSource, /provider-service-chip/);
+ assert.match(fieldsSource, /settings\.changeService/);
+ assert.match(fieldsSource, /onClick=\{onChangeService\}/);
+ // A <label> wrapper would forward clicks on the row to the button.
+ assert.match(fieldsSource, /Not a Field/);
+ assert.match(setupSource, /settings\.changeServiceTitle/);
+});
+
+test("the shared service menu still portals above dialogs for model pickers", () => {
+ const menu = rule(".provider-service-menu");
+ assert.match(menu, /position: fixed;/);
+ assert.match(menu, /z-index: 60;/);
+ assert.match(menu, /max-height: min\(400px, calc\(100vh - 120px\)\);/);
+ assert.match(menu, /visibility: hidden;/);
+ assert.match(styles, /\.provider-service-menu\.is-open \{[^}]*visibility: visible;/);
+ assert.match(styles, /\.provider-service-results\s*\{[^}]*overflow-y: auto;/s);
+ assert.match(subagentPickerSource, /menuClassName="provider-service-menu"/);
+ assert.match(subagentPickerSource, /initialFocus="input"/);
+ assert.match(menuSource, /initialFocus === "input"/);
+ assert.match(menuSource, /anchorRef\?\.current \?\? triggerRef\.current/);
+});
+
+test("named add-path discovery waits for a key and does not flash loading", () => {
+ assert.match(setupSource, /discoveryActive/);
+ assert.match(setupSource, /Boolean\(apiKey\.trim\(\)\)/);
+ assert.match(setupSource, /custom \|\| Boolean\(apiKey\.trim\(\)\) \|\| Boolean\(provider\)/);
+ // Loading is painted inside the debounced run, not when the effect starts.
+ const runAt = hookSource.indexOf("const run = async");
+ const loadingAt = hookSource.indexOf('status: "loading"');
+ assert.ok(runAt !== -1 && loadingAt !== -1, "discovery run/loading missing");
+ assert.ok(runAt < loadingAt, "loading must start inside the debounced run");
+ assert.match(hookSource, /endpointChanged/);
+ assert.match(hookSource, /FETCH_DEBOUNCE_MS/);
+});
+
+test("the connection status line answers whether the key worked", () => {
+ assert.match(fieldsSource, /export function ConnectionStatus/);
+ assert.match(fieldsSource, /aria-live="polite"/);
+ assert.match(fieldsSource, /settings\.connectionKeyHint/);
+ assert.match(fieldsSource, /settings\.connectionChecking/);
+ assert.match(fieldsSource, /settings\.connectionReady/);
+ assert.match(fieldsSource, /canRecommendFrom\(discovery, named\)/);
+ assert.match(fieldsSource, /<ModelsFetchErrorMessage error=\{discovery\.error\} variant="status" \/>/);
+ // The status sits under the key on a named service.
+ const keyAt = fieldsSource.indexOf("provider-setup-key");
+ const statusAt = fieldsSource.indexOf("{status}", keyAt);
+ assert.ok(keyAt !== -1 && statusAt > keyAt, "status follows the key field");
+});
diff --git a/apps/desktop/test/service-picker.test.mjs b/apps/desktop/test/service-picker.test.mjs
deleted file mode 100644
index 81cca9d3e..000000000
--- a/apps/desktop/test/service-picker.test.mjs
+++ /dev/null
@@ -1,63 +0,0 @@
-import assert from "node:assert/strict";
-import { readFile } from "node:fs/promises";
-import test from "node:test";
-import { loadStyles } from "./helpers/styles.mjs";
-
-const read = (rel) => readFile(new URL(rel, import.meta.url), "utf8");
-
-const setupSource = await read("../src/components/settings/ProviderSetupDialog.tsx");
-const pickerSource = await read("../src/components/settings/ServicePicker.tsx");
-const catalogSource = await read("../src/components/settings/service-catalog.ts");
-const hookSource = await read("../src/components/settings/useProviderModels.ts");
-const menuSource = await read("../src/components/settings/AnchoredMenu.tsx");
-const styles = await loadStyles();
-
-test("the service control is a searchable anchored menu, not a native select", () => {
- assert.match(setupSource, /<ServicePicker/);
- assert.doesNotMatch(setupSource, /NAMED_PRESET_GROUPS\.map/);
- assert.doesNotMatch(setupSource, /<optgroup/);
- assert.match(pickerSource, /<AnchoredMenu/);
- assert.match(pickerSource, /settings\.searchService/);
- // Matching itself is covered behaviorally in service-catalog.test.mjs.
- assert.match(pickerSource, /filterServiceOptions\(options, query\)/);
- // Filtering stays in the renderer; a keystroke must not IPC.
- assert.doesNotMatch(pickerSource, /api\./);
- assert.doesNotMatch(catalogSource, /\bapi\.\w+\(/);
-});
-
-test("the service menu portals above the dialog overlay and hides until measured", () => {
- const menu = styles.match(/\.provider-service-menu \{([^}]*)\}/);
- assert.ok(menu, ".provider-service-menu rule is missing");
- assert.match(menu[1], /position: fixed;/);
- assert.match(menu[1], /z-index: 60;/);
- assert.match(menu[1], /max-height: min\(400px, calc\(100vh - 120px\)\);/);
- assert.match(menu[1], /visibility: hidden;/);
- assert.match(styles, /\.provider-service-menu\.is-open \{[^}]*visibility: visible;/);
- assert.match(styles, /\.provider-service-results\s*\{[^}]*overflow-y: auto;/s);
- assert.match(pickerSource, /initialFocus="input"/);
- assert.match(pickerSource, /restoreFocus=\{restoreFocus\}/);
- assert.match(menuSource, /initialFocus === "input"/);
- assert.match(menuSource, /anchorRef\?\.current \?\? triggerRef\.current/);
-});
-
-test("the service list is a flat vendor menu with custom first", () => {
- assert.match(pickerSource, /\[customServiceOption\(t\), \.\.\.namedServiceOptions\(t\)\]/);
- assert.match(pickerSource, /settings\.noServiceMatches/);
- assert.match(pickerSource, /role="option"/);
- assert.doesNotMatch(pickerSource, /presetGroupInternational|presetGroupChina/);
- assert.doesNotMatch(pickerSource, /NAMED_PRESET_GROUPS/);
- assert.doesNotMatch(catalogSource, /NAMED_PRESET_GROUPS/);
-});
-
-test("named add-path discovery waits for a key and does not flash loading", () => {
- assert.match(setupSource, /discoveryActive/);
- assert.match(setupSource, /Boolean\(apiKey\.trim\(\)\)/);
- assert.match(setupSource, /custom \|\| Boolean\(apiKey\.trim\(\)\) \|\| Boolean\(provider\)/);
- // Loading is painted inside the debounced run, not when the effect starts.
- const runAt = hookSource.indexOf("const run = async");
- const loadingAt = hookSource.indexOf('status: "loading"');
- assert.ok(runAt !== -1 && loadingAt !== -1, "discovery run/loading missing");
- assert.ok(runAt < loadingAt, "loading must start inside the debounced run");
- assert.match(hookSource, /endpointChanged/);
- assert.match(hookSource, /FETCH_DEBOUNCE_MS/);
-});
diff --git a/apps/desktop/test/settings-dialog-overlay.test.mjs b/apps/desktop/test/settings-dialog-overlay.test.mjs
index ec27b51f2..16e01d796 100644
--- a/apps/desktop/test/settings-dialog-overlay.test.mjs
+++ b/apps/desktop/test/settings-dialog-overlay.test.mjs
@@ -8,7 +8,6 @@ const read = (rel) => readFile(new URL(rel, import.meta.url), "utf8");
const overlaySources = [
"../src/components/settings/ProviderSetupDialog.tsx",
"../src/components/settings/VendorAccountDialog.tsx",
- "../src/components/settings/VendorPickerDialog.tsx",
"../src/components/settings/OAuthLoginDialog.tsx",
"../src/components/settings/SkillEditorSheet.tsx",
"../src/components/settings/SubagentEditorSheet.tsx",
diff --git a/apps/desktop/test/settings-general.test.mjs b/apps/desktop/test/settings-general.test.mjs
index 6d783c7d2..fb76871c3 100644
--- a/apps/desktop/test/settings-general.test.mjs
+++ b/apps/desktop/test/settings-general.test.mjs
@@ -56,8 +56,9 @@ const vendorAccountDialogSource = await readFile(
new URL("../src/components/settings/VendorAccountDialog.tsx", import.meta.url),
"utf8",
);
-const vendorPickerSource = await readFile(
- new URL("../src/components/settings/VendorPickerDialog.tsx", import.meta.url),
+// Subscriptions are picked in the service chooser since D623.
+const serviceChooserSource = await readFile(
+ new URL("../src/components/settings/ServiceChooser.tsx", import.meta.url),
"utf8",
);
const oauthSource = await readFile(
@@ -322,12 +323,13 @@ test("model configuration lists AI services and vendor accounts together", () =>
// Both credential kinds now pick from the same live, service-provided list.
assert.match(vendorAccountDialogSource, /useProviderModels/);
assert.match(vendorAccountDialogSource, /<ModelSelectionPanes/);
+ assert.match(vendorAccountDialogSource, /<ChosenModelsSummary/);
assert.match(vendorAccountDialogSource, /modelId: persisted\[0\]\.id/);
assert.match(vendorAccountsHookSource, /providerIsReady/);
assert.match(vendorAccountsHookSource, /defaultProviderId: next\?\.id \?\? ""/);
assert.match(vendorAccountsHookSource, /useAppStore\.setState\(\{ settings: nextSettings \}\)/);
- assert.match(vendorPickerSource, /existing accounts do not disable a vendor/);
- assert.match(vendorPickerSource, /vendors\.map/);
+ assert.match(serviceChooserSource, /existing accounts do not disable a\s+vendor/);
+ assert.match(serviceChooserSource, /vendors\.map/);
});
test("a service row opens its editor and keeps only a switch and one menu", () => {
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index 8e3c67662..0dbde3cad 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -1230,9 +1230,31 @@ sklm: {
"apiStyleChatCompletions": "OpenAI-Chat-Abschlüsse",
"apiStyleOpenCodeGo": "OpenCode Go",
"service": "Dienst",
- "chooseService": "Wählen Sie einen Dienst",
"searchService": "Dienste filtern",
"noServiceMatches": "Keine passenden Dienste.",
+ "useCustomEndpoint": "Eigenen Endpunkt verwenden",
+ "chooserSubscriptions": "Mit einem Abo anmelden",
+ "chooserApiKeys": "Mit einem API-Schlüssel verbinden",
+ "customEndpointDesc": "Jede OpenAI- oder Anthropic-kompatible URL",
+ "connectionKeyHint": "Fügen Sie einen API-Schlüssel ein, um zu verbinden und Modelle zu laden.",
+ "connectionUrlHint": "Geben Sie eine Basis-URL ein, um zu verbinden und Modelle zu laden.",
+ "connectionChecking": "Verbindung wird hergestellt…",
+ "connectionReady_one": "Verbunden · {{count}} Modell gefunden",
+ "connectionReady_other": "Verbunden · {{count}} Modelle gefunden",
+ "connectionCatalog_one": "{{count}} bekanntes Modell für diesen Dienst",
+ "connectionCatalog_other": "{{count}} bekannte Modelle für diesen Dienst",
+ "connectionNoModelList_one": "Dieser Dienst listet keine Modelle · {{count}} bekanntes Modell",
+ "connectionNoModelList_other": "Dieser Dienst listet keine Modelle · {{count}} bekannte Modelle",
+ "changeService": "Ändern",
+ "changeServiceTitle": "Dienst ändern",
+ "modelsSummaryTitle": "Modelle",
+ "modelsSummaryLoading": "Modelle werden geladen…",
+ "modelsSummaryFailed": "Modelle konnten nicht geladen werden. Prüfen Sie die Verbindung oben oder fügen Sie ein Modell per ID hinzu.",
+ "manageModels": "Modelle verwalten",
+ "collapseModels": "Einklappen",
+ "addModelManually": "Modell manuell hinzufügen",
+ "modelReasoningTag": "Reasoning",
+ "modelsAutoPicked": "Aus den empfohlenen Modellen ausgewählt. Unter „Modelle verwalten“ anpassen.",
"presetOpenai": "OpenAI",
"presetAnthropic": "Anthropic",
"presetGoogle": "Google Gemini",
@@ -1264,10 +1286,7 @@ sklm: {
"apiStylePiMessages": "Pi Messages (Radius)",
"close": "Schließen",
"vendorAccounts": "Lieferantenkonten",
- "vendorAddAccount": "Konto hinzufügen",
"vendorNoAccounts": "Es ist noch kein Lieferantenkonto angemeldet.",
- "vendorPickTitle": "Wählen Sie einen Anbieter.",
- "vendorPickDesc": "Wählen Sie einen Anbieter, bei dem Sie sich anmelden möchten. Sie können jederzeit ein weiteres Konto desselben Anbieters hinzufügen.",
"vendorSignInTo": "Melden Sie sich bei {{vendor}} an",
"vendorConnected": "Verbunden",
"vendorDisconnected": "Anmeldung erforderlich",
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index 45f564b82..254394e05 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -1245,9 +1245,31 @@ sklm: {
apiStyleChatCompletions: "OpenAI Chat Completions",
apiStyleOpenCodeGo: "OpenCode Go",
service: "Service",
- chooseService: "Choose a service",
searchService: "Filter services",
noServiceMatches: "No matching services.",
+ useCustomEndpoint: "Use a custom endpoint",
+ chooserSubscriptions: "Sign in with a subscription",
+ chooserApiKeys: "Connect with an API key",
+ customEndpointDesc: "Any OpenAI- or Anthropic-compatible URL",
+ connectionKeyHint: "Paste an API key to connect and load models.",
+ connectionUrlHint: "Enter a base URL to connect and load models.",
+ connectionChecking: "Connecting…",
+ connectionReady_one: "Connected · {{count}} model found",
+ connectionReady_other: "Connected · {{count}} models found",
+ connectionCatalog_one: "{{count}} known model for this service",
+ connectionCatalog_other: "{{count}} known models for this service",
+ connectionNoModelList_one: "This service doesn't list models · {{count}} known model",
+ connectionNoModelList_other: "This service doesn't list models · {{count}} known models",
+ changeService: "Change",
+ changeServiceTitle: "Change service",
+ modelsSummaryTitle: "Models",
+ modelsSummaryLoading: "Loading models…",
+ modelsSummaryFailed: "Couldn't load models. Check the connection above, or add a model by ID.",
+ manageModels: "Manage models",
+ collapseModels: "Collapse",
+ addModelManually: "Add a model manually",
+ modelReasoningTag: "Reasoning",
+ modelsAutoPicked: "Picked from the recommended models. Adjust them in Manage models.",
presetOpenai: "OpenAI",
presetAnthropic: "Anthropic",
presetGoogle: "Google Gemini",
@@ -1279,11 +1301,7 @@ sklm: {
apiStylePiMessages: "Pi Messages (Radius)",
close: "Close",
vendorAccounts: "Vendor accounts",
- vendorAddAccount: "Add account",
vendorNoAccounts: "No vendor account is signed in yet.",
- vendorPickTitle: "Choose a vendor",
- vendorPickDesc:
- "Choose a vendor to sign in with. You can add another account from the same vendor at any time.",
vendorSignInTo: "Sign in to {{vendor}}",
vendorConnected: "Connected",
vendorDisconnected: "Needs sign-in",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index dbb82d9cf..46be899c4 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -1230,9 +1230,31 @@ sklm: {
"apiStyleChatCompletions": "Finalizaciones de OpenAI Chat",
"apiStyleOpenCodeGo": "OpenCode Go",
"service": "Servicio",
- "chooseService": "Elija un servicio",
"searchService": "Filtrar servicios",
"noServiceMatches": "No hay servicios coincidentes.",
+ "useCustomEndpoint": "Usar un endpoint personalizado",
+ "chooserSubscriptions": "Iniciar sesión con una suscripción",
+ "chooserApiKeys": "Conectar con una clave de API",
+ "customEndpointDesc": "Cualquier URL compatible con OpenAI o Anthropic",
+ "connectionKeyHint": "Pegue una clave de API para conectar y cargar los modelos.",
+ "connectionUrlHint": "Introduzca una URL base para conectar y cargar los modelos.",
+ "connectionChecking": "Conectando…",
+ "connectionReady_one": "Conectado · {{count}} modelo encontrado",
+ "connectionReady_other": "Conectado · {{count}} modelos encontrados",
+ "connectionCatalog_one": "{{count}} modelo conocido para este servicio",
+ "connectionCatalog_other": "{{count}} modelos conocidos para este servicio",
+ "connectionNoModelList_one": "Este servicio no lista modelos · {{count}} modelo conocido",
+ "connectionNoModelList_other": "Este servicio no lista modelos · {{count}} modelos conocidos",
+ "changeService": "Cambiar",
+ "changeServiceTitle": "Cambiar servicio",
+ "modelsSummaryTitle": "Modelos",
+ "modelsSummaryLoading": "Cargando modelos…",
+ "modelsSummaryFailed": "No se pudieron cargar los modelos. Revise la conexión de arriba o añada un modelo por su ID.",
+ "manageModels": "Gestionar modelos",
+ "collapseModels": "Contraer",
+ "addModelManually": "Añadir un modelo manualmente",
+ "modelReasoningTag": "Razonamiento",
+ "modelsAutoPicked": "Elegidos entre los modelos recomendados. Ajústelos en Gestionar modelos.",
"presetOpenai": "OpenAI",
"presetAnthropic": "Antrópico",
"presetGoogle": "Google Gemini",
@@ -1264,10 +1286,7 @@ sklm: {
"apiStylePiMessages": "Mensajes Pi (Radius)",
"close": "Cerrar",
"vendorAccounts": "Cuentas de proveedores",
- "vendorAddAccount": "Agregar cuenta",
"vendorNoAccounts": "Aún no se ha iniciado sesión en ninguna cuenta de proveedor.",
- "vendorPickTitle": "Elija un proveedor",
- "vendorPickDesc": "Elija un proveedor con el que iniciar sesión. Puedes agregar otra cuenta del mismo proveedor en cualquier momento.",
"vendorSignInTo": "Inicia sesión en {{vendor}}",
"vendorConnected": "Conectado",
"vendorDisconnected": "Necesita iniciar sesión",
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index 7b971f479..b48b1afe8 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -1230,9 +1230,31 @@ sklm: {
"apiStyleChatCompletions": "Achèvements de discussion OpenAI",
"apiStyleOpenCodeGo": "OpenCode Go",
"service": "Service",
- "chooseService": "Choisissez un service",
"searchService": "Filtrer les services",
"noServiceMatches": "Aucun service correspondant.",
+ "useCustomEndpoint": "Utiliser un endpoint personnalisé",
+ "chooserSubscriptions": "Se connecter avec un abonnement",
+ "chooserApiKeys": "Se connecter avec une clé API",
+ "customEndpointDesc": "Toute URL compatible OpenAI ou Anthropic",
+ "connectionKeyHint": "Collez une clé API pour vous connecter et charger les modèles.",
+ "connectionUrlHint": "Saisissez une URL de base pour vous connecter et charger les modèles.",
+ "connectionChecking": "Connexion…",
+ "connectionReady_one": "Connecté · {{count}} modèle trouvé",
+ "connectionReady_other": "Connecté · {{count}} modèles trouvés",
+ "connectionCatalog_one": "{{count}} modèle connu pour ce service",
+ "connectionCatalog_other": "{{count}} modèles connus pour ce service",
+ "connectionNoModelList_one": "Ce service ne liste pas ses modèles · {{count}} modèle connu",
+ "connectionNoModelList_other": "Ce service ne liste pas ses modèles · {{count}} modèles connus",
+ "changeService": "Modifier",
+ "changeServiceTitle": "Changer de service",
+ "modelsSummaryTitle": "Modèles",
+ "modelsSummaryLoading": "Chargement des modèles…",
+ "modelsSummaryFailed": "Impossible de charger les modèles. Vérifiez la connexion ci-dessus ou ajoutez un modèle par son ID.",
+ "manageModels": "Gérer les modèles",
+ "collapseModels": "Réduire",
+ "addModelManually": "Ajouter un modèle manuellement",
+ "modelReasoningTag": "Raisonnement",
+ "modelsAutoPicked": "Choisis parmi les modèles recommandés. Ajustez-les dans Gérer les modèles.",
"presetOpenai": "OpenAI",
"presetAnthropic": "Anthropique",
"presetGoogle": "Google Gemini",
@@ -1264,10 +1286,7 @@ sklm: {
"apiStylePiMessages": "Pi Messages (Radius)",
"close": "Fermer",
"vendorAccounts": "Comptes fournisseurs",
- "vendorAddAccount": "Ajouter un compte",
"vendorNoAccounts": "Aucun compte fournisseur n'est encore connecté.",
- "vendorPickTitle": "Choisissez un fournisseur",
- "vendorPickDesc": "Choisissez un fournisseur avec lequel vous connecter. Vous pouvez ajouter un autre compte du même fournisseur à tout moment.",
"vendorSignInTo": "Connectez-vous à {{vendor}}",
"vendorConnected": "Connecté",
"vendorDisconnected": "Connexion nécessaire",
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index 2fc3011dd..ddf1a7501 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -1243,9 +1243,31 @@ sklm: {
apiStyleChatCompletions: "OpenAI Chat Completions",
apiStyleOpenCodeGo: "OpenCode Go",
service: "서비스",
- chooseService: "서비스 선택",
searchService: "서비스 필터",
noServiceMatches: "일치하는 서비스가 없습니다.",
+ useCustomEndpoint: "사용자 지정 엔드포인트 사용",
+ chooserSubscriptions: "구독으로 로그인",
+ chooserApiKeys: "API 키로 연결",
+ customEndpointDesc: "OpenAI 또는 Anthropic 호환 URL",
+ connectionKeyHint: "API 키를 붙여 넣으면 연결하고 모델을 불러옵니다.",
+ connectionUrlHint: "기본 URL을 입력하면 연결하고 모델을 불러옵니다.",
+ connectionChecking: "연결 중…",
+ connectionReady_one: "연결됨 · 모델 {{count}}개 발견",
+ connectionReady_other: "연결됨 · 모델 {{count}}개 발견",
+ connectionCatalog_one: "이 서비스의 알려진 모델 {{count}}개",
+ connectionCatalog_other: "이 서비스의 알려진 모델 {{count}}개",
+ connectionNoModelList_one: "이 서비스는 모델 목록을 제공하지 않습니다 · 알려진 모델 {{count}}개",
+ connectionNoModelList_other: "이 서비스는 모델 목록을 제공하지 않습니다 · 알려진 모델 {{count}}개",
+ changeService: "변경",
+ changeServiceTitle: "서비스 변경",
+ modelsSummaryTitle: "모델",
+ modelsSummaryLoading: "모델을 불러오는 중…",
+ modelsSummaryFailed: "모델을 불러오지 못했습니다. 위의 연결을 확인하거나 ID로 모델을 추가하세요.",
+ manageModels: "모델 관리",
+ collapseModels: "접기",
+ addModelManually: "모델 직접 추가",
+ modelReasoningTag: "추론",
+ modelsAutoPicked: "추천 모델이 자동으로 선택되었습니다. 모델 관리에서 조정할 수 있습니다.",
presetOpenai: "OpenAI",
presetAnthropic: "Anthropic",
presetGoogle: "Google Gemini",
@@ -1277,11 +1299,7 @@ sklm: {
apiStylePiMessages: "Pi Messages (Radius)",
close: "닫기",
vendorAccounts: "벤더 계정",
- vendorAddAccount: "계정 추가",
vendorNoAccounts: "로그인한 벤더 계정이 아직 없습니다.",
- vendorPickTitle: "벤더 선택",
- vendorPickDesc:
- "로그인할 벤더를 선택하세요. 같은 벤더의 다른 계정도 언제든 추가할 수 있습니다.",
vendorSignInTo: "{{vendor}}에 로그인",
vendorConnected: "연결됨",
vendorDisconnected: "로그인 필요",
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index 575ab4cac..05709788f 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -1233,9 +1233,31 @@ sklm: {
apiStyleChatCompletions: "OpenAI Chat Completions",
apiStyleOpenCodeGo: "OpenCode Go",
service: "Servis",
- chooseService: "Servis seçin",
searchService: "Servisleri süz",
noServiceMatches: "Eşleşen servis yok.",
+ useCustomEndpoint: "Özel uç nokta kullan",
+ chooserSubscriptions: "Abonelikle oturum aç",
+ chooserApiKeys: "API anahtarıyla bağlan",
+ customEndpointDesc: "OpenAI veya Anthropic uyumlu herhangi bir URL",
+ connectionKeyHint: "Bağlanmak ve modelleri yüklemek için bir API anahtarı yapıştırın.",
+ connectionUrlHint: "Bağlanmak ve modelleri yüklemek için bir temel URL girin.",
+ connectionChecking: "Bağlanıyor…",
+ connectionReady_one: "Bağlandı · {{count}} model bulundu",
+ connectionReady_other: "Bağlandı · {{count}} model bulundu",
+ connectionCatalog_one: "Bu servis için bilinen {{count}} model",
+ connectionCatalog_other: "Bu servis için bilinen {{count}} model",
+ connectionNoModelList_one: "Bu servis model listelemiyor · bilinen {{count}} model",
+ connectionNoModelList_other: "Bu servis model listelemiyor · bilinen {{count}} model",
+ changeService: "Değiştir",
+ changeServiceTitle: "Servisi değiştir",
+ modelsSummaryTitle: "Modeller",
+ modelsSummaryLoading: "Modeller yükleniyor…",
+ modelsSummaryFailed: "Modeller yüklenemedi. Yukarıdaki bağlantıyı kontrol edin veya kimliğiyle bir model ekleyin.",
+ manageModels: "Modelleri yönet",
+ collapseModels: "Daralt",
+ addModelManually: "Elle model ekle",
+ modelReasoningTag: "Akıl yürütme",
+ modelsAutoPicked: "Önerilen modeller seçildi. Modelleri yönet bölümünden değiştirebilirsiniz.",
presetOpenai: "OpenAI",
presetAnthropic: "Anthropic",
presetGoogle: "Google Gemini",
@@ -1267,11 +1289,7 @@ sklm: {
apiStylePiMessages: "Pi Messages (Radius)",
close: "Kapat",
vendorAccounts: "Satıcı hesapları",
- vendorAddAccount: "Hesap ekle",
vendorNoAccounts: "Henüz oturum açılmış satıcı hesabı yok.",
- vendorPickTitle: "Satıcı seçin",
- vendorPickDesc:
- "Oturum açmak için bir satıcı seçin. Aynı satıcıdan istediğiniz zaman başka hesap ekleyebilirsiniz.",
vendorSignInTo: "{{vendor}} ile oturum aç",
vendorConnected: "Bağlı",
vendorDisconnected: "Oturum açılmalı",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index 05b03d4cf..92d3e6254 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -1217,9 +1217,31 @@ sklm: {
apiStyleChatCompletions: "OpenAI Chat Completions",
apiStyleOpenCodeGo: "OpenCode Go",
service: "服务",
- chooseService: "选择服务",
searchService: "筛选服务",
noServiceMatches: "没有匹配的服务。",
+ useCustomEndpoint: "使用自定义端点",
+ chooserSubscriptions: "用订阅登录",
+ chooserApiKeys: "用 API Key 连接",
+ customEndpointDesc: "任意 OpenAI 或 Anthropic 兼容地址",
+ connectionKeyHint: "粘贴 API Key 后自动连接并获取模型。",
+ connectionUrlHint: "填写地址后自动连接并获取模型。",
+ connectionChecking: "正在连接…",
+ connectionReady_one: "已连接 · 发现 {{count}} 个模型",
+ connectionReady_other: "已连接 · 发现 {{count}} 个模型",
+ connectionCatalog_one: "该服务已知 {{count}} 个模型",
+ connectionCatalog_other: "该服务已知 {{count}} 个模型",
+ connectionNoModelList_one: "该服务不提供模型列表 · 已知 {{count}} 个模型",
+ connectionNoModelList_other: "该服务不提供模型列表 · 已知 {{count}} 个模型",
+ changeService: "更换",
+ changeServiceTitle: "更换服务",
+ modelsSummaryTitle: "模型",
+ modelsSummaryLoading: "正在获取模型…",
+ modelsSummaryFailed: "无法获取模型。请检查上方的连接,或按 ID 手动添加。",
+ manageModels: "管理模型",
+ collapseModels: "收起",
+ addModelManually: "手动添加模型",
+ modelReasoningTag: "推理",
+ modelsAutoPicked: "已按推荐自动选择,可在「管理模型」中调整。",
presetOpenai: "OpenAI",
presetAnthropic: "Anthropic",
presetGoogle: "Google Gemini",
@@ -1251,10 +1273,7 @@ sklm: {
apiStylePiMessages: "Pi Messages (Radius)",
close: "关闭",
vendorAccounts: "厂商账户",
- vendorAddAccount: "添加账户",
vendorNoAccounts: "还没有登录任何厂商账户。",
- vendorPickTitle: "选择厂商",
- vendorPickDesc: "选择要登录的厂商;同一厂商可以随时再次添加其他账户。",
vendorSignInTo: "登录 {{vendor}}",
vendorConnected: "已连接",
vendorDisconnected: "需要重新登录",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index b55fbb051..944f0a388 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -1217,9 +1217,31 @@ sklm: {
apiStyleChatCompletions: "OpenAI Chat Completions",
apiStyleOpenCodeGo: "OpenCode Go",
service: "服務",
- chooseService: "選擇服務",
searchService: "篩選服務",
noServiceMatches: "沒有匹配的服務。",
+ useCustomEndpoint: "使用自訂端點",
+ chooserSubscriptions: "用訂閱登入",
+ chooserApiKeys: "用 API Key 連線",
+ customEndpointDesc: "任意 OpenAI 或 Anthropic 相容位址",
+ connectionKeyHint: "貼上 API Key 後自動連線並取得模型。",
+ connectionUrlHint: "填寫位址後自動連線並取得模型。",
+ connectionChecking: "正在連線…",
+ connectionReady_one: "已連線 · 發現 {{count}} 個模型",
+ connectionReady_other: "已連線 · 發現 {{count}} 個模型",
+ connectionCatalog_one: "該服務已知 {{count}} 個模型",
+ connectionCatalog_other: "該服務已知 {{count}} 個模型",
+ connectionNoModelList_one: "該服務不提供模型清單 · 已知 {{count}} 個模型",
+ connectionNoModelList_other: "該服務不提供模型清單 · 已知 {{count}} 個模型",
+ changeService: "更換",
+ changeServiceTitle: "更換服務",
+ modelsSummaryTitle: "模型",
+ modelsSummaryLoading: "正在取得模型…",
+ modelsSummaryFailed: "無法取得模型。請檢查上方的連線,或依 ID 手動新增。",
+ manageModels: "管理模型",
+ collapseModels: "收起",
+ addModelManually: "手動新增模型",
+ modelReasoningTag: "推理",
+ modelsAutoPicked: "已依推薦自動選擇,可在「管理模型」中調整。",
presetOpenai: "OpenAI",
presetAnthropic: "Anthropic",
presetGoogle: "Google Gemini",
@@ -1251,10 +1273,7 @@ sklm: {
apiStylePiMessages: "Pi Messages (Radius)",
close: "關閉",
vendorAccounts: "廠商賬戶",
- vendorAddAccount: "新增賬戶",
vendorNoAccounts: "還沒有登入任何廠商賬戶。",
- vendorPickTitle: "選擇廠商",
- vendorPickDesc: "選擇要登入的廠商;同一廠商可以隨時再次新增其他賬戶。",
vendorSignInTo: "登入 {{vendor}}",
vendorConnected: "已連線",
vendorDisconnected: "需要重新登入",