fix(ci): align packing parity and simplify offline sync

Describe bringer input in the shared packing contract and check its trip event against the REST contributor operation. Keep offline map preparation in its own step without changing the order or the sign-out checks.
This commit is contained in:
Maurice
2026-12-05 12:45:31 +01:00
parent 09567d32c4
commit f3bbd1a268
4 changed files with 43 additions and 25 deletions
+22 -24
View File
@@ -441,30 +441,7 @@ export const tripSyncManager = {
await cacheFilesForTrip(trip.id, files).catch(console.error)
}
// 3) Map tiles — awaited, and only when the user opted to store them. The
// places go with every run: "prepared" has to mean the offline search
// works, and the tile switch is about tens of megabytes of imagery, not
// about the megabyte a trip's places cost.
{
const wantTiles = getOfflinePrefs().cacheTiles
const tileUrl = useSettingsStore.getState().settings.map_tile_url || undefined
const cartoKey = useSettingsStore.getState().settings.carto_api_key || undefined
i = 0
for (const trip of prepared) {
if (!isAuthed()) return { status: 'skipped', reason: 'signed-out' }
// Reported only when there is a tile phase to report. The place
// prefetch rides along quietly, the way it always did — it is a
// megabyte, not the tens the progress bar exists for.
if (wantTiles) onProgress?.({ phase: 'tiles', current: ++i, total: prepared.length, label: trip.title })
const places = await offlineDb.places.where('trip_id').equals(trip.id).toArray()
if (wantTiles) {
await prefetchTilesForTrip(trip.id, places, tileUrl, true, cartoKey).catch(console.error)
}
await prefetchPlacesForTrip(trip.id, places, true).catch(console.error)
}
}
if (!isAuthed()) return { status: 'skipped', reason: 'signed-out' }
if (!(await prepareOfflineMaps(prepared, onProgress))) return { status: 'skipped', reason: 'signed-out' }
onProgress?.({ phase: 'done', current: prepared.length, total: prepared.length })
return { status: 'done', trips: prepared.length }
} finally {
@@ -478,6 +455,27 @@ export const tripSyncManager = {
},
}
// Download tiles only when requested, but always cache the places needed for offline search.
async function prepareOfflineMaps(trips: Trip[], onProgress?: (p: PrepareProgress) => void): Promise<boolean> {
const wantTiles = getOfflinePrefs().cacheTiles
const tileUrl = useSettingsStore.getState().settings.map_tile_url || undefined
const cartoKey = useSettingsStore.getState().settings.carto_api_key || undefined
let i = 0
for (const trip of trips) {
if (!isAuthed()) return false
// Reported only when there is a tile phase to report. The place
// prefetch rides along quietly, the way it always did — it is a
// megabyte, not the tens the progress bar exists for.
if (wantTiles) onProgress?.({ phase: 'tiles', current: ++i, total: trips.length, label: trip.title })
const places = await offlineDb.places.where('trip_id').equals(trip.id).toArray()
if (wantTiles) {
await prefetchTilesForTrip(trip.id, places, tileUrl, true, cartoKey).catch(console.error)
}
await prefetchPlacesForTrip(trip.id, places, true).catch(console.error)
}
return isAuthed()
}
async function prepareOfflineUi(): Promise<void> {
// The trip bundle is unusable on iOS if WebKit cannot load the planner itself.
if (!isAuthed() || !isNativeIos()) return
+2 -1
View File
@@ -23,6 +23,7 @@ import {
packingCreateBagRequestSchema,
packingCreateItemRequestSchema,
packingListItemsRequestSchema,
packingSetBringersRequestSchema,
packingSetSharingRequestSchema,
packingUpdateBagRequestSchema,
packingUpdateItemRequestSchema,
@@ -299,7 +300,7 @@ export class PackingMcp {
inputSchema: {
tripId: idSchema,
itemId: idSchema,
user_ids: z.array(idSchema).describe('User IDs of the trip members who bring this item'),
...packingSetBringersRequestSchema.shape,
},
annotations: TOOL_ANNOTATIONS_WRITE,
when: packingAddonOn,
@@ -178,6 +178,21 @@ export const money: CaseGroup = {
},
expect: ['packing:deleted', { event: 'packing:created', only: 'viewers' }],
},
{
tool: 'set_packing_item_bringers',
needs: ['packingItem', 'member'],
args: (s) => ({
tripId: s.trip.id,
itemId: s.packingItem.id,
user_ids: s.packingItem.owner_id ? [s.packingItem.owner_id, s.member.id] : [s.member.id],
}),
rest: {
method: 'post',
path: (s) => packing(s, '/' + s.packingItem.id + '/contributors'),
body: (s) => ({ user_id: s.member.id }),
},
expect: ['packing:updated'],
},
{
// The route used to save the order and tell nobody (G14).
tool: 'reorder_packing_items',
+4
View File
@@ -128,6 +128,10 @@ export const packingAddContributorRequestSchema = z.object({
});
export type PackingAddContributorRequest = z.infer<typeof packingAddContributorRequestSchema>;
export const packingSetBringersRequestSchema = z.object({
user_ids: z.array(idSchema).describe('User IDs of the trip members who bring this item'),
});
export const packingUpdateItemRequestSchema = z.object({
name: z.string().optional(),
// The legacy route accepted both boolean and 0/1 for checked — both stay valid.