Repository navigation
fix(types): derive every PageType list from the canonical enum - #2215
Conversation
PageType (packages/lib/src/utils/enums.ts) has 10 members. Several consumers re-declared that list by hand and had drifted, silently dropping FILE and MACHINE: - apps/web glob search route's VALID_PAGE_TYPES (8/10) — an includeTypes=FILE request degraded to an empty filter, which globSearchPages treats as "no filter", silently returning every page. - The AI glob_search tool's z.enum([...]) (8/10) — agents requesting FILE/MACHINE were rejected by zod before execute() ran. - page-service.ts's PageType union (9/10, missing FILE). - packages/sdk's GLOB_SEARCH_PAGE_TYPES (8/10). - useBreadcrumbs/get-page-breadcrumb-trail unions (9/10, missing MACHINE). - The create_page tool's prose description and the marketing CLI docs page also listed stale/incomplete type lists. Adds packages/lib/src/utils/enums.ts: PageTypeValue, PAGE_TYPE_VALUES, isPageTypeValue, and parsePageTypesParam (the includeTypes query-param parser, now with trimming/dedupe/empty-segment-dropping). Every site above now derives from this, and compile-time AssertExact drift-guard tests pin lib against the DB pgEnum, page-service's local alias, and the SDK's necessarily-inlined list (the SDK can't import @pagespace/lib at runtime). Closes #2150
|
Warning Review limit reached
Next review available in: 34 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe pull request centralizes page-type values and parsing, adds ChangesPage-type contract and parsing
Search filter propagation
Type and description alignment
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…s gloss The prior test only checked the description contains "Create", which would pass even if the getCreatablePageTypes()/getPageTypeConfig() interpolation introduced in the #2150 fix silently produced empty or malformed prose. Assert each creatable type's name-plus-gloss actually appears.
Summary
PageType(packages/lib/src/utils/enums.ts) has 10 members. Five separate hand-written re-declarations of that list had drifted, silently droppingFILEand/orMACHINE:apps/web/.../search/glob/route.tsVALID_PAGE_TYPES(8/10) — anincludeTypes=FILErequest degraded to an empty filter, andglobSearchPagestreats an empty filter as "no filter", so the caller silently got every page instead of just files.glob_searchtool'sz.enum([...])(8/10) — agents requesting FILE/MACHINE were rejected by zod beforeexecute()ever ran.page-service.ts'sPageTypeunion (9/10, missing FILE).packages/sdk'sGLOB_SEARCH_PAGE_TYPES(8/10) — same bug for SDK/CLI callers.useBreadcrumbs.ts/get-page-breadcrumb-trail.tsunions (9/10, missing MACHINE — type-only drift, no runtime symptom).Also fixed two stale prose lists: the
create_pagetool description (now interpolates fromgetCreatablePageTypes()/getPageTypeConfig()so it can't drift from its own schema again) and the marketing CLI docs page (was missing MACHINE).Changes
packages/lib/src/utils/enums.ts:PageTypeValue,PAGE_TYPE_VALUES,isPageTypeValue, andparsePageTypesParam(theincludeTypesquery-param parser — now trims, drops empty segments, and dedupes; unknown values are still silently dropped, preserving prior behavior)..d.tscan't reference the unpublished@pagespace/libpackage), but is pinned to the canonical list by a compile-timeAssertExactdrift-guard test, same pattern as the existingroles-pageperm-drift-guard.test.ts.packages/lib/src/utils/__tests__/enums.test.ts(also pins lib against the DBpgEnum),apps/web/src/services/api/__tests__/page-type-drift-guard.test.ts,packages/sdk/src/operations/__tests__/glob-page-types-drift-guard.test.ts.Test plan
bun --cwd packages/lib test src/utils/__tests__/enums.test.ts— 20 tests pass, including 100%-branch coverage of the parser and the DB-pgEnum drift guard.bun --cwd packages/sdk test src/operations/__tests__— 522 tests pass, including the new SDK drift guard.bun --cwd apps/web test src/app/api/drives src/lib/ai/tools src/services/api— 2725 tests pass (1 unrelated pre-existing failure inactivity-tools.test.tsfrom a local DB-role env issue, untouched by this change).bun run typecheck— clean (drift guards would failtschere if lib/db/sdk/page-service lists ever diverge again).bun run lint— clean (14/14 tasks, includingnext build).bun run changelog:generate— fails in this worktree withERR_MODULE_NOT_FOUNDonscripts/changelog/index.ts; this is the known pre-existing staleness tracked in chore: remove stale docs/ and prune cross-references #1044, not something this PR introduces.Closes #2150
https://claude.ai/code/session_01GC414LHWsWNYAh4qHsNVhF
Summary by CodeRabbit
New Features
FILEandMACHINE, in glob search filters.Documentation
MACHINEas a supported page type.Bug Fixes