Skip to content

Release: development → main - #2685

Merged
mikib0 merged 24 commits into
mainfrom
development
Aug 10, 2026
Merged

Release: development → main#2685
mikib0 merged 24 commits into
mainfrom
development

Conversation

@mikib0

@mikib0 mikib0 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Promote developmentmain.

Connector submissions (unblocks two required form fields)

MCP

Swift / iOS


Verify after deploy

curl -sI https://packratai.com/support
curl -sI https://packratai.com/demo/packrat-chatgpt-demo.mp4   # 200, video/mp4, inline
curl -s  https://mcp.packratai.com/status                      # version

Note

The two landing URLs above are being submitted to the connector directories, so they need to resolve before those forms are completed.

Summary by CodeRabbit

  • New Features
    • Added a Support page with contact guidance, connector documentation, troubleshooting FAQs, and account and policy links.
    • Added reliable offline support for creating, updating, and deleting packs, items, and trips, with automatic retry when connectivity returns.
    • Added structured responses for catalog, guide, and pack-item tools.
  • Bug Fixes
    • Improved API and inline error messages, including clearer handling of actionable server responses.
    • Prevented duplicate records when offline-created content is synchronized.

mikib0 added 18 commits August 9, 2026 15:04
Signing up with an already-registered email showed "This content could not
be loaded right now.", which reads as a server outage when the user simply
needs to pick a different email. Two defects combined to hide the reason:

1. APIErrorBody decoded only `error`, but Better Auth returns
   `{"message": "...", "code": "..."}`. The server's text was dropped at
   the network layer, so `httpError` fell back to "An error occurred".
   Also stop swallowing the body on 401/404 — a 401 from sign-in means
   "Invalid email or password", not "your session expired".

2. InlineErrorView keyword-matched the message to a canned presentation
   and rendered *that* copy. Any message matching no bucket became the
   generic `temporarilyUnavailable` fallback.

Actionable server messages now render verbatim; the friendly canned copy
is retained for offline/auth/not-found, and for messages that look like
decoding dumps or are too long for the banner.

Verified against the live API: duplicate signup returns 422
"User already exists. Use another email."; a fresh email returns 200.
development landed "🧪 surface Swift auth failures", an independent fix for
the same network-layer defect (APIErrorBody decoding only `error` when Better
Auth returns `message`/`code`). Both branches touched validateStatus and
APIErrorBody, so both hunks conflicted.

Resolution keeps development's `APIErrorBody.decodeMessage(from:)` API — it's
the shape already used on the target branch — implemented in terms of this
branch's `displayMessage`, which additionally treats empty strings as absent
so `{"message":""}` falls through instead of rendering a blank banner.

validateStatus keeps this branch's `where message == nil` guards so a
server-supplied message survives on 404 as well as 401.

Note: development fixed only the network half. InlineErrorView there still
renders `presentation.description`, so a decoded message was still replaced by
the generic "This content could not be loaded right now." copy. The
ErrorView.swift fix on this branch remains necessary to actually resolve the
reported bug.

Full unit suite passes after the merge: 168 tests in 46 suites.
fix(swift): show real auth errors instead of "could not be loaded"
Writes made while offline were stranded on-device permanently: there was no
outbox, no retry, and no path by which a locally-created pack or trip ever
reached the server. Every reference to the `local-` id prefix was a guard that
skipped the server rather than a push.

Add a durable outbox:

- `PendingMutation` SwiftData model — entity type, entity id, operation,
  optional parent id, JSON payload, attempt count and terminal-failure flag.
- `OutboxService` drains the queue serially in `createdAt` order on reconnect,
  on foreground, and at launch, so create-then-update replays in the order the
  user made it.
- Retire the `local-` prefix in Packs/Trips in favour of a plain client UUID.
  The API already accepts client-supplied ids on create, so an offline record
  is syncable as-is — no id reconciliation, no dangling child foreign keys.
- Thread that id through `createPack`/`addItem`/`createTrip` so a replayed
  create can't produce a duplicate record.
- Collapse redundant mutations on enqueue: create+delete of a never-synced
  entity cancels out, updates fold into a pending create, and consecutive
  updates collapse to the latest.
- Terminal-failure policy: 4xx is not retried (the payload is wrong), 5xx and
  transport errors retry up to 5 attempts, then mark the mutation failed and
  keep it for the UI rather than dropping it. A 404 on delete and 409 on
  create count as success — the server already agrees.
- Make delete consistent with create/update: a failed delete now stays deleted
  locally and flushes later instead of resurrecting the record.

Refs #2672
…tions

Device testing on iPhone 17 found the outbox silently dropped every delete: a
pack deleted offline vanished from the UI but no PendingMutation row was ever
written, so the delete never reached the server on reconnect.

`OutboxService.enqueue` starts with `guard let context else { return }`, and the
view-model write methods take `context: ModelContext? = nil`. The create/update
form views passed a context, but the delete paths and two item paths relied on
the default nil — so exactly the writes that needed queuing were discarded.

Pass `modelContext` at the call sites that were missing it:

- `TripsListView` deleteTrip (context menu and swipe action)
- `PackDetailView` deleteItem and updateItem
- `CatalogView` addItem in AddCatalogItemToPackSheet

Verified end-to-end against a local API with a real signed-in account: a pack
created offline reaches the server on reconnect, and a pack deleted offline
enqueues (`pack|delete|48d5961a…`), flushes on reconnect, and leaves the queue
empty with no failed rows.

Refs #2672
…outbox

feat(swift): add offline write outbox so local writes reach the server
On macOS a pack or trip can be opened in its own window, and those windows host
the same detail views as the main window — so they queue writes of their own via
`PackDetailView`'s deleteItem/updateItem.

Only the main window carried `.flushesPendingWrites()`, so writes made in a
standalone window stayed queued until the user returned to the main window.
Not data loss (mutations are durable and the main window still flushes on
foreground/reconnect), but sync stalls for anyone working primarily in a
standalone window.

Attach the modifier to both macOS `WindowGroup`s. `OutboxService.flush` already
guards on `isFlushing`, so multiple windows cannot double-send a mutation.

Refs #2672
Lifts ten tools from text-only (Tier 2) to structured output, reusing the
shapes already modeled in @packrat/schemas per this file's reuse policy
rather than re-deriving them:

  packrat_search_gear_catalog    -> CatalogItemsResponseSchema
  packrat_get_catalog_item       -> CatalogItemSchema
  packrat_semantic_gear_search   -> catalog rows + similarity
  packrat_similar_catalog_items  -> catalog rows + similarity
  packrat_list_pack_items        -> list-of-PackItem with nextOffset
  packrat_get_pack_item          -> PackItemSchema
  packrat_list_guides            -> GuidesResponseSchema
  packrat_search_guides          -> GuideSearchResponseSchema
  packrat_get_guide              -> GuideDetailSchema
  packrat_list_guide_categories  -> GuideCategoriesResponseSchema

list_pack_items previously returned the API's bare array; it now normalises
into the { data, nextOffset } envelope its schema declares, matching
list_packs. The similarity schemas use .passthrough() so a service-side
field addition doesn't fail validation in production.

Addresses the connector-directory review's 'add an outputSchema' guidance.
Module docstring updated; tsc + biome clean; MCP tests 1273 pass.
fix(swift): flush the outbox from macOS standalone Pack/Trip windows
feat(mcp): add outputSchema to catalog, pack-item and guide tools
The Guides screen destructured only `isLoading` and `data` from useGuides /
useSearchGuides. When a request failed, `guides` was `[]` and `isLoading` was
false, so ListEmptyComponent rendered "No guides available" — indistinguishable
from a genuinely empty catalog, with no way to retry short of killing the app.

The API is serving content (39 guides), so the reported empty screen was a
failed fetch (offline, expired session, 5xx) being mislabelled as "no content".

Surface `isError`/`error` from both queries and render a titled error state with
a Try Again button that calls refetch(), matching the pattern already used in
PackListScreen. The search overlay's hardcoded empty state now reuses
renderEmpty() so a failed search reports the failure instead of "no guides
found for <query>".

Also fixes the imports to the migration branch's convention — Text was coming
from the @packrat/ui/nativewindui barrel, whose exports all still point at the
removed @packrat-ai/nativewindui package.

Refs #2663
The Claude and ChatGPT connector directory submissions both ask for a
customer support URL, and packratai.com/support was a 404 (as were /contact
and /help). Adds a real support surface rather than pointing reviewers at
the docs page.

Covers: support@packratai.com (already referenced elsewhere on the site)
with what-to-include guidance, connector setup/permission notes, four common
questions (password reset, sync, near-term-only weather, catalog accuracy),
and links to account deletion, privacy and terms.

Follows the existing page conventions (see app/account-deletion/page.tsx).
The Guides screen always showed "No Guides / Guides will appear here" even
though the API serves 39 guides.

GuidesResponse declared `guides`, `data` and `total` — all optional — but the
API returns `{ items, totalCount, page, limit, totalPages }`. Decoding therefore
*succeeded* vacuously with every field nil, and `items` (a computed property,
unrelated to the JSON key) evaluated `guides ?? data ?? []` → []. The `try?` in
listGuides hid the mismatch and the bare-array fallback failed too, so a fully
populated response turned into an empty list with no error.

Same class of bug in categories(): the endpoint returns
`{ categories, count }`, not a bare `[String]`, so `try?` swallowed it and the
filter was always empty.

- Model GuidesResponse/GuideCategoriesResponse on GuidesResponseSchema and
  GuideCategoriesResponseSchema in packages/schemas/src/guides.ts.
- Align Guide with GuideSchema: `description` (exposed as `excerpt` for the row
  UI), plus `categories`, `author`, `difficulty`; drop `imageUrl`, which the API
  never sends.
- Filter on the `categories` tags. `category` is "general" for every guide,
  while /guides/categories returns tags like "gear" and "planning", so the
  picker previously filtered every guide away.
- Drop both `try?` fallbacks so a failed fetch surfaces via ErrorView with retry
  instead of being mislabelled as an empty catalog.
- Decouple categories from the guides request in load(); a categories failure no
  longer discards successfully fetched guides.

Verified by decoding the real payload shape with APIClient's
.convertFromSnakeCase decoder: old model → 0 guides, new model → guides, excerpt
and category tags all populated.

Fixes #2663
The category bar paired a .menu Picker with a trailing Text repeating
`selectedCategory`. A .menu Picker already renders both its label and the
current selection, so the row read "Category  Beginner-Resources ⌄
Beginner-Resources" — the value shown twice over.

Drop the redundant Text and the wrapping HStack/Spacer that only existed to
position it.

Refs #2663
The category row set listRowInsets with leading/trailing 0, so "Category" sat
flush against the card's left edge and the picker against the right, unlike
every other row on the screen.

Use 16pt horizontal insets, matching HomeView and GearInventoryView and lining
the filter up with the guide rows below it.

Refs #2663
The OpenAI Apps submission requires a Demo Recording URL. Hosts the
recording on the main domain rather than a third-party video host, so the
link is stable and we control it.

Serves at https://packratai.com/demo/packrat-chatgpt-demo.mp4

Adds a /demo/* rule to public/_headers so the file is served inline
(Content-Disposition: inline, Content-Type: video/mp4) — a reviewer clicking
the link plays it in-browser instead of downloading it — and cached
immutably.

The landing app is a static Next export (output: 'export'), so public/ is
copied verbatim into out/; no route or component needed.
feat(landing): host the ChatGPT connector demo recording
@github-actions github-actions Bot added the web label Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@mikib0, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 35 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7a1ec0d0-88fc-4088-8e44-92786898b75e

📥 Commits

Reviewing files that changed from the base of the PR and between dc2c9a4 and dbc84ca.

📒 Files selected for processing (21)
  • apps/expo/features/guides/screens/GuidesListScreen.tsx
  • apps/expo/lib/i18n/locales/en.json
  • apps/landing/app/support/page.tsx
  • apps/landing/config/site.ts
  • apps/swift/Sources/PackRat/Features/Guides/GuidesView.swift
  • apps/swift/Sources/PackRat/Features/Packs/PackFormView.swift
  • apps/swift/Sources/PackRat/Features/Packs/PacksListView.swift
  • apps/swift/Sources/PackRat/Features/Packs/PacksViewModel.swift
  • apps/swift/Sources/PackRat/Features/Trips/TripFormView.swift
  • apps/swift/Sources/PackRat/Features/Trips/TripsListView.swift
  • apps/swift/Sources/PackRat/Features/Trips/TripsViewModel.swift
  • apps/swift/Sources/PackRat/Network/APIClient.swift
  • apps/swift/Sources/PackRat/Persistence/LegacyLocalIDMigration.swift
  • apps/swift/Sources/PackRat/Persistence/PendingMutation.swift
  • apps/swift/Sources/PackRat/Services/OutboxService.swift
  • apps/swift/Sources/PackRat/Shared/OutboxFlushModifier.swift
  • apps/swift/Sources/PackRat/Shared/PendingWritesBanner.swift
  • apps/swift/Sources/PackRat/Shared/VisualSampleData.swift
  • apps/swift/Tests/PackRatTests/ErrorPresentationTests.swift
  • apps/swift/Tests/PackRatTests/OutboxTests.swift
  • packages/mcp/src/tools/packs.ts

Walkthrough

The PR adds a support page, durable offline mutation replay for Swift packs and trips, improved error handling, and structured MCP output schemas for catalog, pack-item, and guide tools.

Changes

Swift offline writes and error handling

Layer / File(s) Summary
Mutation persistence and identity contracts
apps/swift/Sources/PackRat/Persistence/*, apps/swift/Sources/PackRat/Services/PackService.swift, apps/swift/Sources/PackRat/Services/TripService.swift
Adds the SwiftData mutation model, payload types, persistence registration, and caller-supplied identifiers for offline-created records.
Outbox enqueue and replay engine
apps/swift/Sources/PackRat/Services/OutboxService.swift
Persists, folds, replays, retries, and classifies queued pack, pack-item, and trip mutations.
View-model mutation integration
apps/swift/Sources/PackRat/Features/Packs/*, apps/swift/Sources/PackRat/Features/Trips/*, apps/swift/Sources/PackRat/Features/Catalog/CatalogView.swift
Queues failed or offline writes, preserves client-generated IDs, keeps deletes optimistic, and passes SwiftData contexts to mutation methods.
Window flush lifecycle
apps/swift/Sources/PackRat/Shared/OutboxFlushModifier.swift, apps/swift/Sources/PackRat/PackRatApp.swift
Flushes pending writes on launch, restored connectivity, and foreground activation for each app window.
HTTP and inline error presentation
apps/swift/Sources/PackRat/Network/APIClient.swift, apps/swift/Sources/PackRat/Shared/ErrorView.swift, apps/swift/Tests/PackRatTests/ErrorPresentationTests.swift
Normalizes server error fields and displays short actionable raw messages while suppressing decoding and infrastructure details. Tests cover decoding and presentation behavior.

Support page

Layer / File(s) Summary
Support content and navigation
apps/landing/app/support/page.tsx
Adds contact instructions, connector guidance, troubleshooting FAQs, and account, privacy, and terms links.

Structured MCP output

Layer / File(s) Summary
MCP output schemas
packages/mcp/src/output-schemas.ts
Adds schemas for catalog, pack-item, and guide tool responses.
Catalog structured responses
packages/mcp/src/tools/catalog.ts
Adds schemas and structured response requests for catalog search, semantic search, item retrieval, and similar-item tools.
Guide structured responses
packages/mcp/src/tools/guides.ts
Adds schemas and structured response requests for guide listing, categories, search, and retrieval.
Pack-item structured responses
packages/mcp/src/tools/packs.ts
Adds structured output handling and normalizes pack-item arrays into a pagination envelope.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SwiftUI
  participant OutboxFlushModifier
  participant OutboxService
  participant SwiftData
  participant RemoteService
  SwiftUI->>OutboxFlushModifier: launch or become active
  OutboxFlushModifier->>OutboxService: flush pending writes
  OutboxService->>SwiftData: load queued mutations
  OutboxService->>RemoteService: replay mutation with stable identifier
  RemoteService-->>OutboxService: return success or failure
  OutboxService->>SwiftData: update retry or completion state
Loading

Possibly related PRs

Suggested labels: mobile, api, database

Suggested reviewers: andrew-bierman

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.88% 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 clearly identifies the main change as promoting the development branch to main.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch development

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.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for packages/analytics (./packages/analytics)

Status Category Percentage Covered / Total
🟢 Lines 100% (🎯 80%) 745 / 745
🟢 Statements 100% (🎯 80%) 745 / 745
🟢 Functions 100% (🎯 85%) 48 / 48
🟢 Branches 87.35% (🎯 80%) 152 / 174
File CoverageNo changed files found.
Generated in workflow #609 for commit dbc84ca by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for packages/overpass (./packages/overpass)

Status Category Percentage Covered / Total
🟢 Lines 100% (🎯 80%) 155 / 155
🟢 Statements 100% (🎯 80%) 155 / 155
🟢 Functions 100% (🎯 80%) 13 / 13
🟢 Branches 95.65% (🎯 70%) 44 / 46
File CoverageNo changed files found.
Generated in workflow #609 for commit dbc84ca by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for packages/utils (./packages/utils)

Status Category Percentage Covered / Total
🟢 Lines 100% (🎯 100%) 92 / 92
🟢 Statements 100% (🎯 100%) 92 / 92
🟢 Functions 100% (🎯 100%) 1 / 1
🟢 Branches 100% (🎯 100%) 1 / 1
File CoverageNo changed files found.
Generated in workflow #609 for commit dbc84ca by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for packages/units (./packages/units)

Status Category Percentage Covered / Total
🟢 Lines 100% (🎯 100%) 35 / 35
🟢 Statements 100% (🎯 100%) 35 / 35
🟢 Functions 100% (🎯 100%) 6 / 6
🟢 Branches 100% (🎯 100%) 11 / 11
File CoverageNo changed files found.
Generated in workflow #609 for commit dbc84ca by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for apps/expo (./apps/expo)

Status Category Percentage Covered / Total
🟢 Lines 97.64% (🎯 95%) 623 / 638
🟢 Statements 97.64% (🎯 95%) 623 / 638
🟢 Functions 100% (🎯 97%) 52 / 52
🟢 Branches 95.19% (🎯 92%) 218 / 229
File CoverageNo changed files found.
Generated in workflow #609 for commit dbc84ca by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for packages/mcp (./packages/mcp)

Status Category Percentage Covered / Total
🟢 Lines 99.28% (🎯 80%) 4316 / 4347
🟢 Statements 99.28% (🎯 80%) 4316 / 4347
🟢 Functions 100% (🎯 80%) 101 / 101
🟢 Branches 98.35% (🎯 80%) 598 / 608
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/mcp/src/output-schemas.ts 100% 100% 100% 100%
packages/mcp/src/tools/catalog.ts 100% 100% 100% 100%
packages/mcp/src/tools/guides.ts 100% 100% 100% 100%
packages/mcp/src/tools/packs.ts 98.87% 95% 100% 98.87% 252-257
Generated in workflow #609 for commit dbc84ca by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for packages/api (./packages/api)

Status Category Percentage Covered / Total
🟢 Lines 99.01% (🎯 95%) 1906 / 1925
🟢 Statements 99.01% (🎯 95%) 1906 / 1925
🟢 Functions 100% (🎯 97%) 100 / 100
🟢 Branches 97.08% (🎯 92%) 665 / 685
File CoverageNo changed files found.
Generated in workflow #609 for commit dbc84ca by the Vitest Coverage Report Action

@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: 10

🤖 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 `@apps/landing/app/support/page.tsx`:
- Around line 28-30: Update the support link in the page component to use
siteConfig.support.email for both the displayed address and mailto href,
importing the existing site configuration symbol instead of hardcoding
support@packratai.com.

In `@apps/swift/Sources/PackRat/Features/Packs/PacksViewModel.swift`:
- Around line 389-394: Implement a one-time migration for cached entities with
legacy local IDs: in
apps/swift/Sources/PackRat/Features/Packs/PacksViewModel.swift lines 389-394,
reconcile cached packs whose IDs start with local-; in lines 404-404, reconcile
cached pack items with local-item- IDs; and in
apps/swift/Sources/PackRat/Features/Trips/TripsViewModel.swift lines 280-283,
reconcile cached trips with local- IDs. For each affected entity, either enqueue
creation under a fresh lowercase UUID and rewrite the cached ID, or remove the
stale row, ensuring subsequent edits, deletes, and sync operations no longer use
the legacy server-rejected IDs.
- Around line 136-166: Remove async throws from createPack and deletePack in
apps/swift/Sources/PackRat/Features/Packs/PacksViewModel.swift (lines 136-166
and 223-249), and from createTrip and deleteTrip in
apps/swift/Sources/PackRat/Features/Trips/TripsViewModel.swift (lines 144-181
and 243-268). Update all callers to remove unreachable catch handling and the
redundant try? in TripsListView, and confirm a view surfaces
OutboxService.failedCount.

In `@apps/swift/Sources/PackRat/Features/Trips/TripsViewModel.swift`:
- Around line 144-181: Update TripsViewModel.createTrip and deleteTrip to remove
throws from their signatures, since all failures are queued through the outbox;
adjust callers such as TripsListView to stop using try/try? while preserving
asynchronous calls. Add the corresponding view-level presentation of
OutboxService.failedCount, following the existing pattern in PacksViewModel.

In `@apps/swift/Sources/PackRat/Network/APIClient.swift`:
- Around line 299-303: Update the displayMessage property to trim each message,
error, and code candidate before checking for emptiness and returning it, so
whitespace-only values fall through to the next candidate. Add a regression test
covering whitespace-only message and error fields and verifying the appropriate
fallback is selected.

In `@apps/swift/Sources/PackRat/Services/OutboxService.swift`:
- Around line 328-330: Update the OutboxService encode path so JSON encoding
failures are not silently converted into nil payloads: log the original encoding
error with useful context or propagate it to the caller, and ensure enqueue
rejects nil payloads for create and update rather than inserting unreplayable
mutations. Preserve successful encoding and enqueue behavior.
- Around line 126-146: Update PendingMutation and OutboxService.flush to persist
and enforce a nextAttemptAt timestamp before calling apply, so queued mutations
are skipped until their backoff window expires. Extend the retry outcome to
identify authentication failures, leaving their attemptCount unchanged while
still retaining the mutation; increment attempts and calculate/store the next
retry time only for other retryable failures, preserving maxAttempts handling.
- Around line 279-301: Update OutboxService.classify(_:operation:) so HTTP 429
and 408 statuses return .retry before the general 400...499 terminal-status
branch; preserve the existing success handling and terminal behavior for other
client errors, while leaving PackRatError.unauthorized handling unchanged.
- Around line 60-89: Update the .delete handling in OutboxService so cancelling
a queued parent .create also deletes all child mutations whose parentId matches
the deleted entity, not just mutations returned by pendingMutations(for:). Add
and use a childMutations(of:context:) helper alongside pendingMutations(for:),
then remove both parent and child mutations before saving, refreshing, and
returning.

In `@packages/mcp/src/tools/packs.ts`:
- Around line 258-263: Update the packrat_list_pack_items response construction
to return the complete items array with nextOffset set to null, rather than
passing items.length to withNextOffset. Preserve the existing normalization of
result.data and structured response behavior.
🪄 Autofix

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 Plus

Run ID: 5527c0f5-3bb7-4e05-95b2-cdde21925d6f

📥 Commits

Reviewing files that changed from the base of the PR and between 6b5b8b9 and dc2c9a4.

⛔ Files ignored due to path filters (2)
  • apps/landing/public/_headers is excluded by !**/public/**
  • apps/landing/public/demo/packrat-chatgpt-demo.mp4 is excluded by !**/*.mp4, !**/public/**
📒 Files selected for processing (20)
  • apps/landing/app/support/page.tsx
  • apps/swift/Sources/PackRat/Features/Catalog/CatalogView.swift
  • apps/swift/Sources/PackRat/Features/Packs/PackDetailView.swift
  • apps/swift/Sources/PackRat/Features/Packs/PacksViewModel.swift
  • apps/swift/Sources/PackRat/Features/Trips/TripsListView.swift
  • apps/swift/Sources/PackRat/Features/Trips/TripsViewModel.swift
  • apps/swift/Sources/PackRat/Network/APIClient.swift
  • apps/swift/Sources/PackRat/PackRatApp.swift
  • apps/swift/Sources/PackRat/Persistence/PendingMutation.swift
  • apps/swift/Sources/PackRat/Persistence/PersistenceController.swift
  • apps/swift/Sources/PackRat/Services/OutboxService.swift
  • apps/swift/Sources/PackRat/Services/PackService.swift
  • apps/swift/Sources/PackRat/Services/TripService.swift
  • apps/swift/Sources/PackRat/Shared/ErrorView.swift
  • apps/swift/Sources/PackRat/Shared/OutboxFlushModifier.swift
  • apps/swift/Tests/PackRatTests/ErrorPresentationTests.swift
  • packages/mcp/src/output-schemas.ts
  • packages/mcp/src/tools/catalog.ts
  • packages/mcp/src/tools/guides.ts
  • packages/mcp/src/tools/packs.ts

Comment thread apps/landing/app/support/page.tsx Outdated
Comment thread apps/swift/Sources/PackRat/Features/Packs/PacksViewModel.swift
Comment thread apps/swift/Sources/PackRat/Features/Packs/PacksViewModel.swift
Comment thread apps/swift/Sources/PackRat/Features/Trips/TripsViewModel.swift
Comment thread apps/swift/Sources/PackRat/Network/APIClient.swift Outdated
Comment thread apps/swift/Sources/PackRat/Services/OutboxService.swift
Comment thread apps/swift/Sources/PackRat/Services/OutboxService.swift
Comment thread apps/swift/Sources/PackRat/Services/OutboxService.swift Outdated
Comment thread apps/swift/Sources/PackRat/Services/OutboxService.swift
Comment thread packages/mcp/src/tools/packs.ts
Two valid findings, both on code added in this release.

1. packrat_list_pack_items advertised a bogus nextOffset. Passing
   `limit: items.length` to withNextOffset made its `items.length >= limit`
   check true for every response — including an empty pack, which returned
   `nextOffset: 0`. A consumer following that value could call the tool
   repeatedly or duplicate items. The endpoint takes only pack_id and returns
   every item in one response, so there is never a next page: return
   `nextOffset: null` directly and don't route it through withNextOffset.
   Comment explains why, so this isn't 'simplified' back later.

2. /support hardcoded support@packratai.com, bypassing the canonical
   siteConfig.support contract (hello@packratai.com, asserted by
   __tests__/legal.pages.test.ts). Render siteConfig.support.email/.mailto
   instead. Also refreshes the now-stale site.ts comment that said we don't
   run a support web page.

The remaining CodeRabbit findings are on the Swift outbox/APIClient work from
other PRs in this release and are left to those authors.

MCP tests 1273 pass; tsc + biome clean. The one failing landing test
(terms-of-service robots metadata) is pre-existing on development and
unrelated.
@cloudflare-workers-and-pages

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
packrat-mcp-dev ce90c76 Aug 10 2026, 05:46 PM

@cloudflare-workers-and-pages

Copy link
Copy Markdown
Contributor

Deploying packrat-landing with  Cloudflare Pages  Cloudflare Pages

Latest commit: ce90c76
Status: ✅  Deploy successful!
Preview URL: https://8032a16c.packrat-landing.pages.dev
Branch Preview URL: https://development.packrat-landing.pages.dev

View logs

Six CodeRabbit findings on the offline write outbox, all still live on
development — the earlier fix commit (e628815) deliberately deferred them.

1. Retries burned the budget with no delay. flush runs at launch, on every
   connectivity change, and on every foreground, so a brief 5xx outage plus a
   few app switches drove attemptCount to maxAttempts in seconds and marked the
   write permanently failed. Persist nextAttemptAt on PendingMutation and gate
   the fetch on it; back off 2s/4s/8s/16s/32s. Defaults to .distantPast so both
   fresh rows and rows written by earlier builds are eligible immediately.

2. An expired session consumed an attempt. classify returned .retry with the
   comment "the write should survive a re-auth", then charged it anyway — five
   foregrounds while signed out permanently failed the write, the opposite of
   the stated intent. Outcome.retry now carries chargesAttempt; the auth paths
   pass false. It still takes a backoff tier, so it can't spin.

3. 429 and 408 were treated as terminal by the blanket 400...499 branch. Both
   are transient — the payload is fine. Route them to .retry. 401 arriving as a
   raw httpError (rather than .unauthorized, which happens when the body carries
   a message) now takes the attempt-free auth path too.

4. Cancelling a queued parent create stranded its children. pendingMutations
   matches on entityId only, so deleting a pack whose create was still queued
   left .packItem rows carrying parentId == packId. Those replayed against an id
   the server never received, 404'd, and surfaced as failed writes for a pack
   the user had deleted. Cascade the cancellation via a childMutations lookup.

5. A failed encode queued an unreplayable write. encode swallowed the error and
   returned nil; enqueue inserted a payload-less create, decode threw
   missingPayload on flush, and the write was marked failed with the original
   error gone. Log the encode failure and refuse a payload-less create/update.

6. Cached rows from the retired `local-` id scheme had no reconciliation path.
   Local ids became plain UUIDs, but rows already on disk kept `local-<uuid>` /
   `local-item-<uuid>`. They were never uploaded, and any edit or delete queued
   a mutation the server 404s, which classify marks terminal — permanent,
   unfixable sync failures for upgrading users. LegacyLocalIDMigration drops
   those cached packs/trips and any mutation keyed on one, once per install, at
   cache load. Dropping rather than re-minting: these are cache entries the
   server has never seen, and re-creating them could resurrect content deleted
   on another device. Pack items live inside CachedPack.jsonData, so they go
   with their parent.

Also, per the same review:

- Four mutation methods kept `async throws` but routed every error into the
  outbox, so caller catch blocks were unreachable and a server rejection was
  invisible at the call site. Drop throws from createPack/deletePack/createTrip/
  deleteTrip and update the four callers, including the redundant `try?` in
  TripsListView.
- Nothing rendered OutboxService.failedCount, so the only remaining failure
  signal was unobservable. PendingWritesBanner surfaces failed (with a dismiss
  that calls discardFailed) and pending counts, attached via the modifier that
  already drives the flush.
- APIErrorBody.displayMessage treated "   " as a real message, which suppressed
  the 401/404 fallback in validateStatus and rendered a banner InlineErrorView
  then trimmed to nothing. Trim each candidate before testing it.

Tests: new OutboxTests covers classification, backoff, the cascade, the
payload-less refusal, update collapsing, and the migration; ErrorPresentation
gains the whitespace regression cases the review asked for.

macOS build succeeds. 192 unit tests run, all passing except a pre-existing
KeychainService failure that reads a real token from the login keychain — it
fails identically on unmodified development. The xcodebuild test runner can't
launch in this environment ("hung before establishing connection"), also
reproduced on unmodified development, so the bundle was run directly.
…ty-state

fix(swift/guides): decode the real /api/guides response so guides render
mikib0 added 2 commits August 10, 2026 21:23
Six findings, all on code added in the previous commit.

1. Child mutations could be sent before their parent create landed. flush
   ordered by createdAt, so the parent create went first — but if it returned
   .retry, the loop continued and still sent the child. The child then drew a
   404 and classify marked it terminal, so a transient parent failure became a
   permanent child failure. Track parents whose create didn't land this pass and
   defer their children to the parent's nextAttemptAt, rather than charging the
   child an attempt for someone else's failure. The rule is extracted as
   shouldDefer(_:blockedParents:) so it's testable without a live flush.

2. "Dismiss" on the pending-writes banner called discardFailed, which deletes
   every failed mutation. It read like hiding a banner but permanently dropped
   the user's unsynced writes. Renamed to "Discard" and gated behind a
   confirmation alert that says the device and server will stay out of sync.

3. LegacyLocalIDMigration set its completion flag even when the scan failed.
   run swallowed fetch errors with try? and returned 0, so a failed first read
   after an upgrade marked the migration done forever — leaving exactly the
   stranded legacy rows it exists to remove. run now returns Int? (nil when any
   fetch fails) and runIfNeeded only writes the flag on a completed scan.

4. Backoff was fully deterministic, so every write failed by one outage became
   eligible at the same instant and the next flush replayed the queue in a
   single burst against a server that was just struggling. Added up to 25%
   jitter and relaxed the timing assertions to ranges, keeping the tier
   ordering and ceiling checks.

5. PacksListView still declared deleteError and an alert for it. Nothing has
   set it since delete errors moved to the outbox banner, so both were dead.

6. OutboxTests covered update+update collapsing but not an update folding into
   a queued create — the branch that decides whether an offline-created entity
   reaches the server with its final values in one request. Added, along with
   tests for the deferral rule and the migration's success reporting.

macOS test target builds; 199 tests pass with no failures.

Note on scope: CI's PackRat-macOS (smoke) job passed on 3882100, which is the
first green confirmation of this work on a real runner — the local xcodebuild
test runner still can't launch here, so the bundle was run directly again.
fix(swift): address the open outbox review findings on PR #2685
@mikib0
mikib0 merged commit 3a94ecb into main Aug 10, 2026
44 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants