Repository navigation
feat(browser-extension): fetch chatgpt-dom-v1 attachment bytes via the page bridge - #3075
Conversation
|
Warning Review limit reached
Next review available in: 28 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (26)
📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5d8ea6f31
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed the Codex finding in 669c122:
330 tests pass ( Re: |
…e page bridge Problem: the chatgpt-dom-v1 DOM-scrape fallback (used only when the authenticated backend-api conversation read fails) recorded just the attachment chip's name with byte_count=0 -- there was no acquisition path at all. The normal chatgpt-native-v1 path already fetches sandbox/file-service bytes live through chatgpt_bridge.js (fetchAssetBytes: sandbox/file kinds resolve a signed download URL via a backend-api metadata call, then fetch+hash it). Solution: chatgpt-dom-v1 has no backend-api mapping to resolve a file/sandbox id from -- the DOM chip's own href/src is the only evidence available, and it is sometimes already a concrete https URL the page itself rendered (e.g. an inline <img src>). Added a "url" request kind to fetchAssetBytes that skips the metadata round trip entirely and reuses the exact same fetch+budget+hash tail already proven for sandbox/file (refactored into fetchBytesFromResolvedUrl), including the existing cross-origin credential-drop rule. chatgpt.js's collectTurns now awaits a new acquireDomAttachmentBytes step (bounded by the same per-file/total-byte/time/failure budgets as the native path) that requests those bytes and sets inline_base64 on the DOM attachment -- the exact field browser_capture.py already decodes into ParsedAttachment.inline_bytes for every adapter, so no receiver/parser change was needed. Chips with no resolvable URL stay honestly byte_count=0. Consistent with polylogue-ptx (PR #2928): this only extends the existing content-script/bridge mechanism precisely where it was missing (chatgpt-dom-v1's byte-acquisition gap); it does not touch the provider-neutral BrowserAction conduit or add a second submit/fetch mechanism. Verification: cd browser-extension && npx vitest run -> 329 passed (1 pre-existing unrelated failure in build.test.js's packaged-service-worker backfill fixture, reproduces identically without this change). npx eslint src/ tests/ -> clean. New coverage: 5 focused fetchAssetBytes "url"-kind tests (direct fetch, cross-origin credential drop, same-origin credential keep, non-https rejection, byte-cap enforcement) plus 2 full-capture DOM-fallback smoke tests proving a chatgpt-dom-v1 capture now yields inline_base64 whose SHA-256 matches the delivered bytes exactly (the invariant the archive blob store re-derives as acquisition_status='acquired'), and that a chip with no fetchable URL stays honestly byte_count=0. Ref polylogue-83u.3 Co-Authored-By: Claude <[email protected]>
chatgpt-dom-v1 attachment byte acquisition (this branch, commit above) closes the only remaining gap this bead scoped -- the general chatgpt-native-v1 sandbox/file-service asset acquisition already shipped in earlier PRs (#2669/#2672/#2712/#2926). Hand-merged the one touched record from a fresh `bd export` rather than copying the whole file: bd resolves its export target independent of invocation cwd, so it also carries unrelated concurrent-session bead activity that doesn't belong on this branch. Co-Authored-By: Claude <[email protected]>
Problem: Codex review of the "url" asset kind (previous commit) found that fetchBytesFromResolvedUrl only checked the byte budget against Content-Length when declared, then buffered the WHOLE response body via arrayBuffer() before checking its actual size. Chunked/streamed CDN responses -- common for DOM-rendered attachments, unlike the sandbox/file endpoints ChatGPT itself controls and which reliably declare Content-Length -- could omit the header entirely, letting an oversized body download in full before being rejected. This was pre-existing behavior for the sandbox/file kinds too, but extending the same tail to arbitrary DOM-rendered URLs meaningfully raises the odds of hitting an undeclared-length response. What changed: added readBoundedBody, which reads the response body via its ReadableStream (response.body.getReader()) and cancels the stream the moment accumulated bytes exceed the budget, rather than buffering first and checking after. Falls back to the previous buffer-then-check behavior only if the environment's Response has no streaming body. fetchBytesFromResolvedUrl now uses it in place of a bare arrayBuffer() call; behavior for a within-budget or declared-oversized body is unchanged. Verification: cd browser-extension && npx vitest run -> 330 passed (1 pre-existing unrelated build.test.js failure). npx eslint src/ tests/ -> clean. Two new tests prove the actual mid-stream bound: a body with no declared Content-Length that exceeds the cap is rejected (downloaded_bytes_over_limit) without needing the header, and a body of the same undeclared-length shape under the cap is still acquired with a correct SHA-256/base64. Co-Authored-By: Claude <[email protected]>
669c122 to
a4bd0b9
Compare
…3078) ## Summary Removes 26 accidentally-committed build artifacts from `browser-extension/.cache/` (a packaged-smoke test's zip/xpi output and unpacked source copy) that landed in master via #3075, and adds the missing `.gitignore` entry. ## Problem The root `.gitignore` covers `/.cache/` and `webui/.cache/` but never `browser-extension/.cache/` — a `git add -A` while reconciling #3075's rebase against a fast-moving master swept these up. ## Solution `git rm -r --cached browser-extension/.cache`, add `browser-extension/.cache/` to `.gitignore`. ## Verification `devtools verify --quick` — 16/16 green. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Closes the last remaining gap in
polylogue-83u.3: thechatgpt-dom-v1DOM-scrape capture fallback now fetches attachment bytes through the same authenticated page-bridge mechanism the native adapter already uses, instead of recording only the chip name withbyte_count=0.Problem
General ChatGPT attachment fetching already ships:
chatgpt_bridge.js(fetchAssetBytes) andchatgpt.js(acquireAssets/collectAssetDescriptors) live-fetch sandbox/file-service bytes for the normalchatgpt-native-v1capture path (landed PR #2669, hardened #2672/#2712/#2926). The only remaining gap is the olderchatgpt-dom-v1fallback — used only when the authenticated backend-api conversation read fails — which had no acquisition path at all:collectAttachmentsrecorded just the chip's name.Architecture constraint
chatgpt-dom-v1has no backend-apimappingto resolve a file/sandbox id from (unlikechatgpt-native-v1); the DOM chip's ownhref/srcis the only evidence available, and it is sometimes already a concretehttps://URL the page itself rendered (e.g. an inline<img src>).Solution
Added a
"url"request kind tochatgpt_bridge.js'sfetchAssetBytesthat skips the metadata round trip entirely and reuses the exact same fetch+budget+hash mechanism already proven for thesandbox/filekinds (refactored the shared tail intofetchBytesFromResolvedUrl), including the existing cross-origin credential-drop rule (never forward page cookies/bearer to a provider-issued or DOM-rendered cross-origin URL).chatgpt.js'scollectTurnsnow awaits a newacquireDomAttachmentBytesstep — budget-bounded identically to the native path (same per-file/total-byte/time/consecutive-failure caps) — that requests those bytes and setsinline_base64on the DOM attachment. That is the exact fieldpolylogue/sources/parsers/browser_capture.pyalready decodes intoParsedAttachment.inline_bytesfor every adapter, so no receiver/parser change was needed —inline_base64is not a new payload field, just onechatgpt-dom-v1was never wired to populate.Chips with no resolvable URL stay honestly
byte_count=0.Consistency with polylogue-ptx
polylogue-ptx(PR #2928, merged) replaced the extension's browser-action/campaign machinery with a provider-neutralBrowserActionconduit. This change only extends the existing content-script/bridge byte-fetch mechanism at its one documented gap; it does not touch, duplicate, or compete with theBrowserActionconduit's submit/receipt machinery.Verification
cd browser-extension && npx vitest run→ 329 passed (1 pre-existing unrelated failure inbuild.test.js's packaged-service-worker backfill fixture — reproduces identically without this change)npx eslint src/ tests/→ cleannode scripts/validate-manifest.mjs→ okfetchAssetBytes"url"-kind tests (direct fetch, cross-origin credential drop, same-origin credential keep, non-https rejection, byte-cap enforcement) plus 2 full-capture DOM-fallback smoke tests (chatgpt_bridge.test.js) executing the real production sources through a simulated authenticated page, proving achatgpt-dom-v1capture now yieldsinline_base64whose SHA-256 exactly matches the delivered bytes, and that a chip with no fetchable URL stays honestlybyte_count=0.Ref polylogue-83u.3
Co-Authored-By: Claude [email protected]