Skip to content

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

fix(asktool): cover long prompt scrolling interactions

vastsa29d76b6a8f49
diff --git a/apps/desktop/src/components/AskToolCard.tsx b/apps/desktop/src/components/AskToolCard.tsx
index 6baab0a7d..c1c1daa4e 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 key={index} className="asktool-question-body">
+ <span key={index} className="asktool-question-body" tabIndex={0}>
<AskToolRichText source={current.question} />
</span>
</h3>
diff --git a/apps/desktop/src/styles/messages.css b/apps/desktop/src/styles/messages.css
index f3d7984f8..6e0cb0e62 100644
--- a/apps/desktop/src/styles/messages.css
+++ b/apps/desktop/src/styles/messages.css
@@ -229,6 +229,11 @@
overscroll-behavior-y: contain;
}
+.asktool-question-body:focus-visible {
+ outline: 2px solid var(--ds-accent);
+ outline-offset: 2px;
+}
+
.asktool-options {
display: grid;
gap: 6px;
diff --git a/docs/spec/04-ux/11-asktool-question-card.md b/docs/spec/04-ux/11-asktool-question-card.md
index 0e16f1450..d0bc97812 100644
--- a/docs/spec/04-ux/11-asktool-question-card.md
+++ b/docs/spec/04-ux/11-asktool-question-card.md
@@ -84,10 +84,11 @@ 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, 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
+horizontal overflow, and contains scroll chaining. The body is keyboard
+focusable with a visible focus ring. 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 138e46ae6..998884b51 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. Next, Skip, and the step
- indicators open each question at the top of that body. The tool output is
+ header actions stay outside that scroller. The question body is keyboard
+ focusable with a visible focus ring. 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
@@ -10805,7 +10806,11 @@ This test plan spec is accepted when:
`04-ux/11-asktool-question-card.md`, ADR 0077
- **Acceptance**: E (interactive tool output), C (inline card)
- **Milestone**: M5
-- **Status**: Draft (runtime/unit coverage active; desktop journey pending)
+- **Automated coverage**: `pnpm test:e2e:asktool-card` mounts the production
+ component in Electron and covers long-prompt scrolling, keyboard reachability,
+ visible header actions, and scroll reset on Next.
+- **Status**: Partially automated (component paths and long-prompt behavior are
+ covered; full application journey pending)
- **Request transition regression**: Keep a one-question request pending in chat
B. In chat A, advance a two-question request to question two, then select B.
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 18763b9ce..87406c769 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
@@ -26,7 +26,7 @@ Asktool 卡是内联输入框批准表面,而不是许可
全角和动作可以共享行;问题文本和自定义输入可能
自然包裹,无需剪裁。问题正文过长时在正文内滚动,而不是把卡片撑出视口:
高度上限为 `min(208px, 24dvh)`,并提供 `24vh` 回退,不可断行的长文本会换行,横向溢出被隐藏,滚动链被限制在正文内。
-Next、Skip 和步骤指示器切换问题时,正文从滚动区域顶部开始。Decline、Skip 和 Next/Submit 留在卡片标题栏,位于该滚动区域之外,因此仍然可点。短问题不预留滚动条槽。
+该正文可通过键盘聚焦,并显示可见焦点环。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 7f3b3cead..d94cff583 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
@@ -6551,7 +6551,7 @@ eleven-tool-round desktop paths are verified by
- **预期**:一次可见一个问题;小指标显示
输入框批准区域中已回答、当前和跳过的状态
Plan 和 Goal 批准使用的停靠位置相同。请求没有
- 倒计时。过长的问题正文在卡片内滚动(`min(208px, 24dvh)`,并有 `24vh` 回退),标题栏上的
+ 倒计时。过长的问题正文在卡片内滚动(`min(208px, 24dvh)`,并有 `24vh` 回退),可通过键盘聚焦且显示焦点环;标题栏上的
Decline、Skip 和 Next/Submit 留在该滚动区域之外。切换问题后正文从顶部开始。工具输出排序为 `question:answer`,使用 `、`
多个答案之间和问题之间的 `\n---\n` 之间,并保持
`question:` 用于跳过的问题。拒绝所有产生空
@@ -6560,7 +6560,8 @@ eleven-tool-round desktop paths are verified by
`04-ux/11-asktool-question-card.md`、ADR 0077
- **验收**:E(交互式工具输出)、C(内联卡)
- **里程碑**:M5
-- **状态**:草案(单位覆盖范围有效;桌面旅程待定)
+- **自动化覆盖**:`pnpm test:e2e:asktool-card` 在 Electron 中挂载生产组件,覆盖长问题滚动、键盘可达性、标题栏动作可见性和点击 Next 后的滚动重置。
+- **状态**:部分自动化(组件路径和长问题行为已覆盖;完整应用桌面旅程仍待完成)
- **请求切换回归**:在聊天 B 留下一个单题请求。在聊天 A 将双题请求推进到第二题,
再切换到 B。B 应显示自己的第一题、空白答案和可用输入框,不应出现应用错误页。
diff --git a/scripts/e2e/asktool-card.tsx b/scripts/e2e/asktool-card.tsx
index 175c225b9..6d641e0f4 100644
--- a/scripts/e2e/asktool-card.tsx
+++ b/scripts/e2e/asktool-card.tsx
@@ -78,6 +78,23 @@ const MULTI_BLOCK_QUESTION: FixtureQuestion = {
options: [{ label: "delta", description: "Fourth choice" }],
};
+const LONG_QUESTIONS: FixtureQuestion[] = [
+ {
+ question: `First long question\n\n${Array.from(
+ { length: 24 },
+ (_, index) => `First prompt paragraph ${index + 1} keeps enough text in the card to require its own scroll area.`,
+ ).join("\n\n")}`,
+ options: [{ label: "Continue", description: "Move to the next question" }],
+ },
+ {
+ question: `Second long question\n\n${Array.from(
+ { length: 24 },
+ (_, index) => `Second prompt paragraph ${index + 1} keeps enough text in the card to require its own scroll area.`,
+ ).join("\n\n")}`,
+ options: [{ label: "Submit", description: "Finish the request" }],
+ },
+];
+
export async function asktoolCardProbe() {
await i18n.init({ lng: "en", resources: { en: { translation: en } } });
const initial = useAppStore.getState();
@@ -301,6 +318,57 @@ export async function asktoolCardProbe() {
`the question number shares the first line with the question text (${numberBox.top}, ${boxes[0]!.top})`,
);
+ // Flow F: a long prompt scrolls inside the card, keeps header actions in
+ // view, and resets to the top when Next replaces the current question.
+ mount("ask-overflow", LONG_QUESTIONS);
+ await until(() => {
+ const body = host.querySelector<HTMLElement>(".asktool-question-body");
+ return Boolean(body && body.clientHeight > 0 && body.scrollHeight > body.clientHeight);
+ }, "long question has an internal scroll range");
+ const firstBody = element<HTMLElement>(".asktool-question-body");
+ assert(firstBody.tabIndex === 0, "the question scroller is keyboard reachable");
+ const tabOrder = [
+ ...host.querySelectorAll<HTMLElement>("button, input, [tabindex='0']"),
+ ];
+ const bodyTabIndex = tabOrder.indexOf(firstBody);
+ assert(
+ tabOrder.indexOf(headerButtons().primary) < bodyTabIndex &&
+ bodyTabIndex < tabOrder.indexOf(options()[0]!),
+ "Tab reaches the question scroller between header actions and answers",
+ );
+ assert(
+ getComputedStyle(firstBody).overflowY === "auto",
+ "the long question scrolls inside its own body",
+ );
+ const actionRects = Object.values(headerButtons()).map((button) => {
+ const rect = button.getBoundingClientRect();
+ return { top: rect.top, bottom: rect.bottom };
+ });
+ assert(
+ actionRects.every(({ top, bottom }) => top >= 0 && bottom <= window.innerHeight),
+ "header actions stay inside the visible window",
+ );
+ firstBody.scrollTop = firstBody.scrollHeight;
+ await frame();
+ assert(firstBody.scrollTop > 0, "the question body accepts scrolling");
+ assert(
+ Object.values(headerButtons()).every((button, index) => {
+ const rect = button.getBoundingClientRect();
+ return Math.abs(rect.top - actionRects[index]!.top) < 1 &&
+ Math.abs(rect.bottom - actionRects[index]!.bottom) < 1;
+ }),
+ "scrolling the prompt does not move its header actions",
+ );
+ flushSync(() => headerButtons().primary.click());
+ await until(
+ () => questionText().includes("Second long question"),
+ "Next advances from the scrolled prompt",
+ );
+ assert(
+ element<HTMLElement>(".asktool-question-body").scrollTop === 0,
+ "the next long question starts at the top",
+ );
+
assert(errors.length === 0, `render errors: ${errors.map(String)}`);
return { ok: true, resolutions: resolutions.length };
} catch (error) {