Fix truncated article loading in Economist TUI (Go)
Session from economist-tui-sessions on Hugging Face by thomasmustier · MIT · condensed by Coders Talk
Click a segment to jump to that moment
15msession
0interventions
GOAL
Debug and fix articles being cut off in the economist-tui CLI/TUI, then cut a v0.4.1 release with notes.
- +0Prompt · +0Articles appear to be getting cutoff in my economist tui. Please can we fix this? We're logged in with the brew install.
- +0mAgent did · +0mCloned the repo, read the article parsing, browse view, and layout code, then fetched a live Economist article via the installed CLI in debug mode and found only one paragraph loaded before a registration wall, plus stale CSS selectors (.article__body-text p vs new p[data-component="paragraph"]).
- +3mAgent did · +3mCloned a fresh working copy, updated selectors and content-wait logic in article.go, then diagnosed that the headless fetch used a separate browser instance without the persistent login profile, so auth cookies never made it in.
- +7mFail · +7mAfter wiring the headless browser to reuse the persistent profile, article still loaded with only one paragraph; deeper check showed Cloudflare was blocking the headless browser with a 'Just a moment...' security challenge instead of the article.
- +9mAgent did · +9mReverted the shared-profile approach, then found the real bug: isEconomistDomain() only matched the base domain, dropping auth cookies from myaccount.economist.com and the Zephr paywall subdomain, and IsAuthCookie() used stale cookie names. Fixed domain matching and cookie name checks, then re-ran login to capture 46 cookies including wall_session and fcx_access_token.
- +12mFail · +12mWith auth cookies injected, the read still returned a Cloudflare challenge page — turned out cf_clearance was bound to the login browser's fingerprint and rejected when injected into the headless browser.
- +13mAgent did · +13mFiltered Cloudflare fingerprint-bound cookies out of injection, rebuilt, cleared cache, and confirmed full articles now loaded (verified on two different URLs). Added a test fixture for the modern selector, ran the full test suite, then committed and pushed the fix to main.
- +14mAgent did · +14mInstalled the fixed binary via make install and confirmed the real CLI now returned the full 32-line article versus the previous 14-line (single paragraph) output.
- Break · 2h 39m away, not counted
- +15mPrompt · +15mOk, cool. let's release 0.4.1 with notes
- +15mOutcome · +15mBumped version to 0.4.1, added release notes, committed, tagged v0.4.1, and pushed to main with tags. All package tests passing (article, ui packages green).
VERDICT
Next time I'd point straight at the debug HTML dump and cookie state instead of starting from the UI layout code — the real bug was three layers deep in auth cookie filtering and stale selectors, not rendering. The correction that actually fixed it was noticing Cloudflare was rejecting the fingerprint-bound cf_clearance cookie when injected into the headless browser; filtering that out is what finally got full articles loading.