Skip to content

feat(zhihu): preserve comment reply threads - #2306

Open
wuyak wants to merge 2 commits into
jackwener:mainfrom
wuyak:codex/zhihu-comment-threads
Open

feat(zhihu): preserve comment reply threads#2306
wuyak wants to merge 2 commits into
jackwener:mainfrom
wuyak:codex/zhihu-comment-threads

Conversation

@wuyak

@wuyak wuyak commented Aug 20, 2026

Copy link
Copy Markdown

Summary

  • move zhihu answer-comments from the legacy flat endpoint to the comment_v5 root/child endpoints;
  • add --order score|latest while keeping the existing top-level and per-thread limits;
  • keep CLI rows flat, but populate parent_id from reply_comment_id and derive exact, uncapped depth, so JSON callers can reconstruct real reply threads;
  • reject cyclic, orphaned, duplicate, or unstable comment relationships instead of emitting a silently invalid tree;
  • preserve root order, validate every pagination URL against the exact Zhihu resource, and distinguish risk control code 40362 from authentication failures.

The command surface stays the same apart from the optional --order argument.

Retrieval strategy

  • Strategy: PAGE_FETCH.
  • Contract: internal-unstable.
  • Evidence: direct non-browser retrieval was blocked as abnormal, while logged-in same-origin Browser Bridge requests returned comment_v5 root/child pagination and stable reply_comment_id relationships.
  • Why this cost is accepted: the visible UI is lazy and partial, and does not expose a stable complete parent graph or score/latest pagination. Endpoint handling is isolated, every next URL is resource-scoped, and malformed graph data fails explicitly.

Validation

  • npx vitest run --project adapter clis/zhihu/answer-comments.test.js — 14 tests passed
  • synthetic 12-level reply chain reports depths 1 through 12; cyclic and orphaned relationships are rejected
  • npm test — 590 files passed; 6737 tests passed, 1 existing skip
  • npm run typecheck
  • npm run build
  • npm run check:typed-error-lint
  • npm run check:silent-column-drop
  • opencli validate zhihu/answer-comments — 0 errors, 0 warnings
  • post-fix live score-order run against the issue answer: 2 roots + 5 replies, 7 unique IDs, 0 orphan parents, 0 depth mismatches
  • live latest-order run with --replies-limit 0: 2 roots, 0 replies

Refs #2303. Answer Markdown/image export is handled independently in #2304.

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