Skip to content

feat: add cursor pagination for thread replies#6

Merged
Leechael merged 2 commits into
mainfrom
fix/thread-cursor-pagination
May 27, 2026
Merged

feat: add cursor pagination for thread replies#6
Leechael merged 2 commits into
mainfrom
fix/thread-cursor-pagination

Conversation

@Leechael

@Leechael Leechael commented May 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add cursor-based pagination for /thread/:screen_name/:tweet_id via ?page=true and ?cursor=....
  • Keep legacy ?max= behavior, now using TweetDetail bottom cursors instead of DOM scrolling.
  • Fix CDP port handling and XHR capture for TweetDetail request headers.

Test Results

  • npx tsc --noEmit --target ES2022 --module ESNext --moduleResolution Bundler --esModuleInterop --skipLibCheck src/actions/common/openPage.ts src/actions/twitter/readThread.ts
  • curl /thread/rauchg/2058245330836271263?page=true -> 200, returns replies and nextCursor
  • curl /thread/rauchg/2058245330836271263?cursor=<nextCursor> -> 200, returns next replies and nextCursor
  • curl /thread/rauchg/2058245330836271263?max=120 -> 200, returns 120 replies
  • prek not available: no prek.toml or .pre-commit-config.yaml found

Test Coverage

No automated test framework covers this path. Verified against live local CDP/X session.

Review Findings

No debug logging or secrets added. Pagination token exposes only X cursor returned by upstream.


Summary by cubic

Adds cursor-based pagination to thread replies for incremental loading. Replaces DOM scrolling with TweetDetail cursor fetches using captured headers, and surfaces cursor-fetch errors clearly.

  • New Features

    • GET /thread/:screen_name/:tweet_id supports ?page=true and ?cursor=...; responses include nextCursor and hasMore.
    • ?max= still works; batches via bottom cursors until the limit.
    • Providing ?cursor=... fetches that page directly using the TweetDetail request template.
  • Bug Fixes

    • Fixed CDP port handling by passing { port } to CDP.List and CDP.New.
    • Network monitor now emits XHR responses after load and includes requestHeaders for follow-up fetches.
    • Surfaced thread cursor fetch failures with clear errors when auth/ct0 are missing or upstream returns non-OK/invalid JSON.

Written for commit 1f8db23. Summary will update on new commits. Review in cubic

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 4 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/actions/twitter/readThread.ts Outdated
@Leechael

Copy link
Copy Markdown
Owner Author

Fixed the issue identified by cubic: cursor page fetch failures now throw explicit errors instead of returning an empty successful page, so auth/network failures are no longer hidden as pagination completion. Verified with targeted TypeScript check.

@Leechael Leechael merged commit d33ba61 into main May 27, 2026
1 check passed
@Leechael Leechael deleted the fix/thread-cursor-pagination branch May 27, 2026 05:08
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