Skip to content

fix(baoyu-post-to-x): reliable image uploads via DOM.setFileInputFiles#190

Closed
LiamVisionary wants to merge 1 commit intoopenclaw:mainfrom
LiamVisionary:fix/x-browser-image-upload
Closed

fix(baoyu-post-to-x): reliable image uploads via DOM.setFileInputFiles#190
LiamVisionary wants to merge 1 commit intoopenclaw:mainfrom
LiamVisionary:fix/x-browser-image-upload

Conversation

@LiamVisionary
Copy link

Summary

  • Image upload: Uses DOM.setFileInputFiles as the primary method for attaching images to posts (same approach already used by x-video.ts and x-article.ts). Clipboard paste is kept as a fallback.
  • Submit reliability: Waits for the post button to be enabled before clicking, uses real CDP mouse events instead of synthetic JS .click(), and verifies the post was submitted by checking the compose dialog closes.

Problem

The clipboard paste approach (Swift copy → osascript Cmd+V) silently fails in many environments:

  • Missing macOS Accessibility permissions
  • Xcode license not accepted (blocks Swift compilation)
  • Background/headless execution contexts
  • Chrome not being the frontmost application

This causes posts to appear as text-only even though image generation succeeded — the agent reports success because the paste command returns exit 0, but the image never actually makes it into the compose box.

Test plan

  • Tested image upload via file input — verified blob: image appears in compose
  • Tested submit with CDP mouse click — post confirmed submitted
  • Verified clipboard paste fallback path still works when file input is unavailable
  • Tested with multiple images

🤖 Generated with Claude Code

…loads

The clipboard paste approach (Swift copy + osascript Cmd+V) silently fails
in many environments: missing Accessibility permissions, Xcode license not
accepted, background/headless contexts, or Chrome not being frontmost.

This changes x-browser.ts to use DOM.setFileInputFiles as the primary image
upload method (same approach already used by x-video.ts and x-article.ts),
with clipboard paste kept as a fallback.

Also improves submit reliability:
- Wait for post button to be enabled (image may still be processing)
- Use real CDP mouse click instead of synthetic JS .click()
- Verify post submission by waiting for compose dialog to close

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openclaw-barnacle
Copy link

Thanks for the pull request! This repository is read-only and is automatically synced from https://clawhub.ai, so we can’t accept changes here. Please make updates on the website instead.

@LiamVisionary
Copy link
Author

Hey @liuhedev — this fixes a reliability issue with image uploads in x-browser.ts.

The problem: The clipboard paste approach (Swift copy → osascript Cmd+V) silently fails in many environments (missing Accessibility permissions, Xcode license issues, background contexts). Posts go through as text-only even though images were generated.

The fix: Uses DOM.setFileInputFiles as the primary upload method — same approach already used by x-video.ts and x-article.ts. Clipboard paste kept as fallback. Also improves submit reliability with real CDP mouse clicks and post confirmation.

Tested end-to-end on macOS, working reliably now. Would appreciate a quick review/merge so all users get the fix. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant