Skip to content

transactions rework integration#1092

Merged
N2D4 merged 3 commits intotransactions-reworkfrom
transactions-rework-integration
Jan 13, 2026
Merged

transactions rework integration#1092
N2D4 merged 3 commits intotransactions-reworkfrom
transactions-rework-integration

Conversation

@BilalG1
Copy link
Contributor

@BilalG1 BilalG1 commented Jan 8, 2026

No description provided.

@cmux-agent
Copy link

cmux-agent bot commented Jan 8, 2026

Older cmux preview screenshots (latest comment is below)

Preview Screenshots

Open Diff Heatmap

Preview screenshots are being captured...

Workspace and dev browser links will appear here once the preview environment is ready.


Generated by cmux preview system

@vercel
Copy link

vercel bot commented Jan 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
stack-backend Ready Ready Preview, Comment Jan 12, 2026 6:23pm
stack-dashboard Ready Ready Preview, Comment Jan 12, 2026 6:23pm
stack-demo Ready Ready Preview, Comment Jan 12, 2026 6:23pm
stack-docs Ready Ready Preview, Comment Jan 12, 2026 6:23pm
test-sandbox Error Error Jan 12, 2026 6:23pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

This PR integrates the transactions rework by fixing critical pagination bugs and consolidating transaction handling logic.

Key Changes:

  • Fixed critical infinite loop bug in PaginatedList.nextOrPrev() by changing OR to AND in while condition
  • Fixed off-by-one pagination hack in listTransactions() by using proper isLast flag instead of fetching extra items
  • Improved merge cursor tracking in PaginatedList.merge() for correct pagination state
  • Consolidated transaction builder logic from separate file into new-transactions.ts
  • Simplified API route handler to delegate to listTransactions() helper
  • Added support for new transaction types in frontend (new-stripe-sub, stripe-resub, stripe-one-time, etc.)
  • Added customerId filter parameter to transaction APIs
  • Comprehensive test coverage for all transaction types and pagination scenarios

Impact:
The pagination bug fixes are critical - the original logic would cause infinite loops in certain edge cases. The refactored code is cleaner, more maintainable, and properly tested.

Confidence Score: 4/5

  • This PR is safe to merge with minor risk from pagination logic complexity
  • The changes fix critical bugs (infinite loops, off-by-one errors) and are well-tested with comprehensive E2E tests. However, pagination logic is inherently complex and the merge operation involves intricate cursor tracking. The score reflects confidence in the fixes while acknowledging pagination edge cases require careful monitoring in production.
  • Pay close attention to packages/stack-shared/src/utils/paginated-lists.tsx - the pagination logic is complex and any future changes should be carefully reviewed

Important Files Changed

File Analysis

Filename Score Overview
packages/stack-shared/src/utils/paginated-lists.tsx 4/5 Fixed critical pagination loop bug (OR to AND), added progress check, improved merge cursor tracking
apps/backend/src/app/api/latest/internal/payments/transactions/route.tsx 5/5 Simplified to delegate to listTransactions helper, removed complex cursor logic, cleaner implementation
apps/backend/src/lib/new-transactions.ts 4/5 Fixed off-by-one pagination bug (removed +1 hack), uses proper PaginatedList API with isLast
apps/dashboard/src/components/data-table/transaction-table.tsx 5/5 Added support for new transaction types (new-stripe-sub, stripe-resub, etc.), improved type safety
apps/e2e/tests/backend/endpoints/api/v1/new-transactions.test.ts 5/5 Comprehensive test coverage for all transaction types, pagination, and filters

Sequence Diagram

sequenceDiagram
    participant Client as Dashboard Client
    participant API as Transaction API Route
    participant Helper as listTransactions()
    participant PL as PaginatedList
    participant DB as Database

    Client->>API: GET /internal/payments/transactions?type=new-stripe-sub&limit=50
    API->>Helper: listTransactions(prisma, tenancy, filter, limit)
    
    Helper->>PL: Create individual paginated lists
    Note over PL: NewStripeSubPaginatedList<br/>StripeResubPaginatedList<br/>StripeOneTimePaginatedList<br/>etc.
    
    Helper->>PL: PaginatedList.merge(...lists)
    Note over PL: Merge all transaction sources
    
    Helper->>PL: mergedList.next(cursor, limit, filter)
    
    loop For each list in parallel
        PL->>DB: Fetch subscriptions/invoices/purchases
        DB-->>PL: Return rows
        PL->>PL: Transform to transactions
    end
    
    PL->>PL: Sort and merge results
    PL->>PL: Track composite cursor
    PL-->>Helper: {items, isLast, cursor}
    
    Helper->>Helper: Extract transactions and nextCursor
    Helper-->>API: {transactions, nextCursor, hasMore}
    
    API-->>Client: {transactions, next_cursor, has_more}
Loading

@cmux-agent
Copy link

cmux-agent bot commented Jan 12, 2026

Older cmux preview screenshots (latest comment is below)

Preview Screenshots

Open Diff Heatmap

Preview screenshots are being captured...

Workspace and dev browser links will appear here once the preview environment is ready.


Generated by cmux preview system

@cmux-agent
Copy link

cmux-agent bot commented Jan 12, 2026

Preview Screenshots

Open Diff Heatmap

Preview screenshots are being captured...

Workspace and dev browser links will appear here once the preview environment is ready.


Generated by cmux preview system

@BilalG1 BilalG1 requested a review from N2D4 January 13, 2026 17:18
@BilalG1 BilalG1 assigned N2D4 and unassigned BilalG1 Jan 13, 2026
@N2D4 N2D4 merged commit 977836b into transactions-rework Jan 13, 2026
23 of 25 checks passed
@N2D4 N2D4 deleted the transactions-rework-integration branch January 13, 2026 18:14
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