Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
Merge remote-tracking branch 'origin/main' into fix/831-startup-blank-screen-watchdog
vastsaa9158a5a4fa5
diff --cc docs/spec/08-meta/decisions-log.mdindex c18e41f6e,5dca06777..0c590d35a--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@@ -6596,22 -6596,62 +6596,82 @@@ that was sitting at the bottom — incl`apps/desktop/test/image-generation-default.test.mjs`, with`provider-model-config.test.mjs` asserting the add branch consults them.+ ## 2026-09-22 — An unreadable command source refuses a slash submission (D613, issue #795)++ - Composer send-time resolution read the merged command list and swallowed a+ failure as `null`, which the submit path could not tell apart from "no such+ command". `/compact` typed while that IPC read failed was therefore sent to the+ model as literal prompt text, and the model acted on it as an instruction.+ - Resolution now answers with three outcomes instead of one nullable value:+ resolved (builtin/plugin/extension dispatch), unknown (templates, aliases, and+ id-less entries continue as prompt text), and unavailable. Unavailable refuses+ the submission, keeps the draft, and shows+ `chat.slashCommandSourceUnavailable`. The failed read leaves the TTL cache+ cold, so the next submit retries it; a warm cache still resolves through a+ source blip.+ - The refusal is fail-closed on purpose: only the command source can say whether+ `/name` is a control command, so while it cannot be read a `name` that looks+ like plain text is refused rather than guessed. Templates and genuinely unknown+ aliases keep the old prompt path. Pinned by+ `apps/desktop/test/slash-command-source.test.mjs` and+ `03-runtime/01-ipc-protocol.md` §13c.++ ## 2026-09-22 — A manual compaction has its own transport deadline and a durable verdict (D614, issue #795)++ - `agent.compact` is a blocking RPC that spends a whole model summary request+ inside the sidecar: pi serializes the conversation, streams the summary, and+ retries a transient failure. It ran under the flat 130s transport default, so a+ ~158s compaction on an 888KB context ended as `sidecar RPC timeout` while the+ sidecar kept working and persisted the checkpoint — the user was told the+ compaction failed, and the next turn proved it had succeeded.+ - The deadline is now derived from the ceilings the sidecar actually enforces:+ one stream watchdog (180s) per attempt, `1 + 3` attempts, the 2s/4s/8s retry+ backoff, and transport slack — `AGENT_COMPACT_RPC_TIMEOUT_MS`, deliberately+ per-method rather than a wider global default.+ - Either host path (Electron `agentCompact` IPC and `RuntimeService.compact`)+ also stops treating a transport timeout as the sidecar's verdict: it re-reads+ the durable `session.compaction` record and reports success when a new+ checkpoint landed, logs the mismatch, and rethrows the timeout otherwise. A+ verdict the sidecar reported itself is never reconciled. Pinned by+ `packages/host-runtime/src/runtime-service.test.ts`,+ `packages/shared/src/protocol.test.ts`,+ `apps/desktop/test/plugin-timeout-budgets.test.mjs`, and+ `03-runtime/01-ipc-protocol.md` §5.4.++ ## 2026-09-22 — An empty transcript read is retried and never cached (D615, issue #795)++ - The renderer treated every durable `session.get` window as the truth, and+ cached it. A window that came back empty for a session with thousands of+ messages — the host answers such a read from a transcript file it may be+ rewriting — was stored as an empty snapshot, hover prefetch re-served it, and+ the pane stayed blank until the app restarted. Nothing distinguished a failed+ or stale read from an empty conversation, and no path retried one.+ - A read is now judged against the session's own count: zero messages for a+ session the sidebar counts as having history triggers one more read, then keeps+ the snapshot the user already has, and otherwise reports+ `chat.sessionTranscriptEmpty`. The empty page is never written to the+ transcript cache, so a hover prefetch cannot poison every later open.+ - This is a defense, not the host-side root cause: the transcript rewrite is the+ reporter's 0.15.1 storage layout, and the read side still answers "session+ exists, no messages" instead of reporting an unreadable transcript. See+ `04-ux/09-interaction-patterns.md` §Session isolation across tabs.+++## 2026-09-22 — A renderer that never reaches its first state gets a bounded surface and a quit channel (D616)++- The renderer's startup had no timeout of its own: `bootstrap()` either+ publishes the initial state or nothing, so one read that never settled left the+ window on the boot surface with no menu, no data, and nothing to act on except+ force-quitting the process (issue #831). The renderer now watches its own wait.+ `STARTUP_SLOW_HINT_MS` (30s) adds logs, diagnostics, and quit to the boot+ surface without calling the boot a failure; `STARTUP_STALLED_MS` (180s) turns it+ into the recovery surface, which also offers a retry that re-runs `bootstrap()`.+- Both bounds sit above the main↔host RPC ceiling (`DEFAULT_RPC_TIMEOUT_MS`,+ 130s), so a slow but successful boot is never read as a failure, and the+ watchdog never cancels the startup it watches: a boot that finishes replaces the+ surface with the shell. The recovery surface replaces the splash (exactly one+ boot surface is mounted), and the renderer-drawn window controls stay above it,+ so a frameless Windows/Linux window can always be closed.+- The renderer gains the quit channel `pi-desktop/app/quit` (`api.quitApp()`),+ whose handler calls `app.quit()` exactly like the Quit menu item, so the ordered+ shutdown, the confirmation dialog, and the close behavior stay the ones the app+ already has. See `03-runtime/07-process-model.md` §3 and E2E-076.diff --cc docs/zh-CN/spec/08-meta/decisions-log.mdindex e1604ee66,6db8ed12d..9e4b9b966--- a/docs/zh-CN/spec/08-meta/decisions-log.md+++ b/docs/zh-CN/spec/08-meta/decisions-log.md@@@ -4678,18 -4678,46 +4678,62 @@@ that amendment are retired by ADR 0268`apps/desktop/test/image-generation-default.test.mjs` 固定,`provider-model-config.test.mjs` 断言新增分支会走这两个判断。+ ## 2026-09-22 —— 指令源不可读时拒绝斜杠提交(D613,issue #795)++ - Composer 在发送时读取合并后的指令列表,并把失败吞成 `null`,而提交路径无法把它与+ “没有这个指令”区分开。于是在该 IPC 读取失败时输入的 `/compact` 会作为字面提示词发给+ 模型,模型据此把它当成指令执行。+ - 解析现在返回三种结果,而不再是一个可空值:已解析(内置 / 插件 / 扩展分发)、未知+ (模板、别名与无 id 条目继续走提示词路径)、不可用。不可用时拒绝提交、保留草稿并显示+ `chat.slashCommandSourceUnavailable`。失败的读取不写 TTL 缓存,因此下一次发送会重试;+ 缓存仍热时,一次数据源抖动不会影响解析。+ - 拒绝是刻意 fail-closed:只有指令源能判断 `/name` 是否为控制指令,因此读不到时,看起来像+ 普通文本的名称也会被拒绝,而不是靠猜测。模板与确实未知的别名保持原有提示词路径。由+ `apps/desktop/test/slash-command-source.test.mjs` 与+ `03-runtime/01-ipc-protocol.md` §13c 固定。++ ## 2026-09-22 —— 手动压缩有自己的传输超时与持久化判定(D614,issue #795)++ - `agent.compact` 是阻塞式 RPC,会在 sidecar 内消耗一次完整的模型摘要请求:pi 序列化会话、+ 流式生成摘要,并重试瞬时失败。它此前沿用扁平的 130 秒传输默认值,因此 888KB 上下文约+ 158 秒的压缩以 `sidecar RPC timeout` 结束,而 sidecar 仍在继续工作并落盘了检查点——用户+ 被告知压缩失败,而下一个回合证明它其实成功了。+ - 超时现在由 sidecar 真正执行的预算推导:每次尝试的流空转看门狗(180 秒)、`1 + 3` 次+ 尝试、2/4/8 秒重试退避,以及传输余量 —— 即 `AGENT_COMPACT_RPC_TIMEOUT_MS`,刻意按方法+ 区分,而不是放宽全局默认值。+ - 两条宿主路径(Electron 的 `agentCompact` IPC 与 `RuntimeService.compact`)也不再把手动+ 压缩的传输超时当作 sidecar 的判定:它们会重新读取持久化的 `session.compaction` 记录,+ 发现新检查点已落盘就报告成功、记录该不一致,否则原样抛出超时。sidecar 自己报告的判定+ 绝不会被这样改写。由 `packages/host-runtime/src/runtime-service.test.ts`、+ `packages/shared/src/protocol.test.ts`、+ `apps/desktop/test/plugin-timeout-budgets.test.mjs` 与+ `03-runtime/01-ipc-protocol.md` §5.4 固定。++ ## 2026-09-22 —— 空记录读取会重试,且绝不入缓存(D615,issue #795)++ - 渲染层把每一次持久化 `session.get` 窗口都当真,并写入缓存。当宿主正在重写记录文件时,+ 对拥有数千条消息的会话返回的空窗口被当成“空快照”存下,侧边栏悬停预取又反复送出它,+ 于是面板一直空白,只有重启应用才能恢复。此前没有任何逻辑区分“读取失败或读到陈旧数据”+ 与“真的空会话”,也没有任何路径重试。+ - 现在的判断依据是会话自己的计数:若侧边栏计为有历史的会话返回零条消息,就再读一次,+ 随后保留用户已有的快照,否则显示 `chat.sessionTranscriptEmpty`。这类空页绝不会写入记录+ 缓存,因此悬停预取不会污染之后每次打开。+ - 这是防御措施,而不是宿主侧根因:记录重写是报告者 0.15.1 的存储布局,而读取侧仍然返回+ “会话存在但没有消息”,而不是报告记录不可读。见 `04-ux/09-interaction-patterns.md`+ §跨选项卡的会话隔离。+++## 2026-09-22 —— 从未拿到初始状态的渲染器有了有界表面与退出通道(D616)++- 渲染器的启动过程本身没有超时:`bootstrap()` 要么发布初始状态,要么什么都不发布,+ 因此一次始终没有落地的读取会让窗口一直停在启动表面上——没有菜单、没有数据,除了+ 强杀进程无事可做(issue #831)。渲染器现在自己监视这段等待:+ `STARTUP_SLOW_HINT_MS`(30 秒)在不判定启动失败的前提下为启动表面加上日志、诊断与+ 退出,`STARTUP_STALLED_MS`(180 秒)把它变成恢复表面,后者还提供重跑+ `bootstrap()` 的重试。+- 两个界限都高于 main↔host 的 RPC 上限(`DEFAULT_RPC_TIMEOUT_MS`,130 秒),因此慢+ 但成功的启动不会被读成失败;看门狗从不取消它所监视的启动,成功完成的启动会用 shell+ 替换该表面。恢复表面替换启动画面(同一时刻只挂载一个启动表面),渲染器绘制的窗口+ 控制按钮保持在其之上,因此无边框的 Windows/Linux 窗口始终可以关闭。+- 渲染器新增退出通道 `pi-desktop/app/quit`(`api.quitApp()`),其处理函数与“退出”+ 菜单项一样调用 `app.quit()`,因此有序关停、确认对话框和关闭行为都仍是应用已有的+ 那一套。参见 `03-runtime/07-process-model.md` §3 与 E2E-076。