PR: #337: [Story-1272] Re-enable Matters search with server q by @ayush-pramaan
View PR →
Story-1272 · pramaan-app · 🌐 app

Matters search now uses the backend result set

This story restores the live Matters search box by connecting ?q= to the new GET /app/matters server-side search contract from pramaan-spec#1271. The app no longer filters only the rows already visible on the current page.

1. Contract sync

openapi/app-api.json was synced from pramaan-functions/main, then pnpm codegen regenerated src/gen.

Contract point Result
AppListMattersQueryParams Includes optional q.
Deprecated matter-list cursor path cursor and limit are gone from the matter list query contract.
MatterListResponse No longer exposes nextCursor.

2. App wiring

File Change
src/lib/matters/gateway.ts Trims and forwards q as a backend query parameter, keeps numbered page/page_size, and returns the cursor-free response view.
src/app/[locale]/(workspace)/matters/page.tsx Passes parsed ?q= into mattersGateway.list with status, type, page, and page size.
src/components/matters/live-matters-list-page.tsx Keeps the existing debounced SettingsSearch URL update and page reset, then renders backend-returned rows directly.
src/app/api/internal/matters/route.ts Maps generated browser query params to the gateway without limit fallback or nextCursor output.

3. Why this fixes the bug

The old client-side path searched only the rows already returned for the active page. A matter on page 3 could never appear while the browser was holding page 1 rows. Now the search term is part of the server request, so total, page count, and returned rows all describe the searched backend result set.

Scope guard: document lists, audit timelines, members, and other cursor-backed resources keep their cursor/limit contracts. Only the live matter-list endpoint moved to search plus numbered pagination.

Verification targets

pnpm test tests/unit/matters-contract.test.ts tests/unit/matters-internal-route.test.ts
pnpm typecheck
pnpm lint
pnpm test
pnpm build
git diff --check

Files changed

17 file(s), +47 / -124 lines

Path Role + -
openapi/app-api.jsonConfig+23-52
src/app/[locale]/(workspace)/matters/page.tsxApp route+2-1
src/app/api/internal/matters/route.tsApp route+2-2
src/components/matters/live-matters-list-page.tsxComponent+3-8
src/components/matters/matters-live-filters.tsComponent+0-23
src/gen/client/appListMatters.tsGenerated contract+1-1
src/gen/hooks/useAppListMatters.tsGenerated contract+1-1
src/gen/hooks/useAppListMattersSuspense.tsGenerated contract+1-1
src/gen/schemas/matterListResponse.jsonGenerated contract+0-5
src/gen/types/AppListMatters.tsGenerated contract+6-7
src/gen/types/MatterListResponse.tsGenerated contract+0-4
src/gen/zod/appListMattersSchema.tsGenerated contract+2-3
src/gen/zod/matterListResponseSchema.tsGenerated contract+0-7
src/lib/matters/gateway.tsLibrary+1-1
src/lib/matters/types.tsLibrary+1-1
tests/unit/matters-contract.test.tsTest+2-4
tests/unit/matters-internal-route.test.tsTest+2-3