The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(mail-ingest): match each AI leg to the data leg it agrees with
Maurice8f5988ee3357
diff --git a/server/src/nest/mail-ingest/mail-ingest-reading.service.ts b/server/src/nest/mail-ingest/mail-ingest-reading.service.tsindex b423b8369..17af0fc8f 100644--- a/server/src/nest/mail-ingest/mail-ingest-reading.service.ts+++ b/server/src/nest/mail-ingest/mail-ingest-reading.service.ts@@ -138,7 +138,7 @@ export class MailIngestReadingService {.flatMap((booking, i) => mapped[i].map((item) => ({ booking, item: withTextReference(item) }))).slice(0, MAIL_INGEST_LIMITS.storedBookings).map(({ booking, item }) => {- const match = machine.find((candidate) => sameBooking(candidate, item));+ const match = machineMatch(machine, item);const disagrees = match !== undefined && criticalDiffers(match, item);return {item: match && !disagrees ? match : item,@@ -154,6 +154,15 @@ export class MailIngestReadingService {}}+/** The machine-read booking an AI item stands for: of several under one reference, the one it agrees with. */+function machineMatch(+ machine: readonly BookingImportPreviewItem[],+ item: BookingImportPreviewItem,+): BookingImportPreviewItem | undefined {+ const same = machine.filter((candidate) => sameBooking(candidate, item));+ return same.find((candidate) => !criticalDiffers(candidate, item)) ?? same[0];+}+function fromMachine(item: BookingImportPreviewItem): MailDraft {return {item,diff --git a/server/tests/unit/nest/mail-ingest/mail-ingest.pipeline.test.ts b/server/tests/unit/nest/mail-ingest/mail-ingest.pipeline.test.tsindex 2ba1a5e02..7fb399c22 100644--- a/server/tests/unit/nest/mail-ingest/mail-ingest.pipeline.test.ts+++ b/server/tests/unit/nest/mail-ingest/mail-ingest.pipeline.test.ts@@ -546,6 +546,20 @@ describe('what a mail names', () => {} as AiReading);}+ it('adds both legs of a round trip under one reference the AI and the data agree on', async () => {+ const user = await person();+ const trip = await makeTrip(orm(), user.id, { start_date: '2030-03-01', end_date: '2030-03-10' });+ machine.mockResolvedValue([FLIGHT, RETURN]);+ aiReads([FLIGHT, RETURN]);++ const entries = await entriesOf(await forward(user.id, eml('round-trip', 'Fwd: Your flights', BOTH)));+ expect(entries.map((entry) => [entry.resolution, entry.reason])).toEqual([+ ['auto_applied', null],+ ['auto_applied', null],+ ]);+ expect(await countRows(orm(), Reservations, { trip: trip.id })).toBe(2);+ });+it('announces the place it created as the place routes do, with its name and position', async () => {const user = await person();const trip = await makeTrip(orm(), user.id, { start_date: '2030-03-01', end_date: '2030-03-10' });