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(assistant): tighten the journal cards' types and keep their helpers private
Maurice8a2cb10f7b62
diff --git a/client/src/components/Assistant/cards/journey/JourneyHeaderCard.test.tsx b/client/src/components/Assistant/cards/journey/JourneyHeaderCard.test.tsxindex e5dc28009..3fec5de48 100644--- a/client/src/components/Assistant/cards/journey/JourneyHeaderCard.test.tsx+++ b/client/src/components/Assistant/cards/journey/JourneyHeaderCard.test.tsx@@ -6,7 +6,7 @@* the change links or unlinks marked; what a new journal brings and what a* deletion or an unlink takes; the receipt that opens the journal.*/-import type { AssistantApplied, AssistantChangePreview, JourneyHeaderCard } from '@trek/shared';+import type { AssistantApplied, AssistantChangePreview, JourneyHeaderCard, JourneyHeaderTrip } from '@trek/shared';import { afterEach, describe, expect, it, vi } from 'vitest';import { fireEvent, render, screen } from '../../../../../tests/helpers/render';@@ -22,13 +22,21 @@ afterEach(() => {useAssistantStore.setState(ASSISTANT, true);});+const TOKYO: JourneyHeaderTrip = {+ id: 5,+ title: 'Tokyo days',+ startDate: '2026-11-02',+ endDate: '2026-11-08',+ change: 'kept',+};+const JAPAN: JourneyHeaderCard = {kind: 'journeyHeader',journeyId: 12,title: 'Japan 2026',subtitle: null,change: 'changed',- trips: [{ id: 5, title: 'Tokyo days', startDate: '2026-11-02', endDate: '2026-11-08', change: 'kept' }],+ trips: [TOKYO],entries: 3,photos: 40,suggestions: null,@@ -86,7 +94,7 @@ describe('a change of a journal itself', () => {journeyId: null,change: 'new',subtitle: 'Autumn',- trips: [{ ...JAPAN.trips[0], change: 'link' }],+ trips: [{ ...TOKYO, change: 'link' }],entries: null,photos: null,suggestions: 9,@@ -105,7 +113,7 @@ describe('a change of a journal itself', () => {first.unmount();const unlink: JourneyHeaderCard = {...JAPAN,- trips: [{ ...JAPAN.trips[0], change: 'unlink' }],+ trips: [{ ...TOKYO, change: 'unlink' }],entries: 1,suggestions: 4,};diff --git a/server/src/nest/assistant/assistant-journal-context.ts b/server/src/nest/assistant/assistant-journal-context.tsindex ce5720991..c7f892a0d 100644--- a/server/src/nest/assistant/assistant-journal-context.ts+++ b/server/src/nest/assistant/assistant-journal-context.ts@@ -26,7 +26,7 @@ export interface JournalCardEntry {}/** A trip the journey holds. */-export interface JournalCardTrip {+interface JournalCardTrip {id: number;title: string;startDate: string | null;diff --git a/server/src/nest/assistant/assistant-journey-offer.ts b/server/src/nest/assistant/assistant-journey-offer.tsindex 7767882be..6b243f36f 100644--- a/server/src/nest/assistant/assistant-journey-offer.ts+++ b/server/src/nest/assistant/assistant-journey-offer.ts@@ -73,7 +73,7 @@ export const JOURNAL_DENIED_TOOLS: Readonly<Record<string, string>> = {* taken into a journal names it `journalId`. The session pins and hides them* like `journeyId`; renaming the argument would break every MCP client.*/-export const JOURNEY_PIN_ALIASES: readonly string[] = ['journalId'];+const JOURNEY_PIN_ALIASES: readonly string[] = ['journalId'];/** Every argument a journey's session pins to its journey. */export const JOURNEY_PIN_ARGS: readonly string[] = [JOURNEY_PINNED_ARG, ...JOURNEY_PIN_ALIASES];diff --git a/server/src/nest/assistant/cards/journey/journey-header.ts b/server/src/nest/assistant/cards/journey/journey-header.tsindex c6c82f778..c22428664 100644--- a/server/src/nest/assistant/cards/journey/journey-header.ts+++ b/server/src/nest/assistant/cards/journey/journey-header.ts@@ -30,7 +30,7 @@ export interface JournalHeaderLoaded {}/** The tools these cards are for. */-export const JOURNAL_HEADER_TOOLS = [+const JOURNAL_HEADER_TOOLS = ['create_journey','update_journey','delete_journey',diff --git a/server/src/nest/assistant/cards/journey/journey-order.ts b/server/src/nest/assistant/cards/journey/journey-order.tsindex e75fcfe9c..2830ed7fd 100644--- a/server/src/nest/assistant/cards/journey/journey-order.ts+++ b/server/src/nest/assistant/cards/journey/journey-order.ts@@ -131,7 +131,7 @@ function stayEntry(args: ToolArgs, stay: Row): Row {/** The row of a stay taken in: what the entry is about, its day, time, place and text. */export function describeStay(ctx: PreviewContext, args: ToolArgs, loaded: StayLoaded | null): Described {- const entry = loaded?.stay+ const entry: Row = loaded?.stay? stayEntry(args, loaded.stay): { title: args.name, story: args.notes, entry_date: args.date };const day = typeof entry.entry_date === 'string' ? formatDate(ctx, entry.entry_date) : '';diff --git a/server/src/nest/assistant/cards/journey/journey-photos.ts b/server/src/nest/assistant/cards/journey/journey-photos.tsindex 2aa4e9ebd..7eb074858 100644--- a/server/src/nest/assistant/cards/journey/journey-photos.ts+++ b/server/src/nest/assistant/cards/journey/journey-photos.ts@@ -88,8 +88,8 @@ function photoLook(row: Row | undefined): JourneyPhotoLook | null {function entryRef(entry: Row | undefined, entryId: number | null): JourneyPhotosEntry | null {if (entryId === null) return null;- const date =- typeof entry?.entry_date === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(entry.entry_date) ? entry.entry_date : null;+ const raw = entry?.entry_date;+ const date = typeof raw === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(raw) ? raw : null;const title =clipped(entry?.title, JOURNEY_PHOTOS_LIMITS.title) ?? clipped(entry?.location_name, JOURNEY_PHOTOS_LIMITS.title);return { entryId, title, date };@@ -156,7 +156,8 @@ export function journalPhotosCard(/** What an entry is called on a row: its title, else its place, else its day. */function entryName(ctx: PreviewContext, entry: Row | undefined): string {- const day = typeof entry?.entry_date === 'string' ? formatDate(ctx, entry.entry_date) : '';+ const raw = entry?.entry_date;+ const day = typeof raw === 'string' ? formatDate(ctx, raw) : '';return text(entry?.title) || text(entry?.location_name) || day;}diff --git a/server/src/nest/journey/journey-entry-patch.helpers.ts b/server/src/nest/journey/journey-entry-patch.helpers.tsindex 5d4da55f1..6ef740e37 100644--- a/server/src/nest/journey/journey-entry-patch.helpers.ts+++ b/server/src/nest/journey/journey-entry-patch.helpers.ts@@ -30,7 +30,7 @@ export type JourneyEntryUpdateInput = Partial<{}>;/** The columns an update writes, as they are stored. */-export interface JourneyEntryColumns {+interface JourneyEntryColumns {type: string;title: string | null;story: string | null;diff --git a/server/src/nest/journey/journey-settings.helpers.ts b/server/src/nest/journey/journey-settings.helpers.tsindex c1d64acd0..f071244f1 100644--- a/server/src/nest/journey/journey-settings.helpers.ts+++ b/server/src/nest/journey/journey-settings.helpers.ts@@ -25,7 +25,7 @@ export type JourneySettingsInput = Partial<{}>;/** The columns an update writes, as they are stored. */-export interface JourneySettingsColumns {+interface JourneySettingsColumns {title: string;subtitle: string | null;cover_gradient: string | null;@@ -45,7 +45,7 @@ const ALLOWED_STATUSES: readonly string[] = ['draft', 'active', 'completed', 'arconst ALLOWED_OVERRIDES: readonly (string | null)[] = [null, 'draft', 'live', 'completed'];/** The flag columns, stored 0/1 and spoken as booleans. */-export const JOURNEY_SETTING_FLAGS = [+const JOURNEY_SETTING_FLAGS = ['show_trip_tracks','photo_location','show_verdict',diff --git a/server/src/nest/journey/journey-settings.service.ts b/server/src/nest/journey/journey-settings.service.tsindex e16b8024d..47f38b434 100644--- a/server/src/nest/journey/journey-settings.service.ts+++ b/server/src/nest/journey/journey-settings.service.ts@@ -13,7 +13,7 @@ import { InjectRepository } from '@mikro-orm/nestjs';import { Injectable } from '@nestjs/common';/** A settings update as the MCP tool answers it: the journey as stored now, and what the update replaced. */-export interface JourneySettingsUpdate {+interface JourneySettingsUpdate {journey: Journey;previous: JourneySettingsPrevious;}@@ -47,7 +47,7 @@ export class JourneySettingsService {const previous = await this.uow.transactional(async () => {const before = await this.journeysRepo.findById(journeyId);if (written) await this.journeysRepo.updateFields(journeyId, { ...patch, updated_at: Date.now() });- return previousSettings(before as Readonly<Record<string, unknown>> | undefined, patch);+ return previousSettings(before as unknown as Readonly<Record<string, unknown>> | undefined, patch);});if (written) await this.journeys.broadcastJourneyEvent(journeyId, 'journey:updated', {}, sid);const journey = (await this.journeysRepo.findById(journeyId)) as Journey | undefined;diff --git a/server/tests/unit/mcp/tools-journey.test.ts b/server/tests/unit/mcp/tools-journey.test.tsindex 5b59469d7..65f297ecc 100644--- a/server/tests/unit/mcp/tools-journey.test.ts+++ b/server/tests/unit/mcp/tools-journey.test.ts@@ -802,10 +802,10 @@ let assetSeq = 0;/** A photo in the journey's gallery, and on the entry when one is named; answers its journey photo id. */async function seedGalleryPhoto(journeyId: number, entryId?: number): Promise<number> {assetSeq += 1;- const trek = await createRow(orm, TrekPhotos, { provider: 'immich', asset_id: `asset-${assetSeq}` });- const gallery = await createRow(orm, JourneyPhotos, {+ const trekId = await insertRow(orm, TrekPhotos, { provider: 'immich', asset_id: `asset-${assetSeq}` });+ const galleryId = await insertRow(orm, JourneyPhotos, {journey: journeyId,- photo: trek.id,+ photo: trekId,caption: null,shared: 0,sort_order: 0,@@ -814,12 +814,12 @@ async function seedGalleryPhoto(journeyId: number, entryId?: number): Promise<nuif (entryId !== undefined) {await insertRow(orm, JourneyEntryPhotos, {entry: entryId,- journeyPhoto: gallery.id,+ journeyPhoto: galleryId,sort_order: 0,created_at: Date.now(),});}- return gallery.id;+ return galleryId;}describe('journey photo tools', () => {