Skip to content

feat: add Reddit connector (saved + upvoted)#81

Merged
graydawnc merged 2 commits intomainfrom
feat/connector-reddit
Apr 15, 2026
Merged

feat: add Reddit connector (saved + upvoted)#81
graydawnc merged 2 commits intomainfrom
feat/connector-reddit

Conversation

@graydawnc
Copy link
Copy Markdown
Collaborator

@graydawnc graydawnc commented Apr 14, 2026

Summary

Adds @spool-lab/connector-reddit as a new plugin exporting two connectors:

  • reddit-saved — posts and comments you saved on Reddit
  • reddit-upvoted — posts you upvoted on Reddit

Both are persistent (ephemeral: false) user-owned lists.

Approach

  • Auth: cookies:chrome — reuses the user's logged-in Reddit session. Same pattern as twitter-bookmarks / xiaohongshu.
  • API: hits old.reddit.com's JSON API. Old Reddit accepts the reddit_session cookie directly — no OAuth bearer token needed.
  • Username: resolved once via /api/me.json and cached per connector instance.
  • Pagination: native Reddit after cursor, 100 items/page.
  • Items: maps both t3 (posts) and t1 (comments) kinds. Filters Reddit's thumbnail sentinel strings (self, default, nsfw, etc.).
  • Errors: 429/5xx with exponential backoff, 401/403 → AUTH_SESSION_EXPIRED (invalidates cached session).
  • Forward-sync: stops at sinceItemId anchor, consistent with github-stars.

Capabilities declared

fetch, cookies:chrome, log — matches twitter-bookmarks.

Distribution

Not bundled — users install via spool://connector/install/@spool-lab/connector-reddit or the connectors directory. Added to packages/landing/public/registry.json.

Known limitations / follow-ups

  • Retry/error-handling block in src/fetch.ts is structurally identical to twitter-bookmarks' graphql-fetch.ts. With two copies now, it's probably time to promote a shared fetchJsonWithRetry helper into @spool/connector-sdk. Deliberately left out of this PR to keep scope tight — will do as a refactor once a third consumer appears or in its own PR.
  • Saved/upvoted is not exhaustive — Reddit also exposes hidden posts, submitted history, and comment karma feeds. Can add later if wanted.
  • No unit tests in the package yet. Local smoke test (fake fetch over fixture listing covering t3/t1/sentinel-thumbnail/unknown-kind) passes — kept it in /tmp rather than adding a test harness to the package since no other connector package has tests either.

Test plan

  • pnpm --filter @spool-lab/connector-reddit build — clean tsc
  • pnpm build — full workspace turbo build passes
  • Local smoke test against fixture listing response
  • Manual: install via dev flow, verify checkAuth returns ok when logged in, sync pulls saved/upvoted pages
  • Manual: log out of reddit.com, verify checkAuth returns AUTH_NOT_LOGGED_IN

🤖 Generated with Claude Code

New @spool-lab/connector-reddit package exporting two connectors:
- reddit-saved — posts and comments you saved
- reddit-upvoted — posts you upvoted

Uses cookies:chrome to reuse the logged-in Reddit session and hits
old.reddit.com's JSON API (session cookie works directly, no bearer
token needed). Handles both t3 (posts) and t1 (comments) kinds, paginates
via the Reddit `after` cursor, respects forward-sync anchors, and maps
429/5xx/401 to the standard SyncErrorCodes with backoff.

Registered in landing registry.json for spool://install/ flow. Not
bundled — users install via the connectors directory or CLI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@graydawnc graydawnc force-pushed the feat/connector-reddit branch from 8c21c80 to e47809d Compare April 15, 2026 03:17
Spool's cookies capability uses a suffix-match (LIKE '%.') against
cookie host_key, so querying 'https://www.reddit.com' builds the pattern
'%.www.reddit.com' and misses the actual cookies which are scoped to
'.reddit.com' (the apex). Query the apex directly to match.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@graydawnc graydawnc marked this pull request as ready for review April 15, 2026 03:28
@graydawnc graydawnc merged commit a62a9ec into main Apr 15, 2026
3 checks passed
@graydawnc graydawnc deleted the feat/connector-reddit branch April 15, 2026 03:31
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