[Bug]: twitter bookmark can time out after 1s even when the bookmark succeeds
Description
opencli twitter bookmark can report TIMEOUT even though the bookmark was successfully created on X.
The command clicks the bookmark button, waits a fixed 1 second, and checks once for [data-testid="removeBookmark"]. On a slower UI update, the write succeeds but the state change is not visible within that 1-second window, so OpenCLI exits with code 75 and an unconfirmed result.
Running the same idempotent command again immediately reports Tweet is already bookmarked., confirming that the first write succeeded.
This appears to be the same timing pattern addressed for twitter whoami in #2252/#2253, where a fixed 1-second read could observe stale UI state. The uncertain-write behavior introduced in #2256 should remain; the issue is that bookmark confirmation uses a single fixed-delay check instead of bounded polling.
Steps to Reproduce
- Confirm Browser Bridge and the X session are healthy with
opencli doctorandopencli twitter whoami -f json. - Choose a tweet that is not currently bookmarked.
- Run:
opencli twitter bookmark 'https://x.com/i/status/<tweet-id>' -f json - Observe a timeout after the bookmark click.
- Check the tweet on X, or run the same command again.
- Observe that the tweet is already bookmarked.
This is timing-dependent, so it may reproduce more often when X takes longer than 1 second to update the target article DOM.
Expected Behavior
After clicking Bookmark, poll the target tweet article for [data-testid="removeBookmark"] for a bounded period (for example, several seconds), instead of sleeping for exactly 1 second and checking once.
If the state still cannot be confirmed before the bound expires, preserve the existing TimeoutError / exit 75 behavior and the instruction to check before retrying.
OpenCLI Version
1.8.7
Node.js Version
Other (v24.15.0)
Operating System
Linux
Logs / Screenshots
$ opencli doctor
[OK] Daemon: running (v1.8.7)
[OK] Extension: connected (v1.0.22)
[OK] Connectivity: connected
$ opencli twitter bookmark 'https://x.com/i/status/<tweet-id>' -f json
ok: false
error:
code: TIMEOUT
message: twitter bookmark confirmation timed out after 1s
help: >-
Bookmark action initiated but UI did not update. Check the tweet before retrying; the bookmark may already have succeeded.
exitCode: 75
$ opencli twitter bookmark 'https://x.com/i/status/<tweet-id>' -f json
[
{
"status": "success",
"message": "Tweet is already bookmarked."
}
]The current confirmation path in clis/twitter/bookmark.js contains a fixed wait and a single check:
bookmarkBtn.click();
await new Promise(r => setTimeout(r, 1000));
const verifyArticle = findTargetArticle() || targetArticle;
const verify = verifyArticle?.querySelector('[data-testid="removeBookmark"]');Source: jackwener/OpenCLI