Public: anyone can read this; the crew can change it.

Lists answer next_cursor as a string, as openapi.json declares (full suite red, #18027) #18040

opened this in answer to

Merged 11h 52m ago, live in production

fix/list-cursor-string → main 0 commits

  • Merged. fix/list-cursor-string was merged into main as ab67833.

Review

Sign in to review this change.
3 files changed +8 −5
docs/features/talk-voice.md +1 −1
@@ -73,7 +73,7 @@ In Talk a widget is drawn as a shown card is, bare under a hairline on its start
7373
7474 ### In the terminal
7575
76 `forge talk` and the terminal's Talk screen print a placed widget from the same data, through the parser every door uses: a chart as one line of block characters a series (one scale for all, its total after it) over the days it spans. `GET /api/v1/conversation/turns` carries the printed reply as `plain` when it places a card or a widget, and every agent turn carries `cards` (#18005): each result its text places, as data a native client can draw itself (`src/core/talk_cards.ts`). A card is `{ ref, kind, title, source, tool, at }` where `ref` is the `cN` of the `::show cN` line. A chart (`kind` is `line`, `bar` or `area`) adds `series: [{ label, unit?, tone?, points: [{ t?, v }] }]`, the very values the page draws and `widgetLines` prints (copied from the kept data, never read back from a drawing), and `levels: true` when a value is a level to read as the last one, not a sum. Any other kind (a card of rows, a receipt) adds `status` and `rows: [{ label, value, link?, depth? }]`. A bearer token of either scope reads them; each shape is in `/api/v1/openapi.json` as `TurnCard`.
76 `forge talk` and the terminal's Talk screen print a placed widget from the same data, through the parser every door uses: a chart as one line of block characters a series (one scale for all, its total after it) over the days it spans. `GET /api/v1/conversation/turns` carries the printed reply as `plain` when it places a card or a widget, and every agent turn carries `cards` (#18005): each result its text places, as data a native client can draw itself (`src/core/talk_cards.ts`). A card is `{ ref, kind, title, source, tool, at }` where `ref` is the `cN` of the `::show cN` line. A chart (`kind` is `line`, `bar` or `area`) adds `series: [{ label, unit?, tone?, points: [{ t?, v }] }]`, the very values the page draws and `widgetLines` prints (copied from the kept data, never read back from a drawing), and `levels: true` when a value is a level to read as the last one, not a sum. Any other kind (a card of rows, a receipt) adds `status` and `rows: [{ label, value, link?, depth? }]`. A bearer token of either scope reads them; each shape is in `/contract/openapi.json` as `TurnCard`.
7777
7878 ### Limits
7979
src/http/respond.ts +4 −3
@@ -640,18 +640,19 @@ export function publicProfile(user: User) {
640640
641641 /**
642642 * Cursor pagination for newest-first lists: a full page means there may be
643 * more, and the cursor is the last item's sort key.
643 * more, and the cursor is the last item's sort key, always as a string: a
644 * pull's or an issue's number included, as openapi.json declares it.
644645 */
645646 export function paged<T>(
646647 items: T[],
647648 limit: number,
648649 cursorOf: (item: T) => string | number,
649 ): { items: T[]; next_cursor: string | number | null } {
650 ): { items: T[]; next_cursor: string | null } {
650651 const last = items[items.length - 1];
651652 return {
652653 items,
653654 next_cursor:
654 items.length >= limit && last !== undefined ? cursorOf(last) : null,
655 items.length >= limit && last !== undefined ? String(cursorOf(last)) : null,
655656 };
656657 }
657658
test/list-cursor-state.test.ts +3 −1
@@ -110,8 +110,10 @@ describe("list cursors and states are validated", () => {
110110 do {
111111 const res = await get(`${route}?limit=2${cursor === null ? "" : `&cursor=${encodeURIComponent(cursor)}`}`);
112112 expect(res.status).toBe(200);
113 const body = (await res.json()) as { items: { id: string }[]; next_cursor: string | number | null };
113 const body = (await res.json()) as { items: { id: string }[]; next_cursor: unknown };
114114 seen.push(...body.items.map((i) => i.id));
115 // A cursor is a string on every list, a pull's or an issue's number included (#18027).
116 if (body.next_cursor !== null) expect(typeof body.next_cursor).toBe("string");
115117 cursor = body.next_cursor === null ? null : String(body.next_cursor);
116118 pages++;
117119 } while (cursor !== null && pages < 10);

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs