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(models): keep stacked model lists scrollable
xjxfcd250d901a3
diff --git a/apps/desktop/src/styles/model-config.css b/apps/desktop/src/styles/model-config.cssindex d0b7b70f1..c9d2c95bd 100644--- a/apps/desktop/src/styles/model-config.css+++ b/apps/desktop/src/styles/model-config.css@@ -1771,6 +1771,8 @@}.provider-setup-panes {+ /* Let the body scroll instead of squeezing stacked lists below a row. */+ flex: none;grid-template-columns: minmax(0, 1fr);}diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.mdindex 4e4941696..c4d6e0cba 100644--- a/docs/spec/04-ux/06-settings-ia.md+++ b/docs/spec/04-ux/06-settings-ia.md@@ -418,6 +418,10 @@ a usage tab.row and keeps the global default model in sync when that account is selected- Test connection resolves the account's OAuth authorization and reports atransient success or failure without probing the provider with an API key+ - At viewport widths up to 940px, both provider and vendor-account model+ panes stack without shrinking to the remaining dialog height. Each model+ list scrolls within its bounded tray; the dialog body scrolls to reach+ either tray. Short, wide windows retain the side-by-side layout.- **Providers** studio:- OpenAI-compatible and custom-service add-provider dialog (opened from Addprovider / empty-state CTA)diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex dc1b2ab1e..824ea9570 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -1031,6 +1031,19 @@ identify the platform validation still needed.- **Milestone**: M2- **Status**: Unit-covered host migration; manual UI journey+#### E2E-MODELS-list-layout: Model lists remain browsable in constrained windows++- **Preconditions:** 60 discovered and configured models; isolated Electron+ fixture with real provider/account dialogs, hooks and production styles.+- **Steps:** Open both dialog types at 850×600, 850×850, 1000×560, 1200×700+ and 1600×1000 content sizes. Scroll each list to its last and first model.+- **Expected:** Every list displays at least one complete row. Both endpoints+ are fully visible inside the list, dialog body and viewport. Narrow panes+ stack; short wide windows keep the side-by-side layout.+- **Command:** `pnpm test:e2e:provider-model-layout`+- **Boundary:** Model-discovery IPC is a fixture; no real credentials or host+ persistence are involved. React, browser layout and scrolling are real.+#### E2E-005K: Preserve explicit extended thinking levels on the wire- **Preconditions**: A provider has a selected model binding with reasoningdiff --git a/docs/zh-CN/spec/04-ux/06-settings-ia.md b/docs/zh-CN/spec/04-ux/06-settings-ia.mdindex 7e3b659d9..8dc71e55c 100644--- a/docs/zh-CN/spec/04-ux/06-settings-ia.md+++ b/docs/zh-CN/spec/04-ux/06-settings-ia.md@@ -210,6 +210,9 @@ Token 用量**不是设置目的地**(D335 / ADR 0173)。已完成回合历因此两种凭据的模型选择完全一致。账户没有 API 密钥输入框,模型发现改由已保存的 OAuth 登录解析。保存会更新该 OAuth 提供商行,并在该账户被选为默认时同步全局默认模型+ - 视口宽度不超过 940px 时,服务与厂商账号的模型面板上下堆叠,+ 不压缩到对话框剩余高度。每份模型列表在有界区域内独立滚动,+ 对话框正文可滚动以访问两份列表;较矮的宽窗口仍保持左右布局。- **提供商**工作室:- OpenAI 兼容的添加提供程序对话框(从添加提供程序/空状态 CTA 打开)- 新建对话框先只显示**服务**。命名端点按厂商平铺(OpenAI、Anthropic、Google、OpenRouter、DeepSeek、通义千问、月之暗面、智谱、硅基流动、火山方舟、MiniMax、MiniMax (OpenAI)、小米、Kimi 编程等),不再分国际 / 国内。选中后显示服务 + API 密钥和主机摘要。自定义端点随后分三行显示服务、名称与接口地址、以及 API 密钥与接口格式,让字段在表单变化时保持稳定对齐;接口地址不附带解释性说明。获取模型失败时,分类结论以一条 toast 报出,空列表处只保留一行「无列表」文案,已有缓存列表时列表原样保留;两种情况都不展示原始 HTTP/JSON 报错。探测结论(已连接、来自目录或被拒绝)只播报一次,密钥下方不再保留状态行。名称(命名行)与可选自定义请求头放在高级设置中。对话框右上角提供明确的“高级设置”按钮,点击后打开独立紧凑弹框,主表单只保留端点和模型面板。弹框可直接添加包含 User-Agent 在内的常用请求头,可将与持久化相同的规范化请求头 JSON 复制到剪贴板(忽略空名称,后者覆盖前者),也支持导入直接请求头对象或 `{ "headers": { ... } }` JSON;导入时按名称合并,不重复添加。列表最多显示五行,更多请求头在自身区域滚动;留空则使用适配器默认值。服务是可搜索锚定菜单(按显示名、厂商、主机过滤),不是原生下拉框。diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.mdindex 30d26e19d..7782d328a 100644--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md@@ -475,6 +475,18 @@ task-candidate E2E 从请求工作树运行,但使用主工作区已经准备- **里程碑**:M2- **状态**:单元覆盖(行级模型标头、请求上下文标头、Anthropic Messages Bearer 认证与令牌轮换);真实 Copilot 账户旅程待验证+#### E2E-MODELS-list-layout:受限窗口中的模型列表可完整浏览++- **前置条件:** 60 个已发现并配置的模型;隔离的 Electron 环境使用真实+ 服务与账号对话框、状态逻辑及生产样式。+- **步骤:** 分别在 850×600、850×850、1000×560、1200×700、1600×1000+ 的内容区打开两种对话框,把每份列表滚到最后一个和第一个模型。+- **期望:** 每份列表至少能完整显示一行;首尾模型均完整位于列表、+ 对话框正文和视口内。窄窗口上下堆叠,较矮的宽窗口保持左右布局。+- **命令:** `pnpm test:e2e:provider-model-layout`+- **边界:** 模型发现 IPC 使用测试数据,不涉及真实凭证或宿主持久化;+ React、浏览器布局和滚动均为真实实现。+#### E2E-006:密钥在重启后仍然存在- **先决条件**:已配置提供商+密钥。diff --git a/package.json b/package.jsonindex 6a1ee20a2..607c3d009 100644--- a/package.json+++ b/package.json@@ -47,6 +47,7 @@"test:e2e:oauth-retry": "node --test apps/desktop/test/anthropic-oauth-retry.test.mjs","test:e2e:boot": "node scripts/e2e-electron-boot.mjs","test:e2e:todos": "node scripts/e2e-todo-checklist.mjs",+ "test:e2e:provider-model-layout": "node scripts/e2e-provider-model-layout.mjs","test:e2e:settings-scroll": "node scripts/e2e-settings-scroll.mjs","test:e2e:config-sync": "node scripts/e2e-config-sync-multidevice.mjs","test:e2e:layout": "node scripts/e2e-three-column-layout.mjs",diff --git a/scripts/e2e-provider-model-layout.mjs b/scripts/e2e-provider-model-layout.mjsnew file mode 100644index 000000000..e8c2fd534--- /dev/null+++ b/scripts/e2e-provider-model-layout.mjs@@ -0,0 +1,107 @@+#!/usr/bin/env node+/** Real React/Chromium coverage for the provider model-list layout. */+import assert from "node:assert/strict";+import { spawn } from "node:child_process";+import { createRequire } from "node:module";+import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { dirname, join } from "node:path";+import { fileURLToPath } from "node:url";+import { resolveElectronBinary } from "./e2e/boot.mjs";++const root = join(dirname(fileURLToPath(import.meta.url)), "..");+const require = createRequire(+ join(root, "packages/agent-runtime/package.json"),+);+const { build } = require("esbuild");+const { electronBinary } = resolveElectronBinary(root);+const temp = await mkdtemp(join(tmpdir(), "pi-provider-model-layout-"));+try {+ await build({+ entryPoints: [join(root, "scripts/e2e/provider-model-layout.tsx")],+ outfile: join(temp, "renderer.js"),+ bundle: true,+ platform: "browser",+ format: "iife",+ jsx: "automatic",+ define: { "process.env.NODE_ENV": '"production"' },+ // CSS is loaded separately below so Tailwind directives do not need a fixture build pipeline.+ loader: { ".css": "empty" },+ alias: {+ "@pi-desktop/i18n": join(root, "packages/i18n/src/index.ts"),+ // The fixture lives outside the desktop package; use its React instance.+ react: join(root, "apps/desktop/node_modules/react"),+ "react-dom": join(root, "apps/desktop/node_modules/react-dom"),+ },+ nodePaths: [join(root, "apps/desktop/node_modules")],+ });+ let css = "";+ for (const name of ["tokens", "base", "ui-kit", "settings", "providers", "model-config"]) {+ css += (await readFile(join(root, `apps/desktop/src/styles/${name}.css`), "utf8")).replace(/@theme(?: inline)?/g, ":root") + "\n";+ }+ await writeFile(join(temp, "style.css"), css);+ await writeFile(+ join(temp, "index.html"),+ '<!doctype html><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src \'self\'; style-src \'self\' \'unsafe-inline\'"><link rel="stylesheet" href="style.css"><title>Provider model layout regression</title><body><script src="renderer.js"></script>',+ );+ await writeFile(+ join(temp, "main.cjs"),+ `+const { app, BrowserWindow } = require("electron");+const path = require("node:path");+app.setPath("userData", path.join(__dirname, "profile"));+app.whenReady().then(async () => {+ const window = new BrowserWindow({ show: false, webPreferences: { sandbox: true, contextIsolation: true, nodeIntegration: false, backgroundThrottling: false } });+ window.webContents.on("console-message", (event) => console.error(event.message));+ try {+ const cases = [];+ for (const [width, height] of [[850, 600], [850, 850], [1000, 560], [1200, 700], [1600, 1000]]) {+ window.setContentSize(width, height);+ await window.loadFile(path.join(__dirname, "index.html"));+ for (const vendor of [false, true]) cases.push(await window.webContents.executeJavaScript("globalThis.providerModelLayoutProbe(" + vendor + ")"));+ }+ const result = { ok: true, cases };+ console.log("PROVIDER_MODEL_LAYOUT_PROBE " + JSON.stringify(result));+ app.quit();+ } catch (error) {+ console.error("PROVIDER_MODEL_LAYOUT_PROBE " + JSON.stringify({ ok: false, error: String(error) }));+ app.exit(1);+ }+});+`,+ );+ const env = { ...process.env };+ delete env.ELECTRON_RUN_AS_NODE;+ const child = spawn(electronBinary, [join(temp, "main.cjs")], {+ env,+ stdio: ["ignore", "pipe", "pipe"],+ });+ let output = "";+ for (const stream of [child.stdout, child.stderr])+ stream.on("data", (data) => {+ output += data;+ });+ const timeout = setTimeout(() => child.kill("SIGKILL"), 45_000);+ let code;+ try {+ code = await new Promise((resolve, reject) => {+ child.once("error", reject);+ child.once("close", resolve);+ });+ } finally {+ clearTimeout(timeout);+ }+ const line = output+ .split(/\r?\n/)+ .find((line) => line.startsWith("PROVIDER_MODEL_LAYOUT_PROBE "));+ assert(+ line,+ `renderer returned no probe result (exit=${code}): ${output.slice(-2000)}`,+ );+ const result = JSON.parse(line.slice("PROVIDER_MODEL_LAYOUT_PROBE ".length));+ console.log("PROVIDER_MODEL_LAYOUT_PROBE " + JSON.stringify(result));+ assert.equal(code, 0, output.slice(-6000));+ assert.equal(result.ok, true);+} finally {+ await rm(temp, { recursive: true, force: true });+}diff --git a/scripts/e2e/provider-model-layout.tsx b/scripts/e2e/provider-model-layout.tsxnew file mode 100644index 000000000..faa94a87b--- /dev/null+++ b/scripts/e2e/provider-model-layout.tsx@@ -0,0 +1,71 @@+import { createRoot } from "react-dom/client";+import { flushSync } from "react-dom";+import { createInstance } from "i18next";+import { I18nextProvider } from "react-i18next";+import { catalogs } from "@pi-desktop/i18n";+import type { ModelBinding, ProviderPublic } from "@pi-desktop/shared";+import { ProviderSetupDialog } from "../../apps/desktop/src/components/settings/ProviderSetupDialog";+import { VendorAccountDialog } from "../../apps/desktop/src/components/settings/VendorAccountDialog";+import { api } from "../../apps/desktop/src/lib/api";++const assert = (value: unknown, message: string) => { if (!value) throw new Error(message); };+const frame = () => new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));+const models: ModelBinding[] = Array.from({ length: 60 }, (_, index) => ({+ id: `model-${String(index).padStart(2, "0")}`, contextWindow: 32000, maxTokens: 4000,+ thinkingLevels: ["off"], defaultThinkingLevel: "off",+}));+const provider: ProviderPublic = {+ id: "fixture", name: "Fixture", vendorKey: "custom", type: "openai_compatible",+ protocol: "openai_compatible", enabled: true, authKind: "none", apiStyle: "chat_completions",+ baseUrl: "http://127.0.0.1:9/v1", hasSecret: false, supportsReasoning: false,+ supportedThinkingLevels: ["off"], createdAt: "", updatedAt: "", models,+};+// Only model discovery's IPC boundary is faked; React, dialogs, hooks and CSS are real.+api.listProviderModels = async () => ({ models: models.map((model) => ({+ modelId: model.id, displayName: model.id, providerId: provider.id, source: "discovered",+ capabilities: ["text"], supportedThinkingLevels: ["off"],+})), source: "remote" });++async function probe(vendor: boolean) {+ const i18n = createInstance();+ await i18n.init({ lng: "en", resources: { en: { translation: catalogs.en } } });+ const host = document.createElement("div");+ document.body.append(host);+ const root = createRoot(host);+ try {+ flushSync(() => root.render(<I18nextProvider i18n={i18n}>+ {vendor+ ? <VendorAccountDialog provider={provider} initialName="Fixture" onClose={() => {}} onSave={() => {}} saving={false} />+ : <ProviderSetupDialog provider={provider} onClose={() => {}} onSaved={() => {}} />}+ </I18nextProvider>));+ const deadline = performance.now() + 5000;+ while (document.querySelector(".provider-models-list")?.children.length !== 60 && performance.now() < deadline) await frame();+ // Wait for the production opening animation before measuring geometry.+ await Promise.all(document.getAnimations().filter((animation) => animation.effect?.getTiming().iterations !== Infinity).map((animation) => animation.finished));+ const heights: number[] = [];+ for (const selector of [".provider-models-list", ".provider-chosen-list"]) {+ const list = document.querySelector<HTMLElement>(selector)!;+ assert(list?.children.length === 60, `${selector}: full model list missing`);+ const first = list.firstElementChild as HTMLElement;+ const last = list.lastElementChild as HTMLElement;+ assert(list.clientHeight >= first.getBoundingClientRect().height, `${selector}: list cannot display even one complete row (height=${list.clientHeight})`);+ for (const row of [last, first]) {+ list.scrollTop = row === last ? list.scrollHeight : 0;+ row.scrollIntoView({ block: "nearest" });+ await frame();+ const item = row.getBoundingClientRect();+ const bounds = list.getBoundingClientRect();+ const body = document.querySelector<HTMLElement>(vendor ? ".vendor-account-body" : ".provider-setup-body")!.getBoundingClientRect();+ assert(item.top >= Math.max(bounds.top, body.top, 0) - 1 && item.bottom <= Math.min(bounds.bottom, body.bottom, innerHeight) + 1,+ `${selector}: ${row === last ? "last" : "first"} model is clipped`);+ }+ heights.push(list.clientHeight);+ }+ const panes = document.querySelector<HTMLElement>(".provider-setup-panes")!;+ const trays = [...panes.children].map((child) => child.getBoundingClientRect());+ assert(innerWidth <= 940 ? trays[1].top >= trays[0].bottom : trays[1].left >= trays[0].right,+ "narrow panes must stack; wide panes must stay side by side");+ return { vendor, viewport: [innerWidth, innerHeight], heights };+ } finally { flushSync(() => root.unmount()); host.remove(); }+}+Object.assign(globalThis, { providerModelLayoutProbe: probe });