Skip to content

refactor(schema): move session list cursor into schema - #56205

Merged
rekram1-node merged 3 commits into
devfrom
session-list-contract
Oct 16, 2026
Merged

rekram1-node merged 3 commits into
devfrom
session-list-contract

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

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/schema so a follow-up can expose session.list to plugins on the same cursors. There is no behavior change and no breaking API change: openapi.json and the Promise client are unchanged, and existing exports remain.

Change

  • Add Session.ListFilter (order, search, parentID, directory, project, subpath) and Session.ListCursor (with make/parse) next to Session.ListAnchor. The cursor keeps its SessionsCursor identifier and brand, and its encoded format is unchanged.
  • SessionsQuery in Protocol is now limit + Session.ListFilter.fields + cursor. The string-to-number limit parsing stays in Protocol because it only applies to URL query parameters.
  • The server handler and ACP use Session.ListCursor. Core's Session facade re-exports it, as it already does for ListAnchor.
  • SessionsCursor stays exported from @opencode/protocol/groups/session as the same value, so existing imports keep working. A test pins this.
  • Regenerated the client. The Effect API now references Session.ListCursor; the Promise types are unchanged.
  • Moved the cursor round-trip test to the schema package and added the new identifiers to the contract hygiene test.

Validation

  • bun test in packages/schema, packages/protocol, packages/server, and packages/httpapi-codegen
  • bun run generate in packages/client
  • bun run check

Added 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

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: SessionsCursor from @opencode/protocol/groups/session. Code importing it needs to switch to Session.ListCursor from @opencode/schema/session.
  • Added: Session.ListFilter and Session.ListCursor in @opencode/schema; core's Session now also re-exports ListCursor.
  • Changed: the Effect client's SessionListInput.cursor and SessionListOutput.cursor now use Session.ListCursor instead of SessionsCursor. It's the same branded string, so this is compatible.
  • Changed (once regenerated): the HTTP OpenAPI query parameters lose the two descriptions and the null variants. The wire format and Promise client types are unchanged.

Comment thread packages/schema/src/session.ts Resolved
@rekram1-node

Copy link
Copy Markdown
Contributor Author

Fixed in the latest commit. The filter fields use raw Schema.optional again, with the descriptions placed as before, because they double as the session.list query parameters. openapi.json is now byte-identical to the base and check:generated passes. The Promise client is unchanged, and the Effect client changes only the cursor type reference.

@rekram1-node
rekram1-node merged commit c77e748 into dev Oct 16, 2026
21 checks passed
@rekram1-node
rekram1-node deleted the session-list-contract branch October 16, 2026 22:01
kobzevvv added a commit to gpt-mem/opencode-mem that referenced this pull request Oct 20, 2026
chore(port): v2.1.0 upstream — 25 из 26 PORT-коммитов перенесены cherry-pick -x

Один коммит (anomalyco#56243, постраничный список сессий) не перенесён: конфликт с нашей схемой пагинации (ListCursor/ListFilter из anomalyco#56205 — ASK, ждёт решения).
25 пунктов ASK также не перенесены — без решения человека.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant