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(composer): start the thinking commit pump synchronously
vastsa3ae0f5402b8d
diff --git a/apps/desktop/src/features/chat/composer/hooks/useComposerModelMenu.ts b/apps/desktop/src/features/chat/composer/hooks/useComposerModelMenu.tsindex e7d5895ec..a457d5adf 100644--- a/apps/desktop/src/features/chat/composer/hooks/useComposerModelMenu.ts+++ b/apps/desktop/src/features/chat/composer/hooks/useComposerModelMenu.ts@@ -22,7 +22,7 @@ import {thinkingProviderForModel,type ComposerMenuView,} from "../model";-import { createLatestCommitQueue } from "./thinking-commit-queue";+import { createLatestCommitQueue } from "../thinking-commit-queue";type UseComposerModelMenuOptions = {mode: Mode;diff --git a/apps/desktop/src/features/chat/composer/thinking-commit-queue.ts b/apps/desktop/src/features/chat/composer/thinking-commit-queue.tsindex e497b3750..6e6fee6e2 100644--- a/apps/desktop/src/features/chat/composer/thinking-commit-queue.ts+++ b/apps/desktop/src/features/chat/composer/thinking-commit-queue.ts@@ -16,62 +16,65 @@ export function createLatestCommitQueue<T>(options: {} {let pending: T | null = null;let generation = 0;- let busy = false;- let tail: Promise<boolean> = Promise.resolve(true);+ let running = false;+ let idleWaiters: Array<() => void> = [];- const invalidate = () => {- generation += 1;- pending = null;+ const notifyIdle = () => {+ if (running || pending !== null) return;+ const waiters = idleWaiters;+ idleWaiters = [];+ for (const waiter of waiters) waiter();};- const drain = async (): Promise<boolean> => {- busy = true;+ const pump = async () => {+ if (running) return;+ running = true;try {while (pending !== null) {const gen = generation;const value = pending;pending = null;- if (gen !== generation) return false;+ if (gen !== generation) break;try {await options.send(value);} catch (error) {generation += 1;pending = null;options.onError?.(error);- return false;+ break;}- if (gen !== generation) return false;+ if (gen !== generation) break;}- return true;} finally {- busy = false;+ running = false;+ if (pending !== null) {+ void pump();+ return;+ }+ notifyIdle();}};+ const invalidate = () => {+ generation += 1;+ pending = null;+ };++ const whenIdle = () =>+ new Promise<void>((resolve) => {+ if (!running && pending === null) {+ resolve();+ return;+ }+ idleWaiters.push(resolve);+ });+const commit = (value: T): Promise<boolean> => {pending = value;const enqueuedAt = generation;- const finish = async (run: Promise<boolean>) => {- const ok = await run;- return ok && generation === enqueuedAt;- };- if (!busy) {- const run = drain();- tail = run.then(- () => true,- () => true,- );- return finish(run);- }- const run = tail.then(drain, drain);- tail = run.then(- () => true,- () => true,- );- return finish(run);+ void pump();+ return whenIdle().then(() => generation === enqueuedAt);};- const idle = () => tail.then(() => undefined);-- return { commit, invalidate, idle };+ return { commit, invalidate, idle: whenIdle };}diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.mdindex af28a38a4..3c022e70f 100644--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@ -173,7 +173,7 @@ Gold source: local Codex electron captures; latest row wins where rows conflict.| D267 | Project archive is one workbench, not three bands | *(row anatomy and inline expansion superseded by D455)* **Revise D168's band layout: Settings → Project archive renders the D257 one-workbench composition — a quiet intro line carrying only the page description, one toolbar (Recent/Name sort on the shared `settings-segment` primitive, search with clear affordance and live match count, primary Add project), and one settings panel whose always-visible Pinned / All projects / Archived groups are non-interactive in-panel header strips with per-section counts instead of one panel per section. The decorative gradient hero band is removed together with the four page-level overview counters it carried, retiring the `project.statProjects`, `project.statOpen`, `project.statArchived`, and `project.statSessions` keys; the per-group counts on the panel's header strips are now the only totals. The external uppercase section labels are removed as well; row geometry matches the capability rows (32px controls, 14px list gap, 28px row glyph). Beyond dropping the four retired counter keys this is presentation only: D168's row anatomy, row menu grouping, search matching, session batching, activation semantics, and accessibility semantics are unchanged, and no ADR is required.** | D168's overview banner used a decorative gradient and `--text-xl` counter tiles, which the design system forbids, and its per-section panels repeated the same elevated frame three times. Demoting the counters to an inline run kept the clutter without earning it: every total they showed is already legible from the per-group strip counts, so restating them above the toolbar duplicated numbers and gave the destination a header no sibling page has. Dropping them leaves the durable index looking and behaving like the agent capability pages. || D455 | Project archive is a list + inspector | *(row anatomy superseded by the same-day "Project archive reads as an inset grouped card list" entry)* **Revise D267's expanding rows: Settings → Project archive keeps the quiet intro and toolbar, then a one-column workbench. The index remains Pinned / All projects / Archived with per-section counts and no visibility toggle (D133). Compact rows show glyph, name, one status tag, session count, and relative time. A click selects and stays in Settings; double-click, Enter, or the inspector Open action activates and returns to chat. Folders, chats (batches of eight), and the row menu open under the selected row at full width. Search still matches session titles and selects the owning project. Presentation only: no IPC, storage, or host change. See ADR 0294 and E2E-038.** | Inline expansion and per-row menus made a long durable index hard to scan, and clicking a name left Settings instead of managing the project. || D456 | Session thinking-parameter omission | **Amend ADR 0194 / ADR 0144 / ADR 0221: session `thinkingLevel` accepts `omit` in addition to the seven canonical levels. Composer prepends `omit` on a reasoning model. Runtime bookkeeping stays `off` and uses the low-level provider stream so no thinking override is synthesized. Binding/catalog capability lists stay canonical. Schema v19 widens the session CHECK to include `omit`. Handshake protocol version is unchanged. See ADR 0295 and E2E-203a.** | Explicit `off` still serializes a disable; users need a session-level do-not-send matching subagents. |-+| D458 | Composer reasoning slider on the menu root | **Amend the combined model × reasoning menu: when more than one level is listed, a native range slider with one labeled stop per level sits under the Reasoning level entry. Slider and tick commits persist the last pending level through `configureActiveSession` without leaving the root; the entry still opens the classic radio list. Tick labels are not tab stops. Renderer only. See issue #417, `04-ux/08-component-spec.md`, and E2E-050.** | Switching a level required a submenu trip; a Codex-style slider keeps the radio list while making quick adjustments one drag. |## E. M5 hardening decisions (0.4.0)| ID | Topic | Decision | Rationale |diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.mdindex ed876b9bc..ea0bf1c71 100644--- a/docs/zh-CN/spec/08-meta/decisions-log.md+++ b/docs/zh-CN/spec/08-meta/decisions-log.md@@ -176,7 +176,7 @@| D267 | 项目存档是一个工作台,而不是三个堆叠带 | *(行剖析与行内展开被 D455 取代)* **修订 D168 的堆叠带布局:设置 → 项目存档改为呈现 D257 的一个工作台构成 —— 一条仅承载页面说明的安静引导行、一个工具栏(使用共享 `settings-segment` 基元的“最近/名称”排序、带清除可供性与实时匹配计数的搜索、主要“添加项目”),以及一个设置面板,其始终可见的固定/所有项目/存档分组是面板内带每部分计数的非交互标题条,而不是每部分一个面板。装饰渐变英雄带被移除,它承载的四个页面级概览计数器也一并移除,并停用 `project.statProjects`、`project.statOpen`、`project.statArchived` 和 `project.statSessions` 键;面板标题条上的分组计数现在是唯一的总计。外部大写部分标签也被移除;行几何与能力页面行一致(32px 控件、14px 列表间距、28px 行字形)。除停用上述四个计数器键外,其余仅为演示层变更:D168 的行剖析、行菜单分组、搜索匹配、会话批处理、激活语义和无障碍语义均不变,且不需要新的 ADR。** | D168 的概述横幅使用了装饰渐变和 `--text-xl` 计数器格,而设计系统明确禁止两者,且其每部分面板把同一个高架框重复了三次。把计数器降级为内联串只是保留了杂乱而没有换来价值:它们展示的每个总计都已能从分组条计数中读出,因此在工具栏上方重述这些数字既重复了数字,也让该目的地拥有了兄弟页面都没有的页头。移除它们后,持久索引在外观和行为上都与智能体能力页面一致。 || D455 | 项目存档改为列表 + 检查器 | *(行剖析被同日的「项目档案呈现为内嵌分组卡片列表」条目取代)* **修订 D267 的展开行:设置 → 项目存档保留安静引导行和工具栏,随后是单列工作台。索引仍按已置顶 / 全部项目 / 已归档分组并显示计数,且没有可见性开关(D133)。精简行显示字形、名称、一个状态标签、会话计数和相对时间。单击选中并留在设置页;双击、Enter 或检查器的打开操作激活项目并返回聊天。文件夹、对话(每批 8 条)和行菜单在选中行下方铺满宽度打开。搜索仍匹配会话标题并选中所属项目。仅演示层:无 IPC、存储或宿主改动。见 ADR 0294 与 E2E-038。** | 行内展开和行菜单让长索引难以扫读,单击名称还会离开设置页,不利于管理。 || D456 | 会话思考参数不发送 | **修订 ADR 0194 / ADR 0144 / ADR 0221:会话 `thinkingLevel` 在七个规范档位之外接受 `omit`。Composer 在推理模型上把 `omit` 放在菜单最前。运行时记账仍为 `off`,走低层 provider 流,不合成思考覆盖。绑定/目录能力列表保持规范档位。Schema v19 把会话 CHECK 扩到包含 `omit`。握手协议版本不变。见 ADR 0295 与 E2E-203a。** | 显式 `off` 仍会序列化为关闭思考;用户需要与子智能体一致的会话级不发送。 |-+| D458 | Composer 菜单根层承载推理滑块 | **修订组合的模型 × 推理菜单:列出一个以上等级时,推理等级条目下方放一条原生 range 滑杆,每个等级一个带标签刻度。滑杆和刻度提交通过 `configureActiveSession` 持久化最后一次待提交档位且不离开根层;条目仍打开经典单选列表。刻度标签不是 Tab 停靠点。仅渲染层。见 issue #417、`04-ux/08-component-spec.md` 与 E2E-050。** | 改档原先必须进子菜单;Codex 风格滑杆保留单选列表,同时让临时调整只需拖一次。 |## E.M5 强化决策 (0.4.0)| 身份证号 | 主题 | 决定 | 基本原理 |