Skip to content

feat(search): add offset pagination to GLOBAL_SEARCH - #5387

Open
pedrofrxncx wants to merge 1 commit into
mainfrom
feat/global-search-pagination-w1
Open

feat(search): add offset pagination to GLOBAL_SEARCH#5387
pedrofrxncx wants to merge 1 commit into
mainfrom
feat/global-search-pagination-w1

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Source: hardening gap in the GLOBAL_SEARCH tool (apps/api/src/tools/search/global-search.ts) — the tool hardcoded offset: 0 on every call, so a caller with more than limit (max 50) matching threads in an org could never reach results past the first page.

Why: COLLECTION_THREADS_LIST already exposes offset/hasMore for the exact same underlying threads.list() storage call — GLOBAL_SEARCH was missing the same pagination contract other list-style tools already follow, so a caller has no way to page through search results for orgs with lots of matching threads.

What changed: added an optional offset field to the input schema (int, min 0, default 0) that's threaded through to ctx.storage.threads.list(), and an hasMore boolean to the output schema (offset + limit < total), mirroring COLLECTION_THREADS_LIST's existing pagination shape. Both fields are additive/optional, so existing callers (the global-search dialog in the web UI) are unaffected.

Verification:

  • bun run fmt
  • cd apps/api && bunx tsc --noEmit — clean
  • bun test apps/api/src/tools/search/global-search.test.ts — 4/4 pass (added two cases: negative offset rejected, offset omitted defaults to undefined)

A reviewer can confirm with the same targeted test command above. Full CI validates the DB-backed integration test (global-search.integration.test.ts), which needs Postgres and wasn't runnable locally in this environment.


Summary by cubic

Add offset-based pagination to GLOBAL_SEARCH so callers can page through results and see if more pages exist. Removes the hardcoded offset: 0 that hid results beyond the first page.

  • New Features
    • Input: optional offset (int ≥ 0, default 0) passed to ctx.storage.threads.list().
    • Output: hasMore boolean computed as offset + limit < total.
    • Pagination shape matches COLLECTION_THREADS_LIST; existing callers continue working with defaults.

Written for commit 15a6aca. Summary will update on new commits.

Review in cubic

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