jackwener / jackwener/OpenCLI

[Bug]: chatgpt image --image exits 1 with 'image upload preview did not appear' after a successful backend upload (waitForChatGPTUploadPreview misses aria-label-only preview chip)

Open Beginner friendly
#2,302 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
29.5k
Forks
2.9k
Avg merge
15h 36m
Merged PRs (30d)
70

Description

### Description

`opencli chatgpt image "" --image ` exits 1 with `image upload preview did not appear` **after a fully successful backend upload**. The preview-detection wait never matches the current chatgpt.com DOM, so every `--image` run fails on the input-attach step even though the file is attached and processed.

### Evidence (trace retained)

Command: `opencli chatgpt image "" --image /tmp/blue.png` → exit 1, `image upload preview did not appear`.

Trace `20260819160307-f8c60825` (`--trace on`) shows the upload itself succeeded end to end:

- `POST /backend-api/files` → **200** (file id `file_00000000507082068fe3db1b953ee7c0` created)
- `POST /backend-api/files/process_upload_stream` → **200**
- Final state snapshot contains both:
- `` (file present on the composer input)
- preview chip rendered as `

`

So the file IS uploaded, processed, and previewed in the UI — only the wait condition fails.

### Root cause (from source reading of `clis/chatgpt/utils.js`)

`waitForChatGPTUploadPreview` matches either:
1. the filename appearing in `innerText`, or
2. a visible media element larger than 32px.

On the current composer DOM the preview chip carries the filename **only in `aria-label`** (not in `innerText`), and the chip contains no >32px media element. Both conditions fail while the upload is actually complete.

### Suggested fix

Also match the preview chip by accessible name, e.g. `[role="group"][aria-label*=""]`, or treat `#upload-files` having the expected file count + no uploading/processing indicator as the ready condition.

### Environment

- opencli v1.8.6 (npm `@jackwener/opencli`), Node v26.0.0, macOS (Apple Silicon)
- Chrome 152 + Browser Bridge extension, ChatGPT Pro session (logged in)
- Reproduced on every `--image` attempt, 2026-08-19

### Not a duplicate of

- #2108 (`browser upload` CDP `-32000` rejection — the upload primitive fails there; here the upload succeeds and only preview detection fails)
- #1898 / #1419 / #1206 (generation-side failures — no output image; here image *input* attach is wrongly reported as failed)

### Workaround

Judge success by trace network evidence + state snapshot (`#upload-files` files + `aria-label` chip) instead of the command exit code; never blind re-run since the upload may already have happened.

Contributor guide

Open the contributing guide

Research direction

Start in clis/chatgpt/utils.js at waitForChatGPTUploadPreview and reproduce the --image command with tracing enabled. Compare the wait condition with the snapshot's role=group aria-label preview chip and upload-files input. Done means a successfully processed image preview is recognized and the command no longer exits with the preview-detection error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, playwright
Domain
cli, frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.