Skip to content

fix(sessions): apply the offset query parameter - #1765

Merged
Dumbris merged 1 commit into
smart-mcp-proxy:mainfrom
rudycelekli:fix/sessions-offset-20261023-01
Oct 26, 2026
Merged

Dumbris merged 1 commit into
smart-mcp-proxy:mainfrom
rudycelekli:fix/sessions-offset-20261023-01

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

Bug

GET /api/v1/sessions documents offset ("Number of sessions to skip for pagination"). It parses the value and echoes it back in the response's offset field, but never passes it on: storage.SessionFilter has no offset, and GetRecentSessionsFiltered always returns the first page. A client paging through sessions gets the newest page repeatedly while the response claims offset: N.

Trigger

With three or more stored sessions:

GET /api/v1/sessions?limit=1&offset=1
  • Expected: the second-newest session, with offset: 1.
  • Actual: the newest session, with offset: 1.

Fix

  • Add Offset to storage.SessionFilter.
  • In GetRecentSessionsFiltered, skip that many sessions after the existing sort and filter, so total stays the filtered count.
  • Set Offset from the already-parsed query value in handleGetSessions.
  • An offset beyond the end returns an empty page.
  • Callers that don't set Offset (the clients hub, runtime) behave exactly as before.

Test

  • TestGetRecentSessionsFiltered_Offset (storage): unfiltered limit=2, offset=1 returns [s-zed, s-api], and a filtered client=cursor, offset=1 returns [s-old-cursor] with total 2. An offset past the end returns an empty page with the total intact.
  • TestSessions_OffsetReachesStorage (httpapi): ?limit=1&offset=2 reaches the controller as SessionFilter.Offset == 2.

Commands run

  • CGO_ENABLED=0 go test -count=1 ./internal/storage: ok
  • CGO_ENABLED=0 go test -count=1 ./internal/httpapi: ok
  • CGO_ENABLED=0 go test -count=1 -run Session ./internal/runtime: ok
  • Storage behaviour reverted (the field kept so the test compiles): the storage test fails, returning [s-cursor2 s-zed] instead of [s-zed s-api].
  • Handler line reverted: the httpapi test fails with expected: 2, actual: 0.
  • gofmt -l on the edited files: no output

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Dumbris Dumbris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified: the PR test fails on main for the reason described and passes on this branch merged with main; race tests for the touched packages and CI lint (bare and server tags) are clean. Also built and tested together with the rest of this batch, independently reviewed, and cross-reviewed with a second model.

@Dumbris
Dumbris merged commit 3b86b9d into smart-mcp-proxy:main Oct 26, 2026
48 checks passed
@Dumbris

Dumbris commented Oct 26, 2026

Copy link
Copy Markdown
Member

Merged. Thank you, @rudycelekli! GET /api/v1/sessions honours offset, so paging works.

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.

3 participants