Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

Merge remote-tracking branch 'origin/main' into fix/827-compaction-fallback-retention

vastsad938e4d2a5f2
diff --cc docs/spec/08-meta/decisions-log.md
index f044b4ae1,0c590d35a..d6f203ca2
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@@ -6656,28 -6656,22 +6656,48 @@@ that was sitting at the bottom — incl
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.
++
+## 2026-09-22 — A failed compaction keeps the recent window (D617, issue #827)
+
+- An automatic compaction whose summary request failed installed a
+ retained-tail checkpoint that carried at most the latest user message, and a
+ rebuild narrowed a stored checkpoint's tail the same way. A long turn
+ therefore reached the next model request as one user sentence: the reported
+ session lost roughly 168 messages (3 user / 34 assistant / 131 tool) between
+ two checkpoints while the transcript on disk and the UI row stayed intact.
+- The fallback now retains the real recent window — the newest contiguous
+ messages of the compacted range, every role, bounded by the keep-recent
+ target and by what the carried summary and the recovery notice leave — and
+ marks it with `details.retainedTailShape`, so a rebuild replays it. A
+ checkpoint without the marker (every successful checkpoint, and every record
+ written before it existed) still normalizes to the latest user message. An
+ `active_turn` fallback also keeps the active task's user message when the
+ window cannot hold it, the fallback drops the assistant messages pi drops
+ anyway and any tool result whose call is not in the window, and
+ `details.failureReason` records `no_new_history` / `summary_budget` /
+ `summary_provider` / `checkpoint_oversized` instead of provider error text.
+- A summary prompt that is still too large after the single reduced pass is no
+ longer skipped: the range is split into contiguous chunks that each fit, at
+ most 16 requests, each carrying the previous chunk's summary, and the
+ checkpoint reports the summed usage of the requests that produced it. Only an
+ empty range, or one past that request bound, still falls back on budget
+ grounds. See ADR 0302, `03-runtime/02-agent-runtime.md`, ADR 0049, ADR 0282.
diff --cc docs/zh-CN/spec/08-meta/decisions-log.md
index 248279a0b,9e4b9b966..2b3cd5c68
--- a/docs/zh-CN/spec/08-meta/decisions-log.md
+++ b/docs/zh-CN/spec/08-meta/decisions-log.md
@@@ -4722,19 -4722,18 +4722,35 @@@ that amendment are retired by ADR 0268
“会话存在但没有消息”,而不是报告记录不可读。见 `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。
++
+## 2026-09-22 —— 摘要失败的压缩保留真实近期窗口(D617,issue #827)
+
+- 自动压缩的摘要请求失败时安装的保留尾部检查点最多只带一条最新用户消息,重建存储的
+ 检查点也会以同样方式收窄尾部。于是在一条长回合里,下一次模型请求只剩一句用户话:
+ 报告中的会话在两次检查点之间丢掉约 168 条消息(3 条用户 / 34 条助手 / 131 条工具),
+ 而磁盘上的转录本与界面行看起来完好。
+- 回退现在保留真实的近期窗口——压缩范围内最新的连续消息,包含所有角色,上限为
+ keep-recent 目标,以及携带摘要与恢复提示之后安全预算剩余的空间——并用
+ `details.retainedTailShape` 标记,使重建时回放整窗。没有该标记的检查点(每个成功
+ 检查点,以及标记出现之前写入的记录)仍归一化为只保留最新的用户消息。`active_turn`
+ 回退还会在窗口装不下时保留当前任务的用户消息;回退会丢弃 pi 本来就会丢的助手消息,
+ 以及调用不在窗口内的工具结果;`details.failureReason` 记录 `no_new_history` /
+ `summary_budget` / `summary_provider` / `checkpoint_oversized`,而不是提供商错误文本。
+- 单次缩减后仍过大的摘要提示不再被跳过:范围会被切成每片都能放下的连续分片,最多 16 次
+ 请求,每次携带上一片的摘要,检查点报告这些请求的用量总和。只有空范围或超过该请求上限
+ 的范围才因预算原因回退。见 ADR 0302、`03-runtime/02-agent-runtime.md`、ADR 0049、ADR 0282。