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
Merged 11h 52m ago, live in production
fix/list-cursor-string → main 0 commits
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 | ||
| 73 | 73 | |
| 74 | 74 | ### In the terminal |
| 75 | 75 | |
| 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`. | |
| 77 | 77 | |
| 78 | 78 | ### Limits |
| 79 | 79 |
src/http/respond.ts +4 −3
| @@ -640,18 +640,19 @@ export function publicProfile(user: User) { | ||
| 640 | 640 | |
| 641 | 641 | /** |
| 642 | 642 | * 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. | |
| 644 | 645 | */ |
| 645 | 646 | export function paged<T>( |
| 646 | 647 | items: T[], |
| 647 | 648 | limit: number, |
| 648 | 649 | cursorOf: (item: T) => string | number, |
| 649 | ): { items: T[]; next_cursor: string | number | null } { | |
| 650 | ): { items: T[]; next_cursor: string | null } { | |
| 650 | 651 | const last = items[items.length - 1]; |
| 651 | 652 | return { |
| 652 | 653 | items, |
| 653 | 654 | next_cursor: |
| 654 | items.length >= limit && last !== undefined ? cursorOf(last) : null, | |
| 655 | items.length >= limit && last !== undefined ? String(cursorOf(last)) : null, | |
| 655 | 656 | }; |
| 656 | 657 | } |
| 657 | 658 |
test/list-cursor-state.test.ts +3 −1
| @@ -110,8 +110,10 @@ describe("list cursors and states are validated", () => { | ||
| 110 | 110 | do { |
| 111 | 111 | const res = await get(`${route}?limit=2${cursor === null ? "" : `&cursor=${encodeURIComponent(cursor)}`}`); |
| 112 | 112 | 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 }; | |
| 114 | 114 | 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"); | |
| 115 | 117 | cursor = body.next_cursor === null ? null : String(body.next_cursor); |
| 116 | 118 | pages++; |
| 117 | 119 | } while (cursor !== null && pages < 10); |
new above
offline