Skip to content

fix(app): address post-merge review comments from #2384#2390

Merged
andrew-bierman merged 1 commit into
developmentfrom
feat/packages-app
May 8, 2026
Merged

fix(app): address post-merge review comments from #2384#2390
andrew-bierman merged 1 commit into
developmentfrom
feat/packages-app

Conversation

@andrew-bierman

@andrew-bierman andrew-bierman commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up fixes from Copilot review comments on #2384, applied after that PR merged.

  • CI fix: apps/expo/features/catalog/types.tscreatedAt/updatedAt changed to string | Date (Drizzle returns Date, Eden Treaty returns string)
  • UUID: replaced crypto.randomUUID() with generateId() backed by crypto.getRandomValues() for older React Native / Hermes compatibility; added packages/app/src/shared/lib/uuid.ts
  • queryKey: catalogInfinite now includes limit + sort in the cache key so different pagination/sort params get independent query entries
  • error messages: String(error)error.value in feed/queries.ts and catalog/queries.ts to match Eden Treaty error shape

Post-Deploy Monitoring & Validation

No additional operational monitoring required: all changes are type-level or client-side query logic with no server-side impact.


Compound Engineered 🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Enhanced catalog browsing with expanded filtering and sorting options.
  • Bug Fixes

    • Improved error messaging for catalog and feed failures.
    • Enhanced date field handling for catalog items to support both string and date formats.
    • Strengthened ID generation for creating trips and pack items for improved reliability.

- 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
Copilot AI review requested due to automatic review settings May 8, 2026 02:16
@github-actions github-actions Bot added the mobile label May 8, 2026
@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR introduces a shared generateId() utility to centralize UUID generation across the app, replacing direct calls to crypto.randomUUID() in pack and trip mutations. It also refactors the queryKeys.catalogInfinite API from positional parameters to a flexible options object, broadens CatalogItem timestamp types, and aligns error handling in queries to use error.value for consistency.

Changes

UUID Utility & Query Infrastructure

Layer / File(s) Summary
Shared UUID Utility
packages/app/src/shared/lib/uuid.ts, packages/app/index.ts
Implements generateId() using crypto.getRandomValues() with proper UUID version/variant bits; re-exported from packages/app root for consumer access.
Query Key API Update
packages/app/src/shared/api/query-keys.ts
queryKeys.catalogInfinite refactored from positional arguments to a single options object supporting search, category, limit, and sort fields.
Timestamp Type Flexibility
apps/expo/features/catalog/types.ts
CatalogItem.createdAt and CatalogItem.updatedAt now accept string | Date instead of only string.
Mutation & Query Implementations
packages/app/src/entities/catalog/queries.ts, packages/app/src/entities/feed/queries.ts, packages/app/src/features/pack/add-item/queries.ts, packages/app/src/features/pack/create/queries.ts, packages/app/src/features/trip/create/queries.ts
Pack, trip, and feed mutations now use generateId() for ID generation. Catalog infinite query uses the new options-based queryKeys.catalogInfinite() API. Error handling in catalog and feed queries aligned to throw error.value for consistent messaging.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PackRat-AI/PackRat#2076: Modifies the same CatalogItem timestamp fields (createdAt/updatedAt) in the same file.
  • PackRat-AI/PackRat#2372: Also changes CatalogItem timestamp field handling; this PR loosens the frontend type to string | Date while the related PR changes API schema coercion.

Suggested labels

mobile

Suggested reviewers

  • mikib0
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly references the PR's primary purpose: addressing post-merge review comments from a previous PR. It accurately describes the nature of the changes (fixes to address review feedback).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/packages-app

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between af56ca3 and f0877d6.

📒 Files selected for processing (9)
  • apps/expo/features/catalog/types.ts
  • packages/app/index.ts
  • packages/app/src/entities/catalog/queries.ts
  • packages/app/src/entities/feed/queries.ts
  • packages/app/src/features/pack/add-item/queries.ts
  • packages/app/src/features/pack/create/queries.ts
  • packages/app/src/features/trip/create/queries.ts
  • packages/app/src/shared/api/query-keys.ts
  • packages/app/src/shared/lib/uuid.ts

Comment on lines +9 to +16
catalogInfinite: (
opts: {
search?: string;
category?: string;
limit?: number;
sort?: { field: string; order: string };
} = {},
) => ['catalogInfinite', opts] as const,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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.

Suggested change
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() using crypto.getRandomValues) and replaced crypto.randomUUID() usage in pack/trip/item create mutations.
  • Updated catalogInfinite query keys to include limit and sort so different pagination/sort params don’t share cache entries.
  • Adjusted error handling to use Eden Treaty’s error.value, and widened Expo catalog createdAt/updatedAt types to string | 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.

Comment on lines +1 to +2
// 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}`);
@andrew-bierman andrew-bierman merged commit d43d69e into development May 8, 2026
13 checks passed
@andrew-bierman andrew-bierman deleted the feat/packages-app branch May 8, 2026 02:25
andrew-bierman added a commit that referenced this pull request May 14, 2026
fix(app): address post-merge review comments from #2384
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants