Skip to content

[Repo Assist] fix(chat): preserve insertion order for failed-tool turns in timeline#699

Merged
shanselman merged 1 commit into
masterfrom
repo-assist/fix-issue-672-error-toolcall-visual-order-398af6967079d93b
Jun 7, 2026
Merged

[Repo Assist] fix(chat): preserve insertion order for failed-tool turns in timeline#699
shanselman merged 1 commit into
masterfrom
repo-assist/fix-issue-672-error-toolcall-visual-order-398af6967079d93b

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Jun 5, 2026

🤖 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 OpenClawChatTimeline renders entries through a Flush() pass that reorders each turn's entries so non-ToolCall entries (assistant messages, reasoning) appear first, followed by ToolCall entries. This is by design for the success case:

[User] → [Assistant reply] → [Tool burst (success)]

However, for the error case, this reordering produces the wrong visual flow:

[User] → [Assistant reply: "something went wrong..."] → [Tool burst (error)]  ← WRONG

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 any ToolCall entry in the turn has ToolResult == ChatToolCallStatus.Error. If so, skip reordering and preserve insertion order:

[User] → [Tool burst (error)] → [Assistant reply: "something went wrong..."]  ← CORRECT

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 returns false for error bursts, so error cards were never nested inside assistant bubbles — that behavior is unchanged.
  • The turnEndAt lookahead array and assistant bubble look-ahead logic work correctly with preserved insertion order: the assistant entry's nextKind won't be ToolCall (no tool burst after it), so no spurious nesting is triggered.
  • The currentBubbleSlot (width-binding) will be null when 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 failed
  • dotnet 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)

Generated by 🌈 Repo Assist, see workflow run.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a

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>
@github-actions github-actions Bot added automation bug Something isn't working repo-assist labels Jun 5, 2026
@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented Jun 5, 2026

Codex review: needs maintainer review before merge. Reviewed June 5, 2026, 9:58 AM ET / 13:58 UTC.

Summary
Review failed before ClawSweeper could summarize the requested change.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Review metrics: none identified.

Merge readiness
Overall: 🌊 off-meta tidepool
Proof: 🌊 off-meta tidepool
Patch quality: 🌊 off-meta tidepool
Result: rating does not apply to this item.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] No close action taken because the review did not complete.

Maintainer options:

  1. Decide the mitigation before merge
    Retry the Codex review after fixing the execution failure.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • Review did not complete, so no work-lane recommendation was made.
Review details

Best 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 changes

Label changes:

  • add rating: 🌊 off-meta tidepool: Overall readiness is 🌊 off-meta tidepool; proof is 🌊 off-meta tidepool and patch quality is 🌊 off-meta tidepool.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🌊 off-meta tidepool, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status no longer selects a status label.
  • remove P2: Current review triage priority is none.
  • remove merge-risk: 🚨 message-delivery: Current PR review selected no merge-risk labels.

Label justifications:

  • rating: 🌊 off-meta tidepool: Overall readiness is 🌊 off-meta tidepool; proof is 🌊 off-meta tidepool and patch quality is 🌊 off-meta tidepool.
Evidence reviewed

What I checked:

  • failure reason: timeout.
  • codex failure detail: Codex review failed for this PR: spawnSync codex ETIMEDOUT.
  • codex stdout: Per-item Codex failure; continuing with the rest of the shard.

Likely related people:

  • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 message-delivery 🚨 Merging this PR could drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 5, 2026
@shanselman shanselman marked this pull request as ready for review June 7, 2026 22:22
@shanselman shanselman merged commit c149f77 into master Jun 7, 2026
7 checks passed
@shanselman shanselman deleted the repo-assist/fix-issue-672-error-toolcall-visual-order-398af6967079d93b branch June 7, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation bug Something isn't working merge-risk: 🚨 message-delivery 🚨 Merging this PR could drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal priority bug or improvement with limited blast radius. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. repo-assist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows Companion Chat shows stale failed tool event while web UI shows completed assistant response

1 participant