fix(app): address post-merge review comments from #2384#2390
Conversation
- expo CatalogItem.createdAt/updatedAt: string | Date (fixes CI cast error) - replace crypto.randomUUID() with generateId() using crypto.getRandomValues() for older React Native / Hermes compatibility - catalogInfinite queryKey now includes limit + sort params - error.value instead of String(error) for Eden Treaty error messages
WalkthroughThis PR introduces a shared ChangesUUID Utility & Query Infrastructure
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/app/src/shared/api/query-keys.ts`:
- Around line 9-16: The catalogInfinite query-key factory currently types
sort.order as string which permits invalid values; change the opts type in
catalogInfinite so that sort: { field: string; order: 'asc' | 'desc' } (tighten
order to the literal union) so callers and cache keys only accept 'asc' or
'desc'—update the catalogInfinite function signature/type annotation accordingly
(refer to catalogInfinite and its opts.sort.order) to enforce the narrowed type
throughout the codebase.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 87b00f3c-e6a7-4582-8ab2-1716a7aeac12
📒 Files selected for processing (9)
apps/expo/features/catalog/types.tspackages/app/index.tspackages/app/src/entities/catalog/queries.tspackages/app/src/entities/feed/queries.tspackages/app/src/features/pack/add-item/queries.tspackages/app/src/features/pack/create/queries.tspackages/app/src/features/trip/create/queries.tspackages/app/src/shared/api/query-keys.tspackages/app/src/shared/lib/uuid.ts
| catalogInfinite: ( | ||
| opts: { | ||
| search?: string; | ||
| category?: string; | ||
| limit?: number; | ||
| sort?: { field: string; order: string }; | ||
| } = {}, | ||
| ) => ['catalogInfinite', opts] as const, |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial | ⚡ Quick win
Tighten the sort.order type from string to 'asc' | 'desc'.
order: string allows any string at the call site, silently accepting values the API will reject. Since this is a query-key factory, the type drives what callers pass and what ends up in cache keys.
🔧 Proposed fix
catalogInfinite: (
opts: {
search?: string;
category?: string;
limit?: number;
- sort?: { field: string; order: string };
+ sort?: { field: string; order: 'asc' | 'desc' };
} = {},
) => ['catalogInfinite', opts] as const,📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| catalogInfinite: ( | |
| opts: { | |
| search?: string; | |
| category?: string; | |
| limit?: number; | |
| sort?: { field: string; order: string }; | |
| } = {}, | |
| ) => ['catalogInfinite', opts] as const, | |
| catalogInfinite: ( | |
| opts: { | |
| search?: string; | |
| category?: string; | |
| limit?: number; | |
| sort?: { field: string; order: 'asc' | 'desc' }; | |
| } = {}, | |
| ) => ['catalogInfinite', opts] as const, |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/app/src/shared/api/query-keys.ts` around lines 9 - 16, The
catalogInfinite query-key factory currently types sort.order as string which
permits invalid values; change the opts type in catalogInfinite so that sort: {
field: string; order: 'asc' | 'desc' } (tighten order to the literal union) so
callers and cache keys only accept 'asc' or 'desc'—update the catalogInfinite
function signature/type annotation accordingly (refer to catalogInfinite and its
opts.sort.order) to enforce the narrowed type throughout the codebase.
There was a problem hiding this comment.
Pull request overview
This PR applies follow-up fixes to the shared @packrat/app client data layer (introduced in #2384) and Expo catalog types, focusing on React Native compatibility, React Query cache correctness, and more accurate error surfacing from Eden Treaty.
Changes:
- Added a cross-platform UUID generator (
generateId()usingcrypto.getRandomValues) and replacedcrypto.randomUUID()usage in pack/trip/item create mutations. - Updated
catalogInfinitequery keys to includelimitandsortso different pagination/sort params don’t share cache entries. - Adjusted error handling to use Eden Treaty’s
error.value, and widened Expo catalogcreatedAt/updatedAttypes tostring | Date.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/app/src/shared/lib/uuid.ts | Adds generateId() for environments where crypto.randomUUID() isn’t available. |
| packages/app/src/shared/api/query-keys.ts | Expands catalogInfinite query key inputs to include limit and sort. |
| packages/app/src/features/trip/create/queries.ts | Uses generateId() for trip creation IDs. |
| packages/app/src/features/pack/create/queries.ts | Uses generateId() for pack creation IDs. |
| packages/app/src/features/pack/add-item/queries.ts | Uses generateId() for pack item creation IDs. |
| packages/app/src/entities/feed/queries.ts | Switches feed fetch error message to use Eden Treaty error.value. |
| packages/app/src/entities/catalog/queries.ts | Updates infinite catalog query key + switches error message to use error.value. |
| packages/app/index.ts | Re-exports the new UUID helper from the package entrypoint. |
| apps/expo/features/catalog/types.ts | Broadens createdAt/updatedAt to handle Date (Drizzle) vs string (Treaty). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // crypto.randomUUID() is not available in older React Native (Hermes < 0.71). | ||
| // crypto.getRandomValues() is available since RN 0.60 via the Hermes polyfill. |
| query: { page: pageParam as number, limit: 20 }, | ||
| }); | ||
| if (error) throw new Error(`Failed to fetch feed: ${String(error)}`); | ||
| if (error) throw new Error(`Failed to fetch feed: ${error.value}`); |
| }, | ||
| }); | ||
| if (error) throw new Error(`Failed to fetch catalog items: ${String(error)}`); | ||
| if (error) throw new Error(`Failed to fetch catalog items: ${error.value}`); |
fix(app): address post-merge review comments from #2384
Summary
Follow-up fixes from Copilot review comments on #2384, applied after that PR merged.
apps/expo/features/catalog/types.ts—createdAt/updatedAtchanged tostring | Date(Drizzle returnsDate, Eden Treaty returnsstring)crypto.randomUUID()withgenerateId()backed bycrypto.getRandomValues()for older React Native / Hermes compatibility; addedpackages/app/src/shared/lib/uuid.tscatalogInfinitenow includeslimit+sortin the cache key so different pagination/sort params get independent query entriesString(error)→error.valueinfeed/queries.tsandcatalog/queries.tsto match Eden Treaty error shapePost-Deploy Monitoring & Validation
No additional operational monitoring required: all changes are type-level or client-side query logic with no server-side impact.
Summary by CodeRabbit
New Features
Bug Fixes