[Repo Assist] fix(chat): preserve insertion order for failed-tool turns in timeline#699
Conversation
When a tool call fails (ChatToolCallStatus.Error), the current Flush() reorder puts non-ToolCall entries first, which places the final assistant acknowledgement at the visual top and the tool error at the bottom where auto-scroll lands. This mismatch causes the user to see only the failed tool event, while the assistant response is above the viewport. Fix: detect if a turn contains any Error-status ToolCall. If so, output all entries in their original insertion order (tool error first, assistant response second). The assistant response then lands at the scroll anchor, matching the web UI presentation. The normal success-case reordering (assistant first, then tool burst) is unchanged. BurstIsNestable already blocks error bursts from being nested inside the assistant bubble, so no visual nesting logic needs updating. Closes #672 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Codex review: needs maintainer review before merge. Reviewed June 5, 2026, 9:58 AM ET / 13:58 UTC. Summary Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Review detailsBest possible solution: Retry the Codex review after fixing the execution failure. Do we have a high-confidence way to reproduce the issue? Unclear. The review failed before ClawSweeper could establish a reproduction path. Is this the best way to solve the issue? Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model gpt-5.5, reasoning high; reviewed against 99efc50cbc22. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Closes #672
Fixes the visual ordering bug where the Windows Companion Chat showed a stale failed tool event while the web UI correctly showed the completed assistant response.
Root Cause
The
OpenClawChatTimelinerenders entries through aFlush()pass that reorders each turn's entries so non-ToolCallentries (assistant messages, reasoning) appear first, followed byToolCallentries. This is by design for the success case:However, for the error case, this reordering produces the wrong visual flow:
The chat auto-scrolls to the bottom — the tool error. The assistant's final response is above the viewport, making it appear as if only the tool error exists. After a restart (history reload), the entries happen to render in a way the user perceives as correct (assistant message visible at scroll position).
Fix
In
Flush(), detect if anyToolCallentry in the turn hasToolResult == ChatToolCallStatus.Error. If so, skip reordering and preserve insertion order:This places the assistant response at the scroll anchor (bottom), matching the web UI and making the final response immediately visible without scrolling.
Normal success-case reordering is unchanged. Only turns containing a failed tool call are affected.
Implementation Notes
BurstIsNestable()already returnsfalsefor error bursts, so error cards were never nested inside assistant bubbles — that behavior is unchanged.turnEndAtlookahead array and assistant bubble look-ahead logic work correctly with preserved insertion order: the assistant entry'snextKindwon't beToolCall(no tool burst after it), so no spurious nesting is triggered.currentBubbleSlot(width-binding) will benullwhen the error tool card renders (since the assistant bubble hasn't been created yet), which is correct — the error card renders at its own natural width.Test Status
dotnet test OpenClaw.Tray.Tests— 934 passed, 2 skipped, 0 faileddotnet test OpenClaw.Shared.Tests— 8 pre-existing failures on master baseline (unrelated, confirmed identical)./build.ps1— not run (Windows PowerShell build script, unavailable in Linux CI)