Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(settings): list subscriptions and API services together
vastsad2b73f8c315a
diff --git a/apps/desktop/electron/main/bootstrap/window.ts b/apps/desktop/electron/main/bootstrap/window.tsindex 6ff288512..a3063ac36 100644--- a/apps/desktop/electron/main/bootstrap/window.ts+++ b/apps/desktop/electron/main/bootstrap/window.ts@@ -1854,16 +1854,17 @@ export async function createWindow({// which is still dark from the destination pass; the remaining// settings scenes are light so the tabs read as one sequence.await setTheme("light");- // Model configuration tab: vendor accounts, provider cards,- // defaults, edit dialog. Addressed by tab id — the settings nav+ // Model configuration tab: defaults, the service list (API services+ // and subscription accounts together), then a row's editor — a row+ // opens its own editor. Addressed by tab id — the settings nav// has been reordered since this scene was written.await setSettingsTab("agent");await new Promise((r) => setTimeout(r, 350));await shot("pi-settings-models");await windowState.mainWindow!.webContents.executeJavaScript(`(() => {- const edit = [...document.querySelectorAll('.provider-row-actions .provider-icon-btn')][0];- const add = document.querySelector('.provider-section-head button');+ const edit = document.querySelector('.model-provider-row.is-openable');+ const add = document.querySelector('.model-provider-add');(edit ?? add)?.dispatchEvent(new MouseEvent('click',{bubbles:true}));})()`);diff --git a/apps/desktop/src/components/settings/AgentCapabilityLayout.tsx b/apps/desktop/src/components/settings/AgentCapabilityLayout.tsxindex c63a8892b..1a5aec724 100644--- a/apps/desktop/src/components/settings/AgentCapabilityLayout.tsx+++ b/apps/desktop/src/components/settings/AgentCapabilityLayout.tsx@@ -446,18 +446,23 @@ export type CapabilityMenuItem = {/*** Overflow menu for one row. Open state is owned by the page so only one row's* menu can be open, and Escape or any outside press dismisses it.+ *+ * `restoreFocus` is false while the chosen item opens something that takes+ * focus itself, such as a dialog, which the trigger would otherwise take back.*/export function CapabilityRowMenu({label,items,open,disabled,+ restoreFocus,onOpenChange,}: {label: string;items: readonly CapabilityMenuItem[];open: boolean;disabled?: boolean;+ restoreFocus?: boolean;onOpenChange: (open: boolean) => void;}) {return (@@ -469,6 +474,7 @@ export function CapabilityRowMenu({label={label}role="menu"align="end"+ restoreFocus={restoreFocus}trigger={(ref) => (<TooltipButtonref={ref}diff --git a/apps/desktop/src/components/settings/ModelConfigPage.tsx b/apps/desktop/src/components/settings/ModelConfigPage.tsxindex 3f9a015ac..fd0dd1925 100644--- a/apps/desktop/src/components/settings/ModelConfigPage.tsx+++ b/apps/desktop/src/components/settings/ModelConfigPage.tsx@@ -1,16 +1,19 @@/**- * Model configuration tab: default model, configured AI services, OAuth- * vendor accounts, and the models.dev enrichment snapshot status.+ * Model configuration tab: default model, the AI service list, and the+ * models.dev enrichment snapshot status.+ *+ * API services, plugin-declared services and vendor subscription accounts+ * share one list (D623). An account row still lives and dies through the+ * vendor-account editor and `deleteOauthAccount`, never the provider CRUD.** The default picker lists each configured model, while provider rows use* `models[0]` as the provider's quick default. Editing the default provider* preserves `settings.defaultModelId` while that model remains configured, and* adding a provider claims the chat or image default only while none resolves.*/-import { useEffect, useMemo, useRef, useState } from "react";+import { useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";import {- OAUTH_AUTH_KIND,imageGenerationBindings,isImageGenerationModel,modelIdsMatch,@@ -21,19 +24,15 @@ import {import { useAppStore } from "../../stores/app-store";import { api } from "../../lib/api";import { providerDisplayName, providerSearchText } from "../../lib/provider-display";-import { Badge, Button, Field, Input, TooltipButton, cx } from "../ui";+import { Button, Input, cx } from "../ui";import {IconCheck,IconChevronDown,IconConfig,- IconCopy,IconKey,- IconPencil,- IconPlug,IconPlus,IconServer,IconSearch,- IconTrash,} from "../icons";import { AnchoredMenu } from "./AnchoredMenu";import {@@ -45,11 +44,13 @@ import {import { planImageGenerationDefaults } from "./image-generation-default";import { copyProviderConfiguration, type ProviderCopyDraft } from "./provider-copy";import { ImageGenerationModelRow } from "./ImageGenerationModelRow";+import { OAuthLoginDialog } from "./OAuthLoginDialog";import { ProviderSetupDialog } from "./ProviderSetupDialog";-import { useProviderReorder } from "./useProviderReorder";-import { VendorAccountsSection } from "./VendorAccountsSection";--const DELETE_CONFIRM_MS = 3000;+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;@@ -61,16 +62,6 @@ type CatalogStatus = {lastError?: string;};-/** Host part of a base URL, or an em dash when nothing is configured. */-function hostFromBaseUrl(baseUrl?: string | null): string {- if (!baseUrl) return "—";- try {- return new URL(baseUrl).host || baseUrl;- } catch {- return baseUrl.replace(/^https?:\/\//, "").split("/")[0] || baseUrl;- }-}-export function ModelConfigPage() {const { t, i18n } = useTranslation();const providers = useAppStore((s) => s.providers);@@ -88,22 +79,20 @@ export function ModelConfigPage() {const [changingImageModel, setChangingImageModel] = useState(false);const [refreshingCatalog, setRefreshingCatalog] = useState(false);const [catalogStatus, setCatalogStatus] = useState<CatalogStatus | null>(null);- // Two-step delete: the first click arms the row, the second removes it.- // Two-step delete: the first click arms the row, the second removes it.- const [confirmDeleteId, setConfirmDeleteId] = useState<string | null>(null);- // Inline API-key entry for a plugin-declared row. The plugin owns the- // provider's fields, so the user supplies only the credential it asks for.- const [keyFor, setKeyFor] = useState<string | null>(null);- const [keyValue, setKeyValue] = useState("");- const confirmTimer = useRef<ReturnType<typeof setTimeout> | null>(null);-- useEffect(() => {- if (!confirmDeleteId) return;- confirmTimer.current = setTimeout(() => setConfirmDeleteId(null), DELETE_CONFIRM_MS);- return () => {- if (confirmTimer.current) clearTimeout(confirmTimer.current);- };- }, [confirmDeleteId]);+ const {+ vendors,+ accountFor,+ login,+ busyAccountId,+ savingAccount,+ startLogin,+ finishLogin,+ closeLogin,+ removeAccount,+ saveAccount,+ } = useVendorAccounts();+ const [pickingVendor, setPickingVendor] = useState(false);+ const [editingAccountId, setEditingAccountId] = useState<string | null>(null);useEffect(() => {void (async () => {@@ -126,11 +115,6 @@ export function ModelConfigPage() {const providerReady = (provider: ProviderPublic) =>providerServesChatModels(provider, imageGenerationCandidates);- const aiProviders = useMemo(- () => providers.filter((provider) => provider.authKind !== OAUTH_AUTH_KIND),- [providers],- );- const reorder = useProviderReorder(aiProviders, busyId !== null || testingId !== null || setupFor !== null);const readyProviders = providers.filter(providerReady);const defaultModelOptionsList = defaultModelOptions(readyProviders, imageGenerationCandidates);const visibleDefaultModelOptions = useMemo(() => {@@ -148,6 +132,9 @@ export function ModelConfigPage() {providers.find((provider) => provider.id === settings.defaultProviderId) ?? null;const editingProvider =setupFor ? providers.find((provider) => provider.id === setupFor) ?? null : null;+ const editingAccount = editingAccountId+ ? providers.find((provider) => provider.id === editingAccountId) ?? null+ : null;const defaultProviderReady = defaultProvider !== null && providerReady(defaultProvider) &&!isImageGenerationModel(imageGenerationCandidates, defaultProvider.id,displayedDefaultModelId(defaultProvider, settings.defaultModelId));@@ -295,7 +282,6 @@ export function ModelConfigPage() {};const removeProvider = async (provider: ProviderPublic) => {- setConfirmDeleteId(null);setBusyId(provider.id);try {await api.deleteProvider(provider.id);@@ -310,26 +296,31 @@ export function ModelConfigPage() {}};+ /** Resolves true once the key is stored, so the row can close its entry. */const saveProviderKey = async (provider: ProviderPublic, value: string) => {setBusyId(provider.id);try {await api.setProviderSecret({ id: provider.id, secretValue: value });await refreshProviders();- setKeyFor(null);- setKeyValue("");showToast(t(value.trim() ? "settings.pluginProviderKeySaved" : "settings.pluginProviderKeyRemoved"),{ variant: "success" },);+ return true;} catch (error) {showToast(error instanceof Error ? error.message : String(error), {variant: "error",});+ return false;} finally {setBusyId(null);}};+ const saveEditingAccount = async (provider: ProviderPublic, form: VendorAccountForm) => {+ if (await saveAccount(provider, form)) setEditingAccountId(null);+ };+const testProvider = async (provider: ProviderPublic) => {setTestingId(provider.id);try {@@ -519,20 +510,38 @@ export function ModelConfigPage() {<div className="model-config-section-head"><div className="settings-card-heading-line"><h3 className="settings-card-heading">{t("settings.providers")}</h3>- {aiProviders.length > 0 ? (- <span className="provider-section-count">{aiProviders.length}</span>+ {providers.length > 0 ? (+ <span className="provider-section-count">{providers.length}</span>) : null}</div>- <Button variant="primary" onClick={() => setSetupFor("")}>- <span className="model-config-btn-inner">- <IconPlus size={14} />- <span>{t("settings.addProvider")}</span>- </span>- </Button>+ <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"+ onClick={() => setSetupFor("")}+ >+ <span className="model-config-btn-inner">+ <IconPlus size={14} />+ <span>{t("settings.addProvider")}</span>+ </span>+ </Button>+ </div></div><div className="settings-panel model-provider-panel">- {aiProviders.length === 0 ? (+ {providers.length === 0 ? (<div className="model-provider-empty"><div className="model-provider-empty-icon" aria-hidden><IconServer size={18} />@@ -547,239 +556,56 @@ export function ModelConfigPage() {</Button></div>) : (- <ul className="model-provider-list" aria-busy={reorder.saving}>- {reorder.providers.map((provider) => {- const isDefault = settings.defaultProviderId === provider.id;- const rowBusy = reorder.saving || busyId === provider.id || testingId === provider.id;- const confirming = confirmDeleteId === provider.id;- const modelCount = provider.models?.length ?? 0;- // A plugin-declared row is refreshed from the plugin's manifest- // on every load, so its fields and its enabled switch are not- // the user's to change. The credential is.- const ownedByPlugin = provider.ownerPluginId;- const keyEntry = keyFor === provider.id;- return (- <li- key={provider.id}- className={cx("model-provider-row", !provider.enabled && "is-disabled", reorder.draggingId === provider.id && "is-dragging")}- data-provider-id={provider.id}- aria-label={t("settings.reorderProvider", { name: provider.name })}- ref={reorder.rowRef(provider.id)}- {...reorder.rowEvents(provider.id)}- >- <div className="model-provider-row-copy">- <div className="model-provider-row-title">- <span className="model-provider-row-name">{provider.name}</span>- {isDefault ? (- <Badge tone="success">{t("settings.default")}</Badge>- ) : null}- {!provider.hasSecret && provider.authKind !== "none" ? (- <Badge tone="warning">{t("settings.noSecret")}</Badge>- ) : null}- {!provider.enabled ? (- <Badge tone="neutral">{t("settings.providerDisabledBadge")}</Badge>- ) : null}- {ownedByPlugin ? (- <span- title={t("settings.pluginProviderManaged", {- plugin: ownedByPlugin,- })}- >- <Badge tone="neutral">{t("settings.pluginProviderBadge")}</Badge>- </span>- ) : null}- </div>- <div className="model-provider-row-meta">- <span>{hostFromBaseUrl(provider.baseUrl)}</span>- <span className="model-provider-meta-dot" aria-hidden>- ·- </span>- <span>{t("settings.providerModelCount", { count: modelCount })}</span>- {ownedByPlugin ? (- <>- <span className="model-provider-meta-dot" aria-hidden>- ·- </span>- <span>{t("settings.pluginProviderBy", { plugin: ownedByPlugin })}</span>- </>- ) : null}- </div>- </div>-- <div className="model-provider-row-actions">- {!isDefault ? (- <Button- size="sm"- variant="ghost"- disabled={rowBusy || !providerReady(provider)}- onClick={() =>- void setDefaultModel(provider, defaultModelOptions([provider], imageGenerationCandidates)[0]?.modelId ?? "")- }- >- {t("settings.makeDefault")}- </Button>- ) : null}- {!ownedByPlugin ? (- <TooltipButton- type="button"- className="icon-btn icon-btn-square model-provider-icon-btn"- tooltip={t("settings.copyProvider")}- ariaLabel={t("settings.copyProvider")}- disabled={rowBusy}- onClick={() => {- setCopyDraft(copyProviderConfiguration(provider, t("settings.copyProviderName", { name: provider.name })));- setSetupFor("");- }}- >- <IconCopy size={14} />- </TooltipButton>- ) : null}- {ownedByPlugin && provider.authKind === "api_key" ? (- <TooltipButton- type="button"- className="icon-btn icon-btn-square model-provider-icon-btn"- tooltip={t("settings.pluginProviderKey")}- ariaLabel={t("settings.pluginProviderKey")}- disabled={rowBusy}- onClick={() => {- setKeyFor(keyEntry ? null : provider.id);- setKeyValue("");- }}- >- <IconKey size={14} />- </TooltipButton>- ) : null}- <TooltipButton- type="button"- className="icon-btn icon-btn-square model-provider-icon-btn"- tooltip={- ownedByPlugin- ? t("settings.pluginProviderManaged", { plugin: ownedByPlugin })- : t("settings.editProvider")- }- ariaLabel={t("settings.editProvider")}- disabled={rowBusy || Boolean(ownedByPlugin)}- onClick={() => setSetupFor(provider.id)}- >- <IconPencil size={14} />- </TooltipButton>- <TooltipButton- type="button"- className={cx(- "icon-btn icon-btn-square model-provider-icon-btn",- testingId === provider.id && "is-testing",- )}- tooltip={t("settings.testConnection")}- ariaLabel={t("settings.testConnection")}- disabled={rowBusy}- onClick={() => void testProvider(provider)}- >- <IconPlug size={14} />- </TooltipButton>- {confirming ? (- <button- type="button"- className="model-provider-delete-confirm"- disabled={rowBusy}- onBlur={() => setConfirmDeleteId(null)}- onClick={() => void removeProvider(provider)}- >- {t("settings.deleteConfirm")}- </button>- ) : (- <TooltipButton- type="button"- className="icon-btn icon-btn-square model-provider-icon-btn is-danger"- tooltip={- ownedByPlugin- ? t("settings.pluginProviderManaged", { plugin: ownedByPlugin })- : t("settings.delete")- }- ariaLabel={t("settings.delete")}- disabled={rowBusy || Boolean(ownedByPlugin)}- onClick={() => setConfirmDeleteId(provider.id)}- >- <IconTrash size={14} />- </TooltipButton>- )}- <TooltipButton- type="button"- className={cx("settings-toggle", provider.enabled && "on")}- role="switch"- aria-checked={provider.enabled}- tooltip={- ownedByPlugin- ? t("settings.pluginProviderManaged", { plugin: ownedByPlugin })- : t("settings.enabledToggle")- }- ariaLabel={t("settings.enabledToggle")}- disabled={rowBusy || Boolean(ownedByPlugin)}- onClick={() => void toggleEnabled(provider)}- >- <span className="settings-toggle-thumb" />- </TooltipButton>- </div>- {keyEntry ? (- <div className="model-provider-key-entry">- <Field- label={t("settings.pluginProviderKey")}- hint={t("settings.pluginProviderKeyHint")}- >- <Input- type="password"- autoFocus- value={keyValue}- placeholder={- provider.hasSecret ? t("settings.apiKeyKeepHint") : undefined- }- onChange={(event) => setKeyValue(event.target.value)}- onKeyDown={(event) => {- if (event.key === "Escape") setKeyFor(null);- if (event.key === "Enter") {- void saveProviderKey(provider, keyValue);- }- }}- />- </Field>- <div className="model-provider-key-actions">- <Button- size="sm"- variant="ghost"- disabled={rowBusy}- onClick={() => setKeyFor(null)}- >- {t("settings.cancel")}- </Button>- {provider.hasSecret ? (- <Button- size="sm"- variant="ghost"- disabled={rowBusy}- onClick={() => void saveProviderKey(provider, "")}- >- {t("settings.pluginProviderKeyRemove")}- </Button>- ) : null}- <Button- size="sm"- disabled={rowBusy || !keyValue.trim()}- onClick={() => void saveProviderKey(provider, keyValue)}- >- {t("settings.save")}- </Button>- </div>- </div>- ) : null}- </li>+ <ServiceList+ providers={providers}+ defaultProviderId={settings.defaultProviderId}+ isReady={providerReady}+ accountFor={accountFor}+ busy={+ busyId !== null ||+ testingId !== null ||+ setupFor !== null ||+ editingAccountId !== null ||+ busyAccountId !== null ||+ savingAccount ||+ login !== null ||+ pickingVendor+ }+ isRowBusy={(id) => busyId === id || testingId === id || busyAccountId === id}+ testingId={testingId}+ onEdit={(provider) =>+ serviceRowKind(provider) === "account"+ ? setEditingAccountId(provider.id)+ : setSetupFor(provider.id)+ }+ onMakeDefault={(provider) =>+ void setDefaultModel(+ provider,+ defaultModelOptions([provider], imageGenerationCandidates)[0]?.modelId ?? "",+ )+ }+ onTest={(provider) => void testProvider(provider)}+ onCopy={(provider) => {+ setCopyDraft(+ copyProviderConfiguration(+ provider,+ t("settings.copyProviderName", { name: provider.name }),+ ),);- })}- </ul>+ setSetupFor("");+ }}+ onToggleEnabled={(provider) => void toggleEnabled(provider)}+ onRemove={(provider) =>+ void (serviceRowKind(provider) === "account"+ ? removeAccount(provider)+ : removeProvider(provider))+ }+ onSaveKey={saveProviderKey}+ />)}</div></section>- <VendorAccountsSection />-<div className="model-catalog-status"><span className="model-catalog-status-text">{catalogStatus@@ -824,6 +650,42 @@ export function ModelConfigPage() {onSaved={afterSaved}/>) : null}++ {pickingVendor && vendors ? (+ <VendorPickerDialog+ vendors={vendors}+ onPick={(vendor) => {+ setPickingVendor(false);+ // 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}++ {editingAccount ? (+ <VendorAccountDialog+ provider={editingAccount}+ initialName={+ accountFor(editingAccount.id)?.account.accountLabel ||+ editingAccount.oauthAccountLabel ||+ editingAccount.name+ }+ saving={savingAccount}+ onClose={() => setEditingAccountId(null)}+ onSave={(form) => void saveEditingAccount(editingAccount, form)}+ />+ ) : null}++ {login ? (+ <OAuthLoginDialog+ vendor={login.vendor}+ session={login.session}+ onDone={finishLogin}+ onClose={closeLogin}+ />+ ) : null}</div>);}diff --git a/apps/desktop/src/components/settings/OAuthLoginDialog.tsx b/apps/desktop/src/components/settings/OAuthLoginDialog.tsxindex e9985c6b7..10a995e9b 100644--- a/apps/desktop/src/components/settings/OAuthLoginDialog.tsx+++ b/apps/desktop/src/components/settings/OAuthLoginDialog.tsx@@ -31,8 +31,8 @@ export function OAuthLoginDialog({vendor: OAuthVendor;/** The attempt this dialog reports on, already begun by the caller. */session: OAuthLoginSession;- /** The login succeeded; the provider row is ready to use. */- onDone: (accountLabel?: string) => void;+ /** The login succeeded; the provider row it names is ready to use. */+ onDone: (accountLabel?: string, providerId?: string) => void;onClose: () => void;}) {const { t } = useTranslation();@@ -85,7 +85,7 @@ export function OAuthLoginDialog({case "done":if (settled.current) break;settled.current = true;- handlers.current.onDone(event.accountLabel);+ handlers.current.onDone(event.accountLabel, event.providerId);break;case "error":setPrompt(null);diff --git a/apps/desktop/src/components/settings/ServiceList.tsx b/apps/desktop/src/components/settings/ServiceList.tsxnew file mode 100644index 000000000..1211218fc--- /dev/null+++ b/apps/desktop/src/components/settings/ServiceList.tsx@@ -0,0 +1,202 @@+/**+ * The AI service list (D623): API services, plugin-declared services and+ * vendor subscription accounts in one card list with one drag order.+ *+ * The list owns only transient row state — which row's menu or key entry is+ * open and which delete is armed — and hands every write back to the page.+ */+import { useState } from "react";+import { useTranslation } from "react-i18next";+import type { ProviderPublic } from "@pi-desktop/shared";+import { IconCopy, IconKey, IconPencil, IconPlug, IconStar, IconTrash } from "../icons";+import { useArmedDelete, type CapabilityMenuItem } from "./AgentCapabilityLayout";+import { ServiceRow } from "./ServiceRow";+import { serviceRowKind } from "./service-row-status";+import { useProviderReorder } from "./useProviderReorder";+import type { AccountEntry } from "./useVendorAccounts";++export type ServiceListProps = {+ providers: ProviderPublic[];+ defaultProviderId: string | undefined;+ /** Whether a row can serve as the app default right now. */+ isReady: (provider: ProviderPublic) => boolean;+ accountFor: (providerId: string) => AccountEntry | null;+ /** A page-level write or dialog is in flight; card order is locked meanwhile. */+ busy: boolean;+ isRowBusy: (providerId: string) => boolean;+ testingId: string | null;+ onEdit: (provider: ProviderPublic) => void;+ onMakeDefault: (provider: ProviderPublic) => void;+ onTest: (provider: ProviderPublic) => void;+ onCopy: (provider: ProviderPublic) => void;+ onToggleEnabled: (provider: ProviderPublic) => void;+ onRemove: (provider: ProviderPublic) => void;+ /** Resolves true once the key is stored, so its entry can close. */+ onSaveKey: (provider: ProviderPublic, value: string) => Promise<boolean>;+};++export function ServiceList({+ providers,+ defaultProviderId,+ isReady,+ accountFor,+ busy,+ isRowBusy,+ testingId,+ onEdit,+ onMakeDefault,+ onTest,+ onCopy,+ onToggleEnabled,+ onRemove,+ onSaveKey,+}: ServiceListProps) {+ const { t } = useTranslation();+ const reorder = useProviderReorder(providers, busy);+ const [menuFor, setMenuFor] = useState<string | null>(null);+ // False while the chosen item opens something that takes focus itself.+ const [restoreMenuFocus, setRestoreMenuFocus] = useState(true);+ const [keyFor, setKeyFor] = useState<string | null>(null);+ const { armed, setArmed } = useArmedDelete();+ // A row that went away with its menu open must not keep swallowing clicks.+ const openMenuId = reorder.providers.some((provider) => provider.id === menuFor)+ ? menuFor+ : null;++ const closeMenu = (restoreFocus: boolean) => {+ setRestoreMenuFocus(restoreFocus);+ setMenuFor(null);+ setArmed(null);+ };++ const toggleKeyEntry = (provider: ProviderPublic) =>+ setKeyFor((current) => (current === provider.id ? null : provider.id));++ const saveKey = async (provider: ProviderPublic, value: string) => {+ if (await onSaveKey(provider, value)) {+ setKeyFor((current) => (current === provider.id ? null : current));+ }+ };++ const menuItems = (provider: ProviderPublic, isDefault: boolean): CapabilityMenuItem[] => {+ const kind = serviceRowKind(provider);+ const items: CapabilityMenuItem[] = [];+ // A plugin owns its row's fields and lifetime; only its key is the user's.+ if (kind !== "plugin") {+ items.push({+ key: "edit",+ label: t(kind === "account" ? "settings.editVendorAccount" : "settings.editProvider"),+ icon: <IconPencil size={14} />,+ onSelect: () => {+ closeMenu(false);+ onEdit(provider);+ },+ });+ }+ if (!isDefault && isReady(provider)) {+ items.push({+ key: "default",+ label: t("settings.makeDefault"),+ icon: <IconStar size={14} />,+ onSelect: () => {+ closeMenu(true);+ onMakeDefault(provider);+ },+ });+ }+ items.push({+ key: "test",+ label: t("settings.testConnection"),+ icon: <IconPlug size={14} />,+ onSelect: () => {+ closeMenu(true);+ onTest(provider);+ },+ });+ if (kind === "api") {+ items.push({+ key: "copy",+ label: t("settings.copyProvider"),+ icon: <IconCopy size={14} />,+ onSelect: () => {+ closeMenu(false);+ onCopy(provider);+ },+ });+ }+ if (kind === "plugin" && provider.authKind === "api_key") {+ items.push({+ key: "key",+ label: t("settings.pluginProviderKey"),+ icon: <IconKey size={14} />,+ onSelect: () => {+ closeMenu(false);+ toggleKeyEntry(provider);+ },+ });+ }+ if (kind !== "plugin") {+ const isArmed = armed === provider.id;+ items.push({+ key: "remove",+ label: isArmed+ ? t("settings.capabilityRemoveConfirm")+ : t(kind === "account" ? "settings.vendorRemoveAccount" : "settings.delete"),+ icon: <IconTrash size={14} />,+ danger: true,+ onSelect: () => {+ if (!isArmed) {+ setArmed(provider.id);+ return;+ }+ closeMenu(true);+ onRemove(provider);+ },+ });+ }+ return items;+ };++ return (+ <ul className="model-provider-list" aria-busy={reorder.saving}>+ {reorder.providers.map((provider) => {+ const kind = serviceRowKind(provider);+ const isDefault = defaultProviderId === provider.id;+ const rowBusy = reorder.saving || isRowBusy(provider.id);+ const onOpen =+ kind !== "plugin"+ ? () => onEdit(provider)+ : provider.authKind === "api_key"+ ? () => toggleKeyEntry(provider)+ : undefined;+ return (+ <ServiceRow+ key={provider.id}+ provider={provider}+ entry={accountFor(provider.id)}+ isDefault={isDefault}+ busy={rowBusy}+ testing={testingId === provider.id}+ dragging={reorder.draggingId === provider.id}+ menuItems={menuItems(provider, isDefault)}+ menuOpen={openMenuId === provider.id}+ anyMenuOpen={openMenuId !== null}+ restoreMenuFocus={restoreMenuFocus}+ onMenuOpenChange={(open) => {+ if (open) setRestoreMenuFocus(true);+ setMenuFor(open ? provider.id : null);+ setArmed(null);+ }}+ onOpen={onOpen}+ onToggleEnabled={() => onToggleEnabled(provider)}+ keyEntryOpen={keyFor === provider.id}+ onSaveKey={(value) => void saveKey(provider, value)}+ onCloseKeyEntry={() => setKeyFor(null)}+ rowRef={reorder.rowRef(provider.id)}+ reorderEvents={reorder.rowEvents(provider.id)}+ />+ );+ })}+ </ul>+ );+}diff --git a/apps/desktop/src/components/settings/ServiceMonogram.tsx b/apps/desktop/src/components/settings/ServiceMonogram.tsxnew file mode 100644index 000000000..ec7bc0a3a--- /dev/null+++ b/apps/desktop/src/components/settings/ServiceMonogram.tsx@@ -0,0 +1,19 @@+/**+ * The letter tile that leads an AI service (D623).+ *+ * Deliberately no brand artwork or colour: every service sits in the same+ * quiet raised tone, so a row is told apart by its name and the tile only gives+ * the eye a column to scan. A name without a letter or digit gets the generic+ * server glyph instead.+ */+import { IconServer } from "../icons";+import { monogramLetter } from "./service-row-status";++export function ServiceMonogram({ name }: { name: string }) {+ const letter = monogramLetter(name);+ return (+ <span className="service-monogram" aria-hidden>+ {letter || <IconServer size={14} />}+ </span>+ );+}diff --git a/apps/desktop/src/components/settings/ServiceRow.tsx b/apps/desktop/src/components/settings/ServiceRow.tsxnew file mode 100644index 000000000..1a38a0b7d--- /dev/null+++ b/apps/desktop/src/components/settings/ServiceRow.tsx@@ -0,0 +1,262 @@+/**+ * One row of the AI service list (D623): an API service, a plugin-declared+ * service or a vendor subscription account.+ *+ * The row itself is the way in — a click or Enter opens its editor — so the+ * only controls left on it are the enable switch and one overflow menu. The+ * click lives on the row element rather than on a button so a card drag still+ * starts anywhere on the card, and the reorder hook's click capture swallows+ * the click a drag ends in.+ */+import { Fragment, useRef, useState, type HTMLAttributes, type Ref } from "react";+import { useTranslation } from "react-i18next";+import type { ProviderPublic } from "@pi-desktop/shared";+import { Badge, Button, Field, Input, TooltipButton, cx } from "../ui";+import { CapabilityRowMenu, type CapabilityMenuItem } from "./AgentCapabilityLayout";+import { ServiceMonogram } from "./ServiceMonogram";+import {+ serviceRowBadges,+ serviceRowKind,+ serviceRowMeta,+ serviceRowTitle,+} from "./service-row-status";+import type { AccountEntry } from "./useVendorAccounts";++/** Presses on these act on their own and never open the row. */+const OWN_CONTROLS = "button, input, select, textarea, a, label, .model-provider-key-entry";++export type ServiceRowProps = {+ provider: ProviderPublic;+ entry: AccountEntry | null;+ isDefault: boolean;+ /** Mid-request (saving, testing, removing): the row starts nothing new. */+ busy: boolean;+ testing: boolean;+ dragging: boolean;+ menuItems: readonly CapabilityMenuItem[];+ menuOpen: boolean;+ /** Any row's menu, so the press that dismisses it does not also open a row. */+ anyMenuOpen: boolean;+ restoreMenuFocus: boolean;+ onMenuOpenChange: (open: boolean) => void;+ /** Absent when there is nothing to open, e.g. a plugin service without a key. */+ onOpen?: () => void;+ onToggleEnabled: () => void;+ keyEntryOpen: boolean;+ onSaveKey: (value: string) => void;+ onCloseKeyEntry: () => void;+ rowRef: Ref<HTMLLIElement>;+ reorderEvents: HTMLAttributes<HTMLLIElement>;+};++export function ServiceRow({+ provider,+ entry,+ isDefault,+ busy,+ testing,+ dragging,+ menuItems,+ menuOpen,+ anyMenuOpen,+ restoreMenuFocus,+ onMenuOpenChange,+ onOpen,+ onToggleEnabled,+ keyEntryOpen,+ onSaveKey,+ onCloseKeyEntry,+ rowRef,+ reorderEvents,+}: ServiceRowProps) {+ const { t } = useTranslation();+ const kind = serviceRowKind(provider);+ const title = serviceRowTitle(provider, entry, t);+ const badges = serviceRowBadges(provider, { isDefault, entry }, t);+ const meta = serviceRowMeta(provider, t);+ // Read at pointerdown, before the outside press has closed the menu.+ const menuWasOpen = useRef(false);+ const { onPointerDown, onClickCapture, onKeyDown, ...reorderAttributes } = reorderEvents;++ return (+ <li+ {...reorderAttributes}+ ref={rowRef}+ className={cx(+ "model-provider-row",+ !provider.enabled && "is-disabled",+ dragging && "is-dragging",+ menuOpen && "menu-open",+ onOpen && "is-openable",+ )}+ data-provider-id={provider.id}+ aria-label={t(onOpen ? "settings.serviceRowLabel" : "settings.reorderProvider", {+ name: title.label,+ })}+ tabIndex={onOpen ? 0 : reorderAttributes.tabIndex}+ aria-disabled={onOpen ? busy : reorderAttributes["aria-disabled"]}+ onPointerDown={(event) => {+ // The menu is portaled, but its React events still bubble through here.+ if (!event.currentTarget.contains(event.target as Node)) return;+ menuWasOpen.current = anyMenuOpen;+ if ((event.target as Element).closest(".model-provider-key-entry")) return;+ onPointerDown?.(event);+ }}+ onClickCapture={(event) => {+ if (event.currentTarget.contains(event.target as Node)) onClickCapture?.(event);+ }}+ onKeyDown={(event) => {+ onKeyDown?.(event);+ if (event.defaultPrevented || event.key !== "Enter") return;+ if (event.target !== event.currentTarget || !onOpen || busy) return;+ event.preventDefault();+ onOpen();+ }}+ onClick={(event) => {+ const dismissedMenu = menuWasOpen.current;+ menuWasOpen.current = false;+ if (!onOpen || busy || dismissedMenu) return;+ const target = event.target as Element;+ if (!event.currentTarget.contains(target)) return;+ const control = target.closest(OWN_CONTROLS);+ if (control && event.currentTarget.contains(control)) return;+ onOpen();+ }}+ >+ <ServiceMonogram name={title.name} />+ <div className="model-provider-row-copy">+ <div className="model-provider-row-title">+ <span className="model-provider-row-name">{title.name}</span>+ {title.account ? (+ <>+ <span className="model-provider-meta-dot" aria-hidden>+ ·+ </span>+ <span className="model-provider-row-account">{title.account}</span>+ </>+ ) : null}+ {badges.map((badge) =>+ badge.title ? (+ <span key={badge.key} title={badge.title}>+ <Badge tone={badge.tone}>{badge.label}</Badge>+ </span>+ ) : (+ <Badge key={badge.key} tone={badge.tone}>+ {badge.label}+ </Badge>+ ),+ )}+ {testing ? (+ <span className="model-provider-row-testing" role="status">+ {t("settings.testing")}+ </span>+ ) : null}+ </div>+ <div className="model-provider-row-meta">+ {meta.map((part, index) => (+ <Fragment key={index}>+ {index > 0 ? (+ <span className="model-provider-meta-dot" aria-hidden>+ ·+ </span>+ ) : null}+ <span>{part}</span>+ </Fragment>+ ))}+ </div>+ </div>++ <div className="model-provider-row-actions">+ {/* A plugin refreshes its row from its manifest on every load, so the+ switch is not the user's to flip; an account has none at all. */}+ {kind !== "account" ? (+ <TooltipButton+ type="button"+ className={cx("settings-toggle", provider.enabled && "on")}+ role="switch"+ aria-checked={provider.enabled}+ tooltip={+ kind === "plugin"+ ? t("settings.pluginProviderManaged", { plugin: provider.ownerPluginId })+ : t("settings.enabledToggle")+ }+ ariaLabel={t("settings.enabledToggle")}+ disabled={busy || kind === "plugin"}+ onClick={onToggleEnabled}+ >+ <span className="settings-toggle-thumb" />+ </TooltipButton>+ ) : null}+ <CapabilityRowMenu+ label={t("settings.serviceRowActions", { name: title.label })}+ items={menuItems}+ open={menuOpen}+ disabled={busy}+ restoreFocus={restoreMenuFocus}+ onOpenChange={onMenuOpenChange}+ />+ </div>++ {keyEntryOpen ? (+ <PluginKeyEntry+ hasSecret={provider.hasSecret}+ busy={busy}+ onSave={onSaveKey}+ onCancel={onCloseKeyEntry}+ />+ ) : null}+ </li>+ );+}++/**+ * The key a plugin-declared service asks for. The plugin owns every other+ * field, so this is the one credential the user supplies.+ */+function PluginKeyEntry({+ hasSecret,+ busy,+ onSave,+ onCancel,+}: {+ hasSecret: boolean;+ busy: boolean;+ onSave: (value: string) => void;+ onCancel: () => void;+}) {+ const { t } = useTranslation();+ const [value, setValue] = useState("");+ // Saving an empty value removes the stored key, which only the explicit+ // button may do; Enter in an empty field does nothing.+ const canSave = !busy && value.trim() !== "";+ return (+ <div className="model-provider-key-entry">+ <Field label={t("settings.pluginProviderKey")} hint={t("settings.pluginProviderKeyHint")}>+ <Input+ type="password"+ autoFocus+ value={value}+ placeholder={hasSecret ? t("settings.apiKeyKeepHint") : undefined}+ onChange={(event) => setValue(event.target.value)}+ onKeyDown={(event) => {+ if (event.key === "Escape") onCancel();+ if (event.key === "Enter" && canSave) onSave(value);+ }}+ />+ </Field>+ <div className="model-provider-key-actions">+ <Button size="sm" variant="ghost" disabled={busy} onClick={onCancel}>+ {t("settings.cancel")}+ </Button>+ {hasSecret ? (+ <Button size="sm" variant="ghost" disabled={busy} onClick={() => onSave("")}>+ {t("settings.pluginProviderKeyRemove")}+ </Button>+ ) : null}+ <Button size="sm" disabled={!canSave} onClick={() => onSave(value)}>+ {t("settings.save")}+ </Button>+ </div>+ </div>+ );+}diff --git a/apps/desktop/src/components/settings/VendorAccountsSection.tsx b/apps/desktop/src/components/settings/VendorAccountsSection.tsxdeleted file mode 100644index 586fec609..000000000--- a/apps/desktop/src/components/settings/VendorAccountsSection.tsx+++ /dev/null@@ -1,260 +0,0 @@-/**- * Sign in with a vendor subscription instead of pasting an API key (ADR 0098).- * Vendor accounts are separate from API providers in the settings hierarchy;- * each account row owns exactly one OAuth provider row and can be removed on- * its own.- */-import { useState } from "react";-import { useTranslation } from "react-i18next";-import { useAppStore } from "../../stores/app-store";-import { api } from "../../lib/api";-import { Badge, Button, TooltipButton, cx } from "../ui";-import { IconKey, IconPencil, IconPlug, IconTrash } from "../icons";-import { OAuthLoginDialog } from "./OAuthLoginDialog";-import {- VendorAccountDialog,- type VendorAccountForm,-} from "./VendorAccountDialog";-import { VendorPickerDialog } from "./VendorPickerDialog";-import { useVendorAccounts, type AccountEntry } from "./useVendorAccounts";--export function VendorAccountsSection() {- const { t } = useTranslation();- const providers = useAppStore((s) => s.providers);- const showToast = useAppStore((s) => s.showToast);- const {- vendors,- accounts,- login,- busyAccountId,- savingAccount,- startLogin,- finishLogin,- closeLogin,- removeAccount,- saveAccount,- } = useVendorAccounts();-- const [confirmDeleteId, setConfirmDeleteId] = useState<string | null>(null);- const [picking, setPicking] = useState(false);- const [editingAccount, setEditingAccount] = useState<AccountEntry | null>(null);- const [testingAccount, setTestingAccount] = useState<string | null>(null);-- const saveEditingAccount = async (form: VendorAccountForm) => {- const entry = editingAccount;- const provider = entry- ? providers.find((candidate) => candidate.id === entry.account.providerId)- : null;- if (!entry || !provider) return;- if (await saveAccount(provider, form)) setEditingAccount(null);- };-- const testAccount = async (entry: AccountEntry) => {- const provider = providers.find((candidate) => candidate.id === entry.account.providerId);- if (!provider) return;- setTestingAccount(provider.id);- try {- const result = (await api.testProvider(provider.id)) as {- ok?: boolean;- message?: string;- status?: number;- };- if (result.ok) {- showToast(t("settings.testOk"), { variant: "success" });- } else {- showToast(- result.message ||- (result.status- ? t("settings.testFailedStatus", { status: result.status })- : t("settings.testFailed")),- { variant: "error" },- );- }- } catch (error) {- showToast(error instanceof Error ? error.message : String(error), {- variant: "error",- });- } finally {- setTestingAccount(null);- }- };-- // Nothing to offer until the runtime reports at least one OAuth vendor.- if (!vendors || vendors.length === 0) return null;-- const editingProvider = editingAccount- ? providers.find((candidate) => candidate.id === editingAccount.account.providerId) ?? null- : null;-- return (- <section className="settings-card-block vendor-accounts-block">- <div className="provider-section-head">- <div>- <div className="settings-card-heading-line">- <h3 className="settings-card-heading">{t("settings.vendorAccounts")}</h3>- {accounts.length > 0 ? (- <span className="provider-section-count">{accounts.length}</span>- ) : null}- </div>- </div>- <Button- variant="primary"- disabled={login !== null}- onClick={() => setPicking(true)}- >- <span className="vendor-btn-inner">- <IconKey size={14} />- <span>{t("settings.vendorAddAccount")}</span>- </span>- </Button>- </div>-- <div className="settings-panel provider-list-panel">- {accounts.length === 0 ? (- <div className="vendor-account-empty">{t("settings.vendorNoAccounts")}</div>- ) : (- <div className="provider-row-list">- {accounts.map((entry) => {- const { vendor, account } = entry;- const provider = providers.find((candidate) => candidate.id === account.providerId);- const connected = account.connected;- const accountName =- account.accountLabel ||- provider?.oauthAccountLabel ||- t("settings.vendorSignedInGeneric");- const duplicateLabel =- entry.totalForVendor > 1- ? ` · ${t("settings.vendorAccountNumber", { number: entry.ordinal })}`- : "";- const confirming = confirmDeleteId === account.providerId;- const busy = busyAccountId === account.providerId;- const testing = testingAccount === account.providerId;- const rowBusy = busy || testing;- return (- <div- key={account.providerId}- className={cx(- "provider-row",- "vendor-account-row",- !connected && "is-disconnected",- )}- >- <div className="provider-row-info">- <div className="provider-row-title-line">- <span className="provider-row-name">{vendor.name}</span>- {vendor.isSubscription ? (- <Badge tone="neutral">{t("settings.vendorSubscription")}</Badge>- ) : null}- <Badge tone={connected ? "success" : "warning"}>- {connected- ? t("settings.vendorConnected")- : t("settings.vendorDisconnected")}- </Badge>- </div>- <div className="provider-row-meta">- <span className="vendor-account-label">- {accountName}- {duplicateLabel}- </span>- </div>- {!connected ? (- <div className="vendor-account-status">- {t("settings.vendorDisconnectedDesc")}- </div>- ) : null}- </div>- <div className="provider-row-actions">- <TooltipButton- type="button"- className="icon-btn provider-icon-btn"- tooltip={t("settings.editVendorAccount")}- ariaLabel={t("settings.editVendorAccount")}- disabled={rowBusy || !provider}- onClick={() => setEditingAccount(entry)}- >- <IconPencil size={14} />- </TooltipButton>- <TooltipButton- type="button"- className={cx(- "icon-btn provider-icon-btn",- testing && "is-testing",- )}- tooltip={t("settings.testConnection")}- ariaLabel={t("settings.testConnection")}- disabled={rowBusy || !provider}- onClick={() => void testAccount(entry)}- >- <IconPlug size={14} />- </TooltipButton>- {confirming ? (- <button- type="button"- className="provider-delete-confirm"- disabled={rowBusy}- onBlur={() => setConfirmDeleteId(null)}- onClick={() => {- setConfirmDeleteId(null);- void removeAccount(entry);- }}- >- {t("settings.deleteConfirm")}- </button>- ) : (- <TooltipButton- type="button"- className="icon-btn provider-icon-btn provider-icon-btn-danger"- tooltip={t("settings.vendorRemoveAccount")}- ariaLabel={t("settings.vendorRemoveAccount")}- disabled={rowBusy}- onClick={() => setConfirmDeleteId(account.providerId)}- >- <IconTrash size={14} />- </TooltipButton>- )}- </div>- </div>- );- })}- </div>- )}- </div>-- {picking ? (- <VendorPickerDialog- vendors={vendors}- onPick={(vendor) => {- setPicking(false);- // 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={() => setPicking(false)}- />- ) : null}-- {editingAccount && editingProvider ? (- <VendorAccountDialog- provider={editingProvider}- initialName={- editingAccount.account.accountLabel ||- editingProvider.oauthAccountLabel ||- editingProvider.name- }- saving={savingAccount}- onClose={() => setEditingAccount(null)}- onSave={(form) => void saveEditingAccount(form)}- />- ) : null}-- {login ? (- <OAuthLoginDialog- vendor={login.vendor}- session={login.session}- onDone={finishLogin}- onClose={closeLogin}- />- ) : null}- </section>- );-}diff --git a/apps/desktop/src/components/settings/default-model.ts b/apps/desktop/src/components/settings/default-model.tsindex 025225895..ef38a3b3d 100644--- a/apps/desktop/src/components/settings/default-model.ts+++ b/apps/desktop/src/components/settings/default-model.ts@@ -125,3 +125,29 @@ export function keepsAppDefaultModel(if (!provider || !providerServesChatModels(provider, imageGeneration)) return false;return hasResolvedDefaultModel(providers, defaultProviderId, defaultModelId);}++/**+ * The app default a finished vendor login claims, or null to leave it alone.+ *+ * Signing in follows the rule adding an API service follows: the new account's+ * head chat model becomes the app default only while the current default does+ * not resolve to a runnable provider, so a first-time subscriber can chat right+ * away and a second login never moves what the user already runs.+ */+export function loginDefaultModel(+ providers: readonly ProviderPublic[],+ providerId: string,+ defaults: { defaultProviderId?: string; defaultModelId?: string },+ imageGeneration?: ImageGenerationBindings | null,+): { providerId: string; modelId: string } | null {+ if (keepsAppDefaultModel(+ providers,+ defaults.defaultProviderId,+ defaults.defaultModelId,+ imageGeneration,+ )) return null;+ const account = providers.find((candidate) => candidate.id === providerId);+ if (!account || !providerServesChatModels(account, imageGeneration)) return null;+ const modelId = defaultModelOptions([account], imageGeneration)[0]?.modelId;+ return modelId ? { providerId: account.id, modelId } : null;+}diff --git a/apps/desktop/src/components/settings/service-row-status.ts b/apps/desktop/src/components/settings/service-row-status.tsnew file mode 100644index 000000000..d7f68f61c--- /dev/null+++ b/apps/desktop/src/components/settings/service-row-status.ts@@ -0,0 +1,130 @@+/**+ * What one row of the AI service list says about itself (D623).+ *+ * API services, plugin-declared services and vendor subscription accounts share+ * one list. These pure helpers decide a row's kind, title, badges and meta line+ * so the rules stay testable without rendering, and the row only lays them out.+ */+import { OAUTH_AUTH_KIND, type ProviderPublic } from "@pi-desktop/shared";+import type { AccountEntry } from "./useVendorAccounts";++type Translate = (key: string, options?: Record<string, unknown>) => string;++/**+ * `api` is a service the user configured, `plugin` one a plugin declares (only+ * its key is the user's), `account` a vendor subscription login.+ */+export type ServiceRowKind = "api" | "plugin" | "account";++export function serviceRowKind(provider: ProviderPublic): ServiceRowKind {+ if (provider.authKind === OAUTH_AUTH_KIND) return "account";+ return provider.ownerPluginId ? "plugin" : "api";+}++export type ServiceRowTitle = {+ /** The service, or the vendor an account signs in to. */+ name: string;+ /** Which account of that vendor, when the row is one. */+ account: string | null;+ /** Both together, for accessible names. */+ label: string;+};++/**+ * An account row reads "vendor · account"; a second login to the same vendor+ * adds its ordinal so two unlabeled accounts stay tellable apart. A label that+ * merely repeats the vendor name (the account editor's prefill) adds nothing.+ */+export function serviceRowTitle(+ provider: ProviderPublic,+ entry: AccountEntry | null | undefined,+ t: Translate,+): ServiceRowTitle {+ if (serviceRowKind(provider) !== "account") {+ return { name: provider.name, account: null, label: provider.name };+ }+ const name = entry?.vendor.name || provider.name;+ const accountLabel = entry?.account.accountLabel || provider.oauthAccountLabel;+ const parts = accountLabel && accountLabel !== name ? [accountLabel] : [];+ if (entry && entry.totalForVendor > 1) {+ parts.push(t("settings.vendorAccountNumber", { number: entry.ordinal }));+ }+ const account = parts.length > 0 ? parts.join(" · ") : null;+ return { name, account, label: account ? `${name} · ${account}` : name };+}++export type ServiceRowBadge = {+ key: "default" | "no-secret" | "signed-out" | "disabled" | "plugin" | "subscription";+ label: string;+ tone: "neutral" | "success" | "warning";+ title?: string;+};++/** Only the badges that say something about this row right now. */+export function serviceRowBadges(+ provider: ProviderPublic,+ context: { isDefault: boolean; entry?: AccountEntry | null },+ t: Translate,+): ServiceRowBadge[] {+ const kind = serviceRowKind(provider);+ const badges: ServiceRowBadge[] = [];+ if (context.isDefault) {+ badges.push({ key: "default", label: t("settings.default"), tone: "success" });+ }+ if (kind === "account") {+ if (!provider.hasOauth) {+ badges.push({ key: "signed-out", label: t("settings.vendorDisconnected"), tone: "warning" });+ }+ } else if (!provider.hasSecret && provider.authKind !== "none") {+ badges.push({ key: "no-secret", label: t("settings.noSecret"), tone: "warning" });+ }+ if (!provider.enabled) {+ badges.push({ key: "disabled", label: t("settings.providerDisabledBadge"), tone: "neutral" });+ }+ if (kind === "plugin") {+ badges.push({+ key: "plugin",+ label: t("settings.pluginProviderBadge"),+ tone: "neutral",+ title: t("settings.pluginProviderManaged", { plugin: provider.ownerPluginId }),+ });+ }+ if (kind === "account" && context.entry?.vendor.isSubscription) {+ badges.push({ key: "subscription", label: t("settings.vendorSubscription"), tone: "neutral" });+ }+ return badges;+}++/**+ * The quiet second line: where an API service points and how many models it+ * serves. An account has no endpoint worth showing, and a signed-out one says+ * what to do instead.+ */+export function serviceRowMeta(provider: ProviderPublic, t: Translate): string[] {+ const kind = serviceRowKind(provider);+ const models = t("settings.providerModelCount", { count: provider.models?.length ?? 0 });+ if (kind === "account") {+ return provider.hasOauth ? [models] : [t("settings.vendorDisconnectedDesc")];+ }+ const parts = [hostFromBaseUrl(provider.baseUrl), models];+ if (kind === "plugin") {+ parts.push(t("settings.pluginProviderBy", { plugin: provider.ownerPluginId }));+ }+ return parts;+}++/** The first letter or digit of a name, or "" when it has none. */+export function monogramLetter(name: string): string {+ const match = name.match(/[\p{L}\p{N}]/u);+ return match ? match[0].toLocaleUpperCase() : "";+}++/** Host part of a base URL, or an em dash when nothing is configured. */+export function hostFromBaseUrl(baseUrl?: string | null): string {+ if (!baseUrl) return "—";+ try {+ return new URL(baseUrl).host || baseUrl;+ } catch {+ return baseUrl.replace(/^https?:\/\//, "").split("/")[0] || baseUrl;+ }+}diff --git a/apps/desktop/src/components/settings/useVendorAccounts.ts b/apps/desktop/src/components/settings/useVendorAccounts.tsindex 78cbaa43f..391780763 100644--- a/apps/desktop/src/components/settings/useVendorAccounts.ts+++ b/apps/desktop/src/components/settings/useVendorAccounts.ts@@ -1,20 +1,27 @@/**- * Vendor (OAuth) accounts for the model settings page (ADR 0098).+ * Vendor (OAuth) accounts for the model settings page (ADR 0098, D623).*- * Owns what an account row needs beyond its provider row: the vendor list the- * runtime reports, the login attempt in flight, and the two writes that must- * keep the app default consistent — removing an account and saving its edits.- * Rendering stays with the caller.+ * Account rows share the AI service list with API services; this hook owns what+ * such a row needs beyond its provider row: the vendor list the runtime+ * reports, the login attempt in flight, and the writes that must keep the app+ * default consistent — a finished login claiming an empty default, removing an+ * account and saving its edits. Rendering stays with the caller.*/import { useCallback, useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";-import type { OAuthAccount, OAuthVendor, ProviderPublic } from "@pi-desktop/shared";+import {+ imageGenerationBindings,+ type OAuthAccount,+ type OAuthVendor,+ type ProviderPublic,+} from "@pi-desktop/shared";import { useAppStore } from "../../stores/app-store";import { api } from "../../lib/api";import {beginOAuthLogin,type OAuthLoginSession,} from "../../lib/oauth-login-session";+import { loginDefaultModel } from "./default-model";import type { VendorAccountForm } from "./VendorAccountDialog";/** A login in flight, together with the dialog reporting on it. */@@ -37,6 +44,30 @@ function providerIsReady(provider: ProviderPublic, excludedId?: string): boolean);}+/**+ * Let a finished login claim the app default the way adding an API service+ * does. Reads the host's rows and settings rather than the store, which has+ * not seen the new account yet.+ */+async function claimLoginDefault(providerId: string): Promise<void> {+ const [{ providers }, current] = await Promise.all([+ api.listProviders(),+ api.getSettings(),+ ]);+ const claim = loginDefaultModel(+ providers,+ providerId,+ current,+ imageGenerationBindings(current.imageGenerationModels, current.imageGeneration),+ );+ if (!claim) return;+ await api.setSettings({+ ...current,+ defaultProviderId: claim.providerId,+ defaultModelId: claim.modelId,+ });+}+export function useVendorAccounts() {const { t } = useTranslation();const providers = useAppStore((s) => s.providers);@@ -68,19 +99,28 @@ export function useVendorAccounts() {// the renderer listening. Cancelling the attempt itself is the dialog's job.useEffect(() => () => login?.session.dispose(), [login]);- const accounts = useMemo<AccountEntry[]>(() => {- if (!vendors) return [];- return vendors.flatMap((vendor) => {+ const accounts = useMemo(() => {+ const byProvider = new Map<string, AccountEntry>();+ for (const vendor of vendors ?? []) {const totalForVendor = vendor.accounts.length;- return vendor.accounts.map((account, index) => ({- vendor,- account,- ordinal: index + 1,- totalForVendor,- }));- });+ vendor.accounts.forEach((account, index) => {+ byProvider.set(account.providerId, {+ vendor,+ account,+ ordinal: index + 1,+ totalForVendor,+ });+ });+ }+ return byProvider;}, [vendors]);+ /** The vendor account behind a provider row, once the vendor list loaded. */+ const accountFor = useCallback(+ (providerId: string): AccountEntry | null => accounts.get(providerId) ?? null,+ [accounts],+ );+/*** Started from the caller's click handler, never from an effect: a click* happens once, where StrictMode would run a mount effect twice and open two@@ -94,38 +134,51 @@ export function useVendorAccounts() {};const finishLogin = useCallback(- (accountLabel?: string) => {+ (accountLabel?: string, providerId?: string) => {const vendorName = login?.vendor.name ?? "";setLogin(null);void loadVendors();- void refreshProviders();showToast(accountLabel? t("settings.vendorSignedInAs", { account: accountLabel }): t("settings.vendorSignedIn", { vendor: vendorName }),{ variant: "success" },);+ void (async () => {+ try {+ if (providerId) await claimLoginDefault(providerId);+ } catch (error) {+ showToast(error instanceof Error ? error.message : String(error), {+ variant: "error",+ });+ } finally {+ await refreshProviders();+ }+ })();},[login, loadVendors, refreshProviders, showToast, t],);+ // Main discards the row a failed or cancelled login created before it+ // reports the outcome, so the list can drop it now.const closeLogin = () => {setLogin(null);void loadVendors();+ void refreshProviders();};- const removeAccount = async (entry: AccountEntry) => {- const { account, vendor } = entry;- setBusyAccountId(account.providerId);+ const removeAccount = async (provider: ProviderPublic) => {+ const vendorName = accounts.get(provider.id)?.vendor.name ?? provider.name;+ setBusyAccountId(provider.id);try {- await api.deleteOauthAccount(account.providerId);+ await api.deleteOauthAccount(provider.id);// A deleted account cannot remain the global default. Pick the first// still-ready service, including an API provider, so the model picker// does not point at a deleted row after refresh.- if (settings?.defaultProviderId === account.providerId) {- const next = providers.find((provider) =>- providerIsReady(provider, account.providerId),+ if (settings?.defaultProviderId === provider.id) {+ const next = providers.find((candidate) =>+ providerIsReady(candidate, provider.id),);const nextSettings = {...settings,@@ -136,7 +189,7 @@ export function useVendorAccounts() {useAppStore.setState({ settings: nextSettings });}await Promise.all([loadVendors(), refreshProviders()]);- showToast(t("settings.vendorAccountRemoved", { vendor: vendor.name }), {+ showToast(t("settings.vendorAccountRemoved", { vendor: vendorName }), {variant: "success",});} catch (error) {@@ -184,7 +237,7 @@ export function useVendorAccounts() {return {vendors,- accounts,+ accountFor,login,busyAccountId,savingAccount,diff --git a/apps/desktop/src/lib/settings-search.ts b/apps/desktop/src/lib/settings-search.tsindex b320ba431..596f6e8e3 100644--- a/apps/desktop/src/lib/settings-search.ts+++ b/apps/desktop/src/lib/settings-search.ts@@ -151,6 +151,9 @@ export const SETTINGS_NAV: SettingsNavEntry[] = ["settings.apiKey","settings.baseUrl","settings.apiStyle",+ // Subscription accounts share the service list (D623).+ "settings.vendorAccounts",+ "settings.vendorSubscription",],},{diff --git a/apps/desktop/src/styles/model-config.css b/apps/desktop/src/styles/model-config.cssindex 93b5861ae..718294419 100644--- a/apps/desktop/src/styles/model-config.css+++ b/apps/desktop/src/styles/model-config.css@@ -1601,12 +1601,37 @@background: var(--ds-tile);}-.model-provider-row.is-disabled {+.model-provider-row:hover,+.model-provider-row.menu-open {+ background: var(--ds-tile-hover);+}++/* Dim the identity of a disabled row but keep its switch fully legible. */+.model-provider-row.is-disabled > .service-monogram,+.model-provider-row.is-disabled > .model-provider-row-copy {opacity: 0.55;}+/* A quiet letter tile stands in for a logo; services carry no brand colour. */+.service-monogram {+ display: inline-flex;+ width: 28px;+ height: 28px;+ flex: none;+ align-items: center;+ justify-content: center;+ border-radius: var(--radius-md);+ background: var(--ds-raised);+ box-shadow: var(--ds-raised-shadow);+ color: var(--ds-text-secondary);+ font-size: var(--text-sm);+ font-weight: var(--font-weight-semibold);+ line-height: var(--leading-tight);+}+.model-provider-row-copy {display: flex;+ flex: 1 1 0;flex-direction: column;gap: 3px;min-width: 0;@@ -1626,6 +1651,22 @@line-height: var(--leading-tight);}+.model-provider-row-account {+ min-width: 0;+ overflow: hidden;+ color: var(--ds-text-muted);+ font-size: var(--text-sm);+ line-height: var(--leading-tight);+ text-overflow: ellipsis;+ white-space: nowrap;+}++.model-provider-row-testing {+ color: var(--ds-text-muted);+ font-size: var(--text-3xs);+ line-height: var(--leading-normal);+}+.model-provider-row-meta {display: flex;align-items: center;@@ -1646,15 +1687,35 @@flex: none;}+/* The overflow menu stays quiet until the row is engaged, as on capability+ rows; the switch stays visible because enablement is read at a glance. */+.model-provider-row-actions .agent-capability-menu-wrap {+ opacity: 0;+ transition: opacity var(--motion-duration-fast) var(--motion-ease-out);+}++.model-provider-row:hover .model-provider-row-actions .agent-capability-menu-wrap,+.model-provider-row:focus-within .model-provider-row-actions .agent-capability-menu-wrap,+.model-provider-row.menu-open .model-provider-row-actions .agent-capability-menu-wrap {+ opacity: 1;+}++/* Without hover there is nothing to reveal it with. */+@media (hover: none) {+ .model-provider-row-actions .agent-capability-menu-wrap {+ opacity: 1;+ }+}+/* A plugin-declared row lets the plugin provide its fields; a key entry belongs- to the plugin, so the user supplies only the key. */+ to the plugin, so the user supplies only the key. It lines up under the name,+ past the monogram, with spacing rather than a rule setting it apart (D297). */.model-provider-key-entry {display: flex;align-items: flex-end;gap: 8px;flex-basis: 100%;- padding-top: 10px;- border-top: 1px solid var(--ds-border-subtle);+ padding-left: 40px;}.model-provider-key-entry > label {@@ -1669,30 +1730,6 @@flex: none;}-.model-provider-icon-btn.is-testing {- color: var(--ds-text-primary);-}--.model-provider-icon-btn.is-danger:hover {- color: var(--ds-warning);-}--.model-provider-delete-confirm {- padding: 3px 9px;- border-radius: var(--radius-full);- background: color-mix(in oklab, var(--ds-warning) 14%, transparent);- color: var(--ds-warning);- font-size: var(--text-3xs);- font-weight: var(--font-weight-medium);- line-height: var(--leading-normal);- cursor: pointer;-}--.model-provider-delete-confirm:focus-visible {- outline: 2px solid var(--ds-accent-soft);- outline-offset: 1px;-}-/* ------------------------------------------------------------ responsive */@media (max-width: 940px) {@@ -1753,15 +1790,6 @@max-width: none;}- .model-provider-row {- flex-direction: column;- align-items: flex-start;- }-- .model-provider-row-actions {- align-self: flex-end;- }-.provider-chosen-thinking-chips {grid-template-columns: repeat(4, minmax(0, 1fr));}@@ -1769,17 +1797,22 @@}@media (prefers-reduced-motion: reduce) {- .model-default-option {+ .model-default-option,+ .model-provider-row-actions .agent-capability-menu-wrap {transition: none;}}-/* Provider cards move with the pointer; surrounding cards preview the open slot. */+/* Provider cards move with the pointer; surrounding cards preview the open slot.+ A card that opens an editor points instead: a press opens it, a drag moves it. */.model-provider-row {cursor: grab;touch-action: none;- transition: transform 160ms ease;+ transition:+ transform 160ms ease,+ background var(--motion-duration-fast) var(--motion-ease-out);}+.model-provider-row.is-openable { cursor: pointer; }.model-provider-row.is-dragging {cursor: grabbing;user-select: none;diff --git a/apps/desktop/src/styles/providers.css b/apps/desktop/src/styles/providers.cssindex 3ae7d672b..d77239dd3 100644--- a/apps/desktop/src/styles/providers.css+++ b/apps/desktop/src/styles/providers.css@@ -1,17 +1,10 @@/*- Configuration → providers — provider list and rows, the add-provider dialog,+ Configuration → providers — the models page heading, the add-provider dialog,the model combobox, project instructions, and the settings segmented control.+ The service list itself lives in model-config.css.*//* Configuration / providers */-.provider-section-head {- display: flex;- align-items: flex-start;- justify-content: space-between;- gap: 16px;- margin-bottom: 10px;-}-.settings-card-heading-line {display: flex;align-items: center;@@ -65,140 +58,6 @@gap: 10px 12px;}-.provider-list-panel {- overflow: hidden;-}--.provider-empty {- display: flex;- flex-direction: column;- align-items: flex-start;- gap: 8px;- padding: 28px 18px;-}--.provider-empty-icon {- display: inline-flex;- align-items: center;- justify-content: center;- width: 36px;- height: 36px;- border-radius: var(--radius-md-plus);- color: var(--ds-accent);- background: color-mix(in oklab, var(--ds-accent) 12%, transparent);-}--.provider-empty-title {- color: var(--ds-text-primary);- font-size: var(--text-base);- font-weight: var(--font-weight-strong);-}--.provider-empty-desc {- max-width: 48ch;- color: var(--ds-text-secondary);- font-size: var(--text-md);- line-height: var(--leading-body);- margin-bottom: 6px;-}--/* D297: rows are tiles with a gap between them; nothing is ruled off. */-.provider-row-list {- display: flex;- flex-direction: column;- gap: 6px;-}--.provider-row {- display: flex;- align-items: center;- justify-content: space-between;- gap: 16px;- padding: 12px 16px;- border-radius: var(--radius-md-plus);- background: var(--ds-tile);-}--.provider-row.is-disabled .provider-row-info {- opacity: 0.55;-}--.provider-row-info {- min-width: 0;- flex: 1;-}--.provider-row-title-line {- display: flex;- flex-wrap: wrap;- align-items: center;- gap: 8px;-}--.provider-row-name {- color: var(--ds-text-primary);- font-size: var(--text-md-plus);- font-weight: var(--font-weight-strong);- line-height: var(--leading-compact);-}--.provider-row-meta {- display: flex;- flex-wrap: wrap;- align-items: center;- gap: 6px;- margin-top: 4px;- color: var(--ds-text-secondary);- font-size: var(--text-sm);-}--.provider-meta-dot {- color: var(--ds-text-muted);-}--.provider-row-actions {- display: flex;- align-items: center;- gap: 6px;- flex: 0 0 auto;-}--.provider-icon-btn {- width: 28px;- height: 28px;- justify-content: center;- color: var(--ds-text-secondary);- transition:- background var(--motion-duration-fast) var(--motion-ease-out),- color var(--motion-duration-fast) var(--motion-ease-out);-}--.provider-icon-btn:hover:not(:disabled) {- color: var(--ds-text-primary);-}--.provider-icon-btn-danger:hover:not(:disabled) {- color: var(--ds-error);- background: color-mix(in oklab, var(--ds-error) 10%, transparent);-}--.provider-delete-confirm {- appearance: none;- border: 0;- padding: 5px 10px;- border-radius: var(--radius-sm);- background: color-mix(in oklab, var(--ds-error) 12%, transparent);- color: var(--ds-error);- font-size: var(--text-sm);- font-weight: var(--font-weight-medium);- white-space: nowrap;- transition: background var(--motion-duration-fast) var(--motion-ease-out);-}--.provider-delete-confirm:hover:not(:disabled) {- background: color-mix(in oklab, var(--ds-error) 20%, transparent);-}-/* D297: a tinted pill track; the active item is raised on it by shadow. */.settings-segment {display: inline-flex;@@ -239,20 +98,6 @@.provider-model-selection-grid {grid-template-columns: 1fr;}-- .provider-section-head {- flex-direction: column;- align-items: stretch;- }-- .provider-row {- flex-direction: column;- align-items: stretch;- }-- .provider-row-actions {- justify-content: flex-end;- }}/* Add-provider dialog */@@ -1350,37 +1195,13 @@white-space: nowrap;}-/* Vendor accounts — sign in with a subscription instead of a pasted key */-.vendor-account-empty {- padding: 12px 16px 14px;- color: var(--ds-text-muted);- font-size: var(--text-sm);-}--.provider-row.vendor-account-row.is-disconnected .provider-row-info {- opacity: 0.78;-}--.vendor-account-label,-.vendor-account-row .font-mono {- overflow-wrap: anywhere;-}--.vendor-account-status {- margin-top: 4px;- color: var(--ds-text-muted);- font-size: var(--text-xs-plus);- line-height: var(--leading-body);-}--.vendor-btn-inner,+/* Vendor login dialog */.oauth-btn-inner {display: inline-flex;align-items: center;gap: 6px;}-/* Vendor login dialog */.oauth-dialog {width: min(100%, 520px);max-height: min(86vh, 720px);diff --git a/apps/desktop/src/styles/settings.css b/apps/desktop/src/styles/settings.cssindex 7f014e6bb..791ea835c 100644--- a/apps/desktop/src/styles/settings.css+++ b/apps/desktop/src/styles/settings.css@@ -423,7 +423,6 @@.settings-panel:has(> .settings-row),.settings-panel.shortcut-map,.settings-panel.agent-capability-panel,-.settings-panel.provider-list-panel:has(> .provider-row-list),.settings-panel.model-provider-panel:has(> .model-provider-list) {gap: 6px;background: transparent;@@ -1695,7 +1694,7 @@* One workbench per page: a description line, a single toolbar (level filter* with counts, one search field, project picker, primary actions), then one* elevated panel whose rows are divided by level group headers. Rows follow- * the provider-row rhythm, lists flow at natural height, and loading/empty+ * the service-row rhythm, lists flow at natural height, and loading/empty* states reuse the same row anatomy.*/@@ -1982,7 +1981,7 @@gap: 6px;}-/* Rows follow the provider-row rhythm: quiet icon, name + badges, meta. */+/* Rows follow the service-row rhythm: quiet icon, name + badges, meta. */.agent-capability-row {display: flex;align-items: center;diff --git a/apps/desktop/test/default-model-display.test.mjs b/apps/desktop/test/default-model-display.test.mjsindex 6d7848364..1a635c851 100644--- a/apps/desktop/test/default-model-display.test.mjs+++ b/apps/desktop/test/default-model-display.test.mjs@@ -13,6 +13,7 @@ import {defaultModelIdOf,displayedDefaultModelId,keepsAppDefaultModel,+ loginDefaultModel,providerOffersModel,providerServesChatModels,hasResolvedDefaultModel,@@ -239,3 +240,75 @@ test("a default provider that is gone still lets the new provider take over", ()"p2",);});++/**+ * A finished vendor login follows the add-provider rule: the account claims the+ * app default only while nothing runnable holds it, so a subscriber who never+ * configured an API key can chat right after signing in.+ */+const account = (over = {}) =>+ provider({+ id: "acct",+ name: "Claude Pro/Max",+ authKind: "oauth",+ hasSecret: false,+ hasOauth: true,+ models: [binding("claude-opus-4.6"), binding("claude-sonnet-4.6")],+ ...over,+ });++test("a first login claims the app default with the account's head model", () => {+ assert.deepEqual(loginDefaultModel([account()], "acct", {}), {+ providerId: "acct",+ modelId: "claude-opus-4.6",+ });+ // A stale id left by a deleted provider is no default either.+ assert.deepEqual(+ loginDefaultModel([account()], "acct", {+ defaultProviderId: "deleted-provider",+ defaultModelId: "gpt-5",+ }),+ { providerId: "acct", modelId: "claude-opus-4.6" },+ );+});++test("a login never moves a default the user already runs", () => {+ const current = provider({ models: [binding("gpt-5")] });+ assert.equal(+ loginDefaultModel([current, account()], "acct", {+ defaultProviderId: "p1",+ defaultModelId: "gpt-5",+ }),+ null,+ );+});++test("a login replaces a default whose provider cannot run", () => {+ const starved = provider({ models: [binding("gpt-5")], hasSecret: false });+ assert.deepEqual(+ loginDefaultModel([starved, account()], "acct", {+ defaultProviderId: "p1",+ defaultModelId: "gpt-5",+ }),+ { providerId: "acct", modelId: "claude-opus-4.6" },+ );+});++test("an account that cannot run a chat model claims nothing", () => {+ // Still signed out, disabled, without any model, or not in the list at all.+ assert.equal(loginDefaultModel([account({ hasOauth: false })], "acct", {}), null);+ assert.equal(loginDefaultModel([account({ enabled: false })], "acct", {}), null);+ assert.equal(+ loginDefaultModel([account({ models: [], defaultModelId: undefined })], "acct", {}),+ null,+ );+ assert.equal(loginDefaultModel([account()], "missing", {}), null);+});++test("a login skips the image model the chat default may not use", () => {+ const images = account({ models: [binding("gpt-image-1"), binding("gpt-5")] });+ assert.deepEqual(+ loginDefaultModel([images], "acct", {}, { providerId: "acct", modelId: "gpt-image-1" }),+ { providerId: "acct", modelId: "gpt-5" },+ );+});diff --git a/apps/desktop/test/service-row-status.test.mjs b/apps/desktop/test/service-row-status.test.mjsnew file mode 100644index 000000000..e1aba04cc--- /dev/null+++ b/apps/desktop/test/service-row-status.test.mjs@@ -0,0 +1,148 @@+/**+ * Behavior of the unified AI service row (D623): API services, plugin services+ * and vendor subscription accounts share one list, so each row derives its+ * title, badges and meta line from the provider row alone plus, for accounts,+ * the vendor entry the runtime reports.+ */+import assert from "node:assert/strict";+import test from "node:test";+import {+ hostFromBaseUrl,+ monogramLetter,+ serviceRowBadges,+ serviceRowKind,+ serviceRowMeta,+ serviceRowTitle,+} from "../src/components/settings/service-row-status.ts";++// Echoes the key and its options, so assertions see which string was chosen.+const t = (key, options) => (options ? `${key}${JSON.stringify(options)}` : key);++const provider = (over = {}) => ({+ id: "p1",+ name: "OpenAI",+ vendorKey: "openai",+ enabled: true,+ hasSecret: true,+ hasOauth: false,+ authKind: "api_key",+ baseUrl: "https://api.openai.com/v1",+ models: [{ id: "gpt-5" }, { id: "gpt-5-mini" }],+ ...over,+});++const account = (over = {}) =>+ provider({+ id: "acct-1",+ name: "Claude Pro/Max",+ vendorKey: "anthropic",+ authKind: "oauth",+ hasOauth: true,+ baseUrl: "https://api.anthropic.com",+ oauthAccountLabel: "[email protected]",+ ...over,+ });++const entry = (over = {}) => ({+ vendor: { vendorId: "anthropic", name: "Claude Pro/Max", isSubscription: true, accounts: [] },+ account: { providerId: "acct-1", accountLabel: "[email protected]", connected: true },+ ordinal: 1,+ totalForVendor: 1,+ ...over,+});++const badgeKeys = (row, context) =>+ serviceRowBadges(row, { isDefault: false, ...context }, t).map((badge) => badge.key);++test("a row's kind follows its credential and its owner", () => {+ assert.equal(serviceRowKind(provider()), "api");+ assert.equal(serviceRowKind(provider({ ownerPluginId: "acme" })), "plugin");+ assert.equal(serviceRowKind(account()), "account");+});++test("an API service is titled by its own name, exactly", () => {+ // The drag-order E2E reads the name span, so nothing may be appended to it.+ assert.deepEqual(serviceRowTitle(provider(), null, t), {+ name: "OpenAI",+ account: null,+ label: "OpenAI",+ });+});++test("an account reads vendor · account, with an ordinal only when needed", () => {+ assert.deepEqual(serviceRowTitle(account(), entry(), t), {+ name: "Claude Pro/Max",+ account: "[email protected]",+ label: "Claude Pro/Max · [email protected]",+ });+ const second = serviceRowTitle(account(), entry({ ordinal: 2, totalForVendor: 2 }), t);+ assert.equal(second.account, '[email protected] · settings.vendorAccountNumber{"number":2}');+ // Before the vendor list loads the row still names itself.+ assert.equal(serviceRowTitle(account(), null, t).label, "Claude Pro/Max · [email protected]");+});++test("an account label that repeats the vendor name is not shown twice", () => {+ const unlabeled = account({ oauthAccountLabel: undefined });+ const repeated = account({ oauthAccountLabel: "Claude Pro/Max" });+ const noLabel = entry({ account: { providerId: "acct-1", connected: true } });+ assert.equal(serviceRowTitle(unlabeled, noLabel, t).label, "Claude Pro/Max");+ assert.equal(+ serviceRowTitle(repeated, entry({ account: { providerId: "acct-1", accountLabel: "Claude Pro/Max", connected: true } }), t).label,+ "Claude Pro/Max",+ );+});++test("badges appear only when they say something about the row", () => {+ assert.deepEqual(badgeKeys(provider()), []);+ assert.deepEqual(badgeKeys(provider(), { isDefault: true }), ["default"]);+ assert.deepEqual(badgeKeys(provider({ hasSecret: false })), ["no-secret"]);+ // A keyless local gateway is not missing anything.+ assert.deepEqual(badgeKeys(provider({ hasSecret: false, authKind: "none" })), []);+ assert.deepEqual(badgeKeys(provider({ enabled: false })), ["disabled"]);+});++test("a plugin row names its owner in the badge's tooltip", () => {+ const [badge] = serviceRowBadges(provider({ ownerPluginId: "acme" }), { isDefault: false }, t);+ assert.equal(badge.key, "plugin");+ assert.equal(badge.title, 'settings.pluginProviderManaged{"plugin":"acme"}');+});++test("an account reports sign-in state and subscription, never a missing key", () => {+ assert.deepEqual(badgeKeys(account(), { entry: entry() }), ["subscription"]);+ assert.deepEqual(+ badgeKeys(account({ hasOauth: false, hasSecret: false }), { entry: entry() }),+ ["signed-out", "subscription"],+ );+ const payAsYouGo = entry({ vendor: { ...entry().vendor, isSubscription: false } });+ assert.deepEqual(badgeKeys(account(), { entry: payAsYouGo, isDefault: true }), ["default"]);+});++test("the meta line shows endpoint and model count for services, count for accounts", () => {+ assert.deepEqual(serviceRowMeta(provider(), t), [+ "api.openai.com",+ 'settings.providerModelCount{"count":2}',+ ]);+ assert.deepEqual(serviceRowMeta(provider({ ownerPluginId: "acme" }), t), [+ "api.openai.com",+ 'settings.providerModelCount{"count":2}',+ 'settings.pluginProviderBy{"plugin":"acme"}',+ ]);+ assert.deepEqual(serviceRowMeta(account(), t), ['settings.providerModelCount{"count":2}']);+ assert.deepEqual(serviceRowMeta(account({ hasOauth: false }), t), [+ "settings.vendorDisconnectedDesc",+ ]);+});++test("the monogram is the first letter or digit of the name", () => {+ assert.equal(monogramLetter("openai"), "O");+ assert.equal(monogramLetter(" (beta) gateway"), "B");+ assert.equal(monogramLetter("01.AI"), "0");+ assert.equal(monogramLetter("月之暗面"), "月");+ assert.equal(monogramLetter("—"), "");+});++test("the endpoint host survives an unparseable or missing base URL", () => {+ assert.equal(hostFromBaseUrl("https://api.openai.com/v1"), "api.openai.com");+ assert.equal(hostFromBaseUrl("api.example.com/v1"), "api.example.com");+ assert.equal(hostFromBaseUrl(undefined), "—");+});diff --git a/apps/desktop/test/settings-general.test.mjs b/apps/desktop/test/settings-general.test.mjsindex a63750974..6d783c7d2 100644--- a/apps/desktop/test/settings-general.test.mjs+++ b/apps/desktop/test/settings-general.test.mjs@@ -34,8 +34,17 @@ const marketplaceSettingsSource = await readFile(),"utf8",);-const vendorAccountsSource = await readFile(- new URL("../src/components/settings/VendorAccountsSection.tsx", import.meta.url),+// API services and vendor accounts share one list (D623).+const serviceListSource = await readFile(+ new URL("../src/components/settings/ServiceList.tsx", import.meta.url),+ "utf8",+);+const serviceRowSource = await readFile(+ new URL("../src/components/settings/ServiceRow.tsx", import.meta.url),+ "utf8",+);+const serviceRowStatusSource = await readFile(+ new URL("../src/components/settings/service-row-status.ts", import.meta.url),"utf8",);// Account lifecycle (remove with default repair, save) lives in the hook.@@ -276,8 +285,11 @@ test("default model selector shows every configured model under its provider", (assert.match(stylesSource, /scrollbar-gutter: stable/);});-test("model configuration separates AI services from independently removable vendor accounts", () => {- assert.match(providersSource, /authKind !== OAUTH_AUTH_KIND/);+test("model configuration lists AI services and vendor accounts together", () => {+ // One list (D623): nothing filters OAuth rows out, and no second section.+ assert.doesNotMatch(providersSource, /authKind !== OAUTH_AUTH_KIND/);+ assert.doesNotMatch(providersSource, /VendorAccountsSection/);+ assert.match(providersSource, /<ServiceList\s+providers=\{providers\}/);// Readiness (a key, an OAuth account, or a no-auth provider) now lives in the// shared helper, so the page must delegate to it instead of re-inlining the// rule next to a second copy that can drift from the picker.@@ -288,24 +300,25 @@ test("model configuration separates AI services from independently removable ven);assert.doesNotMatch(providersSource, /provider-config-hero/);assert.doesNotMatch(providersSource, /settings-section-subtitle/);- assert.match(vendorAccountsHookSource, /api\.deleteOauthAccount\(account\.providerId\)/);+ // An account row still lives and dies through the vendor-account editor and+ // deleteOauthAccount, never through the provider CRUD.+ assert.match(+ providersSource,+ /serviceRowKind\(provider\) === "account"\s*\?\s*setEditingAccountId\(provider\.id\)\s*:\s*setSetupFor\(provider\.id\)/,+ );+ assert.match(+ providersSource,+ /serviceRowKind\(provider\) === "account"\s*\?\s*removeAccount\(provider\)\s*:\s*removeProvider\(provider\)/,+ );+ assert.match(providersSource, /<VendorAccountDialog/);+ assert.match(providersSource, /api\.testProvider\(provider\.id\)/);+ assert.match(vendorAccountsHookSource, /api\.deleteOauthAccount\(provider\.id\)/);assert.match(vendorAccountsHookSource, /api\.updateProvider\(/);assert.match(vendorAccountsHookSource, /oauthAccountLabel: form\.name\.trim\(\)/);assert.match(vendorAccountsHookSource, /defaultModelId: form\.modelId\.trim\(\)/);assert.match(vendorAccountsHookSource, /models: form\.models/);- assert.match(vendorAccountsSource, /api\.testProvider\(provider\.id\)/);- assert.match(vendorAccountsSource, /VendorAccountDialog/);- assert.match(- vendorAccountsSource,- /<Button\s+variant="primary"[\s\S]*vendorAddAccount/,- );- assert.doesNotMatch(vendorAccountsSource, /settings-section-subtitle/);- assert.match(vendorAccountsSource, /settings-panel provider-list-panel/);- assert.match(vendorAccountsSource, /provider-row-list/);- assert.match(vendorAccountsSource, /"provider-row",\s*"vendor-account-row"/);- assert.doesNotMatch(vendorAccountsSource, /vendor-card/);- assert.match(stylesSource, /\.provider-row\.vendor-account-row\.is-disconnected/);assert.doesNotMatch(stylesSource, /\.vendor-card-list/);+ assert.doesNotMatch(stylesSource, /vendor-account-row/);// Both credential kinds now pick from the same live, service-provided list.assert.match(vendorAccountDialogSource, /useProviderModels/);assert.match(vendorAccountDialogSource, /<ModelSelectionPanes/);@@ -317,15 +330,42 @@ test("model configuration separates AI services from independently removable venassert.match(vendorPickerSource, /vendors\.map/);});-test("vendor account rows keep the summary line to one account name", () => {- const accountMeta =- vendorAccountsSource.match(- /<div className="provider-row-meta">[\s\S]*?<\/div>/,- )?.[0] ?? "";- assert.match(accountMeta, /vendor-account-label/);- assert.match(accountMeta, /\{accountName\}/);- assert.match(accountMeta, /\{duplicateLabel\}/);- assert.doesNotMatch(accountMeta, /defaultModelId|provider-meta-dot|font-mono/);+test("a service row opens its editor and keeps only a switch and one menu", () => {+ // The row is the way in; every other action sits in the overflow menu.+ assert.match(serviceRowSource, /<CapabilityRowMenu/);+ assert.doesNotMatch(serviceRowSource, /IconPencil|IconTrash|IconCopy|IconPlug|IconStar/);+ assert.match(serviceListSource, /IconPencil[\s\S]*IconTrash/);+ // The click sits on the row so a card drag can start anywhere on it, while+ // presses on the row's own controls never open the editor.+ assert.match(serviceRowSource, /const OWN_CONTROLS = "button, input, select, textarea, a, label/);+ assert.match(serviceRowSource, /event\.target !== event\.currentTarget \|\| !onOpen \|\| busy/);+ // An account has no enable switch; a plugin's switch belongs to the plugin.+ assert.match(serviceRowSource, /kind !== "account" \? \(/);+ assert.match(serviceRowSource, /disabled=\{busy \|\| kind === "plugin"\}/);+ // A plugin owns its row, so neither edit nor remove is offered for one.+ assert.match(serviceListSource, /if \(kind !== "plugin"\) \{\s*items\.push\(\{\s*key: "edit"/);+ assert.match(serviceListSource, /if \(kind !== "plugin"\) \{\s*const isArmed/);+ // Removal is confirmed inside the menu rather than by a second row button.+ assert.match(serviceListSource, /useArmedDelete\(\)/);+ assert.match(serviceListSource, /settings\.capabilityRemoveConfirm/);+ // D297: the plugin key entry is set apart by spacing, never by a rule.+ const keyEntry = stylesSource.match(/\.model-provider-key-entry\s*\{([^}]*)\}/)?.[1];+ assert.ok(keyEntry, ".model-provider-key-entry rule is missing");+ assert.doesNotMatch(keyEntry, /border/);+});++test("vendor account rows keep the summary to one account name", () => {+ // The account sits in the title beside its vendor; the meta line holds only+ // what service-row-status derives, never the default model id.+ assert.match(+ serviceRowSource,+ /<span className="model-provider-row-account">\{title\.account\}<\/span>/,+ );+ assert.doesNotMatch(serviceRowSource, /defaultModelId|font-mono/);+ assert.match(+ serviceRowStatusSource,+ /return provider\.hasOauth \? \[models\] : \[t\("settings\.vendorDisconnectedDesc"\)\]/,+ );});test("OAuth account identity is provider-scoped across IPC and pi-ai", () => {diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.tsindex 9aa50c52f..8e3c67662 100644--- a/packages/i18n/src/locales/de/index.ts+++ b/packages/i18n/src/locales/de/index.ts@@ -1341,6 +1341,8 @@ sklm: {"removeModel": "Modell entfernen","reorderModel": "Reihenfolge von {{name}} ändern. Ziehen oder die Pfeiltasten nach oben und unten verwenden.","reorderProvider": "Reihenfolge von {{name}} ändern. Ziehen oder die Pfeiltasten nach oben und unten verwenden.",+ "serviceRowLabel": "{{name}}. Eingabetaste zum Bearbeiten; ziehen oder die Pfeiltasten nach oben und unten zum Umsortieren verwenden.",+ "serviceRowActions": "Aktionen für {{name}}",providerOrderFailed: "Anbieterreihenfolge konnte nicht gespeichert werden: {{error}}","modelAlias": "Alias","modelAliasHint": "Wird überall angezeigt, wo das Modell benannt wird; die ID bleibt die Identität der Anfrage.",diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.tsindex 0b741126e..45f564b82 100644--- a/packages/i18n/src/locales/en/index.ts+++ b/packages/i18n/src/locales/en/index.ts@@ -1360,6 +1360,8 @@ sklm: {removeModel: "Remove model",reorderModel: "Reorder {{name}}. Drag or use the Up and Down arrow keys.",reorderProvider: "Reorder {{name}}. Drag or use the Up and Down arrow keys.",+ serviceRowLabel: "{{name}}. Press Enter to edit; drag or use the Up and Down arrow keys to reorder.",+ serviceRowActions: "Actions for {{name}}",providerOrderFailed: "Could not save provider order: {{error}}",modelAlias: "Alias",modelAliasHint: "Shown wherever the model is named. The id stays the request identity.",diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.tsindex 62befdb84..dbb82d9cf 100644--- a/packages/i18n/src/locales/es/index.ts+++ b/packages/i18n/src/locales/es/index.ts@@ -1341,6 +1341,8 @@ sklm: {"removeModel": "Eliminar modelo","reorderModel": "Reordenar {{name}}. Arrastra o usa las flechas arriba y abajo.","reorderProvider": "Reordenar {{name}}. Arrastra o usa las flechas arriba y abajo.",+ "serviceRowLabel": "{{name}}. Pulsa Intro para editar; arrastra o usa las flechas arriba y abajo para reordenar.",+ "serviceRowActions": "Acciones para {{name}}",providerOrderFailed: "No se pudo guardar el orden de los proveedores: {{error}}","modelAlias": "Alias","modelAliasHint": "Se muestra dondequiera que se nombre el modelo; el id sigue siendo la identidad de la solicitud.",diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.tsindex 9a34e4116..7b971f479 100644--- a/packages/i18n/src/locales/fr/index.ts+++ b/packages/i18n/src/locales/fr/index.ts@@ -1341,6 +1341,8 @@ sklm: {"removeModel": "Supprimer le modèle","reorderModel": "Réordonner {{name}}. Faites glisser ou utilisez les flèches haut et bas.","reorderProvider": "Réordonner {{name}}. Faites glisser ou utilisez les flèches haut et bas.",+ "serviceRowLabel": "{{name}}. Appuyez sur Entrée pour modifier ; faites glisser ou utilisez les flèches haut et bas pour réordonner.",+ "serviceRowActions": "Actions pour {{name}}",providerOrderFailed: "Impossible d’enregistrer l’ordre des fournisseurs : {{error}}","modelAlias": "Alias","modelAliasHint": "Affiché partout où le modèle est nommé ; l'id reste l'identité de la requête.",diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.tsindex e98bec760..2fc3011dd 100644--- a/packages/i18n/src/locales/ko/index.ts+++ b/packages/i18n/src/locales/ko/index.ts@@ -1358,6 +1358,8 @@ sklm: {removeModel: "모델 제거",reorderModel: "{{name}} 순서 변경. 드래그하거나 위쪽 및 아래쪽 화살표 키를 사용하세요.",reorderProvider: "{{name}} 순서 변경. 드래그하거나 위쪽 및 아래쪽 화살표 키를 사용하세요.",+ serviceRowLabel: "{{name}}. Enter 키를 눌러 편집하고, 드래그하거나 위쪽 및 아래쪽 화살표 키로 순서를 변경하세요.",+ serviceRowActions: "{{name}} 작업",providerOrderFailed: "공급자 순서를 저장하지 못했습니다: {{error}}",modelAlias: "별칭",modelAliasHint: "모델 이름이 표시되는 곳마다 사용됩니다. ID는 요청 식별자로 유지됩니다.",diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.tsindex efe71b931..575ab4cac 100644--- a/packages/i18n/src/locales/tr/index.ts+++ b/packages/i18n/src/locales/tr/index.ts@@ -1348,6 +1348,8 @@ sklm: {removeModel: "Modeli kaldır",reorderModel: "{{name}} sırasını değiştir. Sürükleyin veya Yukarı ve Aşağı ok tuşlarını kullanın.",reorderProvider: "{{name}} sırasını değiştir. Sürükleyin veya Yukarı ve Aşağı ok tuşlarını kullanın.",+ serviceRowLabel: "{{name}}. Düzenlemek için Enter'a basın; sırayı değiştirmek için sürükleyin veya Yukarı ve Aşağı ok tuşlarını kullanın.",+ serviceRowActions: "{{name}} eylemleri",providerOrderFailed: "Sağlayıcı sırası kaydedilemedi: {{error}}",modelAlias: "Takma ad",modelAliasHint: "Modelin adlandırıldığı her yerde gösterilir; istek kimliği model ID olarak kalır.",diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.tsindex 07e888332..05b03d4cf 100644--- a/packages/i18n/src/locales/zh-CN/index.ts+++ b/packages/i18n/src/locales/zh-CN/index.ts@@ -1328,6 +1328,8 @@ sklm: {removeModel: "移除模型",reorderModel: "调整 {{name}} 的顺序。拖动或使用上下方向键。",reorderProvider: "调整 {{name}} 的顺序。拖动或使用上下方向键。",+ serviceRowLabel: "{{name}}。按 Enter 编辑;拖动或使用上下方向键调整顺序。",+ serviceRowActions: "{{name}} 的操作",providerOrderFailed: "无法保存供应商顺序:{{error}}",modelAlias: "别名",modelAliasHint: "在显示模型名称的地方生效;请求仍使用模型 ID。",diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.tsindex d1fe4b3a6..b55fbb051 100644--- a/packages/i18n/src/locales/zh-TW/index.ts+++ b/packages/i18n/src/locales/zh-TW/index.ts@@ -1328,6 +1328,8 @@ sklm: {removeModel: "移除模型",reorderModel: "調整 {{name}} 的順序。拖曳或使用上下方向鍵。",reorderProvider: "調整 {{name}} 的順序。拖曳或使用上下方向鍵。",+ serviceRowLabel: "{{name}}。按 Enter 編輯;拖曳或使用上下方向鍵調整順序。",+ serviceRowActions: "{{name}} 的操作",providerOrderFailed: "無法儲存供應商順序:{{error}}",modelAlias: "別名",modelAliasHint: "在顯示模型名稱的地方生效;請求仍使用模型 ID。",diff --git a/scripts/e2e/image-generation-ui.tsx b/scripts/e2e/image-generation-ui.tsxindex d2b85798c..370128f3a 100644--- a/scripts/e2e/image-generation-ui.tsx+++ b/scripts/e2e/image-generation-ui.tsx@@ -107,6 +107,11 @@ globalThis.imageGenerationProbe = async () => {assert(element, "missing click target");flushSync(() => element!.click());};+ // A service row opens its own editor (D623); without a name, the first row.+ const editProvider = (name?: string) =>+ click([...container.querySelectorAll<HTMLElement>(".model-provider-row")].find(+ (element) => !name || element.querySelector(".model-provider-row-name")?.textContent === name,+ ));const button = (text: string) =>[...document.querySelectorAll<HTMLButtonElement>("button")].find((element) => element.textContent?.trim() === text,@@ -130,15 +135,8 @@ globalThis.imageGenerationProbe = async () => {(element) => element.textContent?.includes(i18n.t("settings.imageModel")),);assert(!initialImageRow, "unconfigured image model row should be hidden");- const edit =- container.querySelector<HTMLButtonElement>(- 'button[aria-label="' + i18n.t("settings.editProvider") + '"]',- ) ??- container.querySelector<HTMLButtonElement>(- ".model-provider-row button[aria-label*='Edit']",- );// Enter from the real model settings page, not the advanced pane alone.- click(edit);+ editProvider();await until(() => !!imageModelToggle(i18n.t("settings.setImageModel")),"advanced image-model capability missing",@@ -147,11 +145,7 @@ globalThis.imageGenerationProbe = async () => {assert(!settings.imageGeneration, "draft selection persisted before Save");click(button(i18n.t("settings.cancel")));assert(!settings.imageGeneration, "cancel changed binding");- click(- container.querySelector<HTMLButtonElement>(- 'button[aria-label="' + i18n.t("settings.editProvider") + '"]',- ),- );+ editProvider();await until(() => !!imageModelToggle(i18n.t("settings.setImageModel")),"second edit did not mount",@@ -205,8 +199,7 @@ globalThis.imageGenerationProbe = async () => {};assert(textStyle(row.querySelector(".model-default-provider")) === textStyle(defaultRow.querySelector(".model-default-provider")), "provider typography differs from default model");assert(textStyle(row.querySelector(".model-default-model")) === textStyle(defaultRow.querySelector(".model-default-model")), "model typography differs from default model");- const alternateRow = [...container.querySelectorAll<HTMLElement>(".model-provider-row")].find((element) => element.textContent?.includes("Images B"));- click(alternateRow?.querySelector<HTMLButtonElement>('button[aria-label="' + i18n.t("settings.editProvider") + '"]'));+ editProvider("Images B");await until(() => !!imageModelToggle(i18n.t("settings.setImageModel")),"alternate provider edit missing",@@ -258,9 +251,7 @@ globalThis.imageGenerationProbe = async () => {imageGenerationModels: [{ providerId: "chat", modelId: "chat-model" }],};flushSync(() => useAppStore.setState({ settings, providers: [...providers] }));- const editOnlyProvider = () => click(container.querySelector<HTMLButtonElement>(- 'button[aria-label="' + i18n.t("settings.editProvider") + '"]',- ));+ const editOnlyProvider = () => editProvider();editOnlyProvider();await until(() => !!imageModelToggle(i18n.t("settings.imageModelSelected")), "selected image checkbox missing");click(imageModelToggle(i18n.t("settings.imageModelSelected")));@@ -306,9 +297,7 @@ globalThis.imageGenerationProbe = async () => {defaultModelId: remaining ? "chat-model" : "image-one",};flushSync(() => useAppStore.setState({ settings, providers: [...providers] }));- const editImages = () => click(container.querySelector<HTMLButtonElement>(- 'button[aria-label="' + i18n.t("settings.editProvider") + '"]',- ));+ const editImages = () => editProvider();const removeImage = async () => {await until(() => !!document.querySelector(".provider-chosen-row"), "chosen models missing");const chosen = [...document.querySelectorAll<HTMLElement>(".provider-chosen-row")]diff --git a/scripts/e2e/provider-order.tsx b/scripts/e2e/provider-order.tsxindex 543484b3b..0202a9737 100644--- a/scripts/e2e/provider-order.tsx+++ b/scripts/e2e/provider-order.tsx@@ -165,7 +165,7 @@ globalThis.providerOrderProbe = async (restart = false) => {await painted();// Saving a provider must preserve the exact app default picked by the user.- const click = (element: HTMLButtonElement | null) => {+ const click = (element: HTMLElement | null) => {assert(element, "missing provider action");flushSync(() => {element!.dispatchEvent(new PointerEvent("pointerdown", { pointerId: 5, button: 0, bubbles: true }));@@ -177,11 +177,10 @@ globalThis.providerOrderProbe = async (restart = false) => {click(document.querySelector('[aria-label="A · deepseek-reasoner"]'));await until(() => useAppStore.getState().settings?.defaultModelId === "deepseek-reasoner","default picker did not select the second model");+ // The row itself opens its editor (D623).const edit = async (name: string) => {- const selector = `[aria-label="${i18n.t("settings.editProvider")}"]`;- await until(() => !row(name).querySelector<HTMLButtonElement>(selector)?.disabled,- "provider is still saving");- click(row(name).querySelector(selector));+ await until(() => row(name).getAttribute("aria-disabled") !== "true", "provider is still saving");+ click(row(name));await until(() => !!document.querySelector(".provider-setup-dialog"), "provider editor did not open");};const save = async () => {