Skip to content

Conversation

@pirhoo
Copy link
Owner

@pirhoo pirhoo commented Nov 28, 2025

Summary

This PR adds support for retrieving the authenticated user's timeline (posts from followed accounts) to Trotsky, implementing the StepTimeline class with full pagination, iteration, and filtering capabilities.

Key Features

  • Timeline Retrieval - Get posts from accounts the authenticated user follows
  • Pagination Support - Full cursor-based pagination with .take() support
  • Iteration Support - .each() for processing individual posts
  • Filtering - .when() for conditional processing
  • Custom Algorithms - Support for algorithm parameter (e.g., "reverse-chronological")
  • Full TypeScript Types - Complete type safety with AppBskyFeedGetTimeline types

API Endpoint Used

  • app.bsky.feed.getTimeline - Get authenticated user's timeline

Implementation

Core Files:

  • lib/core/StepTimeline.ts - Full implementation extending StepPosts
  • lib/core/Trotsky.ts - Added timeline() method
  • lib/trotsky.ts - Exported StepTimeline class

Tests:

  • tests/core/StepTimeline.test.ts - 12 comprehensive tests covering:
    • Cloning
    • Timeline retrieval
    • Post structure validation
    • Filtering by author
    • Pagination
    • Custom query parameters
    • Empty timeline handling
    • Algorithm parameter support

Documentation:

  • docs/guide/features.md - Updated feature matrix

Usage Examples

// Get recent timeline posts
await Trotsky.init(agent)
  .timeline()
  .take(20)
  .each()
  .tap((step) => {
    console.log(`@${step.context.author.handle}: ${step.context.record.text}`)
  })
  .run()

// Like posts with specific criteria
await Trotsky.init(agent)
  .timeline()
  .take(50)
  .each()
  .when((step) => step?.context?.record?.text?.includes("#typescript"))
  .like()
  .wait(1000)
  .run()

// Use custom algorithm
await Trotsky.init(agent)
  .timeline({ algorithm: "reverse-chronological" })
  .take(10)
  .each()
  .run()

Test Results

Test Suites: 1 skipped, 31 passed, 31 of 32 total
Tests:       1 skipped, 116 passed, 117 total
Time:        302.02s

All tests passing with no regressions to existing functionality.

Files Changed

  • lib/core/StepTimeline.ts - New file (116 lines)
  • lib/core/Trotsky.ts - Added timeline() method
  • lib/trotsky.ts - Export StepTimeline
  • tests/core/StepTimeline.test.ts - New file (218 lines)
  • docs/guide/features.md - Updated status

Notes

  • Follows the same patterns as existing step classes (StepActorPosts, StepSearchPosts)
  • Extends StepPosts for consistent post handling
  • Requires authenticated user (timeline is user-specific)
  • Fully compatible with all existing Trotsky features (.when(), .tap(), .take(), etc.)

@pirhoo pirhoo force-pushed the feat/step-timeline branch from e13c090 to 815c6a7 Compare November 28, 2025 23:49
@pirhoo pirhoo merged commit fff8edb into main Nov 28, 2025
2 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