Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(settings): finish model settings integration
vastsa91abb78b69a8
diff --git a/apps/desktop/src/components/settings/ChosenModelsSummary.tsx b/apps/desktop/src/components/settings/ChosenModelsSummary.tsxindex 82718c545..69244c8ec 100644--- a/apps/desktop/src/components/settings/ChosenModelsSummary.tsx+++ b/apps/desktop/src/components/settings/ChosenModelsSummary.tsx@@ -1,5 +1,5 @@/**- * The chosen models of a service or account, as a short list (D623).+ * The chosen models of a service or account, as a short list (D625).** Most people keep the models a service starts with, so the form shows what* is chosen and leaves the two-pane picker one click away instead of openingdiff --git a/apps/desktop/src/components/settings/ProviderConnectionFields.tsx b/apps/desktop/src/components/settings/ProviderConnectionFields.tsxindex 68f7a193b..abb668cf5 100644--- a/apps/desktop/src/components/settings/ProviderConnectionFields.tsx+++ b/apps/desktop/src/components/settings/ProviderConnectionFields.tsx@@ -1,6 +1,6 @@/*** The connection half of the AI service form: which service, its key, and for- * a custom endpoint the name, URL and API format (D310, D623).+ * a custom endpoint the name, URL and API format (D310, D625).** The chosen service reads as a settled fact with a Change action rather than* an open menu, and a status line under the key says whether the servicediff --git a/apps/desktop/src/components/settings/ServiceChooser.tsx b/apps/desktop/src/components/settings/ServiceChooser.tsxindex a1fb919a3..fc8efa5cf 100644--- a/apps/desktop/src/components/settings/ServiceChooser.tsx+++ b/apps/desktop/src/components/settings/ServiceChooser.tsx@@ -1,6 +1,6 @@/*** Where a new AI service starts: every way to connect, on one searchable page- * (D623).+ * (D625).** The old form opened on a closed Service menu, and subscriptions had their* own button and dialog further down the page, so the first decision wasdiff --git a/apps/desktop/src/components/settings/ServiceList.tsx b/apps/desktop/src/components/settings/ServiceList.tsxindex 1211218fc..25fa90067 100644--- a/apps/desktop/src/components/settings/ServiceList.tsx+++ b/apps/desktop/src/components/settings/ServiceList.tsx@@ -1,5 +1,5 @@/**- * The AI service list (D623): API services, plugin-declared services and+ * The AI service list (D625): 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 isdiff --git a/apps/desktop/src/components/settings/ServiceMonogram.tsx b/apps/desktop/src/components/settings/ServiceMonogram.tsxindex ec7bc0a3a..64bcb6216 100644--- a/apps/desktop/src/components/settings/ServiceMonogram.tsx+++ b/apps/desktop/src/components/settings/ServiceMonogram.tsx@@ -1,5 +1,5 @@/**- * The letter tile that leads an AI service (D623).+ * The letter tile that leads an AI service (D625).** 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 givesdiff --git a/apps/desktop/src/components/settings/ServiceRow.tsx b/apps/desktop/src/components/settings/ServiceRow.tsxindex 1a38a0b7d..ab786d18c 100644--- a/apps/desktop/src/components/settings/ServiceRow.tsx+++ b/apps/desktop/src/components/settings/ServiceRow.tsx@@ -1,5 +1,5 @@/**- * One row of the AI service list (D623): an API service, a plugin-declared+ * One row of the AI service list (D625): 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@@ -11,7 +11,7 @@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 { Badge, Button, Field, Input, SettingsToggle, cx } from "../ui";import { CapabilityRowMenu, type CapabilityMenuItem } from "./AgentCapabilityLayout";import { ServiceMonogram } from "./ServiceMonogram";import {@@ -170,22 +170,12 @@ export function ServiceRow({{/* A plugin refreshes its row from its manifest on every load, so theswitch 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")}+ <SettingsToggle+ checked={provider.enabled}+ label={t("settings.enabledToggle")}disabled={busy || kind === "plugin"}- onClick={onToggleEnabled}- >- <span className="settings-toggle-thumb" />- </TooltipButton>+ onChange={onToggleEnabled}+ />) : null}<CapabilityRowMenulabel={t("settings.serviceRowActions", { name: title.label })}diff --git a/apps/desktop/src/components/settings/VendorAccountDialog.tsx b/apps/desktop/src/components/settings/VendorAccountDialog.tsxindex 88dbf0fdb..ec89594d2 100644--- a/apps/desktop/src/components/settings/VendorAccountDialog.tsx+++ b/apps/desktop/src/components/settings/VendorAccountDialog.tsx@@ -7,7 +7,7 @@* than every model the vendor publishes. Choosing among those rows is* `ModelSelectionPanes`, the same picker the AI service dialog renders, so an* account is not a reduced version of a service. Like a service, the dialog- * opens on the chosen-models summary and the picker is one click away (D623).+ * opens on the chosen-models summary and the picker is one click away (D625).*/import { useEffect, useRef, useState } from "react";import {diff --git a/apps/desktop/src/components/settings/service-row-status.ts b/apps/desktop/src/components/settings/service-row-status.tsindex d7f68f61c..09e3ed0f3 100644--- a/apps/desktop/src/components/settings/service-row-status.ts+++ b/apps/desktop/src/components/settings/service-row-status.ts@@ -1,5 +1,5 @@/**- * What one row of the AI service list says about itself (D623).+ * What one row of the AI service list says about itself (D625).** API services, plugin-declared services and vendor subscription accounts share* one list. These pure helpers decide a row's kind, title, badges and meta linediff --git a/apps/desktop/src/components/settings/useRecommendedModelSelection.ts b/apps/desktop/src/components/settings/useRecommendedModelSelection.tsindex 91dbfa461..8a12bcfd1 100644--- a/apps/desktop/src/components/settings/useRecommendedModelSelection.ts+++ b/apps/desktop/src/components/settings/useRecommendedModelSelection.ts@@ -1,5 +1,5 @@/**- * Preselect recommended models on a new AI service (D623).+ * Preselect recommended models on a new AI service (D625).** The add form used to open with nothing chosen, so saving a key was never* enough: every user had to find a chat model in a list of dozens. This hookdiff --git a/apps/desktop/src/components/settings/useVendorAccounts.ts b/apps/desktop/src/components/settings/useVendorAccounts.tsindex 391780763..f0f21d182 100644--- a/apps/desktop/src/components/settings/useVendorAccounts.ts+++ b/apps/desktop/src/components/settings/useVendorAccounts.ts@@ -1,5 +1,5 @@/**- * Vendor (OAuth) accounts for the model settings page (ADR 0098, D623).+ * Vendor (OAuth) accounts for the model settings page (ADR 0098, D625).** 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 runtimediff --git a/apps/desktop/src/lib/settings-search.ts b/apps/desktop/src/lib/settings-search.tsindex 6bde5fef7..ce27479ab 100644--- a/apps/desktop/src/lib/settings-search.ts+++ b/apps/desktop/src/lib/settings-search.ts@@ -175,7 +175,7 @@ export const SETTINGS_NAV: SettingsNavEntry[] = ["settings.apiKey","settings.baseUrl","settings.apiStyle",- // Subscription accounts share the service list (D623).+ // Subscription accounts share the service list (D625)."settings.vendorAccounts","settings.vendorSubscription",],diff --git a/apps/desktop/src/styles/service-setup.css b/apps/desktop/src/styles/service-setup.cssindex ca840dda7..382a1f37f 100644--- a/apps/desktop/src/styles/service-setup.css+++ b/apps/desktop/src/styles/service-setup.css@@ -1,5 +1,5 @@/*- The AI service dialog's chooser view and chosen-models summary (D623).+ The AI service dialog's chooser view and chosen-models summary (D625).In-flow tiles only (D297): tone and spacing separate them, never a stroke.*/diff --git a/apps/desktop/test/provider-form-layout.test.mjs b/apps/desktop/test/provider-form-layout.test.mjsindex 505183f04..8314c1869 100644--- a/apps/desktop/test/provider-form-layout.test.mjs+++ b/apps/desktop/test/provider-form-layout.test.mjs@@ -20,7 +20,7 @@ const vendorDialogSource = await read("../src/components/settings/VendorAccountD// The panes themselves live in the picker both dialogs render (D269).const pickerSource = await read("../src/components/settings/ModelSelectionPanes.tsx");const fetchErrorSource = await read("../src/components/settings/ModelsFetchErrorMessage.tsx");-// The credential rows live in their own component since D623.+// The credential rows live in their own component since D625.const fieldsSource = await read("../src/components/settings/ProviderConnectionFields.tsx");const summarySource = await read("../src/components/settings/ChosenModelsSummary.tsx");const styles = await loadStyles();@@ -377,7 +377,7 @@ test("Advanced says a fullwidth value folds and a non-Latin-1 value is refused",assert.match(block(".provider-setup-header-note"), /color: var\(--ds-text-muted\)/);});-test("models open as a summary with the full picker one click away (D623)", () => {+test("models open as a summary with the full picker one click away (D625)", () => {for (const source of [setupSource, vendorDialogSource]) {assert.match(source, /managing \?/);assert.match(source, /<ChosenModelsSummary/);diff --git a/apps/desktop/test/service-chooser.test.mjs b/apps/desktop/test/service-chooser.test.mjsindex 6f61076e5..3f93e9afc 100644--- a/apps/desktop/test/service-chooser.test.mjs+++ b/apps/desktop/test/service-chooser.test.mjs@@ -21,7 +21,7 @@ const rule = (selector) => {return match[1];};-test("a new service starts on a searchable chooser, not a closed menu (D623)", () => {+test("a new service starts on a searchable chooser, not a closed menu (D625)", () => {assert.match(setupSource, /<ServiceChooser/);assert.match(setupSource, /const chooserOpen = choosing \|\| !service/);assert.match(setupSource, /\{chooserOpen \? chooserView : formView\}/);diff --git a/apps/desktop/test/service-row-status.test.mjs b/apps/desktop/test/service-row-status.test.mjsindex e1aba04cc..e33c42efa 100644--- a/apps/desktop/test/service-row-status.test.mjs+++ b/apps/desktop/test/service-row-status.test.mjs@@ -1,5 +1,5 @@/**- * Behavior of the unified AI service row (D623): API services, plugin services+ * Behavior of the unified AI service row (D625): 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.diff --git a/apps/desktop/test/settings-general.test.mjs b/apps/desktop/test/settings-general.test.mjsindex 040ce89e2..70af1a94a 100644--- a/apps/desktop/test/settings-general.test.mjs+++ b/apps/desktop/test/settings-general.test.mjs@@ -34,7 +34,7 @@ const marketplaceSettingsSource = await readFile(),"utf8",);-// API services and vendor accounts share one list (D623).+// API services and vendor accounts share one list (D625).const serviceListSource = await readFile(new URL("../src/components/settings/ServiceList.tsx", import.meta.url),"utf8",@@ -56,7 +56,7 @@ const vendorAccountDialogSource = await readFile(new URL("../src/components/settings/VendorAccountDialog.tsx", import.meta.url),"utf8",);-// Subscriptions are picked in the service chooser since D623.+// Subscriptions are picked in the service chooser since D625.const serviceChooserSource = await readFile(new URL("../src/components/settings/ServiceChooser.tsx", import.meta.url),"utf8",@@ -290,7 +290,7 @@ test("default model selector shows every configured model under its provider", (});test("model configuration lists AI services and vendor accounts together", () => {- // One list (D623): nothing filters OAuth rows out, and no second section.+ // One list (D625): 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\}/);diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.tsindex 4869d1d4b..1a063e5b8 100644--- a/packages/i18n/src/locales/pt-BR/index.ts+++ b/packages/i18n/src/locales/pt-BR/index.ts@@ -1247,9 +1247,33 @@ export const ptBR = {apiStyleChatCompletions: "OpenAI Chat Completions",apiStyleOpenCodeGo: "OpenCode Go",service: "Serviço",- chooseService: "Escolha um serviço de IA",searchService: "Filtrar serviços",noServiceMatches: "Nenhum serviço correspondente.",+ useCustomEndpoint: "Usar um endpoint personalizado",+ chooserSubscriptions: "Entrar com uma assinatura",+ chooserApiKeys: "Conectar com uma chave de API",+ customEndpointDesc: "Qualquer URL compatível com OpenAI ou Anthropic",+ connectionKeyHint: "Cole uma chave de API para conectar e carregar modelos.",+ connectionUrlHint: "Insira uma URL base para conectar e carregar modelos.",+ connectionChecking: "Conectando…",+ connectionReady_one: "Conectado · {{count}} modelo encontrado",+ connectionReady_other: "Conectado · {{count}} modelos encontrados",+ connectionCatalog_one: "{{count}} modelo conhecido para este serviço",+ connectionCatalog_other: "{{count}} modelos conhecidos para este serviço",+ connectionNoModelList_one: "Este serviço não lista modelos · {{count}} modelo conhecido",+ connectionNoModelList_other: "Este serviço não lista modelos · {{count}} modelos conhecidos",+ changeService: "Alterar",+ changeServiceTitle: "Alterar serviço",+ modelsSummaryTitle: "Modelos",+ modelsSummaryLoading: "Carregando modelos…",+ modelsSummaryFailed: "Não foi possível carregar modelos. Verifique a conexão acima ou adicione um modelo pelo ID.",+ manageModels: "Gerenciar modelos",+ collapseModels: "Recolher",+ addModelManually: "Adicionar modelo manualmente",+ modelReasoningTag: "Raciocínio",+ modelsAutoPicked: "Selecionados entre os modelos recomendados. Ajuste-os em Gerenciar modelos.",+ serviceRowLabel: "{{name}}. Pressione Enter para editar; arraste ou use as teclas de seta para cima e para baixo para reordenar.",+ serviceRowActions: "Ações de {{name}}",presetOpenai: "OpenAI",presetAnthropic: "Anthropic",presetGoogle: "Google Gemini",@@ -1283,10 +1307,7 @@ export const ptBR = {apiStylePiMessages: "Mensagens Pi (Radius)",close: "Fechar",vendorAccounts: "Contas de provedores",- vendorAddAccount: "Adicionar conta",vendorNoAccounts: "Nenhuma conta conectada.",- vendorPickTitle: "Conectar conta",- vendorPickDesc: "Escolha uma conta para autenticar com este provedor.",vendorSignInTo: "Entrar no {{vendor}}",vendorConnected: "Conectado",vendorDisconnected: "Requer login",diff --git a/scripts/e2e/image-generation-ui.tsx b/scripts/e2e/image-generation-ui.tsxindex 370128f3a..bd1a90bb9 100644--- a/scripts/e2e/image-generation-ui.tsx+++ b/scripts/e2e/image-generation-ui.tsx@@ -107,7 +107,7 @@ 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.+ // A service row opens its own editor (D625); 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,@@ -116,6 +116,11 @@ globalThis.imageGenerationProbe = async () => {[...document.querySelectorAll<HTMLButtonElement>("button")].find((element) => element.textContent?.trim() === text,);+ const editProviderForModelSettings = async (name?: string) => {+ editProvider(name);+ await until(() => !!button(i18n.t("settings.manageModels")), "model summary action missing");+ click(button(i18n.t("settings.manageModels")));+ };const imageModelToggle = (label: string) =>[...document.querySelectorAll<HTMLInputElement>(".provider-chosen-capability input[type=\"checkbox\"]",@@ -136,7 +141,7 @@ globalThis.imageGenerationProbe = async () => {);assert(!initialImageRow, "unconfigured image model row should be hidden");// Enter from the real model settings page, not the advanced pane alone.- editProvider();+ await editProviderForModelSettings();await until(() => !!imageModelToggle(i18n.t("settings.setImageModel")),"advanced image-model capability missing",@@ -145,7 +150,7 @@ globalThis.imageGenerationProbe = async () => {assert(!settings.imageGeneration, "draft selection persisted before Save");click(button(i18n.t("settings.cancel")));assert(!settings.imageGeneration, "cancel changed binding");- editProvider();+ await editProviderForModelSettings();await until(() => !!imageModelToggle(i18n.t("settings.setImageModel")),"second edit did not mount",@@ -199,7 +204,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");- editProvider("Images B");+ await editProviderForModelSettings("Images B");await until(() => !!imageModelToggle(i18n.t("settings.setImageModel")),"alternate provider edit missing",@@ -241,7 +246,15 @@ globalThis.imageGenerationProbe = async () => {const unsetImageRow = [...container.querySelectorAll<HTMLElement>(".settings-row")].find((element) => element.textContent?.includes(i18n.t("settings.imageModel")),);- assert(!unsetImageRow, "unset image model row should be hidden");+ assert(unsetImageRow, "remaining image candidates should stay selectable without an active default");+ assert(+ unsetImageRow.querySelector('[role="status"]')?.textContent === i18n.t("settings.imageModelUnset"),+ "cleared image default should show an unset state",+ );+ assert(+ unsetImageRow.querySelector('button[aria-haspopup="listbox"]'),+ "remaining image candidates should stay in the selector",+ );// Issue #826: release the only chat model through the real edit/save path.providers.splice(0, providers.length, chatProvider);@@ -251,13 +264,12 @@ globalThis.imageGenerationProbe = async () => {imageGenerationModels: [{ providerId: "chat", modelId: "chat-model" }],};flushSync(() => useAppStore.setState({ settings, providers: [...providers] }));- const editOnlyProvider = () => editProvider();- editOnlyProvider();+ await editProviderForModelSettings();await until(() => !!imageModelToggle(i18n.t("settings.imageModelSelected")), "selected image checkbox missing");click(imageModelToggle(i18n.t("settings.imageModelSelected")));click(button(i18n.t("settings.cancel")));assert(settings.imageGeneration?.modelId === "chat-model", "cancel cleared the image default");- editOnlyProvider();+ await editProviderForModelSettings();await until(() => !!imageModelToggle(i18n.t("settings.imageModelSelected")), "selected checkbox did not reopen");click(imageModelToggle(i18n.t("settings.imageModelSelected")));click(button(i18n.t("settings.saveProvider")));@@ -271,7 +283,7 @@ globalThis.imageGenerationProbe = async () => {flushSync(() => useAppStore.setState({ settings: structuredClone(settings) }));render();assert(!container.querySelector(".model-image-row"), "image summary returned after reopen");- editOnlyProvider();+ await editProviderForModelSettings();await until(() => !!imageModelToggle(i18n.t("settings.setImageModel")), "unmarked checkbox did not persist");assert(!imageModelToggle(i18n.t("settings.setImageModel"))?.checked, "reopened model is still marked");click(button(i18n.t("settings.cancel")));diff --git a/scripts/e2e/provider-api-style.tsx b/scripts/e2e/provider-api-style.tsxindex 1f6e3d434..55bc1f079 100644--- a/scripts/e2e/provider-api-style.tsx+++ b/scripts/e2e/provider-api-style.tsx@@ -164,11 +164,15 @@ globalThis.providerApiStyleProbe = async () => {};const searchInput = () => [...document.querySelectorAll<HTMLInputElement>("input[type=checkbox]")].find((input) => input.closest("label")?.textContent?.trim() === i18n.t("settings.nativeWebSearch"));+ const openModelManager = async () => {+ click(control("settings.manageModels"));+ await until(() => Boolean(searchInput()), "model capability settings");+ };try {for (const locale of ["en", "zh-CN"]) {await i18n.changeLanguage(locale);render();- // A new service opens on the chooser (D623); the custom endpoint is the+ // A new service opens on the chooser (D625); the custom endpoint is the// last tile, and picking it moves to the form.const tiles = [...document.querySelectorAll<HTMLButtonElement>("[data-service-id]")];assert(tiles.length > 1, `${locale}: service chooser tiles missing`);@@ -244,6 +248,7 @@ globalThis.providerApiStyleProbe = async () => {const original = { ...fixture("chat_completions"), name: "My service", vendorKey, baseUrl,models: [{ ...fixture("chat_completions").models[0], id: modelId }] };render({ provider: original });+ await openModelManager();await until(() => Boolean(searchInput()), "official model settings");assert(!searchInput()?.disabled && !searchInput()?.checked, `${vendorKey}: search must be directly selectable and default off`);assert(!document.querySelector(".provider-endpoint-guidance"), "official search requires an extra interface action");@@ -252,6 +257,7 @@ globalThis.providerApiStyleProbe = async () => {click(control("settings.cancel"));assert(updates.length === count, "cancel persisted the search opt-in");render({ provider: original });+ await openModelManager();click(searchInput());click(control("settings.saveProvider"));await until(() => updates.length === count + 1, "save search opt-in");@@ -261,6 +267,7 @@ globalThis.providerApiStyleProbe = async () => {assert(update.name === original.name && !("secretValue" in update), "search opt-in replaced name or key");assert(update.models?.[0].nativeWebSearch === true && update.models[0].alias === "Fixture alias", "model settings lost");render({ provider: { ...original, ...update } });+ await openModelManager();assert(searchInput()?.checked && !searchInput()?.disabled, "search opt-in was lost on reopen");click(searchInput());click(control("settings.saveProvider"));@@ -316,7 +323,7 @@ globalThis.providerApiStyleProbe = async () => {const accountAdvanced = document.querySelector<HTMLButtonElement>(".provider-chosen-advanced-toggle");if (accountAdvanced?.getAttribute("aria-expanded") === "false") click(accountAdvanced);await pause(650);- // Models open as a summary (D623); the per-model controls sit behind+ // Models open as a summary (D625); the per-model controls sit behind// Manage models and the row's own Advanced disclosure.assert(document.querySelector(".provider-models-summary"), `${locale}: account dialog did not open on the summary`);click(control("settings.manageModels"));diff --git a/scripts/e2e/provider-order.tsx b/scripts/e2e/provider-order.tsxindex 0202a9737..580b0f451 100644--- a/scripts/e2e/provider-order.tsx+++ b/scripts/e2e/provider-order.tsx@@ -177,7 +177,7 @@ 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).+ // The row itself opens its editor (D625).const edit = async (name: string) => {await until(() => row(name).getAttribute("aria-disabled") !== "true", "provider is still saving");click(row(name));