Skip to content

files: unified pagination cursor across D1 + R2 session-outputs #54

@hrhrng

Description

@hrhrng

Background

The recent /v1/files synthesis (#PR) folds R2 session-outputs entries into the listing when `scope_id` is set. Pagination is currently best-effort:

  • `before_id` / `after_id` cursors only honor the D1 portion
  • R2 `list({prefix, limit: 1000})` caps at 1000; we set `hasMore = true` on hit
  • Caller paginating past 1000 R2 outputs would get nothing more

Work

  • Design a unified cursor that encodes a position across both sets — e.g. `<d1_id>|<r2_continuation_token>`
  • Honor it on subsequent LIST calls (deserialize, advance D1 + R2 in lockstep)
  • Or: switch to a sort-merge over `(created_at, id)` ordering, materialize R2 entries' created_at into the cursor

Why deferred from #PR

No real-world session today exceeds 1000 output files per scope; classic premature complexity. Open this when the cap actually becomes load-bearing.

References

`apps/main/src/routes/files.ts` — `listSessionOutputAsFiles` + the LIST handler

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions