Skip to content

fix(twitter): fail typed when a write command does not go through - #2256

Open
Benjamin-eecs wants to merge 1 commit into
jackwener:mainfrom
Benjamin-eecs:fix/twitter-write-exit-codes
Open

fix(twitter): fail typed when a write command does not go through#2256
Benjamin-eecs wants to merge 1 commit into
jackwener:mainfrom
Benjamin-eecs:fix/twitter-write-exit-codes

Conversation

@Benjamin-eecs

@Benjamin-eecs Benjamin-eecs commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

The twitter write commands returned a status: failed row when the write did not happen, so the process still exited 0 and a caller reading the exit code could not tell a posted tweet from one that never left the composer (#2255).

A write the page reports as not having happened now raises CommandExecutionError carrying the message the adapter already produced: disabled or missing controls, an unusable composer, X's own failure toast, a menu without the action, and the UI-did-not-update branches across the fifteen single-target write commands. Already-correct states, like an already-liked tweet, keep returning success. A submit whose confirmation poll expires raises TimeoutError instead, exit 75, with a hint to check before retrying, since the tweet may already be live and the agent workflow re-posts on CommandExecutionError. The image-upload timeout moves there too. The per-item rows in list-batch-utils.js stay, since a batch reports partial success.

Rebased onto main after #2251 merged; its fresh-evidence tests for the expired confirmation poll are updated here to the TimeoutError contract this PR introduces.

Related issue: Closes #2255

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🌐 New site adapter
  • 📝 Documentation
  • ♻️ Refactor
  • 🔧 CI / build / tooling

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

Documentation (if adding/modifying an adapter)

  • Added doc page under docs/adapters/ (if new adapter)
  • Updated docs/adapters/index.md table (if new adapter)
  • Updated sidebar in docs/.vitepress/config.mts (if new adapter)
  • Updated README.md / README.zh-CN.md when command discoverability changed
  • Used positional args for the command's primary subject unless a named flag is clearly better
  • Normalized expected adapter failures to CliError subclasses instead of raw Error

Screenshots / Output

A post over the character limit, before and after, on the same session:

$ opencli twitter post "opencli overlong post check ..." --format json
[
  {
    "status": "failed",
    "message": "Tweet button is disabled or not found.",
    "text": "opencli overlong post check ..."
  }
]
$ echo $?
0
$ opencli twitter post "opencli overlong post check ..."
ok: false
error:
  code: COMMAND_EXEC
  message: Tweet button is disabled or not found.
  help: Nothing was posted. Open the composer in the browser and retry.
  exitCode: 1
$ echo $?
1

Deleting a tweet that is not yours, the same shape in one of the other commands:

$ opencli twitter delete "https://x.com/IGN/status/2084874815865811245"
ok: false
error:
  code: COMMAND_EXEC
  message: The matched tweet menu did not contain Delete. This tweet may not belong to you.
  help: Nothing changed. Open the tweet in the browser and retry.
  exitCode: 1
$ echo $?
1

A normal post on a test account still succeeds and exits 0. clis/twitter suite 505 / 505, with every converted command's throw pinned by a test; reverting reply.js, throwing a plain Error, discarding X's failure text, or treating an unconfirmed submit as a definite failure in post, reply, or quote each fails a test. Typecheck, both lint gates and doc coverage pass; cli-manifest.json unchanged.

@Benjamin-eecs
Benjamin-eecs force-pushed the fix/twitter-write-exit-codes branch from 7fc4826 to bd21761 Compare August 5, 2026 09:18
@Benjamin-eecs
Benjamin-eecs marked this pull request as ready for review August 5, 2026 09:33
Copilot AI lite review requested due to automatic review settings August 5, 2026 09:33

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Benjamin-eecs
Benjamin-eecs force-pushed the fix/twitter-write-exit-codes branch from bd21761 to 8bd80f3 Compare August 5, 2026 09:45
@Benjamin-eecs Benjamin-eecs changed the title fix(twitter): fail typed when a post, reply or quote does not go out fix(twitter): fail typed when a write command does not go through Aug 5, 2026
@Benjamin-eecs
Benjamin-eecs force-pushed the fix/twitter-write-exit-codes branch 4 times, most recently from be33b9f to a3f474d Compare August 8, 2026 12:49
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.

[Bug]: twitter write commands exit 0 when the write did not happen

2 participants