GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): session.messages cursor drops type filter — following a filtered cursor with a different type silently mixes sequences · Issue #2501 · developing-today-forks/opencode

fix(server): session.messages cursor drops type filter — following a filtered cursor with a different type silently mixes sequences #2501

New issue
Copy link
New issue
Copy link
Closed
#2592
Closed
fix(server): session.messages cursor drops type filter — following a filtered cursor with a different type silently mixes sequences#2501
#2592
Copy link
Labels
app/serverPackage: server (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Description

@dezren39
dezren39
opened on Nov 16, 2026
Issue body actions

Finding

GET /api/session/:sessionID/message cursors are not self-contained: they encode only {id, order, direction} while the type filter lives only in the query string. Following a filtered cursor with a different (or omitted) type silently applies an old anchor to a new filtered sequence, causing gaps or duplicates. The OpenAPI text says "passing the same type when following cursors", but the server never enforces it and the cursor carries nothing to enforce it with.

Contrast session.list, whose cursor preserves every filter field except limit (withCursor spreads directory/project/subpath/search/parentID/order plus anchor).

Evidence (origin/main 99d219d283e0)

  • packages/protocol/src/groups/message.ts:8-40 — SessionMessagesQuery has limit (capped 1..200), order, cursor (opaque string), type (10 literals). Cursor documented as "Do not combine with order" only; nothing binds cursor to type.
  • packages/server/src/handlers/message.ts:11-26 — Cursor struct is {id, order, direction}; encode stores only those three; decode restores only those three.
  • packages/server/src/handlers/message.ts:35-49 — handler decodes cursor for order+anchor but takes type: ctx.query.type fresh from the new request. No comparison against the type used to mint the cursor.
  • packages/core/src/session/store.ts:177-209 — messages() looks up the anchor by (session_id, id) only (:182-189, no type check), builds a seq boundary (:192-196), then applies the new type filter (:204). An anchor of type A paging under type B filters "after A's seq, of type B" — neither page's sequence.

Repro sketch (no fix in this task): page 1 ?type=user&limit=2 → next cursor for last user message U; page 2 ?cursor=<that>&type=assistant (or omitted) returns assistants after U's seq, skipping assistants before U and duplicating none deterministically — a mixed sequence the client never asked for.

limit has the same drift (cursor drops it; next page falls back to default 50), but type is the correctness gap; session.list already preserves its filters (packages/protocol/src/groups/session.ts:84-94, packages/server/src/handlers/session.ts:102-139 spread ...query into the cursor).

Suggested fix

Make message cursors self-contained: encode type (and limit/order) into the cursor like session.list does, prefer the cursor's values on follow-up, and reject a request that combines a cursor with a conflicting explicit type/order with InvalidCursorError/InvalidRequestError. Alternatively validate the anchor row's type against the requested filter before paging.

Acceptance

  • Following a type=user cursor with type=assistant (or omitted vs explicit) is either rejected or yields the original filtered sequence, never a mixed one.
  • Cursor stays opaque to clients; existing order-mismatch rejection (message.ts:35-36) still holds.
  • Focused test pins filtered pagination across two pages with unchanged and changed type.

Related

  • fix(server): bound session.list limit — PositiveInt with no ceiling loads entire table on one request #2483 (session.list uncapped limit) and fix(server): bound fs.find limit — PositiveInt with no ceiling materializes the whole file index on one request #2484 (fs.find uncapped limit) — same pagination family, different endpoint/defect; this one is filter-binding, not a ceiling.
  • PR fix(server): bound session.list and fs.find page limits #2488 (bounds session.list/fs.find) does not touch message cursors.

No code, PR, or queue task in this report.

Activity

  1. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    priority/normalOrdinary priority (the default)
    effort/sSmall: expected under 2 hours of work
    app/serverPackage: server (pkgs/ or apps/ in this repo)
    on Nov 16, 2026
  2. dezren39
    added a commit that references this issue on Nov 17, 2026

    Merge pull request #2592 from developing-today-forks/queue/17917-2501…

    5cace7b
  3. dezren39
    closed this as completedin #2592on Nov 17, 2026
  4. dezren39 commented on Nov 17, 2026

    @dezren39
    dezren39
    on Nov 17, 2026
    Author
    More actions

    🤖 Agent note · done

    • Agent: queue worker (repo-worker-code), lane any-h
    • Session / ID: task 17917
    • Found via: queue claim
    • Task: Triage of issue fix(server): session.messages cursor drops type filter — following a filtered cursor with a different type silently mixes sequences #2501 (inline triage: task/small-fix, priority/normal, effort/s, app/server added; kind/bug already present) — and the fix itself in the same session.
    • Outcome: FIXED AND MERGED. PR fix(server): bind the type filter into session.messages cursors (#2501) #2592 merged 2026-11-17 (merge commit 5cace7be7600): the session.messages cursor now binds the type filter it was minted under. Following a cursor with a conflicting explicit type (including retargeting an unfiltered cursor to a filter) is rejected with InvalidCursorError; following with no type continues the original filtered sequence; pre-binding cursors still decode as unfiltered. packages/server/test/message.test.ts gained the regression test pinning the omitted/same/changed-type follow-ups — 3 pass, 0 fail on the PR head; server typecheck clean; oxlint clean on both changed files. This issue auto-closed on the merge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/serverPackage: server (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.