fix(twitter): drop global tweetPhoto from hasMedia in post submit poll#1812
Open
Benjamin-eecs wants to merge 1 commit into
Open
fix(twitter): drop global tweetPhoto from hasMedia in post submit poll#1812Benjamin-eecs wants to merge 1 commit into
Benjamin-eecs wants to merge 1 commit into
Conversation
tweetPhoto exists for every timeline tweet image so the global query pinned hasMedia true past the success path; attachments + blob: URLs are composer-only. Fixes jackwener#1781
342f553 to
71a664e
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adjusts tweet composer media detection to prevent false positives when determining whether a tweet has been successfully posted.
Changes:
- Stops using the global
[data-testid="tweetPhoto"]selector, which can match timeline content and keephasMediatrue after posting. - Adds clarification comments on why media detection should be composer-scoped.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
236
to
242
| const boxes = Array.from(document.querySelectorAll('[data-testid="tweetTextarea_0"]')).filter(visible); | ||
| const composerStillHasText = boxes.some((box) => normalize(box.innerText || box.textContent || '').includes(expectedText)); | ||
| const hasMedia = !!document.querySelector('[data-testid="attachments"], [data-testid="tweetPhoto"]') | ||
| // Drop the global tweetPhoto query: tweetPhoto exists for every | ||
| // timeline tweet's image and would pin hasMedia true past the | ||
| // success path. attachments + blob: URLs are composer-only. | ||
| const hasMedia = !!document.querySelector('[data-testid="attachments"]') | ||
| || document.querySelectorAll('img[src^="blob:"], video[src^="blob:"]').length > 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
submitTweetinclis/twitter/post.jspolls after clicking the tweet button. The success path falls through to!composerStillHasText && !hasMediaonce the composer clears, buthasMediawas queried against the entire document:document.querySelector('[data-testid="attachments"], [data-testid="tweetPhoto"]').tweetPhotois rendered for every tweet's image in the timeline, including the tweet that was just posted, sohasMediapinned true past the success path and the poll ran untilTweet submission did not complete before timeout., even though the tweet is live on the user's timeline.Drop
tweetPhotofrom the query.attachments(the composer's attachment container) andimg[src^="blob:"]/video[src^="blob:"](the local preview URLs created by the composer's image picker) are composer-only signals and clear when the composer dismisses.Related issue: fixes #1781.
Type of Change
Checklist
Screenshots / Output
Live verified on a logged-in twitter session on macOS 26.5 with opencli 1.8.1 + Browser Bridge v1.0.15. To force the buggy code path I temporarily replaced the toast-detection regex with one that never matches (so the success-toast short-circuit was disabled and the poll fell through to the
!composerStillHasText && !hasMediacheck):/__NEVER_MATCH/)status: failed,Tweet submission did not complete before timeout.after 19s, tweet IS live on timeline (reporter's exact symptom)/__NEVER_MATCH/)status: success, returns URL, 5.8sstatus: successvia toast path (no regression on the happy path)All four test tweets were deleted from the account after the run. Full twitter suite continues to pass: 391/391.