feat(search): add offset pagination to GLOBAL_SEARCH - #5387
Open
pedrofrxncx wants to merge 1 commit into
Open
Conversation
pedrofrxncx
enabled auto-merge (squash)
July 29, 2026 17:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Source: hardening gap in the GLOBAL_SEARCH tool (
apps/api/src/tools/search/global-search.ts) — the tool hardcodedoffset: 0on every call, so a caller with more thanlimit(max 50) matching threads in an org could never reach results past the first page.Why:
COLLECTION_THREADS_LISTalready exposesoffset/hasMorefor the exact same underlyingthreads.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
offsetfield to the input schema (int, min 0, default 0) that's threaded through toctx.storage.threads.list(), and anhasMoreboolean to the output schema (offset + limit < total), mirroringCOLLECTION_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 fmtcd apps/api && bunx tsc --noEmit— cleanbun 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_SEARCHso callers can page through results and see if more pages exist. Removes the hardcodedoffset: 0that hid results beyond the first page.offset(int ≥ 0, default 0) passed toctx.storage.threads.list().hasMoreboolean computed asoffset + limit < total.COLLECTION_THREADS_LIST; existing callers continue working with defaults.Written for commit 15a6aca. Summary will update on new commits.