openclaw - 💡(How to fix) Fix [control-ui] Image attachments cleared before WebSocket send — images lost on connection failure [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#68633Fetched 2026-04-19 15:09:15
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Root Cause

In the compiled control-ui bundle (dist/control-ui/assets/index-*.js), the _p function (send handler) executes:

// Step 1: Clear attachments FIRST
e.chatAttachments = []
// Step 2: Then send via WebSocket
pp(e, {...})

The chatAttachments state is cleared before pp() is called. No try/catch to restore on failure.

Code Example

// Step 1: Clear attachments FIRST
e.chatAttachments = []
// Step 2: Then send via WebSocket
pp(e, {...})

---

const prev = e.chatAttachments;
e.chatAttachments = []; // Clear UI immediately for responsiveness
try {
  await pp(e, {...});
} catch(err) {
  e.chatAttachments = prev; // Restore on failure
}
RAW_BUFFERClick to expand / collapse

Bug Description

In the control-ui webchat, when a user sends a message with image attachment(s), the attachments are cleared from e.chatAttachments before the WebSocket message is actually sent via pp(). If the WebSocket connection fails or drops between these two operations, the attachments are lost with no recovery mechanism.

Steps to Reproduce

  1. Open OpenClaw control-ui webchat
  2. Attach an image to a message
  3. Before clicking send, disconnect the network (or block the WS connection)
  4. Click send — the image disappears from the UI immediately
  5. Reconnect — the message arrives without the image

Root Cause

In the compiled control-ui bundle (dist/control-ui/assets/index-*.js), the _p function (send handler) executes:

// Step 1: Clear attachments FIRST
e.chatAttachments = []
// Step 2: Then send via WebSocket
pp(e, {...})

The chatAttachments state is cleared before pp() is called. No try/catch to restore on failure.

Expected Behavior

Attachments should only be cleared after pp() successfully returns, or restored if send fails.

Suggested Fix

const prev = e.chatAttachments;
e.chatAttachments = []; // Clear UI immediately for responsiveness
try {
  await pp(e, {...});
} catch(err) {
  e.chatAttachments = prev; // Restore on failure
}

Environment

  • OpenClaw: 2026.4.15 (041266a)
  • Node: v22.22.2
  • OS: Linux (WSL)
  • Channel: webchat / control-ui

extent analysis

TL;DR

Clearing the chatAttachments state should be done after the WebSocket message is successfully sent via pp(), with a try-catch block to restore attachments on send failure.

Guidance

  • The current implementation clears chatAttachments before sending the message, which can lead to data loss if the WebSocket connection fails.
  • To fix this, the chatAttachments state should be cleared only after pp() successfully returns, ensuring that attachments are not lost in case of a send failure.
  • A try-catch block can be used to catch any errors that occur during the send operation and restore the chatAttachments state if an error occurs.
  • The suggested fix provided in the issue description appears to be a viable solution, using try and catch to handle the send operation and restore attachments on failure.

Example

const prev = e.chatAttachments;
e.chatAttachments = []; // Clear UI immediately for responsiveness
try {
  await pp(e, {...});
} catch(err) {
  e.chatAttachments = prev; // Restore on failure
}

Notes

This fix assumes that the pp() function returns a promise that resolves when the send operation is successful, and rejects when an error occurs. If this is not the case, additional modifications may be necessary.

Recommendation

Apply the suggested workaround using a try-catch block to restore attachments on send failure, as it directly addresses the identified issue and prevents data loss.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [control-ui] Image attachments cleared before WebSocket send — images lost on connection failure [1 participants]