Skip to content

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

fix(desktop): drop the blank band under a collapsed TodoDock

vastsa0953fb4d918e
diff --git a/apps/desktop/src/components/TodoDock.tsx b/apps/desktop/src/components/TodoDock.tsx
index c3fbf7928..63cfc561f 100644
--- a/apps/desktop/src/components/TodoDock.tsx
+++ b/apps/desktop/src/components/TodoDock.tsx
@@ -64,15 +64,17 @@ export function TodoDock({ sessionId }: { sessionId: string }) {
{expanded ? <IconChevronUp size={14} /> : <IconChevronDown size={14} />}
</Button>
<div className="todo-dock-content" aria-hidden={!expanded}>
- <div className="todo-dock-list" role="list">
- {visible.map((todo, index) => (
- <TodoRow key={`${index}:${todo.content}`} todo={todo} />
- ))}
- {remaining > 0 ? (
- <div className="todo-dock-more" role="status">
- {t("chat.todo.more", { count: remaining })}
- </div>
- ) : null}
+ <div className="todo-dock-clip">
+ <div className="todo-dock-list" role="list">
+ {visible.map((todo, index) => (
+ <TodoRow key={`${index}:${todo.content}`} todo={todo} />
+ ))}
+ {remaining > 0 ? (
+ <div className="todo-dock-more" role="status">
+ {t("chat.todo.more", { count: remaining })}
+ </div>
+ ) : null}
+ </div>
</div>
</div>
</div>
diff --git a/apps/desktop/src/styles/composer.css b/apps/desktop/src/styles/composer.css
index 85d866637..0dd202905 100644
--- a/apps/desktop/src/styles/composer.css
+++ b/apps/desktop/src/styles/composer.css
@@ -818,12 +818,19 @@
transform: translateY(0);
}
+/* The `0fr` row closes only if the clip can shrink below its content, and
+ vertical padding on the animating box holds that row open — as the list's
+ 10px bottom inset did, leaving a blank band under the collapsed header.
+ The clip layer carries the collapse; the inset stays inside it. */
+.todo-dock-clip {
+ min-height: 0;
+ overflow: hidden;
+}
+
.todo-dock-list {
display: grid;
- min-height: 0;
gap: 6px;
padding: 0 10px 10px;
- overflow: hidden;
}
.todo-dock-row {
diff --git a/apps/desktop/test/todo-dock-rendering.test.mjs b/apps/desktop/test/todo-dock-rendering.test.mjs
index ffd424985..66d91d455 100644
--- a/apps/desktop/test/todo-dock-rendering.test.mjs
+++ b/apps/desktop/test/todo-dock-rendering.test.mjs
@@ -52,6 +52,7 @@ test("TodoDock renders bounded session progress and cancelled state", async () =
const html = render();
assert.match(html, /aria-expanded="false"/);
assert.match(html, /class="todo-dock-content" aria-hidden="true"/);
+ assert.match(html, /class="todo-dock-content" aria-hidden="true"><div class="todo-dock-clip">/);
assert.match(html, /extra-0/);
assert.match(html, /4 more items/);
assert.match(html, /lucide-check/);
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index 38224374a..2dc2bd8d6 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -2868,9 +2868,11 @@ reasoning-level control.
closed when the active session changes, and shows at most eight ordered rows.
The list stays mounted while collapsed so opening and closing can animate with
a bounded height/opacity transition; collapsed content is `aria-hidden` and
- reduced-motion users receive an immediate state change. Completed rows use a
- success-tinted tile with a check icon, in-progress rows use the accent tint,
- and cancelled rows are muted; each status symbol has a localized accessible
+ reduced-motion users receive an immediate state change. A collapsed dock
+ reserves only its header row: the list's inset is clipped, never laid out
+ below the header. Completed rows use a success-tinted tile with a check
+ icon, in-progress rows use the accent tint, and cancelled rows are muted;
+ each status symbol has a localized accessible
name and each row renders plain text.
- Renderer snapshots are keyed by session id. A `todos.changed` event with an
older or equal revision is ignored. Session activation and host recovery
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 5a6426687..a2bcb592b 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -9299,6 +9299,7 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
advances revision, including clear, and emits one committed `todos.changed`
snapshot. Invalid or unauthorized writes do not mutate or emit. TodoDock
renders plain text, does not take focus, resets expansion on session changes,
+ keeps a collapsed dock to its header height,
rejects stale events, and skips local recovery for `remote:` sessions because
RACP v1 has no Todo snapshot operation.
- **Specs**: `03-runtime/03-tools-and-permissions.md`,
diff --git a/docs/zh-CN/spec/04-ux/08-component-spec.md b/docs/zh-CN/spec/04-ux/08-component-spec.md
index 035ed757c..cf98ccc75 100644
--- a/docs/zh-CN/spec/04-ux/08-component-spec.md
+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md
@@ -2013,7 +2013,7 @@ MainChat 底部的输入区域,用于撰写和发送提示。支持多行输
- 当活动会话拥有非空的主机清单时,TodoDock 位于 Composer 栈中并显示在 Plan/Goal 批准表面上方;空清单不占布局空间。
- 收起标题显示完成/活动进度和当前 `in_progress` 内容;全部取消时显示明确的取消状态,不显示误导性的 `0/0 completed`。
-- 展开控件可键盘操作,不因更新抢焦点;切换活动会话时保持收起,最多显示八条有序行。列表在收起时仍保持挂载,通过有界的高度/透明度过渡播放展开和收起动画;收起内容设置为 `aria-hidden`,开启减少动画时立即切换状态。完成项使用带 check icon 的成功色区块,进行中使用强调色区块,取消项降低对比度;每个状态符号都有本地化辅助名称,行内容按纯文本渲染。
+列表在收起时仍保持挂载,但收起状态只占标题行高度(列表内边距被裁剪,不会在标题下方留白),通过有界的高度/透明度过渡播放展开和收起动画;
- 渲染器按 session id 保存快照并忽略旧或相同 revision。激活会话和主机恢复时重新读取权威快照,包括已缓存清单;首次读取失败不能导致主机恢复后清单持续隐藏。`remote:` 和 `native-pi:` 会话不拥有本地 Desktop 清单,跳过本地 `todos.get` 恢复;远程 Todo 对等能力留待新增 RACP 契约。
### 11.4 状态
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.md
index 51006ac2b..32825b2b4 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
@@ -5535,7 +5535,7 @@ eleven-tool-round desktop paths are verified by
- **前提:** 隔离的本地 Electron 配置、确定性的 Agent/Host fixture、两个 Desktop 会话,不使用真实 Provider 或付费 API。
- **步骤:** 启动调用 `TodoWrite` 的多步骤 Agent 回合,观察 Composer 上方的 TodoDock,展开后切换会话并确认清单隔离。完成和取消条目,确认最多显示八条以及全部取消状态;清空清单后重载/重启 Host。发送乱序旧 `todos.changed` 事件,确认它不能覆盖新快照;再覆盖非法参数、Plan/Goal、委托和远程会话路径。
-- **预期:** Host SQLite 是权威状态;每次成功全量替换(包括清空)都会推进 revision 并只发出一次已提交的 `todos.changed`。非法或未授权写入既不修改也不发事件。TodoDock 渲染纯文本、不抢焦点、切换会话时收起、拒绝旧事件,并对 `remote:` 会话跳过本地恢复,因为 RACP v1 没有 Todo 快照操作。
+切换会话时收起、收起状态只占标题行高度、拒绝旧事件
- **链接规格:** `03-runtime/03-tools-and-permissions.md`、`03-runtime/04-data-storage.md`、`03-runtime/06-host-rpc-protocol.md`、`04-ux/08-component-spec.md`、ADR 0312。
- **验收:** C / E / F / Quality / Security。
- **里程碑:** M6+。
diff --git a/scripts/e2e/todo-checklist.tsx b/scripts/e2e/todo-checklist.tsx
index 8f062370e..ef6f579d9 100644
--- a/scripts/e2e/todo-checklist.tsx
+++ b/scripts/e2e/todo-checklist.tsx
@@ -38,6 +38,11 @@ async function mount(sessionId: string) {
}
const dock = () => document.querySelector(".todo-dock");
const header = () => document.querySelector<HTMLButtonElement>(".todo-dock-header");
+const box = (selector: string) => document.querySelector(selector)!.getBoundingClientRect();
+const collapsedGap = () => Math.round(box(".todo-dock").height - box(".todo-dock-header").height);
+const dockGeometry = () => `dock ${box(".todo-dock").height}px, header ${box(".todo-dock-header").height}px, `
+ + `content ${box(".todo-dock-content").height}px, clip ${box(".todo-dock-clip").height}px, `
+ + `list ${box(".todo-dock-list").height}px`;
const snapshot = (id: string) => useAppStore.getState().sessionTodos[id];
function items(count: number, prefix: string): SessionTodo[] {
return Array.from({ length: count }, (_, index) => ({ content: `${prefix} ${index + 1}`,
@@ -57,9 +62,19 @@ window.todoChecklistProbe = async () => {
const original = await write(first, items(10, "Task"));
await until(() => header()?.textContent?.includes("Task 1") === true, "Committed host notification must reach TodoDock");
assert(header()?.getAttribute("aria-expanded") === "false", "Dock starts collapsed");
+ // The closed disclosure must not reserve the list's inset: vertical padding on
+ // the collapsing box held the `0fr` row open and left a blank band under it.
+ assert(Math.round(box(".todo-dock-content").height) === 0,
+ `Collapsed disclosure must reserve no height (${dockGeometry()})`);
+ assert(Math.round(box(".todo-dock-clip").height) === 0,
+ `Collapsed clip must reserve no height (${dockGeometry()})`);
+ assert(collapsedGap() === 2, `Collapsed dock must be the header plus its borders (${dockGeometry()})`);
+ checks.push("collapsed-dock-reserves-no-blank-height");
flushSync(() => header()!.click());
await until(() => header()?.getAttribute("aria-expanded") === "true", "Click must expand dock");
assert(document.querySelectorAll(".todo-dock-row").length === 8, "Expanded list is capped at eight rows");
+ await until(() => Math.round(box(".todo-dock-clip").height) === Math.round(box(".todo-dock-list").height),
+ "Expanded clip must match the listed rows once the disclosure transition settles");
assert(document.querySelector(".todo-dock-more")?.textContent?.includes("2"), "Overflow count must render");
checks.push("agent-prompt-tool-discovery-host-write-event-dock-expand-bounded-list");
const normalized = await write(first, [
@@ -78,6 +93,12 @@ window.todoChecklistProbe = async () => {
await mount(second);
await until(() => header()?.textContent?.includes("Other 1") === true, "Session switch must show its own checklist");
assert(header()?.getAttribute("aria-expanded") === "false", "Session switch collapses dock");
+ // Closing after the switch must retract the list completely, not just fade it;
+ // the transition's end state is the sync point, so no arbitrary delay is used.
+ await until(() => collapsedGap() === 2,
+ `Collapsing the dock must retract the listed rows (${dockGeometry()})`);
+ assert(Math.round(box(".todo-dock-content").height) === 0,
+ `Collapsed disclosure must reserve no height (${dockGeometry()})`);
await mount(first);
await until(() => header()?.textContent?.includes("Task 1") === true, "Returning session restores its checklist");
checks.push("session-switch-isolation");