Skip to content

Fix import-source stripping whole Wikipedia pages (#195 regression) - #197

Merged
Programcode merged 2 commits into
mainfrom
fix/import-source-wikipedia-chrome
Oct 22, 2026
Merged

Programcode merged 2 commits into
mainfrom
fix/import-source-wikipedia-chrome

Conversation

@Programcode

@Programcode Programcode commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Fixes a regression from #195 (C2 / LB-02): every Wikipedia import returned 422 "This page did not contain enough readable text to import." (found by T7 with the lib-import recipe on desktop and mobile).

Cause. The new Wikipedia chrome rules in import-source/html-text.ts matched names like toc and noprint with [\s_-] boundaries, so <html class="... vector-toc-available vector-feature-toc-pinned-clientpref-1 ..."> counted as chrome and the whole document was stripped.

Fix. Match whole whitespace-separated id/class tokens (Set lookups) for both the chrome list and the article roots, and never treat <html>/<body> as chrome.

Tests.

  • New: a real Wikipedia page (en.wikipedia.org/wiki/Free_public_transport, fetched 2026-10-22, gzipped fixture, CC BY-SA) keeps >1,000 words of article text and drops the TOC toggle, [edit] links and the language list; plus a synthetic token test. Both fail on main and pass here.
  • Real-fetch handler run (stubbed Supabase, real network) on the lib-import URL: main → 422, this branch → 200 with clean article text.
  • Full npm run verify on the VPS: pass (unit 65 files/446, collaboration 5/30, edge 408, e2e smoke 43).

Summary by CodeRabbit

  • Bug Fixes
    • Improved Wikipedia article imports so article text is retained while navigation and editing controls are excluded.
    • Corrected handling of page styling classes to prevent article text from being mistakenly removed.
  • Tests
    • Added coverage using a real Wikipedia page to verify imported text and removal of page controls.

…e article

#195 matched chrome names like toc with hyphen boundaries, so the <html> flags vector-toc-available and vector-feature-toc-pinned-* marked the whole page as chrome and every Wikipedia import came back empty. Match exact id/class tokens, never treat <html>/<body> as chrome, and test against a real (gzipped) Wikipedia page.
Copilot AI balanced review requested due to automatic review settings October 22, 2026 21:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between f08ae64 and 0d2b161.

📒 Files selected for processing: 1
  • supabase/functions/import-source/html-text_test.ts
ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between b79f858 and f08ae64.

⛔ Files ignored due to path filters: 1
  • supabase/functions/import-source/testdata/wikipedia-free-public-transport.html.gz is excluded by !**/*.gz
📒 Files selected for processing: 2
  • supabase/functions/import-source/html-text.ts
  • supabase/functions/import-source/html-text_test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

Wikipedia article-root and chrome matching now uses case-insensitive whole-token checks. The extraction logic exempts html and body from chrome stripping. Tests cover a stored Wikipedia page and class names that contain chrome-rule fragments.

Changes: Wikipedia HTML text extraction

Layer / File(s) Summary
Token matching and extraction tests
supabase/functions/import-source/html-text.ts, supabase/functions/import-source/html-text_test.ts
Article-root preference and chrome stripping use case-insensitive whole-token matching. html and body are exempt from chrome stripping after article-root checks. Tests check retained article text and removal of navigation and editing chrome.

Estimated code review effort: 2 (Simple) | ~10 minutes

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Essentials by visiting https://app.coderabbit.ai/settings/billing.

Comment @coderabbitai help to get the list of available commands.

@Programcode
Programcode merged commit 6962616 into main Oct 22, 2026
3 of 12 checks passed
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.

2 participants