Skip to content

fix(server): make session list filters exclusive - #56197

Closed
rekram1-node wants to merge 1 commit into
devfrom
session-list-filters
Closed

rekram1-node wants to merge 1 commit into
devfrom
session-list-filters

Conversation

@rekram1-node

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

Copy link
Copy Markdown
Member

Problem

GET /api/session accepts directory, project, and subpath in any combination, but the pagination cursor only carries one location shape: directory, project with an optional subpath, or no location. Encoding the next cursor silently drops whatever does not fit.

  • directory + project: page 1 filters by both; cursor.next keeps only directory, so page 2 returns a different set.
  • subpath without project: accepted, but the store ignores it and the cursor drops it.

Change

  • session.list rejects directory + project and subpath without project with InvalidRequestError (400). No in-repo caller sends either combination.
  • Document the location rules on the query fields, and document that a cursor carries its request's filters, so other filters sent with it are ignored. ACP, the CLI, and the app send the original filters with the cursor, so that behavior is kept.
  • Drop the stale workspace field from the cursor test and cover cursor round trips for each valid location shape.

The check lives in the handler rather than in SessionsQuery: httpapi-codegen requires a flat struct for query schemas and rejects custom checks as unportable. Generated clients are unchanged.

Validation

  • bun test test/session-list.test.ts (server); fails without the handler change
  • bun test in packages/protocol and packages/server
  • bun run generate in packages/client (no diff)
  • bun run check

Added by the opencode bot (AI-generated).

Public API: GET /api/session now rejects directory+project and subpath without project with 400 (breaking only for callers sending those combinations)

@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 fix works. With this change, the new session-list test passes; against the base it fails, because the server returns 200 for directory+project, for subpath on its own and for directory+subpath. Server and protocol tests and type checks pass. I found no in-repo caller of session.list that sends either combination this now rejects.

One thing to fix: the new field descriptions make the committed packages/protocol/openapi.json stale. bun run check:generated in packages/protocol fails with this change and passes on the base. Please run bun run generate there and commit the result.

Public API: GET /api/session now returns 400 (InvalidRequestError) for directory+project and for subpath without project, where it used to accept them (an inconsistent cursor for the first, an ignored subpath for the second). The OpenAPI query parameters gain descriptions. Other request shapes and the generated clients are unchanged. This breaks only callers that send those combinations: they need to send a single location filter.

project: Project.ID.pipe(Schema.optional),
subpath: RelativePath.pipe(Schema.optional),
cursor: SessionsCursor.pipe(Schema.optional),
directory: AbsolutePath.pipe(Schema.optional).annotate({

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.

These descriptions change the generated spec, and the committed packages/protocol/openapi.json doesn't include them yet: bun run check:generated in packages/protocol now fails with "Generated OpenAPI document is stale". Running bun run generate there updates the four query parameters (+8/-4).

@rekram1-node

Copy link
Copy Markdown
Member Author

Closing: this added new filter rules rather than expressing existing ones, and isn't needed to expose session.list to plugins.

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