Repository navigation
refactor(schema): move session list cursor into schema - #56205
Conversation
There was a problem hiding this comment.
The move works: pagination behaves the same, and cursors stay compatible both ways. I ran opencode serve from the base and from this branch on the same data. Both return byte-identical previous/next cursors for the same query, and a cursor issued by the base server pages correctly on this branch. Invalid cursors and invalid order values still return the same errors. Tests pass in schema, protocol, httpapi-codegen and the server's fetch test, and typecheck is clean in schema, protocol, server, core, cli and client.
One thing to fix: bun run check:generated in packages/protocol fails on this branch (it passes on the base) because openapi.json wasn't regenerated. Regenerating it loses the descriptions of the order and parentID query parameters (inline comment), and drops | null from the optional session-list query parameters.
Public API:
- Removed:
SessionsCursorfrom@opencode/protocol/groups/session. Code importing it needs to switch toSession.ListCursorfrom@opencode/schema/session. - Added:
Session.ListFilterandSession.ListCursorin@opencode/schema; core'sSessionnow also re-exportsListCursor. - Changed: the Effect client's
SessionListInput.cursorandSessionListOutput.cursornow useSession.ListCursorinstead ofSessionsCursor. It's the same branded string, so this is compatible. - Changed (once regenerated): the HTTP OpenAPI query parameters lose the two descriptions and the
nullvariants. The wire format and Promise client types are unchanged.
|
Fixed in the latest commit. The filter fields use raw |
chore(port): v2.1.0 upstream — 25 из 26 PORT-коммитов перенесены cherry-pick -x Один коммит (anomalyco#56243, постраничный список сессий) не перенесён: конфликт с нашей схемой пагинации (ListCursor/ListFilter из anomalyco#56205 — ASK, ждёт решения). 25 пунктов ASK также не перенесены — без решения человека.
Why
The session list cursor and filters lived in
@opencode/protocol, so only the server could build or read cursors. Core cannot depend on Protocol, so the plugin host had no way to page through sessions. This moves the contract into@opencode/schemaso a follow-up can exposesession.listto plugins on the same cursors. There is no behavior change and no breaking API change:openapi.jsonand the Promise client are unchanged, and existing exports remain.Change
Session.ListFilter(order, search, parentID, directory, project, subpath) andSession.ListCursor(withmake/parse) next toSession.ListAnchor. The cursor keeps itsSessionsCursoridentifier and brand, and its encoded format is unchanged.SessionsQueryin Protocol is nowlimit+Session.ListFilter.fields+cursor. The string-to-numberlimitparsing stays in Protocol because it only applies to URL query parameters.Session.ListCursor. Core'sSessionfacade re-exports it, as it already does forListAnchor.SessionsCursorstays exported from@opencode/protocol/groups/sessionas the same value, so existing imports keep working. A test pins this.Session.ListCursor; the Promise types are unchanged.Validation
bun testinpackages/schema,packages/protocol,packages/server, andpackages/httpapi-codegenbun run generateinpackages/clientbun run checkAdded by the opencode bot (AI-generated).
Public API: moves SessionsCursor from @opencode/protocol to @opencode/schema as Session.ListCursor and adds Session.ListFilter; wire format unchanged, but importers of the protocol export must update