Skip to content

fix(desktop): state a failed turn's outcome where it happened - #4073

Merged
Astro-Han merged 2 commits into
mainfrom
fix/desktop-failed-turn-banner
Aug 28, 2026
Merged

Astro-Han merged 2 commits into
mainfrom
fix/desktop-failed-turn-banner

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A failed turn's banner made three promises it could not keep.

It named an action that does not exist. The banner joins describeTurnErrorClass() and deriveFailedTurnRecovery() with a CSS ::before dot, so a rate limit rendered as 「触发模型速率限制 · 已保留部分输出,可从这里继续」. There is no "here" to continue from — partialOutputRetained only records that the turn produced assistant text or a tool result, and the one real resume path is app_restarted's safe resume, gated on latestInterruptedResumeTurnId. FailedTurnRecoveryAction's four values were never read by any renderer, only label was, so the recovery layer existed solely to phrase guidance no surface could honor. It is deleted. Each turnError string now says what happened and what to do in one sentence, and what it asks for — send another message — always works.

It painted its own error surface. Marker variant="failed-banner" plus hand-rolled oklch(from var(--destructive) …) borders reimplemented Astryx's Banner, which this same file already uses for the provider retry indicator and which the app uses in ~50 other places. Reason → title, park diagnostic → description, safe resume → endContent. Three MarkerVariants, the bespoke AlertOctagon, and the shell CSS go with it. Severity follows the app's existing tone === 'destructive' ? 'error' : 'warning' grading, so "restarted, press continue" stops looking as severe as blocked billing.

It rendered above the work it described. The banner sat at the head of maka-assistant-answer-content, before segment.items.map() — an outcome reading as a header on reasoning and tool calls that had all succeeded. It now follows the timeline it concludes.

Safe resume is kept: it is the only recovery with a real backend, replaying an interrupted turn's own context instead of asking the user to restate it. Its button and the strings around it move from 「安全恢复」 to 「继续这一轮」 so the control, its pending state, its park description, and its toasts stop describing one act four ways.

Net −122 lines.

Verification

  • npm --workspace @maka/ui run build — pass
  • npm --workspace @maka/desktop run typecheck (preload + main + renderer + storybook) — pass
  • npm run format:check — clean
  • node --test on the three affected files (session-status-presentation, session-error-presentation, chat-turn-steering-order) — 7/7 pass
  • Not run: the full repository suite, left to CI.

Rendered through the real TurnView + Astryx CSS. Banner now follows the answer; app-restart is warning with the resume button, rate limit and auth are error with copy only:

image

image

Review focus

The copy is the substance of this change — every turnError string in both locales was rewritten. Worth reading as user-facing text rather than as a diff.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Claude Code (Opus 5) — traced the three defects to their sources, wrote the change, and rewrote the copy under review by the contributor of record, who chose the approach at each branch (drop the unbacked recovery layer rather than build buttons for it; keep safe resume; grade severity in two tiers).

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@github-actions github-actions Bot added the effort/M Under 500 readable lines label Aug 28, 2026
@Astro-Han
Astro-Han marked this pull request as ready for review August 28, 2026 09:29
@likun666661

Copy link
Copy Markdown
Member

The overall direction looks right: moving the failed-turn outcome below the timeline and replacing the bespoke Marker/CSS surface with Astryx Banner both make the UI simpler and more truthful. Keeping the real app_restarted resume action while removing the unused recovery action enum also makes sense.

I think one part is over-subtracted, though. FailedTurnRecoveryAction was unused, but the derived label was consumed. In particular, the old derivation used partialOutputRetained, toolActivityCount, and erroredToolCount to avoid recommending a blind retry after tools had already run. With this change, a turn that successfully executed a side-effecting tool and then failed with timeout, network, or rate_limit is reduced to error-class-only copy such as “Send a message to retry.” That loses the warning to inspect retained tool results first and may encourage duplicate side effects.

Could we keep the structural simplification but retain a much smaller state-aware guidance derivation, returning only text (no unused action enum)? For example:

  • errored tool -> inspect the tool result before deciding whether to continue
  • any completed tool activity -> the tool may already have run; inspect its result before sending a message to continue
  • partial assistant output -> partial output was retained; send a message to continue
  • otherwise -> use the error-class-specific next step
  • app_restarted -> keep the real resume button

There is also a regression-test gap around the ordering fix. chat-turn-steering-order.test.ts currently asserts before < steering < after and that failure detail appears once, but it never asserts after < failure detail/banner. It therefore passes both the old and new layouts. Adding that ordering assertion, plus a case such as timeout + toolActivityCount > 0 that must not recommend a blind retry, would protect the two important behavioral boundaries.

From an Occam perspective, the converged causal spine seems to be: failed turn -> preserve relevant execution state -> render the truthful outcome after the work -> expose only recovery controls that actually exist. The Banner/placement/dead-enum changes are necessary for that spine; discarding retained-output/tool-activity guidance is not, and reduces safety rather than merely removing complexity.

@Astro-Han

Copy link
Copy Markdown
Contributor Author

Both points hold, and the second is a gap I left.

Ordering test. Confirmed: the test asserted before < steering < after plus one-occurrence, both true of either layout. It now asserts the banner follows the last timeline entry — verified by moving the banner back above the timeline and watching it fail.

Execution-state guidance. The risk is real: a resend after a side-effecting tool can repeat that effect, and error-class copy alone does not say so. Restored as describeFailedTurnExecutionState(), text only, no action enum.

I did not restore the ranked form. That chain put the tool branch ahead of the error class, so auth plus one errored tool advised "inspect the tool result" and dropped "sign in again" — the only step that could change the outcome; context_overflow plus tool activity lost "reduce attachments" the same way. The proposed order (errored tool → tool activity → partial → otherwise error-class) keeps that precedence.

The two facts never actually competed: one is why the turn ended, the other is what it already did. Banner has a slot for each, so the error class takes title, execution state takes description, and neither loses. description is otherwise written only by the parked-resume diagnostic, which exists solely on app_restarted turns, so they cannot collide. No priority chain needed — nothing has to be dropped.

Tests added: timeout + a completed tool asserting the side-effect warning survives, auth + an errored tool asserting the sign-in step is still stated, plus the empty and most-specific cases. Screenshots of all four shapes are in the PR body.

Pushed as 3e68486.

@Astro-Han
Astro-Han requested a review from likun666661 August 28, 2026 11:21
A failed turn's banner made three separate promises it could not keep.

It claimed an action that does not exist. The banner reads
`describeTurnErrorClass()` for a title and `deriveFailedTurnRecovery()`
for a tail, joined by a CSS `::before` dot, so a rate limit rendered as
「触发模型速率限制 · 已保留部分输出,可从这里继续」. There is no "here"
to continue from: `partialOutputRetained` only records that the turn
produced some assistant text or a tool result, and the sole resume path
is `app_restarted`'s safe resume, gated on `latestInterruptedResumeTurnId`.
`FailedTurnRecoveryAction`'s four values were never read by any renderer
— only `label` was — so the whole recovery layer existed to phrase
guidance no surface could honor. It goes; each `turnError` string now
says what happened and what to do in one sentence, and what it tells the
user to do is send another message, which always works.

It painted its own error surface. `Marker variant="failed-banner"` plus
hand-rolled `oklch(from var(--destructive) …)` borders reimplemented
Astryx's `Banner`, which the same file already uses for the provider
retry indicator and which the app uses in ~50 other places. Reason maps
to `title`, the park diagnostic to `description`, safe resume to
`endContent`. Three `MarkerVariant`s, the bespoke `AlertOctagon`, and
the shell CSS go with it; only the block rhythm stays. Severity follows
the app's existing `tone === 'destructive' ? 'error' : 'warning'` grading
so "restarted, press continue" stops looking as loud as blocked billing.

It rendered above the work it described. The banner sat at the head of
`maka-assistant-answer-content`, before `segment.items.map()`, so an
outcome read as a header on reasoning and tool calls that had all
succeeded. It now follows the timeline it concludes.

Safe resume survives all of this: it is the one recovery with a real
backend, replaying an interrupted turn's own context rather than asking
the user to restate it. Its button and every string around it move from
「安全恢复」 to 「继续这一轮」, so the control, its pending state, its
park description, and its toasts stop describing the same act four ways.

Generated-by: Claude Code
Deleting `deriveFailedTurnRecovery()` took a real warning with it. A turn
that ran a tool and then failed on transport — `timeout`, `network`,
`rate_limit` — was left with error-class copy alone, so "send a message
to retry" no longer said that tools had already run and a resend could
repeat their effects. That guidance was worth keeping; only the resume
it falsely promised was not.

`describeFailedTurnExecutionState()` restores it as text, with no action
enum to go unread. It does NOT restore the ranking the old derivation
used. That chain put the tool branch ahead of the error class, so `auth`
plus one errored tool advised "inspect the tool result" and dropped
"sign in again" — the only step that could change the outcome — and
`context_overflow` plus tool activity lost "reduce attachments" the same
way. The two facts never competed for real: one is why the turn ended,
the other is what it already did. `Banner` has a slot for each, so the
error class takes `title`, execution state takes `description`, and
neither has to lose. `description` is otherwise written only by the
parked-resume diagnostic, which exists solely on `app_restarted` turns,
so the two cannot collide.

The ordering fix shipped without a test that could fail for it:
`chat-turn-steering-order.test.ts` asserted steering position and
one-occurrence, both true of either layout. It now asserts the banner
follows the last timeline entry, verified by moving the banner back
above the timeline and watching it fail.

Generated-by: Claude Code
@Astro-Han
Astro-Han force-pushed the fix/desktop-failed-turn-banner branch from 3e68486 to c8e78de Compare August 28, 2026 11:31

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed exact head c8e78ded56391423889b4a502486892260dfdda5.

The failed-turn banner no longer names a continue action the UI cannot run. Reason and leftover tool/partial state stay in separate slots, so an auth failure is not replaced by "inspect the tool". The banner sits after the timeline, uses the shared Banner, and keeps the one real resume button (app_restarted).

No blocking issues on this head.


Posted by an automated review agent operated by @WAWQAQ. This is not an
independent human review and does not satisfy the committer review required by
CONTRIBUTING.md. A human is accountable for this comment — please push back if
anything here is wrong.

简体中文

我审了当前 head。失败回合横幅不再承诺一个并不存在的「继续」动作;原因和工具副作用分开写。没有阻塞问题。

本条评论由 @WAWQAQ 运行的自动化审查程序发出。它不构成 CONTRIBUTING.md
所要求的独立人类审查,也不能替代人类审查。有人类对本条评论负责,如有错误请直接指出。

@Astro-Han
Astro-Han merged commit 3098674 into main Aug 28, 2026
1 check passed
@Astro-Han
Astro-Han deleted the fix/desktop-failed-turn-banner branch August 28, 2026 12:42
Astro-Han added a commit that referenced this pull request Aug 28, 2026
The aborted marker rendered at the top of the assistant answer, above
the reasoning disclosures and tool calls, where it read as a header on
work that had in fact all completed. PR #4073 moved the failed banner
below the timeline for exactly this reason but left the aborted marker
behind; both are terminal outcome markers and share the same slot, so
move the aborted marker next to the failed banner and match its block
rhythm.

Generated-by: Maka
Astro-Han added a commit that referenced this pull request Aug 28, 2026
The aborted marker rendered at the top of the assistant answer, above
the reasoning disclosures and tool calls, where it read as a header on
work that had in fact all completed. PR #4073 moved the failed banner
below the timeline for exactly this reason but left the aborted marker
behind; both are terminal outcome markers and share the same slot, so
move the aborted marker next to the failed banner and match its block
rhythm.

Generated-by: Maka
Astro-Han added a commit that referenced this pull request Aug 28, 2026
* fix(ui): state an aborted turn's outcome after its timeline

The aborted marker rendered at the top of the assistant answer, above
the reasoning disclosures and tool calls, where it read as a header on
work that had in fact all completed. PR #4073 moved the failed banner
below the timeline for exactly this reason but left the aborted marker
behind; both are terminal outcome markers and share the same slot, so
move the aborted marker next to the failed banner and match its block
rhythm.

Generated-by: Maka

* fix(ui): use Astryx badge for aborted turns

Aborted turns are settled facts, but their outcome was rendered through a Maka-only Marker variant and bespoke visual recipe. Render the terminal outcome with Astryx's neutral Badge while preserving its position after the timeline, retain only the flex alignment needed by the transcript container, and cover both the component contract and ordering.

Generated-by: Codex

* fix(ui): render aborts as chat status notices

An aborted turn is a short, settled status change with no recovery action. Astryx documents ChatSystemMessage as the Chat-family primitive for inline status notices, while Badge is reserved for states users need to notice or act on. Render the outcome as a system-message sibling after the assistant timeline, remove the marker-era parentheses and layout hook, and pin the component, copy, and ordering contracts.

Generated-by: Codex

* docs(ui): remove stale abort marker reference

Generated-by: Codex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants