Skip to content

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

fix(asktool): reset question scroll when the prompt changes (#1531)

Frank-zhu2000ec6f8fe40649
diff --git a/apps/desktop/src/components/AskToolCard.tsx b/apps/desktop/src/components/AskToolCard.tsx
index 2fa4eaeb7..6baab0a7d 100644
--- a/apps/desktop/src/components/AskToolCard.tsx
+++ b/apps/desktop/src/components/AskToolCard.tsx
@@ -173,7 +173,7 @@ export function AskToolCard({ request, queued = 0 }: { request: PendingAsk; queu
<span className="asktool-question-number">
{t("askTool.questionNumber", { number: index + 1 })}
</span>
- <span className="asktool-question-body">
+ <span key={index} className="asktool-question-body">
<AskToolRichText source={current.question} />
</span>
</h3>
diff --git a/apps/desktop/src/styles/messages.css b/apps/desktop/src/styles/messages.css
index d3d3a918f..f3d7984f8 100644
--- a/apps/desktop/src/styles/messages.css
+++ b/apps/desktop/src/styles/messages.css
@@ -220,11 +220,12 @@
display: block;
min-width: 0;
/* Long prompts scroll here so header actions stay on screen (#1531).
- Short prompts keep today's layout: no reserved scrollbar gutter. */
+ Do not reserve a scrollbar gutter. */
max-height: min(208px, 24vh);
max-height: min(208px, 24dvh);
overflow-x: hidden;
overflow-y: auto;
+ overflow-wrap: anywhere;
overscroll-behavior-y: contain;
}
diff --git a/apps/desktop/test/permission-inline.test.mjs b/apps/desktop/test/permission-inline.test.mjs
index 082e7559d..478a4c321 100644
--- a/apps/desktop/test/permission-inline.test.mjs
+++ b/apps/desktop/test/permission-inline.test.mjs
@@ -186,6 +186,7 @@ test("asktool card is a stepwise, non-expiring composer question surface", () =>
assert.match(questionBody, /overflow-y:\s*auto/);
assert.match(questionBody, /overscroll-behavior-y:\s*contain/);
assert.doesNotMatch(questionBody, /scrollbar-gutter/);
+ assert.match(questionBody, /overflow-wrap:\s*anywhere/);
assert.match(
askCardSource,
/className="asktool-card-header-actions"[\s\S]*className="asktool-question-body"/,
@@ -208,6 +209,25 @@ test("asktool card is a stepwise, non-expiring composer question surface", () =>
);
});
+test("asktool question body opens at the top when the question index changes", () => {
+ // Next, Skip, and the step indicators only call setIndex. The question
+ // body is one scroller for the whole request, so a later long prompt keeps
+ // the previous scrollTop unless that body remounts with the index or the
+ // offset is cleared when index changes (#1531).
+ const bodyTag = askCardSource.match(
+ /<span\b[^>]*className="asktool-question-body"[^>]*>/,
+ )?.[0];
+ assert.ok(bodyTag);
+ const remountsOnIndex = /\bkey=\{index\}/.test(bodyTag);
+ const clearsScrollOnIndex =
+ /scrollTop\s*=\s*0/.test(askCardSource) &&
+ /\[\s*index\s*\]/.test(askCardSource);
+ assert.ok(
+ remountsOnIndex || clearsScrollOnIndex,
+ "question body keeps scrollTop across index changes",
+ );
+});
+
test("permission approval stays pending until an explicit decision", () => {
assert.doesNotMatch(cardSource, /setInterval|permissionSecondsLeft|role="timer"/);
assert.doesNotMatch(eventsSource, /receivedAt/);
diff --git a/docs/spec/04-ux/11-asktool-question-card.md b/docs/spec/04-ux/11-asktool-question-card.md
index 618a59f3d..0e16f1450 100644
--- a/docs/spec/04-ux/11-asktool-question-card.md
+++ b/docs/spec/04-ux/11-asktool-question-card.md
@@ -83,11 +83,12 @@ contains scroll chaining, and preserves keyboard scroll padding. The question
header, custom-answer input, and Skip / Next / Submit actions remain visible
while the user scrolls through the options. A long question prompt scrolls
inside the question body instead of growing the dock: the body uses
-`min(208px, 24dvh)` with a `24vh` fallback, hides horizontal overflow, and
-contains scroll chaining. Decline, Skip, and Next/Submit stay in the card
-header, outside that scroller, so they remain reachable. Short prompts do not
-reserve a scrollbar gutter. This behavior also applies on narrow screens; the
-card does not rely on page-level scrolling.
+`min(208px, 24dvh)` with a `24vh` fallback, wraps unbroken tokens, hides
+horizontal overflow, and contains scroll chaining. Next, Skip, and the step
+indicators open each question at the top of that scroller. Decline, Skip, and
+Next/Submit stay in the card header, outside that scroller, so they remain
+reachable. Short prompts do not reserve a scrollbar gutter. This behavior also
+applies on narrow screens; the card does not rely on page-level scrolling.
## Request transitions
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index f054a558f..138e46ae6 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -10786,8 +10786,9 @@ This test plan spec is accepted when:
reachable. Scrolling the list does not move the conversation page or hide the
action row. A long question prompt is bounded the same way: the question body
scrolls inside the card (`min(208px, 24dvh)`, with a `24vh` fallback) and the
- header actions stay outside that scroller. The tool output is ordered as
- `question:answer`, uses `、` between multiple answers and `\n---\n`
+ header actions stay outside that scroller. Next, Skip, and the step
+ indicators open each question at the top of that body. The tool output is
+ ordered as `question:answer`, uses `、` between multiple answers and `\n---\n`
between questions, and
keeps `question:` for the skipped question. Markdown renders as rich text
without activating embedded links or loading images. Selecting a formatted
diff --git a/docs/zh-CN/spec/04-ux/11-asktool-question-card.md b/docs/zh-CN/spec/04-ux/11-asktool-question-card.md
index 9ec7bb787..18763b9ce 100644
--- a/docs/zh-CN/spec/04-ux/11-asktool-question-card.md
+++ b/docs/zh-CN/spec/04-ux/11-asktool-question-card.md
@@ -25,8 +25,8 @@ Asktool 卡是内联输入框批准表面,而不是许可
该卡没有倒计时或到期副本。在窄屏幕上,选项仍然存在
全角和动作可以共享行;问题文本和自定义输入可能
自然包裹,无需剪裁。问题正文过长时在正文内滚动,而不是把卡片撑出视口:
-高度上限为 `min(208px, 24dvh)`,并提供 `24vh` 回退,横向溢出被隐藏,滚动链被限制在正文内。
-Decline、Skip 和 Next/Submit 留在卡片标题栏,位于该滚动区域之外,因此仍然可点。短问题不预留滚动条槽。
+高度上限为 `min(208px, 24dvh)`,并提供 `24vh` 回退,不可断行的长文本会换行,横向溢出被隐藏,滚动链被限制在正文内。
+Next、Skip 和步骤指示器切换问题时,正文从滚动区域顶部开始。Decline、Skip 和 Next/Submit 留在卡片标题栏,位于该滚动区域之外,因此仍然可点。短问题不预留滚动条槽。
## 版式层级
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 10b3760a5..7f3b3cead 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
@@ -6552,7 +6552,7 @@ eleven-tool-round desktop paths are verified by
输入框批准区域中已回答、当前和跳过的状态
Plan 和 Goal 批准使用的停靠位置相同。请求没有
倒计时。过长的问题正文在卡片内滚动(`min(208px, 24dvh)`,并有 `24vh` 回退),标题栏上的
- Decline、Skip 和 Next/Submit 留在该滚动区域之外。工具输出排序为 `question:answer`,使用 `、`
+ Decline、Skip 和 Next/Submit 留在该滚动区域之外。切换问题后正文从顶部开始。工具输出排序为 `question:answer`,使用 `、`
多个答案之间和问题之间的 `\n---\n` 之间,并保持
`question:` 用于跳过的问题。拒绝所有产生空
每个问题的占位符,仍然完成工具调用。