Skip to content

fix(chatgpt): filter user-uploaded images in Chinese UI; allow large image uploads - #2261

Open
HARRY-BEAR wants to merge 1 commit into
jackwener:mainfrom
HARRY-BEAR:main
Open

fix(chatgpt): filter user-uploaded images in Chinese UI; allow large image uploads#2261
HARRY-BEAR wants to merge 1 commit into
jackwener:mainfrom
HARRY-BEAR:main

Conversation

@HARRY-BEAR

Copy link
Copy Markdown

Problem

Two bugs break opencli chatgpt image --image <photo> for non-trivial use cases:

1. Chinese UI: user-uploaded reference image is reported as the generated result

getChatGPTVisibleImageUrls filters user-uploaded images via isUserUploadPreview, which only matches:

  • the English button label prefix Open image: (the Chinese UI uses 打开图片:用户上传的图片)
  • English keywords upload|uploaded|attachment (Chinese UI says 上传)

In the Chinese ChatGPT UI, the re-rendered upload has an empty alt, so it escapes the filter. The adapter then detects the re-rendered attachment as a "newly generated image", downloads it, and reports success — the user receives the original photo instead of the generated image.

2. Uploads > ~750 KB fail with fetch failed

When CDP file input injection is unavailable, uploadChatGPTImages falls back to base64-in-page.evaluate. The daemon caps request bodies at MAX_BODY = 1 MB; a typical 2 MB photo becomes a >1 MB base64 payload, the daemon destroys the connection (Body too large), and the CLI surfaces a bare fetch failed.

Fix

  • Match the Chinese button label prefix 打开图片: and the keyword 上传 in the upload filter.
  • Raise MAX_BODY to 32 MB (still bounded, but fits base64 image payloads).

Verification

  • Reproduced both bugs, then verified the fix end-to-end on a Chinese-UI ChatGPT session:
    • 1.3 MB original PNG passed directly (no compression) and a correct badge-concept sheet (1086×1448) was generated and saved.
    • A second run with a different 2.3 MB image also succeeded in one shot.
  • npm run typecheck passes; npm run test:adapter passes (499 files / 5200 tests).

…ge image payloads

- chatgpt image adapter: the attachment filter in getChatGPTVisibleImageUrls
  only matched the English 'Open image:' button label and English keywords
  (upload/uploaded/attachment). In the Chinese ChatGPT UI the button is
  labeled '打开图片:用户上传的图片' (Open image: user uploaded image) and
  the image alt is empty, so user-uploaded reference images escaped the
  filter and were reported as generated results (the original photo was
  downloaded instead of the generated image). Add the Chinese button label
  prefix and the '上传' keyword to the filter.
- daemon: raise MAX_BODY from 1 MB to 32 MB. The chatgpt image upload
  fallback (base64-in-evaluate) serializes the image into the command body;
  a typical 2 MB photo becomes a >1 MB base64 payload and the daemon
  rejected it with a connection reset ('fetch failed').
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