Skip to content

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

fix(chat): prevent the retry error message from being clipped on a new chat (#702)

MakkaPakka12138094afaa76ff2
diff --git a/.github/pr-assets/run-activity-error-popover/01-before-clipped.png b/.github/pr-assets/run-activity-error-popover/01-before-clipped.png
new file mode 100644
index 000000000..840b1c6b7
Binary files /dev/null and b/.github/pr-assets/run-activity-error-popover/01-before-clipped.png differ
diff --git a/.github/pr-assets/run-activity-error-popover/02-after-scrollable.png b/.github/pr-assets/run-activity-error-popover/02-after-scrollable.png
new file mode 100644
index 000000000..fb4bba8d8
Binary files /dev/null and b/.github/pr-assets/run-activity-error-popover/02-after-scrollable.png differ
diff --git a/apps/desktop/src/features/chat/transcript/ActivityGroup.tsx b/apps/desktop/src/features/chat/transcript/ActivityGroup.tsx
index 99aa48642..dc77f76a2 100644
--- a/apps/desktop/src/features/chat/transcript/ActivityGroup.tsx
+++ b/apps/desktop/src/features/chat/transcript/ActivityGroup.tsx
@@ -503,6 +503,8 @@ export function RunActivityIndicator({ activity }: { activity: AgentActivity })
const { t } = useTranslation();
const [now, setNow] = useState(Date.now);
const retryErrorDetailsId = useId();
+ const retryReasonRef = useRef<HTMLSpanElement | null>(null);
+ const retryPlateRef = useRef<HTMLSpanElement | null>(null);
useEffect(() => {
setNow(Date.now());
@@ -515,6 +517,66 @@ export function RunActivityIndicator({ activity }: { activity: AgentActivity })
);
const label = runActivityLabel(activity, t as Translate, now);
const retryError = activity.phase === "retrying" ? activity.error : undefined;
+
+ // The plate hangs off the tail row inside `.thread-scroll`, whose
+ // `overflow: auto` clips it, and the conversation bar paints over the same
+ // band from a higher stacking level. The room depends on where the row sits
+ // in the viewport, which no window-based rule can know: a short transcript
+ // leaves the row mid-window, and a long provider message still lost its first
+ // lines (ADR 0196). Measure the room the row actually leaves - the plate is
+ // anchored 8px above the trigger, so its own bottom edge starts that room -
+ // and let the remainder scroll.
+ useEffect(() => {
+ if (!retryError) return;
+ const reason = retryReasonRef.current;
+ const plate = retryPlateRef.current;
+ if (!reason || !plate) return;
+ const measure = () => {
+ const toolbarHeight =
+ Number.parseFloat(
+ getComputedStyle(reason).getPropertyValue("--ds-toolbar-height"),
+ ) || 0;
+ // The plate is anchored 8px above the trigger, so its own bottom edge
+ // starts the room - but the resting state carries a 4px downward
+ // translate the revealed state drops. Measure the settled edge, or the
+ // cap comes out 4px too generous and the top slides under the bar.
+ const resting = getComputedStyle(plate).transform;
+ const offset = resting === "none" ? 0 : new DOMMatrixReadOnly(resting).m42;
+ const settledBottom = plate.getBoundingClientRect().bottom - offset;
+ const room = Math.floor(settledBottom - toolbarHeight);
+ // The heading stays readable: only the message body scrolls inside the
+ // plate, which keeps the plate's own rounded corner away from a
+ // scrollbar (Chromium does not clip one to the radius).
+ const bodyText = plate.querySelector<HTMLElement>(
+ ".run-activity-error-message",
+ );
+ const chrome = bodyText
+ ? bodyText.getBoundingClientRect().top -
+ plate.getBoundingClientRect().top +
+ (Number.parseFloat(getComputedStyle(plate).paddingBottom) || 0)
+ : 0;
+ plate.style.setProperty(
+ "--run-activity-error-max-height",
+ `${Math.max(0, room)}px`,
+ );
+ plate.style.setProperty(
+ "--run-activity-error-body-max-height",
+ `${Math.max(0, Math.floor(room - chrome))}px`,
+ );
+ };
+ measure();
+ window.addEventListener("resize", measure);
+ const scroller = reason.closest(".thread-scroll");
+ scroller?.addEventListener("scroll", measure, { passive: true });
+ const observer =
+ typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
+ observer?.observe(document.documentElement);
+ return () => {
+ window.removeEventListener("resize", measure);
+ scroller?.removeEventListener("scroll", measure);
+ observer?.disconnect();
+ };
+ }, [retryError]);
const retryErrorSummary = retryError
? (() => {
const key = `errors.${retryError.code}`;
@@ -527,6 +589,7 @@ export function RunActivityIndicator({ activity }: { activity: AgentActivity })
: label;
const labelContent = retryError ? (
<span
+ ref={retryReasonRef}
className="run-activity-retry-reason"
tabIndex={0}
aria-describedby={retryErrorDetailsId}
@@ -535,6 +598,7 @@ export function RunActivityIndicator({ activity }: { activity: AgentActivity })
<span className="working-indicator-label">{label}</span>
<span
id={retryErrorDetailsId}
+ ref={retryPlateRef}
className="run-activity-error-popover message-error"
role="tooltip"
>
diff --git a/apps/desktop/src/styles/messages.css b/apps/desktop/src/styles/messages.css
index 7493b52b5..be9e3a941 100644
--- a/apps/desktop/src/styles/messages.css
+++ b/apps/desktop/src/styles/messages.css
@@ -327,6 +327,8 @@
.run-activity-retry-reason {
position: relative;
+ /* The plate hangs this far above the trigger; the bridge below covers it. */
+ --run-activity-error-gap: 8px;
display: inline-flex;
min-width: 0;
align-items: center;
@@ -334,6 +336,19 @@
outline: none;
}
+/* The pointer has to cross the gap between the trigger and the plate to reach
+ the plate's scrollbar. That band belongs to the indicator row, not to the
+ trigger, so `:hover` dropped there and the plate closed mid-reach. The bridge
+ is part of the trigger, which keeps the path hovered. */
+.run-activity-retry-reason::before {
+ content: "";
+ position: absolute;
+ top: calc(-1 * var(--run-activity-error-gap));
+ left: 0;
+ right: 0;
+ height: var(--run-activity-error-gap);
+}
+
.run-activity-retry-reason:focus-visible {
border-radius: var(--radius-2xs);
box-shadow: 0 0 0 2px color-mix(in oklab, var(--ds-accent) 80%, transparent);
@@ -342,31 +357,54 @@
/* The retry reason borrows the assistant error card's hierarchy without
adding a second transcript row. It is hover/focus-only so the active row
remains compact at rest. The in-flow `.message-error` wash is transparent;
- this floating tooltip mixes the same tint over an opaque elevated plate. */
+ this floating tooltip mixes the same tint over an opaque elevated plate.
+ The plate hangs above the tail status row inside `.thread-scroll`, whose
+ `overflow: auto` clips it at the scrollport edge, and the conversation bar
+ paints over the same band one stacking level higher, so an unbounded plate
+ lost the first lines of a long provider message (ADR 0196) - the part a
+ reader needs. Cap it to the room the tail row leaves: the window minus the
+ conversation bar, minus the composer reserve `.thread-content` already
+ holds (16px above `--composer-dock-height`), minus the 46px status row and
+ this plate's own 8px gap. The remainder scrolls, the way
+ `.message-error-details pre` already handles long error text. */
.run-activity-error-popover.message-error {
position: absolute;
- bottom: calc(100% + 8px);
+ bottom: calc(100% + var(--run-activity-error-gap));
left: 0;
z-index: 8;
display: block;
width: min(360px, calc(100vw - 32px));
padding: 10px 12px;
+ max-height: calc(100vh - var(--ds-toolbar-height, 46px) - var(--composer-dock-height, 228px) - 70px);
+ /* RunActivityIndicator measures the room the tail row actually leaves and
+ publishes it here; the calc is only the first-paint fallback. */
+ max-height: var(--run-activity-error-max-height, calc(100dvh - var(--ds-toolbar-height, 46px) - var(--composer-dock-height, 228px) - 70px));
+ /* The plate itself does not scroll: Chromium paints a scrollbar outside a
+ rounded corner, so the bar crossed the radius. The body below the heading
+ owns the scrolling instead. */
+ overflow: hidden;
background: color-mix(in oklab, var(--ds-error) 10%, var(--ds-bg-elevated-opaque));
box-shadow: var(--ds-shadow-dialog);
opacity: 0;
pointer-events: none;
transform: translateY(4px);
visibility: hidden;
+ /* Leaving the trigger keeps the plate for one short beat, so a reader
+ reaching for the scrollbar is not punished for the trip. */
transition:
- opacity var(--motion-duration-fast) var(--motion-ease-out),
- transform var(--motion-duration-fast) var(--motion-ease-out),
- visibility 0s linear var(--motion-duration-fast);
+ opacity var(--motion-duration-fast) var(--motion-ease-out) 240ms,
+ transform var(--motion-duration-fast) var(--motion-ease-out) 240ms,
+ visibility 0s linear calc(var(--motion-duration-fast) + 240ms);
}
.run-activity-retry-reason:hover .run-activity-error-popover,
.run-activity-retry-reason:focus-visible .run-activity-error-popover {
opacity: 1;
- pointer-events: none;
+ /* The capped plate is scrollable, so the revealed state has to take the
+ pointer. Hovering the plate keeps this trigger's `:hover` alive - the
+ plate is its child - so a long provider message can be scrolled and
+ selected instead of losing its first lines above the scrollport. */
+ pointer-events: auto;
transform: translateY(0);
visibility: visible;
transition-delay: 0s;
@@ -380,6 +418,11 @@
font-size: var(--text-xs);
line-height: var(--leading-normal);
overflow-wrap: anywhere;
+ /* Body-only scrolling (measured by RunActivityIndicator): the heading above
+ stays put while a long provider message scrolls inside the plate. */
+ max-height: var(--run-activity-error-body-max-height, none);
+ overflow-y: auto;
+ overscroll-behavior-y: contain;
}
@media (prefers-reduced-motion: reduce) {
diff --git a/apps/desktop/test/active-turn-surface.test.mjs b/apps/desktop/test/active-turn-surface.test.mjs
index 70ffa3c45..656a8fb17 100644
--- a/apps/desktop/test/active-turn-surface.test.mjs
+++ b/apps/desktop/test/active-turn-surface.test.mjs
@@ -83,6 +83,55 @@ test("active turns show immediate and phase-specific feedback without a progress
messagesStyles,
/\.run-activity-retry-reason:hover[\s\S]*\.run-activity-error-popover/,
);
+ // The retry plate hangs above the tail row inside `.thread-scroll`, whose
+ // `overflow: auto` clips it at the scrollport edge, and the conversation bar
+ // paints over the same band one stacking level higher. An unbounded plate
+ // therefore lost the first lines of a long provider message, so the plate is
+ // bounded to the room the tail row leaves and the rest scrolls.
+ const popoverRule =
+ messagesStyles.match(/\.run-activity-error-popover\.message-error \{[\s\S]*?\n\}/)?.[0] ??
+ "";
+ assert.match(
+ popoverRule,
+ /max-height: calc\(100vh - var\(--ds-toolbar-height, 46px\) - var\(--composer-dock-height, 228px\) - 70px\);/,
+ );
+ assert.match(
+ popoverRule,
+ /max-height: var\(--run-activity-error-max-height, calc\(100dvh - var\(--ds-toolbar-height, 46px\) - var\(--composer-dock-height, 228px\) - 70px\)\);/,
+ );
+ // The room depends on where the tail row sits, so the component measures it
+ // against the conversation bar and republishes it on resize and scroll.
+ assert.match(transcript, /--run-activity-error-max-height/);
+ assert.match(
+ transcript,
+ /closest\("\.thread-scroll"\)[\s\S]*?addEventListener\("scroll", measure/,
+ );
+ // The plate clips; only the body scrolls, so no scrollbar crosses the radius.
+ assert.match(popoverRule, /overflow: hidden;/);
+ const bodyRule =
+ messagesStyles.match(/\.run-activity-error-message \{[\s\S]*?\n\}/)?.[0] ?? "";
+ assert.match(
+ bodyRule,
+ /max-height: var\(--run-activity-error-body-max-height, none\);/,
+ );
+ assert.match(bodyRule, /overflow-y: auto;/);
+ assert.match(bodyRule, /overscroll-behavior-y: contain;/);
+ assert.match(transcript, /--run-activity-error-body-max-height/);
+ // A bounded plate only helps if the revealed state can take the pointer.
+ const retryRevealRule =
+ messagesStyles.match(/\.run-activity-retry-reason:hover[\s\S]*?\n\}/)?.[0] ?? "";
+ assert.match(retryRevealRule, /pointer-events: auto;/);
+ // The plate sits one gap above the trigger, and that band belongs to the
+ // indicator row: without a bridge on the trigger the pointer loses `:hover`
+ // while travelling to the plate's scrollbar and the message closes mid-reach.
+ assert.match(
+ messagesStyles,
+ /\.run-activity-retry-reason::before \{[\s\S]*?height: var\(--run-activity-error-gap\);[\s\S]*?\n\}/,
+ );
+ assert.match(popoverRule, /bottom: calc\(100% \+ var\(--run-activity-error-gap\)\);/);
+ // Leaving keeps the plate for one short beat so the trip is recoverable.
+ assert.match(popoverRule, /visibility 0s linear calc\(var\(--motion-duration-fast\) \+ 240ms\);/);
+ assert.doesNotMatch(retryRevealRule, /pointer-events: none;/);
assert.match(messagesStyles, /\.run-activity-indicator\[data-phase="waiting-subagents"\]/);
assert.match(messagesStyles, /\.working-indicator-mark > span\s*\{[\s\S]*?animation:\s*working-indicator-dot\s+1s/);
assert.doesNotMatch(proseStyles, /\.working-indicator\s*\{|\.shimmer-text\s*\{/);
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index c3254865c..d442bb961 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -5624,6 +5624,10 @@ identify the platform validation still needed.
- **Expected**:
- The Plan/Goal approval bar paints `--ds-bg-composer` with `--ds-shadow-composer` rather than the in-flow `--ds-tile` wash, so it remains a readable plate over the transparent composer dock.
- The retry hover tooltip mixes the error tint over `--ds-bg-elevated-opaque`, so transcript text does not show through.
+ - The retry tooltip is capped to the room above the tail status row and
+ scrolls the remainder, so a long provider message keeps its first lines
+ inside the transcript scrollport and below the conversation bar instead of
+ being hidden by either.
- **Specs linked**: `04-ux/03-permission-ux.md`, `04-ux/08-component-spec.md`
- **Acceptance**: C, Quality
- **Milestone**: M6
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 55fe9a00a..eae7dc182 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
@@ -3809,6 +3809,8 @@ IPC 请求无法关闭。
- **预期**:
- Plan/Goal 审批条使用 `--ds-bg-composer` 加 `--ds-shadow-composer`,而不是正文流里的 `--ds-tile` 薄洗,因此在透明停靠栏上仍可读。
- 重试 hover tooltip 把错误色混在 `--ds-bg-elevated-opaque` 上,记录正文不会透出。
+ - 重试 tooltip 的高度被限制在尾部状态行上方的可用空间内,其余部分可滚动,
+ 因此较长的 provider 消息会保留开头几行,不会被记录滚动容器或会话顶栏遮住。
- **链接规格**:`04-ux/03-permission-ux.md`、`04-ux/08-component-spec.md`
- **接受**:C、品质
- **里程碑**:M6