Skip to content

fix(fetch): filter SPA internal API from network candidates and add render wait - #107

Merged
lidge-jun merged 3 commits into
devfrom
codex/fix-fetch-spa-content
Aug 14, 2026
Merged

fix(fetch): filter SPA internal API from network candidates and add render wait#107
lidge-jun merged 3 commits into
devfrom
codex/fix-fetch-spa-content

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Summary

Fixes adaptive-fetch returning backend API JSON instead of rendered page content on SPA URLs (e.g. ChatGPT conversation pages).

Problem

When fetching SPA URLs like ChatGPT conversations, agbrowse returned raw /backend-api/settings/user JSON instead of the rendered conversation text. Three root causes:

  1. isAuthEndpoint() missed SPA-internal paths (/backend-api/*, /backend-anon/*)
  2. content-scorer scored large JSON blobs highly due to text length
  3. Browser escalation waited only 300ms — too short for React SPA hydration

Changes

  • browser-escalation.mjs: Added isSpaInternalEndpoint() filter for /backend-api/, /backend-anon/, /_next/data/, /api/auth/, /api/v[0-9]+/. Added waitForSpaContent() that polls up to 3s when visible text is under 200 chars.
  • content-scorer.mjs: Added -30 score penalty for network_api candidates whose text is valid JSON (raw API responses, not user content).
  • test/unit/browser-adaptive-fetch-spa.test.mjs: 8 new tests covering SPA endpoint filtering and JSON blob scoring.

Test Results

82 tests pass across 5 affected test files. gate:typecheck passes.

Closes #97

…ender wait

Three fixes for adaptive-fetch returning backend API JSON instead of
rendered SPA content (e.g. ChatGPT conversation pages):

1. Add isSpaInternalEndpoint() filter for /backend-api/*, /backend-anon/*,
   /_next/data/*, /api/auth/*, /api/v[0-9]+/* URL patterns
2. Penalise network_api candidates whose text is raw JSON (-30 score)
3. Replace fixed 300ms post-navigation wait with waitForSpaContent()
   that polls up to 3s when visible text is under 200 chars
@lidge-jun
lidge-jun marked this pull request as ready for review August 14, 2026 16:56
@lidge-jun
lidge-jun merged commit c2c0bee into dev Aug 14, 2026
2 checks passed
@lidge-jun
lidge-jun deleted the codex/fix-fetch-spa-content branch August 14, 2026 16:56
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