Skip to content

fix(weread): harden reader fallback and search mapping#562

Open
Astro-Han wants to merge 3 commits intojackwener:mainfrom
Astro-Han:worktree-fix-weread-cookie-domain
Open

fix(weread): harden reader fallback and search mapping#562
Astro-Han wants to merge 3 commits intojackwener:mainfrom
Astro-Han:worktree-fix-weread-cookie-domain

Conversation

@Astro-Han
Copy link
Copy Markdown
Contributor

Description

Harden WeRead reader fallback and search URL mapping to avoid silent mismatches when private API auth expires.

Related issue:

Type of Change

  • 🐛 Bug fix
  • ♻️ Refactor

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

Documentation (if adding/modifying an adapter)

  • Added doc page under docs/adapters/ (if new adapter)
  • Updated docs/adapters/index.md table (if new adapter)
  • Updated sidebar in docs/.vitepress/config.mts (if new adapter)
  • Updated README.md / README.zh-CN.md when command discoverability changed
  • Used positional args for the command's primary subject unless a named flag is clearly better
  • Normalized expected adapter failures to CliError subclasses instead of raw Error

Screenshots / Output

Validated locally with:

  • npx vitest run src/clis/weread/commands.test.ts src/clis/weread/utils.test.ts src/weread-search-regression.test.ts src/weread-private-api-regression.test.ts
  • npx tsc --noEmit
  • npx tsx src/main.ts weread shelf --limit 1 -f json
  • npx tsx src/main.ts weread book 29196155 -f json
  • npx tsx src/main.ts weread search 文明 --limit 2 -f json

…okies

- Parallelize search API + HTML fetch with Promise.all
- Add generic numeric entity decoding (decimal + hex) in decodeHtmlText
- Extract loadWebShelfSnapshotWithVid to pass currentVid downstream,
  avoiding a redundant getCookies call in waitForTrustedWebShelfSnapshot
- Split mixed early-return conditions with individual comments
- Add mirror comments between browser/Node trusted-index logic
@Astro-Han
Copy link
Copy Markdown
Contributor Author

Follow-up simplification commit (0766d1a) based on code review:

  • search.ts: parallelize API JSON + HTML fetch with Promise.all
  • search.ts: generalize decodeHtmlText to handle decimal (&#NNN;) and hex (&#xNNN;) numeric entities
  • utils.ts: extract internal loadWebShelfSnapshotWithVid and pass currentVid into waitForTrustedWebShelfSnapshot, eliminating a redundant getCookies IPC call
  • utils.ts: add mirror comments between browser-side hasTrustedIndexes and Node-side getTrustedIndexedBookIds to prevent single-side edits

Test files relocated under src/clis/weread/; 42 tests passing, typecheck clean.

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