openclaw-windows-node icon indicating copy to clipboard operation
openclaw-windows-node copied to clipboard

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

Open gerwin-van-giessen opened this issue 5 months ago β€’ 2 comments

Summary

The OpenClaw Windows Companion Chat can sometimes display a failed tool event as the visible chat output, while the web UI (http://localhost:18789) correctly shows the final assistant response for the exact same conversation.

After closing and reopening the Windows Companion App, the displayed output matches the web UI again. This suggests that the underlying chat state is correct, but the Companion UI may be rendering a stale intermediate event instead of the latest assistant message.

Example

Windows Companion (before restart)

OpenClaw Windows Companion Chat before restart

The Companion displays only a failed tool event:

⚠️ πŸ› οΈ `run openclaw nodes (agent)` failed

Web UI

OpenClaw WebUI Chat

The same conversation in the web UI correctly displays the final assistant response.

Windows Companion (after restart)

OpenClaw Windows Companion Chat after restart

After restarting the Companion, the correct assistant response is displayed and matches the web UI.

Expected Behavior

The Windows Companion should automatically update to display the latest assistant response once it becomes available, even if a previous tool call failed.

Actual Behavior

Before restarting, the Windows Companion remains stuck showing a failed tool event, while the web UI already shows the completed response. Restarting the Companion resolves the inconsistency.

Steps to Reproduce

  1. Open a chat in the Windows Companion.
  2. Send the following prompt:
List all available OpenClaw nodes and explain what each node does.
  1. Wait for the assistant response.
  2. Compare the conversation in the Windows Companion and the web UI (http://localhost:18789).
  3. Observe that the web UI shows the completed response while the Companion only shows a failed tool event.
  4. Restart the Windows Companion.
  5. Observe that the Companion now displays the same response as the web UI.

Additional Notes

  • The issue occurs within the same chat and the same OpenClaw instance.
  • No messages appear to be lost.
  • The final assistant response exists and is visible in the web UI.
  • Restarting the Companion causes the correct state to be loaded.
  • This appears to be a UI synchronization, streaming, or event-rendering issue rather than a backend or conversation-state issue.

gerwin-van-giessen avatar Jun 03 '26 17:06 gerwin-van-giessen

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 3, 2026, 1:11 PM ET / 17:11 UTC.

Summary Keep open: current main still has a plausible native Companion chat rendering/reconciliation gap where a failed tool row can remain the terminal visible row even after the assistant response exists, and I found no linked fix or canonical replacement in the provided context.

Reproducibility: no. high-confidence live reproduction was run in this read-only review. Source inspection gives a plausible current-main path: failed ToolCall rows render after assistant rows within a turn, so the bottom visible row can remain the failed tool event even after the assistant response exists.

Ways to help us reproduce this

  • Add a screenshot or short recording showing the behavior.
  • Add expected vs actual behavior.

Next step A focused repair PR is plausible because the likely files, source path, and regression boundary are narrow, but the worker should preserve failed tool context and avoid broad chat redesign.

Review details

Best possible solution:

Keep the failed tool event as context, but make the native chat's final visible state and scroll target prioritize the completed assistant response, with regression coverage for failed-tool-plus-final-assistant live ordering and restart/history parity.

Do we have a high-confidence way to reproduce the issue?

No high-confidence live reproduction was run in this read-only review. Source inspection gives a plausible current-main path: failed ToolCall rows render after assistant rows within a turn, so the bottom visible row can remain the failed tool event even after the assistant response exists.

Is this the best way to solve the issue?

Yes, a narrow native chat rendering/reconciliation fix is the right direction. The transcript appears to exist in backend/history, so this should not require a backend migration or new configuration option.

AGENTS.md: found, but no applicable review policy affected this item.

Remaining risk / open question:

  • The exact gateway event sequence from the reporter's run is not available, so the current-main reproduction is source-based rather than a live Windows Companion/Web UI run.

Codex review notes: model gpt-5.5, reasoning high; reviewed against f839cf53aa0c.

Label changes

Label changes:

  • add P2: This is a normal-priority native chat UI bug with clear user-visible confusion but no evidence of backend transcript loss or crash-level impact.
  • add impact:message-loss: The latest assistant response is effectively suppressed from the Companion's visible output until restart.
  • add impact:session-state: The live Companion timeline can diverge from the web UI/history state for the same conversation until the app reloads history.
  • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
  • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.

Label justifications:

  • P2: This is a normal-priority native chat UI bug with clear user-visible confusion but no evidence of backend transcript loss or crash-level impact.
  • impact:message-loss: The latest assistant response is effectively suppressed from the Companion's visible output until restart.
  • impact:session-state: The live Companion timeline can diverge from the web UI/history state for the same conversation until the app reloads history.
Evidence reviewed

Acceptance criteria:

  • ./build.ps1
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore

What I checked:

  • Reporter evidence: The issue body includes before/web/after screenshots and states that the web UI shows the final assistant response while the Companion shows a failed tool event until restart; there are no comments, timeline events, linked PRs, or protected labels in the provided GitHub context.
  • Current renderer orders tools after assistant text: OpenClawChatTimeline reorders entries within each user turn so non-tool entries render first and ToolCall entries render afterward; error tool bursts are kept external rather than nested in the assistant bubble, which can leave the failed tool row as the bottom visible row. (src/OpenClaw.Tray.WinUI/Chat/OpenClawChatTimeline.cs:2398, f839cf53aa0c)
  • Assistant finals are applied to the live timeline when received: OnChatMessageReceived maps assistant chat.message frames to ChatMessageEvent with ReconcilePrevious=true and ends the turn on final frames, so the likely gap is presentation or missed reconciliation rather than backend transcript loss. (src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs:1309, f839cf53aa0c)
  • History reload is idempotent unless forced: LoadHistoryAsync returns when a thread is already marked loaded, while automatic forced reloads are tied to reconnect; this matches the report that a restart reloads the correct history but does not prove live reconciliation after the current turn completes. (src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs:386, 7d9152f427a3)
  • Existing tests cover adjacent cases but not this combined ordering: Tests cover final assistant frames after lifecycle end and tool error extraction separately, but I did not find a regression test for failed tool event plus later final assistant response staying visible as the latest output. (tests/OpenClaw.Tray.Tests/OpenClawChatDataProviderTests.cs:211, f839cf53aa0c)
  • Feature history: Blame and path history show the current native chat provider, reducer, renderer, and tests were introduced together in commit 7d9152f, which is tagged v0.6.0 and contained on current master. (src/OpenClaw.Tray.WinUI/Chat/OpenClawChatTimeline.cs:2398, 7d9152f427a3)

Likely related people:

  • RΓ©gis Brid: Blame and path history attribute the current native chat renderer, provider, reducer, and related tests to commit 7d9152f, which introduced the relevant behavior and tests. (role: recent area contributor; confidence: high; commits: 7d9152f427a3, 08cab69a038c; files: src/OpenClaw.Tray.WinUI/Chat/OpenClawChatTimeline.cs, src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs, src/OpenClaw.Chat/ChatTimelineReducer.cs)
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[bot] avatar Jun 03 '26 17:06 clawsweeper[bot]

πŸ€– This is an automated response from Repo Assist.

Root cause analysis

I traced this through the rendering layer and found the likely cause.

OpenClawChatTimeline.cs reorders entries for display β€” within each turn, all ToolCall entries are moved to render after all non-ToolCall entries (src/OpenClaw.Tray.WinUI/Chat/OpenClawChatTimeline.cs:2399–2426):

// Non-tools first
for (int j = turnStart; j < endExclusive; j++)
    if (Props.Entries[j].Kind != ChatTimelineItemKind.ToolCall)
        orderedIdx[outPos++] = j;
// Tools last
for (int j = turnStart; j < endExclusive; j++)
    if (Props.Entries[j].Kind == ChatTimelineItemKind.ToolCall)
        orderedIdx[outPos++] = j;

This was intentional β€” the gateway emits tool_start before assistant_delta, but the desired visual flow is [User] β†’ [Assistant reply] β†’ [Tool burst], so the assistant message appears first and tool details hang below.

For the failure case this has the wrong outcome:

  1. Tool starts β†’ tool errors
  2. Assistant sends a final reply explaining the failure
  3. The reordering places the final assistant reply first, then the failed tool event last
  4. Auto-scroll follows to the visual bottom β†’ the user sees the failed tool event, not the assistant reply above it

The underlying reducer state is correct β€” the assistant entry is present and has the right text. Only the rendering order and scroll position are wrong.

Suggested fix direction

The code already treats error bursts differently β€” they're kept external (not nested inside the assistant bubble) because "failures remain visually prominent" (line 2462–2471). The same principle should apply to sort order: error bursts should be kept in their original insertion position (before the final assistant message) rather than sorted to the end.

A minimal fix in the Flush() function: distinguish between success/in-progress tool calls (sort after assistant, current behavior) and error tool calls (keep in insertion order, before the final assistant message). This would make the visual bottom the assistant's reply rather than the raw error.

Related PR

I've opened a draft PR with reducer-level regression tests for this sequence that pin the expected state and serve as a baseline for any rendering fix: [link to be assigned β€” Repo Assist PR for test(chat): add regression coverage for failed-tool + final-assistant sequence]

The tests confirm the state is correct; the fix belongs in OpenClawChatTimeline.Flush() in the WinUI layer.

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

github-actions[bot] avatar Jun 05 '26 01:06 github-actions[bot]