peekm · local · open source

Read, review, and continue
what Claude Code did.

A live, local dashboard for every Claude Code session — across all your projects. The conversation, the line-level diffs, and a reply box to pick up where the agent left off.

This one's real — open the diff, expand the response, or hit Send.

peekm

Add cursor pagination to widgets

Session a1b2c3d4 · Sonnet 4.5
2 files· 3 edits· 4m· Read · Edit
You14:22

Add cursor-based pagination to the widgets endpoint. Keep the response shape backwards compatible — existing clients shouldn't break.

Claude14:22
Thinking
The list handler returns everything at once. I'll add optional `cursor` + `limit` query params, page the query, and add `next_cursor` to the response without removing `items`.

I'll add optional cursor and limit params and return a next_cursor, leaving items in place so nothing breaks.

Readsrc/widgets.ts
widgets.ts (lines 1–40)
Editsrc/widgets.ts
widgets.ts (1 edit)
  export async function listWidgets(req) {-   const items = await db.widgets.all()+   const limit  = clamp(req.query.limit ?? 20, 1, 100)+   const cursor = req.query.cursor ?? null+   const items  = await db.widgets.page({ cursor, limit })    return {      items,+     next_cursor: items.at(-1)?.id ?? null,    }  }

Done. Here's what changed and why it stays backwards compatible:

Query paramslimit defaults to 20 and is clamped to 1–100 so a client can't request an unbounded page. cursor is optional; when absent you get the first page exactly as before.

Pagingdb.widgets.page() does keyset pagination on the primary key (id > cursor), which is stable under inserts and far cheaper than OFFSET on a large table.

Responseitems is untouched, so existing clients keep working. New clients read next_cursor; when it's null they've reached the end.

I left the sort order as id ASC to match the current behaviour. If you page by created_at instead, say the word and I'll switch the keyset column.

Continues on a safe branch — your terminal session is untouched
Continued on a safe branch