Skip to content

fix(ui): avoid redundant reload after final chat event#70391

Open
cholaolu-boop wants to merge 2 commits into
openclaw:mainfrom
cholaolu-boop:fix/ui-final-event-history-reload
Open

fix(ui): avoid redundant reload after final chat event#70391
cholaolu-boop wants to merge 2 commits into
openclaw:mainfrom
cholaolu-boop:fix/ui-final-event-history-reload

Conversation

@cholaolu-boop

Copy link
Copy Markdown

Summary

  • keep Filter internal compaction artifacts from chat history #70348 as the separate Gateway sanitizer fix
  • this patch addresses the remaining UI reload/resync amplifier
  • Gateway oversize/placeholder remains separately open as a possible second lever
  • the edge cases from review are follow-up items, but not blockers for this patch

Testing

  • pnpm vitest ui/src/ui/chat-event-reload.test.ts ui/src/ui/app-gateway.node.test.ts

@greptile-apps

greptile-apps Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR avoids a redundant loadChatHistory call when the final chat event already carries the assistant message directly in its payload, allowing the UI to append it locally instead of round-tripping to the server. Both the direct final-event reload path and the deferred session.message replay path now respect this condition.

Confidence Score: 5/5

Safe to merge; the one noted edge case (absent role implicitly treated as assistant) is a pre-existing contract assumption and is acknowledged as a follow-up.

Logic changes are correct for all tested paths; tests cover the key scenarios; the only finding is a P2 edge case around role-absent messages that doesn't affect well-formed payloads from the current server.

ui/src/ui/chat-event-reload.ts — the hasDisplayableAssistantFinalMessage role guard

Prompt To Fix All With AI
This is a comment left during a code review.
Path: ui/src/ui/chat-event-reload.ts
Line: 9-11

Comment:
**Absent `role` is silently treated as "assistant"**

When `message` has no `role` field (or `role` is not a string), the guard on line 9 is skipped and the function falls through to the content check, returning `true` — meaning the reload is suppressed as if the message were a confirmed assistant message. If the server ever emits a final event with a message that has content but no `role`, the deferred session reload will be incorrectly dropped.

Consider returning `false` explicitly when `role` is absent:

```typescript
  const role = entry.role;
  if (typeof role !== "string" || role.toLowerCase() !== "assistant") {
    return false;
  }
```

```suggestion
  if (typeof role !== "string" || role.toLowerCase() !== "assistant") {
    return false;
  }
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(ui): avoid redundant reload after fi..." | Re-trigger Greptile

Comment thread ui/src/ui/chat-event-reload.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a840eb7a48

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ui/src/ui/app-gateway.ts Outdated
@prtags

prtags Bot commented Apr 23, 2026

Copy link
Copy Markdown

Related work from PRtags group liberal-lynx-ebvz

Title: Open PR candidate: Control UI terminal chat history reload races

Number Title
#67699 fix(ui): prevent chat messages from disappearing after send when tools are used
#70391* fix(ui): avoid redundant reload after final chat event

* This PR

@vincentkoc vincentkoc force-pushed the fix/ui-final-event-history-reload branch from a840eb7 to 4bd0589 Compare April 28, 2026 07:48
@vincentkoc

Copy link
Copy Markdown
Member

ProjectClownfish pushed a narrow repair to this branch so the original contributor path can stay canonical.

Source PR: #70391
Validation: pnpm -s vitest run ui/src/ui/chat-event-reload.test.ts ui/src/ui/app-gateway.node.test.ts; pnpm check:changed
Contributor credit is preserved in the branch history and PR context.

@clawsweeper

clawsweeper Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep open: current main still has the deferred reload gap this PR targets, and the branch contains a focused repair. It is not merge-ready because the PR is dirty against current main, has only test/CI proof instead of real Control UI behavior proof, and still edits release-owned changelog content.

Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

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

No live reproduction was run in this read-only review. Source inspection and the PR's targeted tests give a clear unit-level path: a deferred same-session session.message followed by a final assistant payload currently clears without reloading on main.

Is this the best way to solve the issue?

Yes, the runtime change is the narrowest maintainable fix because it preserves direct final-event reload suppression while replaying only an already-deferred same-session reload. The PR still needs branch refresh, real behavior proof, and removal of the release-owned changelog edit.

Security review:

Security review cleared: The diff touches Control UI reload logic, focused tests, and changelog text; I found no concrete security or supply-chain regression.

AGENTS.md: found and applied where relevant.

What I checked:

  • stale F-rated PR: PR was opened 2026-04-22T23:39:32Z, is older than 30 days, and the latest review rated it F.
  • proof blocker: real behavior proof is mock_only and proof tier is F, so this branch is not merge-ready without contributor follow-up.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • vincentkoc: Current shallow blame for the affected Control UI files points to Vincent Koc, he co-authored/reviewed the active-send reload work, and he pushed the narrow repair commit to this PR branch. (role: recent area contributor and branch repair author; confidence: high; commits: 3060ebf0523a, 7734a40a5650, 4bd0589d8233; files: ui/src/ui/app-gateway.ts, ui/src/ui/chat-event-reload.ts, ui/src/ui/app-gateway.node.test.ts)
  • steipete: The final-event reload helper and tests appear to date to dc6afeb4f882d3ff875f6444af07e9227f0a0479, authored by Peter Steinberger. (role: feature introducer; confidence: medium; commits: dc6afeb4f882; files: ui/src/ui/chat-event-reload.ts, ui/src/ui/chat-event-reload.test.ts, ui/src/ui/app-gateway.ts)
  • scotthuang: The active-send/deferred reload path was introduced in 7734a40a5650d0861a86a3860a049ad9c3a8f624, authored by scotthuang and reviewed/co-authored by vincentkoc. (role: adjacent behavior introducer; confidence: medium; commits: 7734a40a5650; files: ui/src/ui/app-gateway.ts, ui/src/ui/app-gateway.node.test.ts)

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

@vincentkoc vincentkoc added clawsweeper Tracked by ClawSweeper automation and removed clownfish:human-review labels Apr 28, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 20, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. label May 22, 2026
@BunsDev BunsDev mentioned this pull request May 28, 2026
25 tasks
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui clawsweeper Tracked by ClawSweeper automation P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants