Skip to content

fix(twitter): preserve text when posting images#1180

Open
hanzili wants to merge 1 commit intojackwener:mainfrom
hanzili:fix/twitter-post-images
Open

fix(twitter): preserve text when posting images#1180
hanzili wants to merge 1 commit intojackwener:mainfrom
hanzili:fix/twitter-post-images

Conversation

@hanzili
Copy link
Copy Markdown

@hanzili hanzili commented Apr 25, 2026

Summary

  • upload images before inserting tweet text so X's composer re-render cannot erase Draft.js content
  • use the current /compose/post route and explicit composer/file input readiness checks
  • insert text with native browser input when available, fall back to DOM events, and verify text before clicking Post
  • wait for submission completion instead of reporting success immediately after click
  • add adapter regression coverage for image posting order, upload timeout, fallback text insertion, and validation paths

Test Plan

  • npx vitest run --project adapter clis/twitter/post.test.js clis/twitter/reply.test.js
  • npm run build
  • git diff --check

Background

While using opencli twitter post "text" --images image.jpg, the command could report success while the resulting tweet was missing text/media. X's composer can reset the Draft.js editor while media is attaching, so the command now attaches media first and verifies the final composer state before posting.

@hanzili hanzili force-pushed the fix/twitter-post-images branch from eb90b71 to 3357e57 Compare April 25, 2026 17:45
@hanzili
Copy link
Copy Markdown
Author

hanzili commented Apr 25, 2026

Live-tested the patched local build against X with an actual image upload.

Result verified on the profile:

The live test exposed one extra edge case: X can publish successfully while stale composer/media nodes remain visible long enough for the CLI's submission-complete heuristic to time out. I updated the PR to:

  • prefer the Page nativeType CDP insertion helper before the older bridge insert-text path
  • treat X's success toast as completion even when stale composer nodes remain
  • add regression coverage for both cases

Updated local verification:

  • npm run build
  • npx vitest run --project adapter clis/twitter/post.test.js clis/twitter/reply.test.js → 20/20 passing
  • git diff --check

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