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
feat(assistant): journal entry cards, and markdown stripped in shared
Maurice984ee67517f1
diff --git a/client/scripts/format-baseline.json b/client/scripts/format-baseline.jsonindex d4157106d..0c989e623 100644--- a/client/scripts/format-baseline.json+++ b/client/scripts/format-baseline.json@@ -400,8 +400,6 @@"src/components/Journey/moodConfig.ts","src/components/Journey/photoZoom.test.ts","src/components/Journey/photoZoom.ts",- "src/components/Journey/stripMarkdown.test.ts",- "src/components/Journey/stripMarkdown.ts","src/components/Journey/useConnectedPhotoProviders.test.tsx","src/components/Journey/useConnectedPhotoProviders.ts","src/components/Journey/useEntryPhotoOrder.test.ts",diff --git a/client/src/components/Assistant/cards/journey/JourneyChangeSlots.tsx b/client/src/components/Assistant/cards/journey/JourneyChangeSlots.tsxnew file mode 100644index 000000000..933cfa26c--- /dev/null+++ b/client/src/components/Assistant/cards/journey/JourneyChangeSlots.tsx@@ -0,0 +1,126 @@+import type { AssistantChangeRow, JourneyEntriesCard } from '@trek/shared';+import { AlignLeft, CalendarDays, Clock, MapPin, Tag, Type } from 'lucide-react';++import { useTranslation } from '../../../../i18n';+import type { ChangeItem } from '../../assistantParts';+import { FactChange } from '../parts/CardFacts';+import { EntryMarks, EntryStory, EntryThumb } from './JourneyEntryParts';+import { flagOf, stateOf } from './journeyTones';+import { entryHoverProps, useEntryHover } from './useEntryHover';++/**+ * What a change row of a journal entry adds to the row it already is (its+ * verb and subject): the facts, words and states it changes, each old to new,+ * the entry's photo at the end of the subject line when it has one already,+ * and under the row the start of its text and how it reads. A deleted entry made from a trip place says it+ * goes back to a suggestion. A change that failed, was discarded or ran out+ * shows the row alone.+ */++const GONE: ReadonlySet<ChangeItem['state']> = new Set(['failed', 'discarded', 'expired']);++/** The facts a journal change row names on its faint line, in this order: when, then where. */+const FACT_ICONS = { day: CalendarDays, time: Clock, location: MapPin } as const;+/** The words an update rewrites, named only when they change: the entry's title and its text. */+const WORD_ICONS = { name: Type, text: AlignLeft } as const;+type FactRow = AssistantChangeRow & { labelKey: keyof typeof FACT_ICONS };+type WordRow = AssistantChangeRow & { labelKey: keyof typeof WORD_ICONS };+const TO_SUGGESTION = 'mt-1 text-caption text-content-faint';+const HOVER_BOX = 'flex flex-none';++/** A row's old value, for a row that had one. */+function beforeOf(row: AssistantChangeRow): string | null {+ return row.op !== 'add' && row.before ? row.before : null;+}++/** A row that holds something: a new value, or an old one it clears. */+function holds(row: AssistantChangeRow): boolean {+ return row.after !== '' || beforeOf(row) !== null;+}++/** A state an update sets (who sees the entry, its mood, weather or kind, a flag), named in the user's words. */+function StateChange({ row }: { row: AssistantChangeRow }) {+ const { t } = useTranslation();+ const flag = flagOf(row.field, row.after);+ if (flag) return <FactChange icon={flag.Icon} before={null} after={t(flag.labelKey)} tone="info" />;+ const was = stateOf(row.field, row.before);+ const now = stateOf(row.field, row.after);+ const Icon = (now ?? was)?.Icon ?? Tag;+ const named = (tone: typeof now, value: string | null) => (tone ? t(tone.labelKey) : value);+ return (+ <FactChange+ icon={Icon}+ before={named(was, beforeOf(row))}+ after={named(now, row.after) || t('assistant.card.common.removed')}+ />+ );+}++/**+ * When and where the entry is, before and after on a change (the day, the+ * time and the place), then the title and text an update rewrites and the+ * states it sets. A value an update clears reads as removed.+ */+export function JourneyEntryFacts({ item }: { card: JourneyEntriesCard; item: ChangeItem }) {+ const { t } = useTranslation();+ const rows = item.preview?.rows ?? [];+ const removed = t('assistant.card.common.removed');+ const order = Object.keys(FACT_ICONS);+ const facts = rows+ .filter((row): row is FactRow => row.labelKey in FACT_ICONS && holds(row))+ .sort((a, b) => order.indexOf(a.labelKey) - order.indexOf(b.labelKey));+ // A new entry's text and a deleted one's show under the row already; only a rewrite names them here.+ const words = rows.filter((row): row is WordRow => row.op === 'change' && row.labelKey in WORD_ICONS && holds(row));+ const states = rows.filter((row) => row.labelKey === 'field' && holds(row));+ return (+ <>+ {facts.map((row) => (+ <FactChange+ key={row.labelKey}+ icon={FACT_ICONS[row.labelKey]}+ before={beforeOf(row)}+ after={row.after || removed}+ />+ ))}+ {words.map((row) => (+ <FactChange+ key={row.labelKey}+ icon={WORD_ICONS[row.labelKey]}+ before={beforeOf(row)}+ after={row.after || removed}+ tone="info"+ />+ ))}+ {states.map((row) => <StateChange key={row.field ?? row.labelKey} row={row} />)}+ </>+ );+}++/** The entry's photo beside the subject, for an entry that is written already; resting on it shows its place. */+export function JourneyEntryAside({ card, item }: { card: JourneyEntriesCard; item: ChangeItem }) {+ const hover = useEntryHover(card.journeyId, item.toolCallId);+ const look = card.entries[0];+ if (!look || look.photoId === null || GONE.has(item.state)) return null;+ return (+ <span className={HOVER_BOX} {...entryHoverProps(hover, look)}>+ <EntryThumb look={look} size="sm" />+ </span>+ );+}++/** The start of the entry's text and its marks, under the row; resting on them shows its place on the map. */+export function JourneyEntryBody({ card, item }: { card: JourneyEntriesCard; item: ChangeItem }) {+ const { t } = useTranslation();+ const hover = useEntryHover(card.journeyId, item.toolCallId);+ const look = card.entries[0];+ if (!look || GONE.has(item.state)) return null;+ return (+ <div {...entryHoverProps(hover, look)}>+ <EntryStory look={look} roomy={false} />+ <EntryMarks look={look} />+ {card.change === 'willDelete' && look.fromTripPlace && (+ <p className={TO_SUGGESTION}>{t('assistant.card.journey.toSuggestion')}</p>+ )}+ </div>+ );+}diff --git a/client/src/components/Assistant/cards/journey/JourneyEntriesBlock.tsx b/client/src/components/Assistant/cards/journey/JourneyEntriesBlock.tsxnew file mode 100644index 000000000..9d351bf7f--- /dev/null+++ b/client/src/components/Assistant/cards/journey/JourneyEntriesBlock.tsx@@ -0,0 +1,170 @@+import type { AssistantMessage, JourneyEntryLook } from '@trek/shared';+import { ArrowUpRight } from 'lucide-react';+import { useMemo } from 'react';++import { useTranslation } from '../../../../i18n';+import { DAY_COLORS } from '../../../Journey/dayColors';+import { cardTitle } from '../../../Journey/journeyCard';+import JourneyEntryCover from '../../../Journey/JourneyEntryCover';+import { LinkedJournalIcon } from '../../../Trips/LinkedJournalIcon';+import { useAssistantView } from '../../assistantViewContext';+import type { CardEntry } from '../cardTypes';+import CardFrame from '../parts/CardFrame';+import CardStrip from '../parts/CardStrip';+import { type JournalEntries, coverEntryOf, mergeJournalCards, titleSourceOf } from './journeyCardModel';+import { EntryMarks, EntryStory, EntryThumb, EntryWhen } from './JourneyEntryParts';+import { type EntryHover, entryHoverProps, useEntryHover } from './useEntryHover';+import { useJourneyOpen } from './useJourneyOpen';++/**+ * The entries an answer read from one journal. One or two stand as rows+ * under each other, with their photo, facts and the start of their text;+ * three or more run as a strip of the journal's own tiles, the ones the read+ * left out counted in a last tile. Either way the journal's name closes the+ * card with the way into it, and every entry opens where it is written.+ * Resting on an entry with a place, or tabbing to it, shows it on the plan's+ * map.+ */++const ROW = '-mx-1.5 flex gap-2.5 rounded-[12px] px-1.5 py-2 hover:bg-surface-hover';+const ROW_DIVIDED = '-mx-1.5 flex gap-2.5 rounded-[12px] border-t border-edge-faint px-1.5 py-2 hover:bg-surface-hover';+const TITLE = 'line-clamp-2 text-body font-semibold leading-tight text-content';+const TITLE_BUTTON =+ 'block w-full rounded-md text-start outline-none hover:underline focus-visible:ring-2 focus-visible:ring-accent';+/** The phone's taller target, the title still at the top of the row. */+const TITLE_BUTTON_TALL = `${TITLE_BUTTON} min-h-10`;+const FOOTER = 'mt-1 flex items-center gap-2 border-t border-edge-faint pt-2 text-caption';+const FOOTER_TITLE = 'min-w-0 flex-1 truncate text-content-muted';+const FAINT = 'text-content-faint';+const OPEN = 'inline-flex flex-none items-center gap-1 font-medium text-accent hover:underline';+const OPEN_TALL = 'inline-flex h-10 flex-none items-center gap-1 font-medium text-accent hover:underline';+/** The size and corners of the journal's own tile, so the count stands in the row like one more entry. */+const MORE_TILE_BOX = 'flex h-[152px] w-[136px] flex-none items-center justify-center rounded-[18px]';+const MORE_TILE_LOOK =+ 'border border-dashed border-edge px-3 text-center text-caption text-content-muted hover:bg-surface-hover';+const MORE_TILE = `${MORE_TILE_BOX} ${MORE_TILE_LOOK}`;+const TILE = 'flex-none snap-start';++type Open = ((entryId: number | null) => void) | null;++/** The journal's name and the way into it, under the card. */+function JournalFooter({ journal, open }: { journal: JournalEntries; open: Open }) {+ const { t } = useTranslation();+ const { variant } = useAssistantView();+ const title = journal.journalTitle ?? t('assistant.card.journey.label');+ const count = journal.entries.length + journal.more;+ return (+ <div className={FOOTER}>+ <LinkedJournalIcon size={12} className={FAINT} />+ <span title={title} className={FOOTER_TITLE}>+ <bdi>{title}</bdi>+ {count > 2 && <span className="ms-1.5 tabular-nums">{t('assistant.card.journey.entries', { count })}</span>}+ </span>+ {open && (+ <button type="button" onClick={() => open(null)} className={variant === 'fullscreen' ? OPEN_TALL : OPEN}>+ {t('assistant.card.journey.open')}+ <ArrowUpRight size={12} aria-hidden="true" className="rtl:-scale-x-100" />+ </button>+ )}+ </div>+ );+}++/** One entry as a row: its photo, its title (the way to it), its facts and the start of its text. */+function EntryRow({+ look,+ divided,+ open,+ hover,+}: {+ look: JourneyEntryLook;+ divided: boolean;+ open: Open;+ hover: EntryHover;+}) {+ const { t } = useTranslation();+ const { density, variant } = useAssistantView();+ const roomy = density === 'roomy';+ const title = <bdi className={TITLE}>{cardTitle(titleSourceOf(look), t)}</bdi>;+ return (+ <div className={divided ? ROW_DIVIDED : ROW} {...entryHoverProps(hover, look)}>+ <EntryThumb look={look} size={roomy ? 'lg' : 'md'} />+ <div className="min-w-0 flex-1">+ {open ? (+ <button+ type="button"+ onClick={() => open(look.entryId)}+ className={variant === 'fullscreen' ? TITLE_BUTTON_TALL : TITLE_BUTTON}+ >+ {title}+ </button>+ ) : (+ title+ )}+ <EntryWhen look={look} />+ <EntryMarks look={look} />+ <EntryStory look={look} roomy={roomy} />+ </div>+ </div>+ );+}++/** One or two entries, under each other. */+function JournalRows({ journal, fallbackRef }: { journal: JournalEntries; fallbackRef: string }) {+ const { t } = useTranslation();+ const open = useJourneyOpen(journal.journeyId, journal.tripJournal);+ const hover = useEntryHover(journal.journeyId, fallbackRef);+ return (+ <CardFrame label={t('assistant.card.journey.label')}>+ {journal.entries.map((look, index) => (+ <EntryRow key={look.entryId ?? `new-${index}`} look={look} divided={index > 0} open={open} hover={hover} />+ ))}+ <JournalFooter journal={journal} open={open} />+ </CardFrame>+ );+}++/** Three or more entries, as the journal's own tiles in a row, the rest counted at its end. */+function JournalStrip({ journal, fallbackRef }: { journal: JournalEntries; fallbackRef: string }) {+ const { t } = useTranslation();+ const open = useJourneyOpen(journal.journeyId, journal.tripJournal);+ const hover = useEntryHover(journal.journeyId, fallbackRef);+ const label = journal.journalTitle ?? t('assistant.card.journey.label');+ return (+ <div>+ <CardStrip label={label} count={journal.entries.length + journal.more} watch={journal.entries}>+ {journal.entries.map((look, index) => (+ <li key={look.entryId ?? `new-${index}`} className={TILE} {...entryHoverProps(hover, look)}>+ <JourneyEntryCover+ entry={coverEntryOf(look)}+ dayColor={DAY_COLORS[(look.dayIndex ?? 0) % DAY_COLORS.length]}+ isActive={false}+ onClick={() => open?.(look.entryId)}+ tone="app"+ />+ </li>+ ))}+ {journal.more > 0 && (+ <li className={TILE}>+ <button type="button" onClick={() => open?.(null)} disabled={!open} className={MORE_TILE}>+ {t('assistant.card.journey.more', { count: journal.more })}+ </button>+ </li>+ )}+ </CardStrip>+ <JournalFooter journal={journal} open={open} />+ </div>+ );+}++/** The answer cards of one journal, as rows or as a strip by how many entries they hold. */+export default function JourneyEntriesBlock({ cards }: { cards: readonly CardEntry[]; message: AssistantMessage }) {+ const journal = useMemo(() => mergeJournalCards(cards), [cards]);+ if (!journal || journal.entries.length === 0) return null;+ const fallbackRef = cards[0]?.toolCallId ?? 'card';+ return journal.entries.length <= 2 ? (+ <JournalRows journal={journal} fallbackRef={fallbackRef} />+ ) : (+ <JournalStrip journal={journal} fallbackRef={fallbackRef} />+ );+}diff --git a/client/src/components/Assistant/cards/journey/JourneyEntriesCard.test.tsx b/client/src/components/Assistant/cards/journey/JourneyEntriesCard.test.tsxnew file mode 100644index 000000000..e06013017--- /dev/null+++ b/client/src/components/Assistant/cards/journey/JourneyEntriesCard.test.tsx@@ -0,0 +1,298 @@+/**+ * FE-AI-JOURNEY-001 to FE-AI-JOURNEY-010+ *+ * The journal's cards in the chat: one or two entries as rows with their+ * photo, facts and text, three or more as a strip of the journal's own tiles+ * with the rest counted, each entry opening where it is written (the trip's+ * Journal tab or the journal's page), the map pin while resting on one, and+ * a change row of an entry with its photo, text and marks, and every field+ * an update changes, old to new.+ */+import type {+ AssistantApplied,+ AssistantChangePreview,+ AssistantMessage,+ JourneyEntriesCard,+ JourneyEntryLook,+} from '@trek/shared';+import type { ReactNode } from 'react';+import { afterEach, describe, expect, it, vi } from 'vitest';++import { fireEvent, render, screen } from '../../../../../tests/helpers/render';+import { useAssistantStore } from '../../../../store/assistantStore';+import { useTripJournalLinkStore } from '../../../../store/tripJournalLinkStore';+import AssistantChangeCard from '../../AssistantChangeCard';+import type { ChangeItem } from '../../assistantParts';+import { type AssistantView, AssistantViewContext } from '../../assistantViewContext';+import JourneyEntriesBlock from './JourneyEntriesBlock';++const TRIP = 4;+const ASSISTANT = useAssistantStore.getState();+const LINKS = useTripJournalLinkStore.getState();+const MESSAGE = { id: 'm1', role: 'assistant', parts: [], status: 'complete', createdAt: '' } as AssistantMessage;++function look(over: Partial<JourneyEntryLook> = {}): JourneyEntryLook {+ return {+ entryId: 12,+ type: 'entry',+ title: 'Sunset at the Spree',+ date: '2026-10-21',+ time: '14:30',+ place: 'Berlin',+ point: { lat: 52.52, lng: 13.405 },+ countryCode: 'DE',+ story: 'The light over the river was unreal.',+ mood: null,+ weather: null,+ photoId: 7,+ video: false,+ photoCount: 1,+ visibility: 'private',+ draft: false,+ fromTripPlace: false,+ dayIndex: 0,+ ...over,+ };+}++function card(entries: JourneyEntryLook[], over: Partial<JourneyEntriesCard> = {}): JourneyEntriesCard {+ return {+ kind: 'journeyEntries',+ journeyId: 3,+ journalTitle: 'Berlin 2026',+ tripJournal: false,+ change: 'none',+ entries,+ more: 0,+ ...over,+ };+}++function inView(ui: ReactNode, view: Partial<AssistantView> = {}) {+ const value: AssistantView = { tripId: TRIP, variant: 'window', ...view };+ return render(<AssistantViewContext.Provider value={value}>{ui}</AssistantViewContext.Provider>);+}++function block(cards: JourneyEntriesCard[], view: Partial<AssistantView> = {}) {+ const entries = cards.map((c, i) => ({ toolCallId: `call_${i}`, card: c }));+ return inView(<JourneyEntriesBlock cards={entries} message={MESSAGE} />, view);+}++afterEach(() => {+ useAssistantStore.setState(ASSISTANT, true);+ useTripJournalLinkStore.setState(LINKS, true);+ vi.restoreAllMocks();+});++describe('the journal entries card', () => {+ it('FE-AI-JOURNEY-001: one entry reads as a row with its photo, facts, marks and text under the journal', () => {+ const { container } = block([card([look({ visibility: 'public', draft: true, photoCount: 4, video: true })])]);+ expect(screen.getByRole('region', { name: 'Journal entries' })).toBeInTheDocument();+ expect(screen.getByText('Sunset at the Spree')).toBeInTheDocument();+ expect(screen.getByText('14:30')).toBeInTheDocument();+ expect(screen.getByText('Berlin')).toBeInTheDocument();+ expect(screen.getByText('The light over the river was unreal.')).toBeInTheDocument();+ expect(screen.getByText('Public')).toBeInTheDocument();+ expect(screen.getByText('Draft')).toBeInTheDocument();+ expect(screen.getByText('4 photos')).toBeInTheDocument();+ expect(screen.getByText('Opens with a video')).toBeInTheDocument();+ expect(screen.getByText('Berlin 2026')).toBeInTheDocument();+ expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/7/thumbnail');+ });++ it('FE-AI-JOURNEY-002: an entry without a photo takes the width, and a known mood and weather are named', () => {+ const { container } = block([card([look({ photoId: null, mood: 'amazing', weather: 'cold' })])]);+ expect(container.querySelector('img')).toBeNull();+ expect(screen.getByText('Amazing')).toBeInTheDocument();+ // `cold` is the id the journal stores for snow.+ expect(screen.getByText('Snowy')).toBeInTheDocument();+ block([card([look({ entryId: 20, mood: 'ecstatic', weather: 'Drizzle at noon' })], { journeyId: 8 })]);+ expect(screen.getByText('Drizzle at noon')).toBeInTheDocument();+ expect(screen.queryByText('ecstatic')).toBeNull();+ });++ it('FE-AI-JOURNEY-003: three or more entries run as the journal tiles, the ones left out counted at the end', () => {+ const entries = [+ look({ entryId: 1, title: 'Arrival', dayIndex: 0 }),+ look({ entryId: 2, title: 'Museum Island', dayIndex: 1 }),+ look({ entryId: 3, title: 'Teufelsberg', dayIndex: 1, photoId: null }),+ ];+ block([card(entries, { more: 5 })]);+ expect(screen.getByRole('region', { name: 'Berlin 2026' })).toBeInTheDocument();+ expect(screen.getAllByRole('listitem')).toHaveLength(4);+ expect(screen.getByRole('button', { name: /Museum Island/ })).toBeInTheDocument();+ expect(screen.getByRole('button', { name: '5 more in the journal' })).toBeInTheDocument();+ expect(screen.getByText('8 entries')).toBeInTheDocument();+ });++ it('FE-AI-JOURNEY-004: two reads of one journal draw as one card, each entry once', () => {+ block([card([look({ entryId: 1, title: 'Old title' })]), card([look({ entryId: 1, title: 'New title' })])]);+ expect(screen.getByText('New title')).toBeInTheDocument();+ expect(screen.queryByText('Old title')).toBeNull();+ });++ it("FE-AI-JOURNEY-005: an entry opens in the trip's Journal tab when the trip shows that journal, else on its page", () => {+ const onOpen = vi.fn();+ const first = block([card([look()])], { onOpen });+ fireEvent.click(screen.getByRole('button', { name: 'Sunset at the Spree' }));+ expect(onOpen).toHaveBeenLastCalledWith({ kind: 'page', path: '/journey/3?entry=12' });+ fireEvent.click(screen.getByRole('button', { name: /Open in the journal/ }));+ expect(onOpen).toHaveBeenLastCalledWith({ kind: 'page', path: '/journey/3' });+ first.unmount();++ useTripJournalLinkStore.setState({+ byTrip: {+ [String(TRIP)]: {+ link: {+ journey_id: 3,+ title: 'Berlin 2026',+ subtitle: null,+ cover_image: null,+ owner_id: 1,+ linked_by: 1,+ created_at: 0,+ my_role: 'editor',+ members: null,+ },+ can_link: true,+ can_unlink: true,+ can_edit_members: false,+ },+ },+ });+ block([card([look()])], { onOpen });+ fireEvent.click(screen.getByRole('button', { name: 'Sunset at the Spree' }));+ expect(onOpen).toHaveBeenLastCalledWith({ kind: 'tab', tab: 'journal', params: { entry: '12' } });+ });++ it('FE-AI-JOURNEY-006: without a shell to open into, the title is no button and the card has no way out', () => {+ block([card([look()])]);+ expect(screen.queryByRole('button', { name: 'Sunset at the Spree' })).toBeNull();+ expect(screen.queryByRole('button', { name: /Open in the journal/ })).toBeNull();+ });++ it('FE-AI-JOURNEY-007: resting on an entry with a place pins it on the map; leaving and going take the pin away', () => {+ const setPreviewPin = vi.fn();+ useAssistantStore.setState({ setPreviewPin });+ const { unmount } = block([card([look(), look({ entryId: 13, title: 'Nowhere', point: null })])]);+ fireEvent.mouseEnter(screen.getByText('Sunset at the Spree').closest('div') as HTMLElement);+ expect(setPreviewPin).toHaveBeenLastCalledWith({+ tripId: TRIP,+ ref: 'journey:3:12',+ lat: 52.52,+ lng: 13.405,+ name: 'Sunset at the Spree',+ });+ fireEvent.mouseLeave(screen.getByText('Sunset at the Spree').closest('div') as HTMLElement);+ expect(setPreviewPin).toHaveBeenLastCalledWith(null);+ unmount();+ expect(setPreviewPin).toHaveBeenLastCalledWith(null);+ });+});++describe('a change row of a journal entry', () => {+ const DELETE_ROWS: AssistantChangePreview['rows'] = [+ { op: 'add', labelKey: 'day', before: null, after: 'Tue, Oct 21' },+ { op: 'add', labelKey: 'location', before: null, after: 'Museum Island' },+ { op: 'add', labelKey: 'text', before: null, after: 'Not a fact' },+ ];++ function item(+ state: ChangeItem['state'],+ held: JourneyEntriesCard,+ over: Partial<AssistantChangePreview> = {}+ ): ChangeItem {+ const preview: AssistantChangePreview = {+ toolCallId: 'w1',+ verbKey: 'removeJournalEntry',+ subject: 'Sunset at the Spree',+ rows: DELETE_ROWS,+ dayId: null,+ placeIds: [],+ undoable: false,+ domain: 'journey',+ card: held,+ ...over,+ };+ const receipt: AssistantApplied = {+ toolCallId: 'w1',+ entity: 'journey_entry',+ ids: [12],+ dayId: null,+ undoUntil: null,+ };+ return { toolCallId: 'w1', preview, applied: state === 'applied' ? receipt : null, state, card: held };+ }++ it('FE-AI-JOURNEY-008: a waiting delete shows the photo, the text and that it goes back to a suggestion; a receipt opens it', () => {+ const entry = look({ fromTripPlace: true, visibility: 'shared' });+ const held = card([entry], { change: 'willDelete', tripJournal: true });+ const onOpen = vi.fn();+ const first = inView(<AssistantChangeCard items={[item('pending', held)]} />, { onOpen });+ expect(screen.getByText('Delete the journal entry')).toBeInTheDocument();+ expect(screen.getByText('The light over the river was unreal.')).toBeInTheDocument();+ expect(screen.getByText('Shared')).toBeInTheDocument();+ expect(screen.getByText('Goes back to a suggestion')).toBeInTheDocument();+ expect(screen.getByText('Tue, Oct 21')).toBeInTheDocument();+ expect(screen.getByText('Museum Island')).toBeInTheDocument();+ expect(screen.queryByText('Not a fact')).toBeNull();+ expect(document.querySelector('img')).toHaveAttribute('src', '/api/photos/7/thumbnail');+ first.unmount();++ const second = inView(<AssistantChangeCard items={[item('applied', held)]} />, { onOpen });+ expect(screen.queryByRole('button', { name: 'Show on map' })).toBeNull();+ fireEvent.click(screen.getByRole('button', { name: 'Open in the journal' }));+ expect(onOpen).toHaveBeenCalledWith({ kind: 'tab', tab: 'journal', params: { entry: '12' } });+ second.unmount();++ inView(<AssistantChangeCard items={[item('failed', held)]} />, { onOpen });+ expect(screen.queryByText('Goes back to a suggestion')).toBeNull();+ expect(document.querySelector('img')).toBeNull();+ });++ it('FE-AI-JOURNEY-009: a waiting update names every field it changes old to new, a cleared one as removed', () => {+ const rows: AssistantChangePreview['rows'] = [+ { op: 'change', labelKey: 'name', before: 'Sunset', after: 'Sunset at the Spree' },+ { op: 'change', labelKey: 'time', before: '14:30', after: '' },+ { op: 'change', labelKey: 'text', before: 'Old story', after: 'New story' },+ { op: 'change', labelKey: 'field', field: 'visibility', before: 'private', after: 'public' },+ { op: 'change', labelKey: 'field', field: 'mood', before: 'good', after: '' },+ { op: 'change', labelKey: 'field', field: 'weather', before: 'sunny', after: 'Drizzle' },+ { op: 'change', labelKey: 'field', field: 'is_draft', before: '✓', after: '✗' },+ ];+ const held = card([look({ photoId: null })], { change: 'changed' });+ inView(<AssistantChangeCard items={[item('pending', held, { verbKey: 'updateJournalEntry', rows })]} />);+ expect(screen.getByText('Change the journal entry')).toBeInTheDocument();+ expect(screen.getByText('Sunset')).toHaveClass('line-through');+ expect(screen.getByText('14:30')).toHaveClass('line-through');+ expect(screen.getByText('Old story')).toHaveClass('line-through');+ expect(screen.getByText('New story')).toBeInTheDocument();+ expect(screen.getByText('Private')).toHaveClass('line-through');+ expect(screen.getByText('Public')).toBeInTheDocument();+ expect(screen.getByText('Good')).toHaveClass('line-through');+ expect(screen.getByText('Sunny')).toHaveClass('line-through');+ expect(screen.getByText('Drizzle')).toBeInTheDocument();+ expect(screen.getByText('No longer a draft')).toBeInTheDocument();+ expect(screen.getAllByText('Removed')).toHaveLength(2);+ });++ it('FE-AI-JOURNEY-010: resting on a waiting change shows its entry on the map, and leaving takes the pin away', () => {+ const setPreviewPin = vi.fn();+ useAssistantStore.setState({ setPreviewPin });+ const held = card([look()], { change: 'changed' });+ inView(<AssistantChangeCard items={[item('pending', held, { verbKey: 'updateJournalEntry', rows: [] })]} />);+ const story = screen.getByText('The light over the river was unreal.');+ fireEvent.mouseEnter(story);+ expect(setPreviewPin).toHaveBeenLastCalledWith({+ tripId: TRIP,+ ref: 'journey:3:12',+ lat: 52.52,+ lng: 13.405,+ name: 'Sunset at the Spree',+ });+ fireEvent.mouseLeave(story);+ expect(setPreviewPin).toHaveBeenLastCalledWith(null);+ fireEvent.focus(document.querySelector('img')?.parentElement?.parentElement as HTMLElement);+ expect(setPreviewPin).toHaveBeenLastCalledWith(expect.objectContaining({ ref: 'journey:3:12' }));+ });+});diff --git a/client/src/components/Assistant/cards/journey/JourneyEntryParts.tsx b/client/src/components/Assistant/cards/journey/JourneyEntryParts.tsxnew file mode 100644index 000000000..eb2a2e23e--- /dev/null+++ b/client/src/components/Assistant/cards/journey/JourneyEntryParts.tsx@@ -0,0 +1,128 @@+import type { JourneyEntryLook } from '@trek/shared';+import { CalendarDays, Globe, Images, MapPin, Play, Users } from 'lucide-react';++import { useTranslation } from '../../../../i18n';+import { cardDateLabel, cardPlace } from '../../../Journey/journeyCard';+import { SoftPill, TimePill, WhiteBadge } from '../../../Planner/planParts';+import CountryFlag from '../../../shared/CountryFlag';+import { CardFacts } from '../parts/CardFacts';+import { titleSourceOf } from './journeyCardModel';+import { moodOf, weatherOf } from './journeyTones';++/**+ * The pieces a journal entry is drawn from in the chat, the same in an+ * answer, a change row and a receipt: its photo, the facts of when and where+ * as the planner's badges, the marks of how it reads (shared, draft, mood,+ * weather, more photos) and the start of its text. Every fact wraps, none is+ * cut.+ */++const THUMB_SIZE = { sm: 'size-11', md: 'size-16', lg: 'size-20' } as const;+const THUMB_BOX = 'relative flex-none';+const THUMB_IMG = 'size-full rounded-lg bg-surface-secondary object-cover';+const VIDEO_MARK = 'absolute bottom-1 end-1';+const ICON = 'flex-none text-content-faint';+const STORY = {+ compact: 'mt-1.5 line-clamp-2 text-caption text-content-secondary',+ roomy: 'mt-1.5 line-clamp-3 text-caption text-content-secondary',+} as const;++/** The entry's photo as a square, a clip marked as one; nothing without a photo. */+export function EntryThumb({ look, size }: { look: JourneyEntryLook; size: keyof typeof THUMB_SIZE }) {+ const { t } = useTranslation();+ if (look.photoId === null) return null;+ return (+ <span className={`${THUMB_BOX} ${THUMB_SIZE[size]}`}>+ <img src={`/api/photos/${look.photoId}/thumbnail`} alt="" loading="lazy" className={THUMB_IMG} />+ {look.video && (+ <SoftPill className={VIDEO_MARK} icon={<Play size={10} aria-hidden="true" />}>+ <span className="sr-only">{t('assistant.card.journey.video')}</span>+ </SoftPill>+ )}+ </span>+ );+}++/** When and where: the day, the time, the place with its flag. */+export function EntryWhen({ look }: { look: JourneyEntryLook }) {+ const { locale } = useTranslation();+ const place = cardPlace(titleSourceOf(look));+ return (+ <CardFacts>+ <WhiteBadge icon={<CalendarDays size={10} strokeWidth={2.2} aria-hidden="true" className={ICON} />}>+ {cardDateLabel(look.date, locale)}+ </WhiteBadge>+ {look.time && <TimePill>{look.time}</TimePill>}+ {(place || look.countryCode) && (+ <SoftPill icon={<MapPin size={10} strokeWidth={2.2} aria-hidden="true" className={ICON} />}>+ {look.countryCode && <CountryFlag code={look.countryCode} size={12} />}+ {place && <bdi className="truncate">{place}</bdi>}+ </SoftPill>+ )}+ </CardFacts>+ );+}++/** Shared or public; nothing for a private entry. */+function VisibilityMark({ visibility }: { visibility: JourneyEntryLook['visibility'] }) {+ const { t } = useTranslation();+ if (visibility === 'private') return null;+ const shared = visibility === 'shared';+ const Icon = shared ? Users : Globe;+ return (+ <SoftPill tone="info" icon={<Icon size={10} strokeWidth={2.2} aria-hidden="true" />}>+ {shared ? t('journey.visibility.shared') : t('journey.visibility.public')}+ </SoftPill>+ );+}++/** A mood the journal knows, in its own colour; nothing for any other. */+function MoodMark({ id }: { id: string | null }) {+ const { t } = useTranslation();+ const mood = moodOf(id);+ if (!mood) return null;+ return (+ // The mood's own colour, the theme's token the journal draws it in.+ <SoftPill icon={<mood.Icon size={10} strokeWidth={2.2} aria-hidden="true" style={{ color: mood.color }} />}>+ {t(mood.labelKey)}+ </SoftPill>+ );+}++/** The weather by the journal's name for it, or as the traveller wrote it. */+function WeatherMark({ weather }: { weather: string | null }) {+ const { t } = useTranslation();+ if (!weather) return null;+ const known = weatherOf(weather);+ return (+ <SoftPill icon={known && <known.Icon size={10} strokeWidth={2.2} aria-hidden="true" className={ICON} />}>+ <bdi className="truncate">{known ? t(known.labelKey) : weather}</bdi>+ </SoftPill>+ );+}++/** How the entry reads: shared or public, a draft, its mood and weather, its photos past the first. */+export function EntryMarks({ look }: { look: JourneyEntryLook }) {+ const { t } = useTranslation();+ const mood = moodOf(look.mood) !== null;+ if (look.visibility === 'private' && !look.draft && !mood && !look.weather && look.photoCount < 2) return null;+ return (+ <CardFacts>+ <VisibilityMark visibility={look.visibility} />+ {look.draft && <SoftPill tone="warning">{t('journey.entry.draft')}</SoftPill>}+ <MoodMark id={look.mood} />+ <WeatherMark weather={look.weather} />+ {look.photoCount > 1 && (+ <SoftPill icon={<Images size={10} strokeWidth={2.2} aria-hidden="true" className={ICON} />}>+ {t('assistant.card.journey.photos', { count: look.photoCount })}+ </SoftPill>+ )}+ </CardFacts>+ );+}++/** The start of the entry's text, two lines where room is short, three where there is room. */+export function EntryStory({ look, roomy }: { look: JourneyEntryLook; roomy: boolean }) {+ if (!look.story) return null;+ return <p className={roomy ? STORY.roomy : STORY.compact}>{look.story}</p>;+}diff --git a/client/src/components/Assistant/cards/journey/journeyCardModel.test.ts b/client/src/components/Assistant/cards/journey/journeyCardModel.test.tsnew file mode 100644index 000000000..60e2f07e1--- /dev/null+++ b/client/src/components/Assistant/cards/journey/journeyCardModel.test.ts@@ -0,0 +1,175 @@+/**+ * FE-AI-JOURNEY-MODEL-001 to FE-AI-JOURNEY-MODEL-009+ *+ * The pure side of the journal's cards: where an entry opens, how the cards+ * of one answer about one journal merge, how an entry reads to the journal's+ * own tile, the mood and weather names, and the journal's look in the chat:+ * its verbs, tools, steps, what an applied entry opens, its grouping and the+ * lookup that gives way to the change it served.+ */+import type { AssistantApplied, JourneyEntriesCard, JourneyEntryLook, TrekCard } from '@trek/shared';+import { describe, expect, it } from 'vitest';++import { CARD_RULES, ENTITY_LOOK, STEP_LOOKS, TOOL_LABELS, VERB_LOOK } from '../cardLooks';+import { coverEntryOf, journalTarget, mergeJournalCards } from './journeyCardModel';+import { flagOf, moodOf, stateOf, weatherOf } from './journeyTones';+import { JOURNEY_LOOK } from './journeyLook';++function look(over: Partial<JourneyEntryLook> = {}): JourneyEntryLook {+ return {+ entryId: 12,+ type: 'entry',+ title: 'Sunset',+ date: '2026-10-21',+ time: null,+ place: 'Berlin',+ point: null,+ countryCode: 'DE',+ story: null,+ mood: null,+ weather: null,+ photoId: null,+ video: false,+ photoCount: 0,+ visibility: 'private',+ draft: false,+ fromTripPlace: false,+ dayIndex: null,+ ...over,+ };+}++function card(entries: JourneyEntryLook[], over: Partial<JourneyEntriesCard> = {}): JourneyEntriesCard {+ return {+ kind: 'journeyEntries',+ journeyId: 3,+ journalTitle: null,+ tripJournal: false,+ change: 'none',+ entries,+ more: 0,+ ...over,+ };+}++describe('journeyCardModel', () => {+ it('FE-AI-JOURNEY-MODEL-001: an entry opens in the Journal tab of the trip that shows it, else on the journal page', () => {+ expect(journalTarget(3, 12, true)).toEqual({ kind: 'tab', tab: 'journal', params: { entry: '12' } });+ expect(journalTarget(3, null, true)).toEqual({ kind: 'tab', tab: 'journal' });+ expect(journalTarget(3, 12, false)).toEqual({ kind: 'page', path: '/journey/3?entry=12' });+ expect(journalTarget(3, null, false)).toEqual({ kind: 'page', path: '/journey/3' });+ });++ it('FE-AI-JOURNEY-MODEL-002: the reads of one journal merge: each entry once, the later read winning, by day', () => {+ const later = look({ entryId: 2, date: '2026-10-22', title: 'Later' });+ const merged = mergeJournalCards([+ { toolCallId: 'a', card: card([look({ entryId: 2, date: '2026-10-22' }), look({ entryId: 1 })], { more: 4 }) },+ { toolCallId: 'b', card: card([later], { journalTitle: 'B' }) },+ { toolCallId: 'c', card: card([look({ entryId: null, date: '2026-10-20' })], { tripJournal: true }) },+ ]);+ expect(merged?.entries.map((e) => e.entryId)).toEqual([null, 1, 2]);+ expect(merged?.entries[2]?.title).toBe('Later');+ expect(merged).toMatchObject({ journeyId: 3, journalTitle: 'B', tripJournal: true, more: 4 });+ expect(mergeJournalCards([{ toolCallId: 'x', card: { kind: 'tourList' } as TrekCard }])).toBeNull();+ });++ it("FE-AI-JOURNEY-MODEL-003: an entry reads to the journal's tile with its photo, never one without a picture", () => {+ expect(coverEntryOf(look({ photoId: 7, video: true }))).toMatchObject({+ id: 12,+ entry_date: '2026-10-21',+ location_name: 'Berlin',+ country_code: 'DE',+ photos: [{ photo_id: 7, media_type: 'video' }],+ });+ expect(coverEntryOf(look({ entryId: null })).photos).toEqual([]);+ });++ it('FE-AI-JOURNEY-MODEL-004: moods and weathers read as the journal draws them, anything else as nothing', () => {+ expect(moodOf('amazing')).toMatchObject({ labelKey: 'journey.mood.amazing', color: 'var(--mood-amazing)' });+ // Neither journal editor writes "tired"; the journal shows no mood for it.+ expect(moodOf('tired')).toBeNull();+ // `cold` is the id the journal stores for snow.+ expect(weatherOf('cold')?.labelKey).toBe('journey.weather.cold');+ expect(weatherOf('sunny')?.labelKey).toBe('journey.weather.sunny');+ expect(weatherOf('drizzle at noon')).toBeNull();+ expect(moodOf('toString')).toBeNull();+ expect(moodOf(null)).toBeNull();+ });++ it('FE-AI-JOURNEY-MODEL-009: the states an update sets are named by field, flags by on and off', () => {+ expect(stateOf('visibility', 'public')?.labelKey).toBe('journey.visibility.public');+ expect(stateOf('type', 'skeleton')?.labelKey).toBe('journey.entry.suggestion');+ expect(stateOf('mood', 'good')?.labelKey).toBe('journey.mood.good');+ expect(stateOf('weather', 'cold')?.labelKey).toBe('journey.weather.cold');+ expect(stateOf('weather', 'Drizzle')).toBeNull();+ expect(stateOf('visibility', 'toString')).toBeNull();+ expect(stateOf(undefined, 'public')).toBeNull();+ expect(flagOf('is_draft', '✓')?.labelKey).toBe('journey.entry.draft');+ expect(flagOf('is_draft', '✗')?.labelKey).toBe('assistant.card.journey.notDraft');+ expect(flagOf('dismissed', '✗')?.labelKey).toBe('assistant.card.journey.restored');+ expect(flagOf('stats_excluded', '✓')?.labelKey).toBe('journey.editor.statsExcluded');+ expect(flagOf('visibility', '✓')).toBeNull();+ });++ it('FE-AI-JOURNEY-MODEL-005: the journal names its verbs, tools and reading steps in the merged look', () => {+ expect(VERB_LOOK.addJournalEntry.labelKey).toBe('assistant.change.verb.addJournalEntry');+ expect(VERB_LOOK.removeJournalEntry.tone).toBe('danger');+ expect(TOOL_LABELS.link_trip_journal?.labelKey).toBe('assistant.tool.link_trip_journal');+ expect(STEP_LOOKS.list_journey_entries?.stepKey).toBe('assistant.step.readingJournal');+ expect(JOURNEY_LOOK.cards.journeyEntries.followUps.find((f) => f.edits)?.id).toBe('journalToday');+ });++ it('FE-AI-JOURNEY-MODEL-006: an applied entry opens where its card says; reads group per journal and yield to its change', () => {+ const applied: AssistantApplied = {+ toolCallId: 'w',+ entity: 'journey_entry',+ ids: [40],+ dayId: null,+ undoUntil: null,+ };+ const entity = ENTITY_LOOK.journey_entry;+ expect(entity.onMap).toBeUndefined();+ expect(entity.open?.(applied, card([look()], { tripJournal: true }))).toEqual({+ kind: 'tab',+ tab: 'journal',+ params: { entry: '40' },+ });+ const fromCard = entity.open?.({ ...applied, ids: [] }, card([look()]));+ expect(fromCard).toEqual({ kind: 'page', path: '/journey/3?entry=12' });+ expect(entity.open?.(applied, null)).toBeNull();++ const read = card([look()]);+ expect(CARD_RULES.group(read)).toBe('journey:3');+ expect(CARD_RULES.yieldsToChange(read, card([look()], { change: 'changed' }))).toBe(true);+ expect(CARD_RULES.yieldsToChange(read, card([look()], { journeyId: 9, change: 'changed' }))).toBe(false);+ expect(CARD_RULES.yieldsToChange(read, { kind: 'tourList' } as TrekCard)).toBe(false);+ });++ it('FE-AI-JOURNEY-MODEL-007: a list answer stays beside a change that touches only part of it, or writes a new entry', () => {+ const list = card([look({ entryId: 1 }), look({ entryId: 2, date: '2026-10-22' })]);+ expect(CARD_RULES.yieldsToChange(list, card([look({ entryId: null })], { change: 'new' }))).toBe(false);+ expect(CARD_RULES.yieldsToChange(list, card([look({ entryId: 2 })], { change: 'changed' }))).toBe(false);+ const lookup = card([look({ entryId: 2 })]);+ expect(CARD_RULES.yieldsToChange(lookup, card([look({ entryId: 2 })], { change: 'willDelete' }))).toBe(true);+ expect(CARD_RULES.yieldsToChange(card([]), card([look()], { change: 'changed' }))).toBe(false);+ });++ it('FE-AI-JOURNEY-MODEL-008: merged reads count their days over the whole card, a lone entry read included', () => {+ const merged = mergeJournalCards([+ {+ toolCallId: 'a',+ card: card([+ look({ entryId: 1, date: '2026-10-20', dayIndex: 0 }),+ look({ entryId: 2, date: '2026-10-22', dayIndex: 1 }),+ ]),+ },+ { toolCallId: 'b', card: card([look({ entryId: 2, date: '2026-10-22', dayIndex: null })]) },+ { toolCallId: 'c', card: card([look({ entryId: 3, date: '2026-10-21', dayIndex: 0 })]) },+ ]);+ expect(merged?.entries.map((e) => [e.entryId, e.dayIndex])).toEqual([+ [1, 0],+ [3, 1],+ [2, 2],+ ]);+ });+});diff --git a/client/src/components/Assistant/cards/journey/journeyCardModel.ts b/client/src/components/Assistant/cards/journey/journeyCardModel.tsnew file mode 100644index 000000000..90287f224--- /dev/null+++ b/client/src/components/Assistant/cards/journey/journeyCardModel.ts@@ -0,0 +1,95 @@+import type { JourneyEntryLook } from '@trek/shared';++import type { CoverEntry } from '../../../Journey/JourneyEntryCover';+import type { CardEntry, EntityTarget } from '../cardTypes';++/**+ * The pure side of the journal's cards: where an entry opens, how the cards+ * of one answer about one journal become one, and how an entry looks to the+ * journal's own tile.+ */++/**+ * Where an entry opens: the trip's own Journal tab when the journal is the+ * one the trip shows, else the journal's page, at that entry either way.+ */+export function journalTarget(journeyId: number, entryId: number | null, inTrip: boolean): EntityTarget {+ const entry = entryId === null ? null : String(entryId);+ if (inTrip) return { kind: 'tab', tab: 'journal', ...(entry === null ? {} : { params: { entry } }) };+ return { kind: 'page', path: entry === null ? `/journey/${journeyId}` : `/journey/${journeyId}?entry=${entry}` };+}++/** The cards of one journal in one answer, drawn as one. */+export interface JournalEntries {+ journeyId: number;+ journalTitle: string | null;+ tripJournal: boolean;+ entries: JourneyEntryLook[];+ more: number;+}++/** By day; the sort is stable, so a day keeps the order its read gave it (the journal's own). */+function byDay(a: JourneyEntryLook, b: JourneyEntryLook): number {+ if (a.date === b.date) return 0;+ return a.date < b.date ? -1 : 1;+}++/**+ * The entries with their day counted again over all of them: each read counts+ * its own days, and a lone entry's read counts none, so one card colours a+ * day the same wherever its entries came from.+ */+function withDays(entries: readonly JourneyEntryLook[]): JourneyEntryLook[] {+ const days = [...new Set(entries.map((look) => look.date))];+ return entries.map((look) => ({ ...look, dayIndex: days.indexOf(look.date) }));+}++/**+ * The cards of one answer about one journal as one: every entry once (a+ * later read of an entry wins), in the journal's order, its days counted over+ * the whole card, the most a read left out kept as `more`. Null when none is a+ * journal card.+ */+export function mergeJournalCards(cards: readonly CardEntry[]): JournalEntries | null {+ const own = cards.flatMap((entry) => (entry.card.kind === 'journeyEntries' ? [entry.card] : []));+ const first = own[0];+ if (!first) return null;+ const byId = new Map<string, JourneyEntryLook>();+ own.forEach((card, cardIndex) => {+ card.entries.forEach((look, index) => {+ byId.set(look.entryId === null ? `new-${cardIndex}-${index}` : String(look.entryId), look);+ });+ });+ return {+ journeyId: first.journeyId,+ journalTitle: own.map((card) => card.journalTitle).find((title) => title !== null) ?? null,+ tripJournal: own.some((card) => card.tripJournal),+ entries: withDays([...byId.values()].sort(byDay)),+ more: Math.max(0, ...own.map((card) => card.more)),+ };+}++/** An entry as the journal's own tile reads it. */+export function coverEntryOf(look: JourneyEntryLook): CoverEntry {+ return {+ id: look.entryId ?? 0,+ type: look.type,+ title: look.title,+ story: look.story,+ location_name: look.place,+ location_lat: look.point?.lat ?? null,+ location_lng: look.point?.lng ?? null,+ country_code: look.countryCode,+ entry_date: look.date,+ entry_time: look.time,+ mood: look.mood,+ weather: look.weather,+ // The server picked a photo that has a picture, so no clip here lacks its poster.+ photos: look.photoId === null ? [] : [{ photo_id: look.photoId, media_type: look.video ? 'video' : 'image' }],+ };+}++/** What `cardTitle` reads of an entry. */+export function titleSourceOf(look: JourneyEntryLook): Pick<CoverEntry, 'title' | 'type' | 'location_name'> {+ return { title: look.title, type: look.type, location_name: look.place };+}diff --git a/client/src/components/Assistant/cards/journey/journeyLook.ts b/client/src/components/Assistant/cards/journey/journeyLook.tsindex 928a58c50..4337dbe00 100644--- a/client/src/components/Assistant/cards/journey/journeyLook.ts+++ b/client/src/components/Assistant/cards/journey/journeyLook.ts@@ -1,18 +1,63 @@+import { BookOpen, BookOpenText, BookPlus, BookX } from 'lucide-react';+import type { PackLook } from '../cardTypes';+import { journalTarget } from './journeyCardModel';/*** What the journeys bring to the chat's pure look: the verbs, tool names and* steps they add, what an applied change of theirs opens, and the look of each- * of their kinds. Empty until the journey cards fill it. A look stays pure,- * icons and literals only: the chat's main chunk reads every look, so whatever- * a look imports ships with it.+ * of their kinds. A look stays pure, icons and literals only: the chat's main+ * chunk reads every look, so whatever a look imports ships with it.+ *+ * An applied entry opens in the journal: in the trip's Journal tab when the+ * card saw that the trip shows this journal, else on the journal's page.*/export const JOURNEY_LOOK = {- verbs: {},- tools: {},- steps: {},- entities: {},+ verbs: {+ addJournalEntry: { Icon: BookPlus, tone: 'success', labelKey: 'assistant.change.verb.addJournalEntry' },+ updateJournalEntry: { Icon: BookOpenText, tone: 'info', labelKey: 'assistant.change.verb.updateJournalEntry' },+ removeJournalEntry: { Icon: BookX, tone: 'danger', labelKey: 'assistant.change.verb.removeJournalEntry' },+ },+ tools: {+ create_journey: { labelKey: 'assistant.tool.create_journey' },+ update_journey: { labelKey: 'assistant.tool.update_journey' },+ add_journey_trip: { labelKey: 'assistant.tool.add_journey_trip' },+ link_trip_journal: { labelKey: 'assistant.tool.link_trip_journal' },+ reorder_journey_entries: { labelKey: 'assistant.tool.reorder_journey_entries' },+ },+ steps: {+ get_trip_journal: { stepKey: 'assistant.step.readingJournal' },+ list_journey_entries: { stepKey: 'assistant.step.readingJournal' },+ get_journey: { stepKey: 'assistant.step.readingJournal' },+ get_journey_entry: { stepKey: 'assistant.step.readingJournal' },+ },+ entities: {+ journey_entry: {+ Icon: BookOpen,+ openLabelKey: 'assistant.card.journey.open',+ open: (applied, card) =>+ card?.kind === 'journeyEntries'+ ? journalTarget(card.journeyId, applied.ids[0] ?? card.entries[0]?.entryId ?? null, card.tripJournal)+ : null,+ },+ },cards: {- journeyEntries: {},+ journeyEntries: {+ entity: () => 'journey_entry',+ followUps: [+ { id: 'journalToday', labelKey: 'assistant.followUp.journalToday', edits: true },+ { id: 'journalSummary', labelKey: 'assistant.followUp.journalSummary' },+ ],+ // The reads of one journal in one answer draw as one card.+ group: (card) => `journey:${card.journeyId}`,+ // A read that looked up an entry gives way to the change it served: the change shows the entry already.+ // A read holding entries the change leaves alone stays, and a new entry has no read to replace.+ yieldsToChange: (answer, change) => {+ if (change.kind !== 'journeyEntries' || change.journeyId !== answer.journeyId) return false;+ const touched = new Set(change.entries.flatMap((look) => (look.entryId === null ? [] : [look.entryId])));+ const readIds = answer.entries.map((read) => read.entryId);+ return readIds.length > 0 && readIds.every((id) => id !== null && touched.has(id));+ },+ },},} satisfies PackLook<'journeyEntries'>;diff --git a/client/src/components/Assistant/cards/journey/journeyTones.ts b/client/src/components/Assistant/cards/journey/journeyTones.tsnew file mode 100644index 000000000..2f18f5814--- /dev/null+++ b/client/src/components/Assistant/cards/journey/journeyTones.ts@@ -0,0 +1,125 @@+import {+ BookOpenText,+ Cloud,+ CloudLightning,+ CloudRain,+ CloudSun,+ Eye,+ EyeOff,+ Frown,+ Globe,+ Lock,+ type LucideIcon,+ MapPinCheck,+ Meh,+ PenLine,+ Route,+ Smile,+ SmilePlus,+ Snowflake,+ Sparkles,+ Sun,+ Users,+} from 'lucide-react';++/**+ * How the states of a journal entry read in the chat, the way the journal+ * draws them: its moods with the glyphs of its tiles, its weathers, and the+ * words for what an update sets beyond the text (who sees the entry, its+ * kind, a draft, the route, a waved-away suggestion).+ */++/** How a state is drawn: its glyph and the key of its name. */+interface EntryTone {+ Icon: LucideIcon;+ labelKey: string;+}++/**+ * The four moods the journal's editors write, with the glyphs its tiles draw+ * them in; the colour is the theme's mood token of the same name. Any other+ * id is left out, the way the journal leaves it out.+ */+const MOODS: Readonly<Record<string, EntryTone & { color: string }>> = {+ amazing: { Icon: SmilePlus, labelKey: 'journey.mood.amazing', color: 'var(--mood-amazing)' },+ good: { Icon: Smile, labelKey: 'journey.mood.good', color: 'var(--mood-good)' },+ neutral: { Icon: Meh, labelKey: 'journey.mood.neutral', color: 'var(--mood-neutral)' },+ rough: { Icon: Frown, labelKey: 'journey.mood.rough', color: 'var(--mood-rough)' },+};++/** The six weathers the journal offers. `cold` is the id it stores for snow, and its name says so. */+const WEATHERS: Readonly<Record<string, EntryTone>> = {+ sunny: { Icon: Sun, labelKey: 'journey.weather.sunny' },+ partly: { Icon: CloudSun, labelKey: 'journey.weather.partly' },+ cloudy: { Icon: Cloud, labelKey: 'journey.weather.cloudy' },+ rainy: { Icon: CloudRain, labelKey: 'journey.weather.rainy' },+ stormy: { Icon: CloudLightning, labelKey: 'journey.weather.stormy' },+ cold: { Icon: Snowflake, labelKey: 'journey.weather.cold' },+};++const VISIBILITIES: Readonly<Record<string, EntryTone>> = {+ private: { Icon: Lock, labelKey: 'journey.visibility.private' },+ shared: { Icon: Users, labelKey: 'journey.visibility.shared' },+ public: { Icon: Globe, labelKey: 'journey.visibility.public' },+};++const TYPES: Readonly<Record<string, EntryTone>> = {+ entry: { Icon: BookOpenText, labelKey: 'assistant.card.journey.typeEntry' },+ checkin: { Icon: MapPinCheck, labelKey: 'assistant.card.journey.typeCheckin' },+ skeleton: { Icon: Sparkles, labelKey: 'journey.entry.suggestion' },+};++/** The flags an update sets, each by what it reads as when on (✓) and when off (✗). */+const FLAGS: Readonly<Record<string, { on: EntryTone; off: EntryTone }>> = {+ is_draft: {+ on: { Icon: PenLine, labelKey: 'journey.entry.draft' },+ off: { Icon: PenLine, labelKey: 'assistant.card.journey.notDraft' },+ },+ stats_excluded: {+ on: { Icon: Route, labelKey: 'journey.editor.statsExcluded' },+ off: { Icon: Route, labelKey: 'assistant.card.journey.onRoute' },+ },+ dismissed: {+ on: { Icon: EyeOff, labelKey: 'journey.suggestions.dismissed' },+ off: { Icon: Eye, labelKey: 'assistant.card.journey.restored' },+ },+};++/** How a flag comes on a change row, the way the server writes a boolean. */+const FLAG_ON = '✓';++/** An own entry of a table only, so `toString` and the like name nothing. */+function own<T>(table: Readonly<Record<string, T>>, id: string | null | undefined): T | null {+ if (!id || !Object.prototype.hasOwnProperty.call(table, id)) return null;+ return table[id] ?? null;+}++/** A mood the journal knows; null for any other. */+export function moodOf(id: string | null): (EntryTone & { color: string }) | null {+ return own(MOODS, id);+}++/** A weather the journal offers; null for a free word the traveller wrote. */+export function weatherOf(id: string | null): EntryTone | null {+ return own(WEATHERS, id);+}++/** A flag of a change row: what it reads as now; null for a field that is no flag. */+export function flagOf(field: string | undefined, value: string): EntryTone | null {+ const flag = own(FLAGS, field);+ if (!flag) return null;+ return value === FLAG_ON ? flag.on : flag.off;+}++/**+ * A state of a change row by the field it sets (the tool's own name) and a+ * value as stored: its glyph and name, or null where the card has no name for+ * it (a weather the traveller wrote in their words, which reads as it is).+ */+export function stateOf(field: string | undefined, value: string | null): EntryTone | null {+ if (field === 'mood') return moodOf(value);+ if (field === 'weather') return weatherOf(value);+ if (field === 'visibility') return own(VISIBILITIES, value);+ if (field === 'type') return own(TYPES, value);+ return null;+}diff --git a/client/src/components/Assistant/cards/journey/journeyViews.tsx b/client/src/components/Assistant/cards/journey/journeyViews.tsxindex c6641bc97..2466c2ab9 100644--- a/client/src/components/Assistant/cards/journey/journeyViews.tsx+++ b/client/src/components/Assistant/cards/journey/journeyViews.tsx@@ -1,12 +1,21 @@-import { type CardView, PENDING_VIEW } from '../cardTypes';+import type { CardView } from '../cardTypes';+import { JourneyEntryAside, JourneyEntryBody, JourneyEntryFacts } from './JourneyChangeSlots';+import JourneyEntriesBlock from './JourneyEntriesBlock';/**- * How the kinds of the journeys draw in the chat; each one draws nothing until- * its cards are built. This file only maps each kind to its view: the- * components live in sibling files, since a file that exports anything besides- * components breaks fast refresh, and lint:warnings holds+ * How the kinds of the journeys draw in the chat: the entries a read found+ * as a block of their own, and a change row of an entry with its photo beside+ * the subject, its day, time and place and whatever an update changes on the+ * faint line, and the start of its text under it. This file only maps each+ * kind to its view: the components live in sibling files, since a file that+ * exports anything besides components breaks fast refresh, and lint:warnings holds* react-refresh/only-export-components at zero for a new file.*/export const JOURNEY_VIEWS = {- journeyEntries: PENDING_VIEW,+ journeyEntries: {+ Block: JourneyEntriesBlock,+ Aside: JourneyEntryAside,+ Facts: JourneyEntryFacts,+ Body: JourneyEntryBody,+ },} satisfies { [K in 'journeyEntries']: CardView<K> };diff --git a/client/src/components/Assistant/cards/journey/useEntryHover.ts b/client/src/components/Assistant/cards/journey/useEntryHover.tsnew file mode 100644index 000000000..cedfec295--- /dev/null+++ b/client/src/components/Assistant/cards/journey/useEntryHover.ts@@ -0,0 +1,41 @@+import type { JourneyEntryLook } from '@trek/shared';++import { useTranslation } from '../../../../i18n';+import { cardTitle } from '../../../Journey/journeyCard';+import { useCardPoint } from '../parts/useCardPoint';+import { titleSourceOf } from './journeyCardModel';++/** Shows an entry on the plan's map, or takes it away (null). */+export type EntryHover = (look: JourneyEntryLook | null) => void;++/**+ * The way a card's entries show on the map while the pointer rests on one or+ * the keyboard is on it: a pin under the entry's own key; nothing for one+ * without a place. The pin goes when the card does.+ */+export function useEntryHover(journeyId: number, fallbackRef: string): EntryHover {+ const { t } = useTranslation();+ const point = useCardPoint();+ return (look) => {+ if (!look?.point) {+ point.hover(null);+ return;+ }+ point.hover({+ ref: `journey:${journeyId}:${look.entryId ?? fallbackRef}`,+ lat: look.point.lat,+ lng: look.point.lng,+ name: cardTitle(titleSourceOf(look), t),+ });+ };+}++/** What an element standing for one entry listens to: the pointer resting on it and the focus inside it. */+export function entryHoverProps(hover: EntryHover, look: JourneyEntryLook) {+ return {+ onMouseEnter: () => hover(look),+ onMouseLeave: () => hover(null),+ onFocus: () => hover(look),+ onBlur: () => hover(null),+ };+}diff --git a/client/src/components/Assistant/cards/journey/useJourneyOpen.ts b/client/src/components/Assistant/cards/journey/useJourneyOpen.tsnew file mode 100644index 000000000..a1db87216--- /dev/null+++ b/client/src/components/Assistant/cards/journey/useJourneyOpen.ts@@ -0,0 +1,19 @@+import { useTripJournalLinkStore } from '../../../../store/tripJournalLinkStore';+import { useAssistantView } from '../../assistantViewContext';+import { journalTarget } from './journeyCardModel';++/**+ * Opens an entry of a journal from a card, decided when it is clicked: in the+ * trip's Journal tab when the trip shows this journal (as the card saw it, or+ * as the trip's journal link says now), else on the journal's page. Null where+ * the shell around the chat cannot open anything.+ */+export function useJourneyOpen(journeyId: number, tripJournal: boolean): ((entryId: number | null) => void) | null {+ const { tripId, onOpen } = useAssistantView();+ const shown = useTripJournalLinkStore((s) => {+ const link = s.byTrip[String(tripId)]?.link;+ return !!link && link.my_role !== null && link.journey_id === journeyId;+ });+ if (!onOpen) return null;+ return (entryId) => onOpen(journalTarget(journeyId, entryId, tripJournal || shown));+}diff --git a/client/src/components/Journey/stripMarkdown.test.ts b/client/src/components/Journey/stripMarkdown.test.tsdeleted file mode 100644index d932c06df..000000000--- a/client/src/components/Journey/stripMarkdown.test.ts+++ /dev/null@@ -1,38 +0,0 @@-// FE-UTIL-STRIPMD-001 to FE-UTIL-STRIPMD-006--import { describe, it, expect } from 'vitest';-import { stripMarkdown } from './stripMarkdown';--describe('stripMarkdown', () => {- it('FE-UTIL-STRIPMD-001: strips bold and italic formatting', () => {- expect(stripMarkdown('**bold** and _italic_')).toBe('bold and italic');- expect(stripMarkdown('__also bold__ and *also italic*')).toBe('also bold and also italic');- });-- it('FE-UTIL-STRIPMD-002: strips headings', () => {- expect(stripMarkdown('# Heading 1')).toBe('Heading 1');- expect(stripMarkdown('## Heading 2')).toBe('Heading 2');- expect(stripMarkdown('### Heading 3')).toBe('Heading 3');- });-- it('FE-UTIL-STRIPMD-003: converts links to text and removes images', () => {- expect(stripMarkdown('[click here](https://example.com)')).toBe('click here');- expect(stripMarkdown('')).toBe('');- });-- it('FE-UTIL-STRIPMD-004: strips code blocks and inline code', () => {- expect(stripMarkdown('use `console.log`')).toBe('use console.log');- expect(stripMarkdown('```\ncode block\n```')).toBe('');- });-- it('FE-UTIL-STRIPMD-005: strips blockquotes and lists', () => {- expect(stripMarkdown('> quoted text')).toBe('quoted text');- expect(stripMarkdown('- item one')).toBe('item one');- expect(stripMarkdown('1. first item')).toBe('first item');- });-- it('FE-UTIL-STRIPMD-006: strips strikethrough and horizontal rules', () => {- expect(stripMarkdown('~~deleted~~')).toBe('deleted');- expect(stripMarkdown('---')).toBe('');- });-});diff --git a/client/src/pages/journeyDetail/useJourneyDetail.test.tsx b/client/src/pages/journeyDetail/useJourneyDetail.test.tsxindex 818788be7..c3533d3e4 100644--- a/client/src/pages/journeyDetail/useJourneyDetail.test.tsx+++ b/client/src/pages/journeyDetail/useJourneyDetail.test.tsx@@ -1,6 +1,6 @@-// FE-JRN-DETHOOK-001 to FE-JRN-DETHOOK-032+// FE-JRN-DETHOOK-001 to FE-JRN-DETHOOK-039import { describe, it, expect, beforeEach, afterEach, vi, type Mock } from 'vitest';-import { useLocation } from 'react-router';+import { useLocation, useSearchParams } from 'react-router';import { delay, http, HttpResponse } from 'msw';import { server } from '../../../tests/helpers/msw/server';import { act, render, screen, fireEvent, waitFor } from '../../../tests/helpers/render';@@ -91,9 +91,12 @@ function Harness({ renderEntries = true }: { renderEntries?: boolean }) {const state = useJourneyDetail();latest = state;const location = useLocation();+ const [, setSearchParams] = useSearchParams();return (<div><span data-testid="search">{location.search}</span>+ {/* A link into the open journal, the way the assistant chat's "Open in the journal" sends one. */}+ <button type="button" data-testid="relink" onClick={() => setSearchParams({ entry: '2' })} /><div ref={state.feedRef} data-testid="feed">{renderEntries && (state.current?.entries ?? []).map(e => (<div key={e.id} data-entry-id={String(e.id)} data-testid={`entry-${e.id}`}>{e.title}</div>@@ -260,6 +263,126 @@ describe('useJourneyDetail', () => {expect(reads).not.toHaveBeenCalled();});+ it('FE-JRN-DETHOOK-037: photo book saves and presence frames do not read the journey again', async () => {+ setup();+ await waitFor(() => expect(latest.current).not.toBeNull());+ const handler = vi.mocked(addListener).mock.calls[0][0] as (e: Record<string, unknown>) => void;+ const reads = vi.fn();+ server.use(http.get('/api/journeys/7', () => {+ reads();+ return HttpResponse.json(buildDetail());+ }));++ handler({ type: 'journey:book:saved', journeyId: 7, version: 3, savedBy: 2 });+ handler({ type: 'journey:book:peers', journeyId: 7, peers: [] });+ handler({ type: 'journey:book:cursor', journeyId: 7, x: 1, y: 2, spreadIndex: 0 });+ await new Promise(r => setTimeout(r, 20));+ expect(reads).not.toHaveBeenCalled();+ });++ it('FE-JRN-DETHOOK-038: a burst of changes while a reload is open reads the journey once more, not once per event', async () => {+ setup();+ await waitFor(() => expect(latest.current).not.toBeNull());+ const handler = vi.mocked(addListener).mock.calls[0][0] as (e: Record<string, unknown>) => void;+ const reads = vi.fn();+ server.use(http.get('/api/journeys/7', async () => {+ reads();+ await delay(30);+ return HttpResponse.json(buildDetail({ title: 'After the burst' }));+ }));++ for (let i = 0; i < 5; i++) handler({ type: 'journey:entry:updated', journeyId: 7 });+ await waitFor(() => expect(reads).toHaveBeenCalledTimes(2));+ await waitFor(() => expect(latest.current?.title).toBe('After the burst'));+ await new Promise(r => setTimeout(r, 80));+ expect(reads).toHaveBeenCalledTimes(2);+ });++ it('FE-JRN-DETHOOK-039: a reload that fails keeps the journal shown and the next change reads it again', async () => {+ setup();+ await waitFor(() => expect(latest.current).not.toBeNull());+ const handler = vi.mocked(addListener).mock.calls[0][0] as (e: Record<string, unknown>) => void;+ let fail = true;+ const reads = vi.fn();+ server.use(http.get('/api/journeys/7', () => {+ reads();+ return fail+ ? HttpResponse.json({ error: 'boom' }, { status: 500 })+ : HttpResponse.json(buildDetail({ title: 'Back again' }));+ }));++ handler({ type: 'journey:entry:updated', journeyId: 7 });+ await waitFor(() => expect(reads).toHaveBeenCalledTimes(1));+ await new Promise(r => setTimeout(r, 20));+ expect(latest.current?.title).toBe('Japan 2026');++ fail = false;+ handler({ type: 'journey:entry:updated', journeyId: 7 });+ await waitFor(() => expect(latest.current?.title).toBe('Back again'));+ });++ it('FE-JRN-DETHOOK-033: ?entry= opens the journal at that entry, scrolls it in and leaves the URL', async () => {+ const scrolled = vi.fn();+ vi.spyOn(HTMLElement.prototype, 'scrollIntoView').mockImplementation(function (this: HTMLElement) {+ scrolled(this.getAttribute('data-entry-id'));+ });+ setup({ search: '?entry=2' });++ await waitFor(() => expect(latest.openAtEntryId).toBe('2'));+ await waitFor(() => expect(screen.getByTestId('search').textContent).toBe(''));+ await waitFor(() => expect(scrolled).toHaveBeenCalledWith('2'));+ expect(latest.activeEntryId).toBe('2');+ });++ it('FE-JRN-DETHOOK-034: an ?entry= this journal does not hold is dropped and opens it as usual', async () => {+ setup({ search: '?entry=99' });++ await waitFor(() => expect(latest.current).not.toBeNull());+ await waitFor(() => expect(screen.getByTestId('search').textContent).toBe(''));+ expect(latest.openAtEntryId).not.toBe('99');+ });++ it('FE-JRN-DETHOOK-035: a second link to the same entry, with the journal open already, scrolls to it again', async () => {+ const scrolled = vi.fn();+ vi.spyOn(HTMLElement.prototype, 'scrollIntoView').mockImplementation(function (this: HTMLElement) {+ scrolled(this.getAttribute('data-entry-id'));+ });+ setup({ search: '?entry=2' });+ await waitFor(() => expect(scrolled).toHaveBeenCalledTimes(1));+ await waitFor(() => expect(screen.getByTestId('search').textContent).toBe(''));++ fireEvent.click(screen.getByTestId('relink'));++ await waitFor(() => expect(scrolled).toHaveBeenCalledTimes(2));+ expect(scrolled).toHaveBeenLastCalledWith('2');+ await waitFor(() => expect(screen.getByTestId('search').textContent).toBe(''));+ });++ it('FE-JRN-DETHOOK-036: an entry added nearer today does not scroll the open journal again', async () => {+ const day = (offset: number) => {+ const d = new Date();+ d.setDate(d.getDate() + offset);+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;+ };+ const detail = buildDetail({+ entries: [buildEntry({ entry_date: day(-3) }), buildEntry({ id: 2, title: 'Kyoto', entry_date: day(2) })],+ });+ serveJourney(detail);+ const scrolled = vi.fn();+ vi.spyOn(HTMLElement.prototype, 'scrollIntoView').mockImplementation(function (this: HTMLElement) {+ scrolled(this.getAttribute('data-entry-id'));+ });+ setup();+ await waitFor(() => expect(scrolled).toHaveBeenCalledWith('1'));++ const added = buildEntry({ id: 3, title: 'Nara', entry_date: day(-1) });+ act(() => useJourneyStore.setState({ current: { ...detail, entries: [...detail.entries, added] } }));++ await waitFor(() => expect(latest.openAtEntryId).toBe('3'));+ await new Promise(r => setTimeout(r, 450));+ expect(scrolled).toHaveBeenCalledTimes(1);+ });+it('FE-JRN-DETHOOK-010: the websocket listener is detached on unmount', async () => {const { unmount } = setup();await waitFor(() => expect(addListener).toHaveBeenCalled());diff --git a/client/src/pages/journeyDetail/useJourneyDetail.ts b/client/src/pages/journeyDetail/useJourneyDetail.tsindex 6ccc6a27a..56ed72c6f 100644--- a/client/src/pages/journeyDetail/useJourneyDetail.ts+++ b/client/src/pages/journeyDetail/useJourneyDetail.ts@@ -87,6 +87,22 @@ export function useJourneyDetail({ journeyId, embedded = false }: JourneyDetailOsetSearchParams(p => { p.delete('create'); return p }, { replace: true })}}, [searchParams, current, canEditEntries])+ // A link into one entry (`?entry=<id>`, the assistant chat's "Open in the journal"):+ // kept here and dropped from the URL, so a reload does not repeat it. It wins over+ // today below for as long as this journal holds that entry. Every link counts+ // apart (`seq`), so a second click on the same entry scrolls to it again.+ const requestedEntry = searchParams.get('entry')+ const [entryLink, setEntryLink] = useState(requestedEntry === null ? null : { id: requestedEntry, seq: 1 })+ const [seenEntryParam, setSeenEntryParam] = useState(requestedEntry)+ if (requestedEntry !== seenEntryParam) {+ setSeenEntryParam(requestedEntry)+ if (requestedEntry !== null) setEntryLink(link => ({ id: requestedEntry, seq: (link?.seq ?? 0) + 1 }))+ }+ const linkedEntryId = entryLink?.id ?? null+ useEffect(() => {+ if (requestedEntry === null) return+ setSearchParams(p => { p.delete('entry'); return p }, { replace: true })+ }, [requestedEntry, setSearchParams])const [unlinkTrip, setUnlinkTrip] = useState<{ trip_id: number; title: string } | null>(null)const [showSettings, setShowSettings] = useState(false)const [hideSkeletons, setHideSkeletons] = useState(false)@@ -119,10 +135,31 @@ export function useJourneyDetail({ journeyId, embedded = false }: JourneyDetailOuseEffect(() => {if (!id) returnconst journeyId = Number(id)+ // One read at a time: events that arrive while it is open ask for exactly+ // one more after it, so a burst of changes is two reads, not one per event.+ let live = true+ let reading = false+ let again = false+ const reload = () => {+ reading = true+ again = false+ // Also the failure path: a 404 has already become `notFound` in the store+ // (handled above), anything else keeps the journal as shown until the+ // next event reads it again.+ const settle = () => {+ reading = false+ if (again && live) reload()+ }+ void loadJourney(journeyId).then(settle, settle)+ }const handler = (event: Record<string, unknown>) => {const type = event.type as stringif (!type?.startsWith('journey:')) returnif (event.journeyId !== journeyId) return+ // The photo book has its own store in Studio (useBookStore), and its+ // presence frames come many times a second: none of them changes what+ // this page reads.+ if (type.startsWith('journey:book:')) return// Its owner deleted it elsewhere: there is nothing left to read again, so// the page goes back to the list (a journal shown inside a trip stays put).if (type === 'journey:deleted') {@@ -133,10 +170,17 @@ export function useJourneyDetail({ journeyId, embedded = false }: JourneyDetailOreturn}// reload journey data on any change from other contributors- loadJourney(journeyId)+ if (reading) {+ again = true+ return+ }+ reload()}addListener(handler)- return () => removeListener(handler)+ return () => {+ live = false+ removeListener(handler)+ }}, [id])// scroll sync with map — the sticky map on the right follows whichever@@ -454,6 +498,7 @@ export function useJourneyDetail({ journeyId, embedded = false }: JourneyDetailOconst openAtEntryId = useMemo(() => {const entries = current?.entries ?? []if (entries.length === 0) return null+ if (linkedEntryId !== null && entries.some(e => String(e.id) === linkedEntryId)) return linkedEntryIdconst dated = [...entries].sort((a, b) => a.entry_date.localeCompare(b.entry_date))const today = new Date()const todayKey = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`@@ -466,25 +511,29 @@ export function useJourneyDetail({ journeyId, embedded = false }: JourneyDetailO// from its beginning.const dayStart = dated.find(e => e.entry_date === target.entry_date) ?? targetreturn String(dayStart.id)- }, [current?.entries])+ }, [current?.entries, linkedEntryId])- // Desktop only: scroll it into the feed once per journey, after the list is up.+ // Desktop only: scroll it into the feed once per journey and once per link, after+ // the list is up, so a linked entry scrolls in even when the journal is open+ // already. Today's entry moving as entries come and go does not scroll again.// The scroll-sync primes at 300ms and would otherwise pick a winner from the top// of the feed and pin the map there.- const openedAtRef = useRef<number | null>(null)+ const openedAtRef = useRef<string | null>(null)+ const linkKey = entryLink && entryLink.id === openAtEntryId ? `${entryLink.id}#${entryLink.seq}` : ''useEffect(() => {if (isMobile || !current || view !== 'timeline') return- if (openedAtRef.current === current.id) return- if (!openAtEntryId) { openedAtRef.current = current.id; return }+ const openKey = `${current.id}:${linkKey}`+ if (openedAtRef.current === openKey) return+ if (!openAtEntryId) { openedAtRef.current = openKey; return }const timer = window.setTimeout(() => {const el = document.querySelector(`[data-entry-id="${openAtEntryId}"]`)if (!el) return- openedAtRef.current = current.id+ openedAtRef.current = openKeyel.scrollIntoView({ block: 'center' })setActiveEntryId(openAtEntryId)}, 350)return () => window.clearTimeout(timer)- }, [current, openAtEntryId, isMobile, view])+ }, [current, openAtEntryId, linkKey, isMobile, view])const locatedEntryIdsRef = useRef(new Set<string>())useEffect(() => {diff --git a/server/src/nest/assistant/cards/journey/index.ts b/server/src/nest/assistant/cards/journey/index.tsindex 97ab4e8a6..392c4a864 100644--- a/server/src/nest/assistant/cards/journey/index.ts+++ b/server/src/nest/assistant/cards/journey/index.ts@@ -1,4 +1,80 @@-import type { DomainCards } from '../card-types';+import type { DomainCards, ToolArgs, ToolCards } from '../card-types';+import { argId, idIn, recordOf } from '../card-values';+import {+ JOURNEY_DESCRIBERS,+ journalAppliedCard,+ journalChangeCard,+ loadJournal,+ type JournalLoaded,+} from './journey-change';+import { readCard } from './journey-look';+import { DELETE_CREATED_ENTRY } from './journey-undo';+import type { JourneyEntriesCard } from '@trek/shared';-/** The cards of the travel journal. None yet: this package fills them in. */-export const JOURNEY_CARDS: DomainCards = { id: 'journey', tools: {} };+/**+ * The travel journal in the assistant chat. A read of a journal's entries+ * shows them as a card beside the answer; a held write of an entry shows the+ * entry it will write, change or delete, and once applied the entry as it+ * was stored, its photo and country included. A created entry can be taken+ * back while nothing was written to it since.+ */++/** The entry a create or a change answered with, else the one a delete named. */+function entryIds(args: ToolArgs, result: unknown): number[] {+ const id = idIn(result, 'entry') ?? argId(args, 'entryId');+ return id === null ? [] : [id];+}++/**+ * The card of a read that answers `{ entries | entry, journey: { id, title } }`.+ * One entry read on its own has no day of the journal to colour it by.+ */+function readAnswer(journeyId: number | null, value: unknown, key: 'entries' | 'entry'): JourneyEntriesCard | null {+ const answer = recordOf(value);+ const title = recordOf(answer.journey).title;+ if (key === 'entry') return readCard(journeyId, title, [answer.entry], false);+ return readCard(journeyId, title, answer.entries);+}++/** A journal write's card entries: its words, its lookups, its card while held and once applied. */+function journalWrite(tool: string): ToolCards<JournalLoaded> {+ return {+ load: (args, read) => loadJournal(tool, args, read),+ change: (_ctx, args, loaded) => journalChangeCard(tool, args, loaded),+ applied: ({ result, preview }) => journalAppliedCard(tool, result, preview),+ appliedIds: entryIds,+ };+}++export const JOURNEY_CARDS: DomainCards = {+ id: 'journey',+ tools: {+ list_journey_entries: { answer: ({ args, value }) => readAnswer(argId(args, 'journeyId'), value, 'entries') },+ get_journey_entry: { answer: ({ value }) => readAnswer(idIn(value, 'journey'), value, 'entry') },+ get_journey: {+ answer: ({ value }) => {+ const journey = recordOf(recordOf(value).journey);+ return readCard(argId(journey, 'id'), journey.title, journey.entries);+ },+ },+ create_journey_entry: {+ write: { verbKey: 'addJournalEntry', entity: 'journey_entry' },+ describe: JOURNEY_DESCRIBERS.create_journey_entry,+ undo: DELETE_CREATED_ENTRY,+ ...journalWrite('create_journey_entry'),+ },+ update_journey_entry: {+ write: { verbKey: 'updateJournalEntry', entity: 'journey_entry' },+ describe: JOURNEY_DESCRIBERS.update_journey_entry,+ ...journalWrite('update_journey_entry'),+ },+ delete_journey_entry: {+ write: { verbKey: 'removeJournalEntry', entity: 'journey_entry' },+ describe: JOURNEY_DESCRIBERS.delete_journey_entry,+ ...journalWrite('delete_journey_entry'),+ },+ },+ prompt: [+ 'Journal: get_trip_journal finds the journal this trip shows. To show entries, call list_journey_entries with from/to for the days asked: the app draws them as cards, so do not list them again in your answer.',+ ],+};diff --git a/server/src/nest/assistant/cards/journey/journey-change.ts b/server/src/nest/assistant/cards/journey/journey-change.tsnew file mode 100644index 000000000..58493833e--- /dev/null+++ b/server/src/nest/assistant/cards/journey/journey-change.ts@@ -0,0 +1,214 @@+import type { CardReader, Described, PreviewContext, ToolArgs } from '../card-types';+import { argId, idIn, recordOf, type Row } from '../card-values';+import { formatDate, Rows, text } from '../preview-format';+import { entriesCard, lookOf } from './journey-look';+import {+ stripMarkdown,+ type AssistantChangePreview,+ type AssistantChangeRow,+ type JourneyEntriesCard,+} from '@trek/shared';++/**+ * The change cards of the journal entries an assistant writes, changes and+ * deletes: the words of the row (what the entry is about, its day, time,+ * place and the start of its text, before and after on a change) and the+ * card under it, built from the call's arguments over the entry as it stands.+ * A change does not touch the trip plan, so it names no day and no place.+ *+ * What an update sets beyond the words (who sees the entry, its mood and+ * weather, its kind, whether it is a draft, counts on the route or is waved+ * away) goes on `field` rows under the tool's own names, as stored ids and+ * flags as ✓ or ✗; the card names each in the user's words.+ */++/** What a held journal write looked up before its card is drawn. */+export interface JournalLoaded {+ /** The entry as it stands (a change or a delete); null for a new one. */+ entry: Row | null;+ journeyId: number | null;+ /** The journal's title, as stored. */+ title: unknown;+ /** The journal is the one the open trip shows in its Journal tab. */+ tripJournal: boolean;+}++/** The fields of an entry an update can set, by the names the tool and the row share. */+const ENTRY_FIELDS = [+ 'title',+ 'story',+ 'entry_date',+ 'entry_time',+ 'location_name',+ 'location_lat',+ 'location_lng',+ 'mood',+ 'weather',+ 'visibility',+ 'type',+ 'is_draft',+] as const;++/** The states of an entry an update can set, each a row of its own when it changes. */+const STATE_FIELDS = ['visibility', 'mood', 'weather', 'type', 'is_draft', 'stats_excluded', 'dismissed'] as const;+const FLAG_FIELDS: ReadonlySet<string> = new Set(['is_draft', 'stats_excluded', 'dismissed']);++/** The journal the open trip shows, as `get_trip_journal` answers. */+async function tripJournalOf(read: CardReader): Promise<{ journeyId: number | null; title: unknown }> {+ const link = recordOf(recordOf(await read('get_trip_journal')).link);+ return { journeyId: argId(link, 'journey_id'), title: link.title };+}++/**+ * What a journal write needs beyond its arguments: for a new entry the+ * journal's title (the trip's own journal, else the user's list), for a+ * change or a delete the entry as it stands. At most three reads. An update+ * that brings back a waved-away suggestion (`dismissed: false`) finds no+ * entry, since the read leaves dismissed ones out as the journal does: its+ * row then stands on its arguments alone, without a card.+ */+export async function loadJournal(tool: string, args: ToolArgs, read: CardReader): Promise<JournalLoaded | null> {+ const trip = await tripJournalOf(read);+ if (tool === 'create_journey_entry') {+ const journeyId = argId(args, 'journeyId');+ if (journeyId === null) return null;+ if (trip.journeyId === journeyId) return { entry: null, journeyId, title: trip.title, tripJournal: true };+ const journeys = recordOf(await read('list_journeys')).journeys;+ const own = Array.isArray(journeys) ? journeys.map(recordOf).find((row) => row.id === journeyId) : undefined;+ return { entry: null, journeyId, title: own?.title ?? null, tripJournal: false };+ }+ const entryId = argId(args, 'entryId');+ if (entryId === null) return null;+ const found = recordOf(await read('get_journey_entry', { entryId }));+ const journeyId = idIn(found, 'journey');+ if (journeyId === null) return null;+ return {+ entry: recordOf(found.entry),+ journeyId,+ title: recordOf(found.journey).title,+ tripJournal: trip.journeyId === journeyId,+ };+}++/** A story as a row shows it: its markdown taken off, cut like any value. */+function storyText(value: unknown): string {+ return typeof value === 'string' ? text(stripMarkdown(value)) : '';+}++/** What an entry is about: its title, else its place, else its day. */+function subjectOf(ctx: PreviewContext, row: Row): string {+ const day = typeof row.entry_date === 'string' ? formatDate(ctx, row.entry_date) : '';+ return text(row.title) || text(row.location_name) || day;+}++function dayText(ctx: PreviewContext, value: unknown): string {+ return typeof value === 'string' ? formatDate(ctx, value) : '';+}++function described(subject: string, rows: Rows): Described {+ return { subject, rows, dayId: null, placeIds: [], domain: 'journey' };+}++/** A state as its row writes it: a flag (stored 0 or 1, sent as a boolean) as ✓ or ✗, anything else as it is. */+function stateText(field: string, value: unknown): string {+ return FLAG_FIELDS.has(field) ? text(value === true || value === 1) : text(value);+}++/**+ * A row for each state the update sets to something other than what the entry+ * holds. A state the entry as read does not name has no before: that is the+ * case of a waved-away suggestion brought back, which the read never finds.+ */+function addStateRows(rows: Rows, before: Row, args: ToolArgs): void {+ for (const field of STATE_FIELDS) {+ if (!(field in args)) continue;+ const was = field in before ? stateText(field, before[field]) : '';+ const now = stateText(field, args[field]);+ if (was === now) continue;+ const row: AssistantChangeRow = { op: 'change', labelKey: 'field', field, before: was || null, after: now };+ rows.rows.push(row);+ }+}++/** The fields of the entry an update sets: those its arguments name, a null among them clearing one. */+function changedFields(args: ToolArgs): Array<(typeof ENTRY_FIELDS)[number]> {+ return ENTRY_FIELDS.filter((field) => field in args);+}++export const JOURNEY_DESCRIBERS = {+ create_journey_entry: (ctx: PreviewContext, args: ToolArgs): Described => {+ const rows = new Rows()+ .add('day', dayText(ctx, args.entry_date))+ .add('time', text(args.entry_time))+ .add('location', text(args.location_name))+ .add('text', storyText(args.story));+ return described(subjectOf(ctx, args), rows);+ },+ update_journey_entry: (ctx: PreviewContext, args: ToolArgs, loaded: JournalLoaded | null): Described => {+ const before: Row = loaded?.entry ?? {};+ const rows = new Rows();+ if ('title' in args) rows.change('name', text(before.title), text(args.title));+ if ('entry_date' in args) rows.change('day', dayText(ctx, before.entry_date), dayText(ctx, args.entry_date));+ if ('entry_time' in args) rows.change('time', text(before.entry_time), text(args.entry_time));+ if ('location_name' in args) rows.change('location', text(before.location_name), text(args.location_name));+ if ('story' in args) rows.change('text', storyText(before.story), storyText(args.story));+ addStateRows(rows, before, args);+ return described(subjectOf(ctx, { ...before, ...args }), rows);+ },+ delete_journey_entry: (ctx: PreviewContext, _args: ToolArgs, loaded: JournalLoaded | null): Described => {+ const entry: Row = loaded?.entry ?? {};+ const rows = new Rows().add('day', dayText(ctx, entry.entry_date)).add('location', text(entry.location_name));+ return described(subjectOf(ctx, entry), rows);+ },+};++/** The card under a held journal write: the entry it will write, change or delete. */+export function journalChangeCard(+ tool: string,+ args: ToolArgs,+ loaded: JournalLoaded | null,+): JourneyEntriesCard | null {+ if (!loaded) return null;+ const journal = { journeyId: loaded.journeyId, title: loaded.title, tripJournal: loaded.tripJournal };+ if (tool === 'create_journey_entry') {+ const row = { ...args, id: null, photos: [], is_draft: args.is_draft === true };+ const look = lookOf(row, { fromArgs: new Set(ENTRY_FIELDS) });+ return entriesCard({ ...journal, change: 'new' }, look ? [look] : [], 0);+ }+ if (!loaded.entry) return null;+ if (tool === 'update_journey_entry') {+ const set = changedFields(args);+ const row = { ...loaded.entry, ...Object.fromEntries(set.map((field) => [field, args[field]])) };+ const look = lookOf(row, { fromArgs: new Set(set) });+ return entriesCard({ ...journal, change: 'changed' }, look ? [look] : [], 0);+ }+ const look = lookOf(loaded.entry);+ return entriesCard({ ...journal, change: 'willDelete' }, look ? [look] : [], 0);+}++/**+ * The card of an applied write: the entry as the tool answered it, with its+ * photos and the country its place lies in, beside the journal the held card+ * named. A delete keeps its held card.+ */+export function journalAppliedCard(+ tool: string,+ result: unknown,+ preview: AssistantChangePreview | null,+): JourneyEntriesCard | null {+ if (tool === 'delete_journey_entry') return null;+ const entry = recordOf(recordOf(result).entry);+ const held = preview?.card?.kind === 'journeyEntries' ? preview.card : null;+ const look = lookOf(entry);+ const journeyId = argId(entry, 'journey_id') ?? held?.journeyId ?? null;+ return entriesCard(+ {+ journeyId,+ title: held?.journalTitle ?? null,+ tripJournal: held?.tripJournal ?? false,+ change: tool === 'create_journey_entry' ? 'new' : 'changed',+ },+ look ? [look] : [],+ 0,+ );+}diff --git a/server/src/nest/assistant/cards/journey/journey-look.ts b/server/src/nest/assistant/cards/journey/journey-look.tsnew file mode 100644index 000000000..5b7c766b3--- /dev/null+++ b/server/src/nest/assistant/cards/journey/journey-look.ts@@ -0,0 +1,174 @@+import { clipped, clockOf, finite, isLat, isLng, recordOf, type Row } from '../card-values';+import {+ compareCodeUnits,+ JOURNEY_CARD_LIMITS,+ journeyEntryTypeSchema,+ journeyEntryVisibilitySchema,+ stripMarkdown,+ type JourneyEntriesCard,+ type JourneyEntryLook,+} from '@trek/shared';++/**+ * A journal entry as a chat card shows it, read from an entry row the way+ * the journey tools answer it (`listEntries`: the row with its photos) or+ * from a held call's arguments, which use the same names. Nothing of the row+ * is trusted: a field that does not read is left out, an entry without a day+ * is no entry. Text from a result is masked like a provider answer; text from+ * arguments, what will be stored, is only cut.+ */++type Change = JourneyEntriesCard['change'];++/** Where each field of a look comes from: the stored row (masked) or the call's arguments (cut only). */+interface LookSource {+ /** The fields the arguments set; every other field is read from a stored row. */+ fromArgs?: ReadonlySet<string>;+ /** The sorted days of the whole read, for each entry's day colour. */+ days?: readonly string[];+}++const DATE = /^\d{4}-\d{2}-\d{2}$/;++/** The day an entry row is written on, when it names one. */+function dayOf(row: Row): string | null {+ return typeof row.entry_date === 'string' && DATE.test(row.entry_date) ? row.entry_date : null;+}++function positiveId(value: unknown): number | null {+ return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : null;+}++/** One line of text the user wrote into a call, cut to `max`; not masked, since that is what will be stored. */+function argLine(value: unknown, max: number): string | null {+ if (typeof value !== 'string') return null;+ const line = value.replace(/\s+/g, ' ').trim();+ if (line === '') return null;+ return line.length > max ? `${line.slice(0, max - 1)}…` : line;+}++/** A field as a card line: masked when it comes from a stored row, cut only when from the arguments. */+function lineOf(row: Row, key: string, max: number, source: LookSource): string | null {+ return source.fromArgs?.has(key) ? argLine(row[key], max) : clipped(row[key], max);+}++/** The start of a story, its markdown taken off. */+function storyOf(row: Row, source: LookSource): string | null {+ const story = row.story;+ if (typeof story !== 'string') return null;+ return lineOf({ story: stripMarkdown(story) }, 'story', JOURNEY_CARD_LIMITS.story, source);+}++/**+ * The first photo with a picture to show: a clip on this server without a+ * poster has none (its thumbnail answers 404), so the next one is taken.+ */+function coverOf(photos: Row[]): { photoId: number | null; video: boolean } {+ const ordered = [...photos].sort((a, b) => (finite(a.sort_order) ?? 0) - (finite(b.sort_order) ?? 0));+ const cover = ordered.find(+ (photo) =>+ positiveId(photo.photo_id) !== null &&+ !(photo.media_type === 'video' && photo.provider === 'local' && !photo.thumbnail_path),+ );+ if (!cover) return { photoId: null, video: false };+ return { photoId: positiveId(cover.photo_id), video: cover.media_type === 'video' };+}++/** Both coordinates, or neither. */+function pointOf(row: Row): JourneyEntryLook['point'] {+ const lat = finite(row.location_lat);+ const lng = finite(row.location_lng);+ return isLat(lat) && isLng(lng) ? { lat, lng } : null;+}++/** An entry as a card shows it; null for one without a day. */+export function lookOf(value: unknown, source: LookSource = {}): JourneyEntryLook | null {+ const row = recordOf(value);+ const date = dayOf(row);+ if (!date) return null;+ const photos = Array.isArray(row.photos) ? row.photos.map(recordOf) : [];+ const type = journeyEntryTypeSchema.safeParse(row.type);+ const visibility = journeyEntryVisibilitySchema.safeParse(row.visibility);+ const country = typeof row.country_code === 'string' ? row.country_code : '';+ const mood = typeof row.mood === 'string' ? row.mood.trim().toLowerCase() : '';+ const day = source.days?.indexOf(date) ?? -1;+ return {+ entryId: positiveId(row.id),+ type: type.success ? type.data : 'entry',+ title: lineOf(row, 'title', JOURNEY_CARD_LIMITS.title, source),+ date,+ time: clockOf(row.entry_time),+ place: lineOf(row, 'location_name', JOURNEY_CARD_LIMITS.place, source),+ point: pointOf(row),+ countryCode: /^[A-Za-z]{2}$/.test(country) ? country.toUpperCase() : null,+ story: storyOf(row, source),+ mood: /^[a-z]{1,20}$/.test(mood) ? mood : null,+ weather: lineOf(row, 'weather', JOURNEY_CARD_LIMITS.weather, source),+ ...coverOf(photos),+ photoCount: Math.min(photos.length, 1_000_000),+ visibility: visibility.success ? visibility.data : 'private',+ draft: row.is_draft === true || row.is_draft === 1,+ fromTripPlace: positiveId(row.source_place_id) !== null && row.type !== 'skeleton',+ dayIndex: day >= 0 && day <= 9_999 ? day : null,+ };+}++/** What a card about a journal says beside its entries. */+interface JournalOf {+ journeyId: number | null;+ title: unknown;+ tripJournal: boolean;+ change: Change;+}++/** The card itself, or null when it holds no entry or names no journal. */+export function entriesCard(journal: JournalOf, entries: JourneyEntryLook[], more: number): JourneyEntriesCard | null {+ if (journal.journeyId === null || entries.length === 0) return null;+ return {+ kind: 'journeyEntries',+ journeyId: journal.journeyId,+ journalTitle: clipped(journal.title, JOURNEY_CARD_LIMITS.journal),+ tripJournal: journal.tripJournal,+ change: journal.change,+ entries,+ more,+ };+}++/** The journal's reading order: by day, then as the traveller ordered the day. */+function readingOrder(a: { row: Row; look: JourneyEntryLook }, b: { row: Row; look: JourneyEntryLook }): number {+ const day = compareCodeUnits(a.look.date, b.look.date);+ if (day !== 0) return day;+ const order = (finite(a.row.sort_order) ?? 0) - (finite(b.row.sort_order) ?? 0);+ return order !== 0 ? order : (finite(a.row.id) ?? 0) - (finite(b.row.id) ?? 0);+}++/**+ * The entries of a read as one card: the written ones in reading order (only+ * the suggestions when nothing is written yet), the latest eight of them, the+ * rest counted. Dismissed suggestions never show; each entry knows its day's+ * place in the whole read for its colour, unless `withDays` is off (one entry+ * read alone says nothing about the journal's days).+ */+export function readCard(+ journeyId: number | null,+ title: unknown,+ rows: unknown,+ withDays = true,+): JourneyEntriesCard | null {+ const all = (Array.isArray(rows) ? rows.map(recordOf) : []).filter(+ (row) => row.dismissed !== true && row.dismissed !== 1,+ );+ const written = all.filter((row) => row.type !== 'skeleton');+ const shown = written.length > 0 ? written : all;+ const days = withDays+ ? [...new Set(shown.map(dayOf).filter((day): day is string => day !== null))].sort(compareCodeUnits)+ : [];+ const looks = shown+ .map((row) => ({ row, look: lookOf(row, { days }) }))+ .filter((pair): pair is { row: Row; look: JourneyEntryLook } => pair.look !== null)+ .sort(readingOrder)+ .map((pair) => pair.look);+ const kept = looks.slice(-JOURNEY_CARD_LIMITS.entries);+ return entriesCard({ journeyId, title, tripJournal: false, change: 'none' }, kept, looks.length - kept.length);+}diff --git a/server/src/nest/assistant/cards/journey/journey-undo.ts b/server/src/nest/assistant/cards/journey/journey-undo.tsnew file mode 100644index 000000000..55aca34bb--- /dev/null+++ b/server/src/nest/assistant/cards/journey/journey-undo.ts@@ -0,0 +1,41 @@+import type { ToolCards, UndoSnapshot } from '../card-types';+import { idIn, readKey, recordOf } from '../card-values';++/** How the undo reads the created entry again: by its id, whatever the turn read before. */+function entryRead(result: unknown) {+ return { tool: 'get_journey_entry', args: { entryId: idIn(result, 'entry') } };+}++function photoCount(entry: Record<string, unknown>): number {+ return Array.isArray(entry.photos) ? entry.photos.length : 0;+}++/**+ * A created entry, unchanged since: still there, not written since it was+ * made (every write of an entry stamps its `updated_at`), and holding the+ * photos it was created with, none added since, which the undo would delete+ * along with it.+ */+function entryUnchanged(result: unknown, snapshot: UndoSnapshot): boolean {+ const created = recordOf(recordOf(result).entry);+ const read = entryRead(result);+ if (read.args.entryId === null) return false;+ const current = recordOf(recordOf(snapshot.reads.get(readKey(read.tool, read.args))).entry);+ return (+ current.id === created.id &&+ current.updated_at !== undefined &&+ current.updated_at === created.updated_at &&+ photoCount(current) === photoCount(created)+ );+}++/** A created journal entry taken back by deleting it; a written-up suggestion is never one the create made. */+export const DELETE_CREATED_ENTRY: NonNullable<ToolCards['undo']> = {+ tool: 'delete_journey_entry',+ args: (_args, result) => {+ const entryId = idIn(result, 'entry');+ return entryId ? { entryId } : null;+ },+ reads: (_args, result) => [entryRead(result)],+ unchanged: entryUnchanged,+};diff --git a/server/tests/unit/nest/assistant/cards/journey/journey-cards.test.ts b/server/tests/unit/nest/assistant/cards/journey/journey-cards.test.tsnew file mode 100644index 000000000..46ce1ccf7--- /dev/null+++ b/server/tests/unit/nest/assistant/cards/journey/journey-cards.test.ts@@ -0,0 +1,367 @@+/**+ * ASTCARD-JRN-001 to ASTCARD-JRN-015+ *+ * The travel journal's cards in the assistant chat: the entries a read shows+ * beside its answer, the entry a held write will write, change or delete,+ * the entry as it was stored once applied, the words of the change row, and+ * the way back from a created entry. Every card is checked against the+ * shared union through the registry's guard, as the turn checks it.+ */+import { buildTripCard } from '../../../../../../src/nest/assistant/assistant-context';+import type { CardReader, PreviewContext, UndoSnapshot } from '../../../../../../src/nest/assistant/cards/card-types';+import { readKey } from '../../../../../../src/nest/assistant/cards/card-values';+import { JOURNEY_CARDS } from '../../../../../../src/nest/assistant/cards/journey';+import { loadJournal, type JournalLoaded } from '../../../../../../src/nest/assistant/cards/journey/journey-change';+import { lookOf } from '../../../../../../src/nest/assistant/cards/journey/journey-look';+import {+ answerCardOf,+ appliedCardOf,+ ASSISTANT_UNDO_MAP,+ ASSISTANT_WRITE_TOOLS,+ CARD_PROMPT_LINES,+ changeCardOf,+ undoReadsOf,+} from '../../../../../../src/nest/assistant/cards/registry';+import { appliedChange, describeToolCall } from '../../../../../../src/nest/assistant/tool-call-preview.helpers';+import {+ journeyEntriesCardSchema,+ trekCardSchema,+ type AssistantChangePreview,+ type JourneyEntriesCard,+} from '@trek/shared';++import { beforeEach, describe, expect, it, vi } from 'vitest';++const logMock = vi.hoisted(() => ({ logInfo: vi.fn(), logError: vi.fn(), logWarn: vi.fn(), logDebug: vi.fn() }));+vi.mock('../../../../../../src/nest/audit/audit-log.logger', () => logMock);++beforeEach(() => vi.clearAllMocks());++const trip = buildTripCard(1, 7, { trip: { title: 'Berlin' } }, null, null);+const ctx: PreviewContext = {+ card: trip,+ categories: new Map(),+ locale: 'en',+ today: '2026-10-22',+ airport: () => null,+};+const answerInput = (args: Record<string, unknown>, value: unknown) => ({+ toolCallId: 'call_read',+ args,+ value,+ card: trip,+ today: '2026-10-22',+});++function entry(over: Record<string, unknown> = {}): Record<string, unknown> {+ return {+ id: 12,+ journey_id: 3,+ type: 'entry',+ title: 'Sunset at the Spree',+ story: 'The light over the river was **unreal**.',+ entry_date: '2026-10-21',+ entry_time: '14:30',+ location_name: 'Berlin, Germany',+ location_lat: 52.52,+ location_lng: 13.405,+ country_code: 'de',+ mood: 'amazing',+ weather: 'sunny',+ visibility: 'public',+ sort_order: 0,+ is_draft: false,+ dismissed: false,+ source_place_id: null,+ updated_at: 1_000,+ photos: [],+ ...over,+ };+}++function cardOf(value: unknown): JourneyEntriesCard {+ return journeyEntriesCardSchema.parse(trekCardSchema.parse(value));+}++/** A reader over fixed answers, counting what it was asked. */+function readerOf(answers: Record<string, unknown>): { read: CardReader; asked: string[] } {+ const asked: string[] = [];+ const read: CardReader = (tool, args = {}) => {+ asked.push(readKey(tool, args));+ return Promise.resolve(answers[readKey(tool, args)] ?? answers[tool] ?? null);+ };+ return { read, asked };+}++const LINKED = { link: { journey_id: 3, title: 'Berlin 2026' } };++describe('the answer cards', () => {+ it('ASTCARD-JRN-001: a list reads in the journal order, without dismissed ones, each day with its colour index', () => {+ const value = {+ journey: { id: 3, title: 'Berlin 2026' },+ entries: [+ entry({ id: 3, entry_date: '2026-10-22', sort_order: 0, title: 'Third' }),+ entry({ id: 2, entry_date: '2026-10-21', sort_order: 1, title: 'Second' }),+ entry({ id: 1, entry_date: '2026-10-21', sort_order: 0, title: 'First' }),+ entry({ id: 4, entry_date: '2026-10-20', dismissed: true, title: 'Gone' }),+ entry({ id: 5, entry_date: '2026-10-19', type: 'skeleton', title: 'Suggestion' }),+ ],+ };+ const card = cardOf(answerCardOf('list_journey_entries', answerInput({ journeyId: 3 }, value)));+ expect(card.journalTitle).toBe('Berlin 2026');+ expect(card.change).toBe('none');+ expect(card.tripJournal).toBe(false);+ expect(card.entries.map((e) => e.title)).toEqual(['First', 'Second', 'Third']);+ expect(card.entries.map((e) => e.dayIndex)).toEqual([0, 0, 1]);+ expect(card.more).toBe(0);+ });++ it('ASTCARD-JRN-002: only suggestions show while nothing is written, and past eight the latest eight show', () => {+ const skeletons = [+ entry({ id: 1, type: 'skeleton' }),+ entry({ id: 2, type: 'skeleton', entry_date: '2026-10-22' }),+ ];+ const onlySuggestions = cardOf(+ answerCardOf('list_journey_entries', answerInput({ journeyId: 3 }, { journey: {}, entries: skeletons })),+ );+ expect(onlySuggestions.entries.map((e) => e.type)).toEqual(['skeleton', 'skeleton']);+ expect(onlySuggestions.journalTitle).toBeNull();++ const many = Array.from({ length: 11 }, (_, i) => entry({ id: i + 1, entry_date: `2026-10-${String(i + 10)}` }));+ const card = cardOf(answerCardOf('list_journey_entries', answerInput({ journeyId: 3 }, { entries: many })));+ expect(card.entries).toHaveLength(8);+ expect(card.entries[0]?.entryId).toBe(4);+ expect(card.entries[7]?.entryId).toBe(11);+ expect(card.entries[0]?.dayIndex).toBe(3);+ expect(card.more).toBe(3);+ });++ it('ASTCARD-JRN-003: no entry, no journal or a broken answer give no card', () => {+ expect(answerCardOf('list_journey_entries', answerInput({ journeyId: 3 }, { entries: [] }))).toBeNull();+ expect(answerCardOf('list_journey_entries', answerInput({}, { entries: [entry()] }))).toBeNull();+ expect(answerCardOf('list_journey_entries', answerInput({ journeyId: 3 }, 'Journey not found'))).toBeNull();+ expect(answerCardOf('list_journey_entries', answerInput({ journeyId: 3 }, { entries: [{ id: 1 }] }))).toBeNull();+ });++ it('ASTCARD-JRN-004: one entry read alone and a whole journal each draw their card', () => {+ const read = { entry: entry(), journey: { id: 3, title: 'B' } };+ const one = cardOf(answerCardOf('get_journey_entry', answerInput({ entryId: 12 }, read)));+ expect(one.journeyId).toBe(3);+ expect(one.entries).toHaveLength(1);+ expect(one.entries[0]?.dayIndex).toBeNull();++ const journey = { id: 3, title: 'Berlin 2026', entries: [entry(), entry({ id: 13, entry_date: '2026-10-22' })] };+ const whole = cardOf(answerCardOf('get_journey', answerInput({ journeyId: 3 }, { journey })));+ expect(whole.entries.map((e) => e.entryId)).toEqual([12, 13]);+ expect(whole.journalTitle).toBe('Berlin 2026');+ });+});++describe('an entry as a card shows it', () => {+ it('ASTCARD-JRN-005: the story loses its markdown and is cut to its start; an e-mail address is masked', () => {+ const look = lookOf(+ entry({ story: `# Day one\n\n**${'word '.repeat(80)}**`, title: 'Met [email protected] at the pier' }),+ );+ expect(look?.story?.startsWith('Day one word word')).toBe(true);+ expect(look?.story).toHaveLength(240);+ expect(look?.story?.endsWith('…')).toBe(true);+ expect(look?.title).toBe('Met [hidden] at the pier');+ });++ it('ASTCARD-JRN-006: a time reads as HH:MM, coordinates come as a pair, and the rest is tidied', () => {+ expect(lookOf(entry({ entry_time: '9:05' }))?.time).toBe('09:05');+ expect(lookOf(entry({ entry_time: 'noon' }))?.time).toBeNull();+ expect(lookOf(entry({ location_lng: null }))?.point).toBeNull();+ expect(lookOf(entry())?.point).toEqual({ lat: 52.52, lng: 13.405 });+ const tidy = lookOf(entry({ country_code: 'xyz', mood: 'Very happy', visibility: 'friends', type: 'diary' }));+ expect(tidy).toMatchObject({ countryCode: null, mood: null, visibility: 'private', type: 'entry' });+ expect(lookOf(entry())?.countryCode).toBe('DE');+ expect(lookOf(entry({ entry_date: '21.10.2026' }))).toBeNull();+ });++ it('ASTCARD-JRN-007: the cover skips a clip without a poster and carries no address of a picture', () => {+ const photos = [+ { photo_id: 31, sort_order: 0, media_type: 'video', provider: 'local', thumbnail_path: null, file_path: 'a.mp4' },+ { photo_id: 32, sort_order: 1, media_type: 'video', provider: 'immich', thumbnail_path: null },+ { photo_id: 33, sort_order: 2, media_type: 'image', provider: 'local', thumbnail_path: '/uploads/t.jpg' },+ ];+ const look = lookOf(entry({ photos }));+ expect(look).toMatchObject({ photoId: 32, video: true, photoCount: 3 });+ const text = JSON.stringify(+ answerCardOf('list_journey_entries', answerInput({ journeyId: 3 }, { entries: [entry({ photos })] })),+ );+ for (const leak of ['http', '/api/', '/uploads/', 'file_path', 'thumbnail_path']) expect(text).not.toContain(leak);+ });++ it('ASTCARD-JRN-008: a suggestion made from a trip place goes back to one when deleted, a draft says so', () => {+ expect(lookOf(entry({ source_place_id: 9 }))?.fromTripPlace).toBe(true);+ expect(lookOf(entry({ source_place_id: 9, type: 'skeleton' }))?.fromTripPlace).toBe(false);+ expect(lookOf(entry({ is_draft: 1 }))?.draft).toBe(true);+ });+});++describe('the change cards', () => {+ it('ASTCARD-JRN-009: a new entry is drawn from its arguments, in the trip journal or a journal of the list', async () => {+ const args = {+ journeyId: 3,+ entry_date: '2026-10-22',+ title: 'Write to me at [email protected]',+ story: '_Calm_ day',+ };+ const linked = readerOf({ get_trip_journal: LINKED });+ const loaded = await loadJournal('create_journey_entry', args, linked.read);+ expect(loaded).toEqual({ entry: null, journeyId: 3, title: 'Berlin 2026', tripJournal: true });+ expect(linked.asked).toEqual([readKey('get_trip_journal')]);+ const card = cardOf(changeCardOf('create_journey_entry', ctx, args, loaded));+ expect(card).toMatchObject({ change: 'new', journalTitle: 'Berlin 2026', tripJournal: true, more: 0 });+ expect(card.entries[0]).toMatchObject({+ entryId: null,+ visibility: 'private',+ photoId: null,+ photoCount: 0,+ title: 'Write to me at [email protected]',+ story: 'Calm day',+ dayIndex: null,+ });++ const other = readerOf({+ get_trip_journal: { link: null },+ list_journeys: { journeys: [{ id: 3, title: 'Japan' }] },+ });+ const fromList = await loadJournal('create_journey_entry', args, other.read);+ expect(fromList).toMatchObject({ title: 'Japan', tripJournal: false });+ expect(await loadJournal('create_journey_entry', {}, other.read)).toBeNull();+ });++ it('ASTCARD-JRN-010: a change merges its arguments over the entry: a named key wins, null clears, the rest stays', async () => {+ const { read, asked } = readerOf({+ get_trip_journal: { link: { journey_id: 8, title: 'Other' } },+ get_journey_entry: { entry: entry({ weather: 'rainy' }), journey: { id: 3, title: 'Berlin 2026' } },+ });+ const args = { entryId: 12, title: 'Evening at the Spree', location_name: null };+ const loaded = await loadJournal('update_journey_entry', args, read);+ expect(asked).toContain(readKey('get_journey_entry', { entryId: 12 }));+ expect(loaded?.tripJournal).toBe(false);+ const card = cardOf(changeCardOf('update_journey_entry', ctx, args, loaded));+ expect(card.change).toBe('changed');+ expect(card.entries[0]).toMatchObject({+ entryId: 12,+ title: 'Evening at the Spree',+ place: null,+ weather: 'rainy',+ });+ });++ it('ASTCARD-JRN-011: a delete shows the entry it removes; a failed lookup leaves the row without a card', async () => {+ const loaded: JournalLoaded = { entry: entry({ source_place_id: 9 }), journeyId: 3, title: 'B', tripJournal: true };+ const card = cardOf(changeCardOf('delete_journey_entry', ctx, { entryId: 12 }, loaded));+ expect(card.change).toBe('willDelete');+ expect(card.entries[0]?.fromTripPlace).toBe(true);++ const failing = readerOf({});+ expect(await loadJournal('delete_journey_entry', { entryId: 12 }, failing.read)).toBeNull();+ expect(changeCardOf('delete_journey_entry', ctx, { entryId: 12 }, null)).toBeNull();+ expect(changeCardOf('update_journey_entry', ctx, { entryId: 12 }, null)).toBeNull();+ });++ it('ASTCARD-JRN-012: the change row names the entry, its day, time, place, text and states, before and after', () => {+ const created = describeToolCall('create_journey_entry', 'c1', { journeyId: 3, entry_date: '2026-10-22' }, ctx);+ expect(created).toMatchObject({+ verbKey: 'addJournalEntry',+ domain: 'journey',+ undoable: true,+ subject: 'Thu, Oct 22',+ });+ expect(describeToolCall('create_journey_entry', 'c0', {}, ctx).verbKey).toBe('addJournalEntry');++ const withPlace = describeToolCall(+ 'create_journey_entry',+ 'c2',+ { journeyId: 3, entry_date: '2026-10-22', entry_time: '14:30', location_name: 'Museum Island', story: '**Hi**' },+ ctx,+ );+ expect(withPlace.subject).toBe('Museum Island');+ expect(withPlace.rows.map((r) => [r.labelKey, r.after])).toEqual([+ ['day', 'Thu, Oct 22'],+ ['time', '14:30'],+ ['location', 'Museum Island'],+ ['text', 'Hi'],+ ]);++ const loaded: JournalLoaded = { entry: entry(), journeyId: 3, title: 'B', tripJournal: false };+ const updated = describeToolCall('update_journey_entry', 'c3', { entryId: 12, entry_time: '18:00' }, ctx, loaded);+ expect(updated).toMatchObject({ verbKey: 'updateJournalEntry', subject: 'Sunset at the Spree', undoable: false });+ expect(updated.rows).toEqual([{ op: 'change', labelKey: 'time', before: '14:30', after: '18:00' }]);+ expect(describeToolCall('update_journey_entry', 'c4', {}, ctx).rows).toEqual([]);++ // Who sees it, its mood and whether it is a draft each get a row; a state set to what it holds gets none.+ const states = { entryId: 12, visibility: 'private', mood: null, weather: 'sunny', is_draft: true };+ expect(describeToolCall('update_journey_entry', 'c6', states, ctx, loaded).rows).toEqual([+ { op: 'change', labelKey: 'field', field: 'visibility', before: 'public', after: 'private' },+ { op: 'change', labelKey: 'field', field: 'mood', before: 'amazing', after: '' },+ { op: 'change', labelKey: 'field', field: 'is_draft', before: '✗', after: '✓' },+ ]);+ // A suggestion brought back is not found by the read, so its row has no before.+ expect(describeToolCall('update_journey_entry', 'c7', { entryId: 12, dismissed: false }, ctx).rows).toEqual([+ { op: 'change', labelKey: 'field', field: 'dismissed', before: null, after: '✗' },+ ]);++ const removed = describeToolCall('delete_journey_entry', 'c5', { entryId: 12 }, ctx, loaded);+ expect(removed).toMatchObject({ verbKey: 'removeJournalEntry', subject: 'Sunset at the Spree' });+ expect(removed.card?.kind).toBe('journeyEntries');+ });+});++describe('the applied change', () => {+ it('ASTCARD-JRN-013: the receipt card is the entry as stored, beside the journal the held card named', () => {+ const loaded: JournalLoaded = { entry: null, journeyId: 3, title: 'Berlin 2026', tripJournal: true };+ const args = { journeyId: 3, entry_date: '2026-10-22' };+ const held = cardOf(changeCardOf('create_journey_entry', ctx, args, loaded));+ const preview = { card: held } as unknown as AssistantChangePreview;+ const stored = entry({ id: 40, photos: [{ photo_id: 9, media_type: 'image', provider: 'local' }] });+ const card = cardOf(appliedCardOf('create_journey_entry', { args: {}, result: { entry: stored }, preview }));+ expect(card).toMatchObject({ journeyId: 3, journalTitle: 'Berlin 2026', tripJournal: true, change: 'new' });+ expect(card.entries[0]).toMatchObject({ entryId: 40, photoId: 9, countryCode: 'DE' });+ const deleted = { args: { entryId: 12 }, result: { success: true }, preview };+ expect(appliedCardOf('delete_journey_entry', deleted)).toBeNull();++ expect(appliedChange('create_journey_entry', 'c1', {}, { entry: stored }, null, null)).toMatchObject({+ entity: 'journey_entry',+ ids: [40],+ });+ const removed = appliedChange('delete_journey_entry', 'c2', { entryId: 12 }, { success: true }, null, null);+ expect(removed?.ids).toEqual([12]);+ });++ it('ASTCARD-JRN-014: a created entry is taken back while nothing was written to it and no photo was added', () => {+ const undo = ASSISTANT_UNDO_MAP.create_journey_entry;+ const created = { entry: entry({ id: 40, updated_at: 5 }) };+ expect(undo?.tool).toBe('delete_journey_entry');+ expect(undo?.args({}, created, null)).toEqual({ entryId: 40 });+ expect(undo?.args({}, {}, null)).toBeNull();+ const reads = undoReadsOf('create_journey_entry', {}, created);+ expect(reads).toEqual([{ tool: 'get_journey_entry', args: { entryId: 40 } }]);+ expect(undoReadsOf('create_journey_entry', {}, {}).map((r) => r.tool)).toEqual(['get_journey_entry']);++ const check = JOURNEY_CARDS.tools.create_journey_entry?.undo;+ const snapshot = (current: unknown): UndoSnapshot => ({+ summary: {},+ places: {},+ reads: new Map([[readKey('get_journey_entry', { entryId: 40 }), current]]),+ });+ expect(check?.unchanged(created, snapshot({ entry: entry({ id: 40, updated_at: 5 }) }))).toBe(true);+ expect(check?.unchanged(created, snapshot({ entry: entry({ id: 40, updated_at: 6 }) }))).toBe(false);+ const withPhoto = entry({ id: 40, updated_at: 5, photos: [{ photo_id: 1 }] });+ expect(check?.unchanged(created, snapshot({ entry: withPhoto }))).toBe(false);+ expect(check?.unchanged(created, snapshot(null))).toBe(false);+ });++ it('ASTCARD-JRN-015: the journal brings its verbs, its undo and one prompt line to the registry', () => {+ expect(ASSISTANT_WRITE_TOOLS.create_journey_entry).toEqual({ verbKey: 'addJournalEntry', entity: 'journey_entry' });+ expect(ASSISTANT_WRITE_TOOLS.update_journey_entry?.verbKey).toBe('updateJournalEntry');+ expect(ASSISTANT_WRITE_TOOLS.delete_journey_entry?.verbKey).toBe('removeJournalEntry');+ expect(ASSISTANT_UNDO_MAP.update_journey_entry).toBeUndefined();+ expect(CARD_PROMPT_LINES).toEqual(expect.arrayContaining(JOURNEY_CARDS.prompt ?? []));+ expect(JOURNEY_CARDS.prompt).toHaveLength(1);+ });+});diff --git a/shared/src/assistant/cards/journey-entries.card.spec.ts b/shared/src/assistant/cards/journey-entries.card.spec.tsnew file mode 100644index 000000000..607d76087--- /dev/null+++ b/shared/src/assistant/cards/journey-entries.card.spec.ts@@ -0,0 +1,126 @@+import {+ ASSISTANT_CHANGE_VERB_KEYS,+ assistantAppliedSchema,+ assistantChangePreviewSchema,+ assistantMessagePartSchema,+ uiStreamChunkSchema,+} from '../assistant.schema';+import { storedTrekCardSchema, trekCardSchema } from './index';+import { JOURNEY_CARD_LIMITS, journeyEntriesCardSchema, type JourneyEntryLook } from './journey-entries.card';++import { describe, expect, it } from 'vitest';++// JRNCARD-001 to JRNCARD-006++function look(over: Partial<JourneyEntryLook> = {}): JourneyEntryLook {+ return {+ entryId: 12,+ type: 'entry',+ title: 'Sunset at the Spree',+ date: '2026-10-21',+ time: '14:30',+ place: 'Berlin',+ point: { lat: 52.52, lng: 13.405 },+ countryCode: 'DE',+ story: 'The light over the river was unreal.',+ mood: 'amazing',+ weather: 'sunny',+ photoId: 7,+ video: false,+ photoCount: 4,+ visibility: 'public',+ draft: false,+ fromTripPlace: false,+ dayIndex: 0,+ ...over,+ };+}++function card(entries: JourneyEntryLook[], over: Record<string, unknown> = {}) {+ return {+ kind: 'journeyEntries',+ journeyId: 3,+ journalTitle: 'Berlin 2026',+ tripJournal: true,+ change: 'none',+ entries,+ more: 0,+ ...over,+ };+}++describe('the journal entries card', () => {+ it('JRNCARD-001: reads a full card through the union, as itself', () => {+ const parsed = trekCardSchema.parse(card([look(), look({ entryId: 13, photoId: null, dayIndex: 1 })]));+ expect(parsed.kind).toBe('journeyEntries');+ expect(journeyEntriesCardSchema.parse(parsed).entries).toHaveLength(2);+ });++ it('JRNCARD-002: holds one to eight entries, a pending entry without an id among them', () => {+ expect(journeyEntriesCardSchema.safeParse(card([])).success).toBe(false);+ const eight = Array.from({ length: JOURNEY_CARD_LIMITS.entries }, (_, i) => look({ entryId: i + 1 }));+ expect(journeyEntriesCardSchema.safeParse(card(eight)).success).toBe(true);+ expect(journeyEntriesCardSchema.safeParse(card([...eight, look({ entryId: 99 })])).success).toBe(false);+ expect(journeyEntriesCardSchema.safeParse(card([look({ entryId: null })], { change: 'new' })).success).toBe(true);+ });++ it('JRNCARD-003: a story past its bound, a bad date, time or country reads as no card at all', () => {+ const bad = [+ look({ story: 'x'.repeat(JOURNEY_CARD_LIMITS.story + 1) }),+ look({ date: '21.10.2026' }),+ look({ time: '9:05' }),+ look({ countryCode: 'de' }),+ look({ mood: 'Very Happy' }),+ look({ point: { lat: 91, lng: 0 } }),+ look({ title: '' }),+ ];+ for (const entry of bad) {+ expect(journeyEntriesCardSchema.safeParse(card([entry])).success).toBe(false);+ expect(storedTrekCardSchema.parse(card([entry]))).toBeNull();+ }+ });++ it('JRNCARD-004: carries no address of a picture, only the photo id', () => {+ const parsed = journeyEntriesCardSchema.parse(+ card([{ ...look(), thumbnail_path: '/uploads/x.jpg', file_path: 'secret' } as JourneyEntryLook]),+ );+ const text = JSON.stringify(parsed);+ expect(text).not.toContain('thumbnail_path');+ expect(text).not.toContain('/uploads/');+ expect(parsed.entries[0]?.photoId).toBe(7);+ });++ it('JRNCARD-005: rides a data-trek-card part and chunk, and a change preview', () => {+ const data = { toolCallId: 'call_1', card: card([look()]) };+ const part = assistantMessagePartSchema.parse({ type: 'data-trek-card', data });+ expect(part.type === 'data-trek-card' && part.data.card?.kind).toBe('journeyEntries');+ const chunk = uiStreamChunkSchema.parse({ type: 'data-trek-card', data });+ expect(chunk.type === 'data-trek-card' && chunk.data.card?.kind).toBe('journeyEntries');+ const preview = assistantChangePreviewSchema.parse({+ toolCallId: 'call_1',+ verbKey: 'addJournalEntry',+ subject: 'Sunset at the Spree',+ rows: [],+ dayId: null,+ placeIds: [],+ undoable: true,+ card: card([look({ entryId: null })], { change: 'new' }),+ });+ expect(preview.verbKey).toBe('addJournalEntry');+ expect(preview.card?.kind).toBe('journeyEntries');+ });++ it('JRNCARD-006: names its verbs and its entity in the shared enums', () => {+ expect(ASSISTANT_CHANGE_VERB_KEYS).toEqual(+ expect.arrayContaining(['addJournalEntry', 'updateJournalEntry', 'removeJournalEntry']),+ );+ const applied = assistantAppliedSchema.parse({+ toolCallId: 'call_1',+ entity: 'journey_entry',+ ids: [12],+ dayId: null,+ undoUntil: null,+ });+ expect(applied.entity).toBe('journey_entry');+ });+});diff --git a/shared/src/assistant/cards/journey-entries.card.ts b/shared/src/assistant/cards/journey-entries.card.tsindex 1e316719a..2df849b20 100644--- a/shared/src/assistant/cards/journey-entries.card.ts+++ b/shared/src/assistant/cards/journey-entries.card.ts@@ -1,5 +1,72 @@+import { idSchema } from '../../common/primitives.schema';+import { journeyEntryTypeSchema, journeyEntryVisibilitySchema } from '../../journey/journey.schema';+import { cardClockSchema, cardCountSchema, cardDateSchema, cardLatSchema, cardLngSchema, cardText } from './card-parts';+import { z } from 'zod';-/** Entries of a travel journal. Only its kind so far; the travel journal cards give it its fields. */-export const journeyEntriesCardSchema = z.object({ kind: z.literal('journeyEntries') });+/**+ * Entries of one travel journal as the assistant chat shows them: what a+ * read of the journal found (one entry or several), what a held change will+ * write, and what it wrote once applied. One kind for all three, so the+ * answer, the change row and the receipt read one shape.+ */++/** How much of a journal a card carries; the server clips to the same numbers. */+export const JOURNEY_CARD_LIMITS = { entries: 8, title: 100, place: 80, story: 240, journal: 80, weather: 40 } as const;++/**+ * One entry as a card shows it. Its texts are plain and on one line (the story+ * without its markdown, cut to its start), masked like a provider answer when+ * they come from a result; a photo travels as its id, never as a path.+ */+export const journeyEntryLookSchema = z.object({+ /** Null for an entry a held change has not written yet. */+ entryId: idSchema.nullable(),+ type: journeyEntryTypeSchema,+ title: cardText(JOURNEY_CARD_LIMITS.title).nullable(),+ date: cardDateSchema,+ time: cardClockSchema.nullable(),+ /** The place as the entry names it; the client shortens it as the journal does. */+ place: cardText(JOURNEY_CARD_LIMITS.place).nullable(),+ point: z.object({ lat: cardLatSchema, lng: cardLngSchema }).nullable(),+ countryCode: z+ .string()+ .regex(/^[A-Z]{2}$/)+ .nullable(),+ story: cardText(JOURNEY_CARD_LIMITS.story).nullable(),+ /** A mood id; the client draws the ones it knows and leaves the rest out. */+ mood: z+ .string()+ .regex(/^[a-z]{1,20}$/)+ .nullable(),+ /** A weather id the journal knows, or the words the traveller wrote. */+ weather: cardText(JOURNEY_CARD_LIMITS.weather).nullable(),+ /** The TREK photo the entry opens with (its thumbnail), the first one that has a picture. */+ photoId: idSchema.nullable(),+ /** That photo is the poster of a clip. */+ video: z.boolean(),+ photoCount: cardCountSchema,+ visibility: journeyEntryVisibilitySchema,+ draft: z.boolean(),+ /** Made from a place of a trip: deleting it turns it back into a suggestion. */+ fromTripPlace: z.boolean(),+ /** Which day of the journal it falls on, counted from 0, for the day's colour; null when unknown. */+ dayIndex: z.number().int().min(0).max(9_999).nullable(),+});+export type JourneyEntryLook = z.infer<typeof journeyEntryLookSchema>;++/** What a change card's entry goes through: nothing on an answer, else what the change does to it. */+export const JOURNEY_CARD_CHANGES = ['none', 'new', 'changed', 'willDelete'] as const;++export const journeyEntriesCardSchema = z.object({+ kind: z.literal('journeyEntries'),+ journeyId: idSchema,+ journalTitle: cardText(JOURNEY_CARD_LIMITS.journal).nullable(),+ /** The journal is the one the open trip shows in its Journal tab, as read when the card was made. */+ tripJournal: z.boolean(),+ change: z.enum(JOURNEY_CARD_CHANGES),+ entries: z.array(journeyEntryLookSchema).min(1).max(JOURNEY_CARD_LIMITS.entries),+ /** Entries the read found that the card does not carry. */+ more: cardCountSchema,+});export type JourneyEntriesCard = z.infer<typeof journeyEntriesCardSchema>;diff --git a/shared/src/assistant/cards/journey.contract.ts b/shared/src/assistant/cards/journey.contract.tsindex 83cda21a8..0944698a3 100644--- a/shared/src/assistant/cards/journey.contract.ts+++ b/shared/src/assistant/cards/journey.contract.ts@@ -10,5 +10,7 @@ export * from './journey-entries.card';* or entity is added here and nowhere else.*/export const JOURNEY_CARD_SCHEMAS = [journeyEntriesCardSchema] as const;-export const JOURNEY_VERB_KEYS = [] as const;-export const JOURNEY_APPLIED_ENTITIES = [] as const;+/** An entry written, changed or deleted. */+export const JOURNEY_VERB_KEYS = ['addJournalEntry', 'updateJournalEntry', 'removeJournalEntry'] as const;+/** An entry of a journal; the receipt opens it there. */+export const JOURNEY_APPLIED_ENTITIES = ['journey_entry'] as const;diff --git a/shared/src/common/strip-markdown.spec.ts b/shared/src/common/strip-markdown.spec.tsnew file mode 100644index 000000000..8653d0907--- /dev/null+++ b/shared/src/common/strip-markdown.spec.ts@@ -0,0 +1,53 @@+import { stripMarkdown } from './strip-markdown';++import { describe, expect, it } from 'vitest';++// STRIPMD-001 to STRIPMD-008 (moved from the client's FE-UTIL-STRIPMD-001 to 006)++describe('stripMarkdown', () => {+ it('STRIPMD-001: strips bold and italic formatting', () => {+ expect(stripMarkdown('**bold** and _italic_')).toBe('bold and italic');+ expect(stripMarkdown('__also bold__ and *also italic*')).toBe('also bold and also italic');+ });++ it('STRIPMD-002: strips headings', () => {+ expect(stripMarkdown('# Heading 1')).toBe('Heading 1');+ expect(stripMarkdown('## Heading 2')).toBe('Heading 2');+ expect(stripMarkdown('### Heading 3')).toBe('Heading 3');+ });++ it('STRIPMD-003: converts links to text and removes images', () => {+ expect(stripMarkdown('[click here](https://example.com)')).toBe('click here');+ expect(stripMarkdown('')).toBe('');+ });++ it('STRIPMD-004: strips code blocks and inline code', () => {+ expect(stripMarkdown('use `console.log`')).toBe('use console.log');+ expect(stripMarkdown('```\ncode block\n```')).toBe('');+ });++ it('STRIPMD-005: strips blockquotes and lists', () => {+ expect(stripMarkdown('> quoted text')).toBe('quoted text');+ expect(stripMarkdown('- item one')).toBe('item one');+ expect(stripMarkdown('1. first item')).toBe('first item');+ });++ it('STRIPMD-006: strips strikethrough and horizontal rules', () => {+ expect(stripMarkdown('~~deleted~~')).toBe('deleted');+ expect(stripMarkdown('---')).toBe('');+ });++ it('STRIPMD-007: keeps the link quirks of the old regex and joins the lines', () => {+ expect(stripMarkdown('[a[b](c)')).toBe('a[b');+ expect(stripMarkdown('[](c) after')).toBe('after');+ expect(stripMarkdown('[a] (c)')).toBe('[a] (c)');+ expect(stripMarkdown('[a](c\n) next')).toBe('[a](c ) next');+ expect(stripMarkdown('one\n\ntwo\nthree')).toBe('one two three');+ });++ it('STRIPMD-008: a long run of brackets without a close reads in linear time', () => {+ const started = Date.now();+ expect(stripMarkdown('[x'.repeat(32_000)).length).toBe(64_000);+ expect(Date.now() - started).toBeLessThan(1_000);+ });+});diff --git a/client/src/components/Journey/stripMarkdown.ts b/shared/src/common/strip-markdown.tssimilarity index 53%rename from client/src/components/Journey/stripMarkdown.tsrename to shared/src/common/strip-markdown.tsindex 5cb9462a8..76ffef865 100644--- a/client/src/components/Journey/stripMarkdown.ts+++ b/shared/src/common/strip-markdown.ts@@ -1,29 +1,31 @@/**- * Strip markdown formatting to get plain text for previews.- * Handles: bold, italic, headings, links, images, blockquotes, code, lists, hr.+ * Markdown formatting taken off a text, for a preview of it in one line: a+ * journal entry's story on a card. Handles bold, italic, headings, links,+ * images, blockquotes, code, lists and rules. Shared, so the server's chat+ * cards and the client strip a story the same way.*/export function stripMarkdown(md: string): string {const withoutImages = md- .replace(/^#{1,6}\s+/gm, '') // headings+ .replace(/^#{1,6}\s+/gm, '') // headings// the alt text is a run that cannot contain "](", so it ends on the first one// instead of being retried against every later "](". Same matches, no backtracking- .replace(/!\[(?:(?!\]\().)*\]\(.*?\)/g, '') // images+ .replace(/!\[(?:(?!\]\().)*\]\(.*?\)/g, ''); // images- return stripLinks(withoutImages) // links → text- .replace(/(`{3}[\s\S]*?`{3})/g, '') // code blocks- .replace(/`([^`]+)`/g, '$1') // inline code- .replace(/\*\*(.+?)\*\*/g, '$1') // bold **- .replace(/__(.+?)__/g, '$1') // bold __- .replace(/\*(.+?)\*/g, '$1') // italic *- .replace(/_(.+?)_/g, '$1') // italic _- .replace(/~~(.+?)~~/g, '$1') // strikethrough- .replace(/^>\s?/gm, '') // blockquotes- .replace(/^[-*+]\s+/gm, '') // unordered lists- .replace(/^\d+\.\s+/gm, '') // ordered lists- .replace(/^---+$/gm, '') // horizontal rules- .replace(/\n{2,}/g, ' ') // collapse multiple newlines- .replace(/\n/g, ' ') // remaining newlines → spaces- .trim()+ return stripLinks(withoutImages) // links → text+ .replace(/(`{3}[\s\S]*?`{3})/g, '') // code blocks+ .replace(/`([^`]+)`/g, '$1') // inline code+ .replace(/\*\*(.+?)\*\*/g, '$1') // bold **+ .replace(/__(.+?)__/g, '$1') // bold __+ .replace(/\*(.+?)\*/g, '$1') // italic *+ .replace(/_(.+?)_/g, '$1') // italic _+ .replace(/~~(.+?)~~/g, '$1') // strikethrough+ .replace(/^>\s?/gm, '') // blockquotes+ .replace(/^[-*+]\s+/gm, '') // unordered lists+ .replace(/^\d+\.\s+/gm, '') // ordered lists+ .replace(/^---+$/gm, '') // horizontal rules+ .replace(/\n{2,}/g, ' ') // collapse multiple newlines+ .replace(/\n/g, ' ') // remaining newlines → spaces+ .trim();}/**@@ -31,7 +33,7 @@ export function stripMarkdown(md: string): string {* target could be built from back when this was `.*?`. Testing a single character against* it spells that out without hand-listing \n, \r and the two Unicode separators.*/-const notALineTerminator = /./+const notALineTerminator = /./;/*** Replace `[label](target)` with its label, exactly as `/\[([^\]]*)\]\(.*?\)/g` did.@@ -45,48 +47,48 @@ const notALineTerminator = /./** The semantics are the regex's, quirks included:* - the label runs to the FIRST `]` and may itself contain `[`, so `[a[b](c)` keeps- * `a[b` — narrowing the label to `[^[\]]` would have been a behaviour change;+ * `a[b`; narrowing the label to `[^[\]]` would have been a behaviour change;* - the label may be empty, since `[^\]]*` is zero-or-more, so `[](c)` is a link;* - `(` has to sit directly after that `]`;* - the target ends at the first `)`, and `.` cannot cross a line terminator, so a `(`* whose first `)` only turns up on a later line is not a link at all.*/function stripLinks(input: string): string {- let out = ''- let cursor = 0 // everything before this has already been copied into `out`- let search = 0 // where the next `[` is looked for+ let out = '';+ let cursor = 0; // everything before this has already been copied into `out`+ let search = 0; // where the next `[` is looked for// First `)`-or-line-terminator at or after the target we last examined. Targets are- // examined left to right, so this only ever moves forward — which is what stops a+ // examined left to right, so this only ever moves forward, which is what stops a// document full of `[a](` from being re-read once per candidate.- let stop = 0+ let stop = 0;for (;;) {- const open = input.indexOf('[', search)- if (open === -1) break+ const open = input.indexOf('[', search);+ if (open === -1) break;- const close = input.indexOf(']', open + 1)+ const close = input.indexOf(']', open + 1);// No `]` left anywhere: neither this `[` nor any after it can match. Rediscovering// that from every `[` in turn is what the regex spent quadratic time on.- if (close === -1) break+ if (close === -1) break;// Every `[` between `open` and `close` has that same first `]`, so the verdict on- // what follows it is the verdict for all of them — skip the lot when it fails.+ // what follows it is the verdict for all of them: skip the lot when it fails.if (input[close + 1] !== '(') {- search = close + 1- continue+ search = close + 1;+ continue;}- if (stop < close + 2) stop = close + 2- while (stop < input.length && input[stop] !== ')' && notALineTerminator.test(input[stop])) stop+++ if (stop < close + 2) stop = close + 2;+ while (stop < input.length && input[stop] !== ')' && notALineTerminator.test(input.charAt(stop))) stop++;if (input[stop] !== ')') {- search = close + 1- continue+ search = close + 1;+ continue;}- out += input.slice(cursor, open) + input.slice(open + 1, close)- cursor = stop + 1- search = stop + 1+ out += input.slice(cursor, open) + input.slice(open + 1, close);+ cursor = stop + 1;+ search = stop + 1;}- return out + input.slice(cursor)+ return out + input.slice(cursor);}diff --git a/shared/src/i18n/ar/assistantJourney.ts b/shared/src/i18n/ar/assistantJourney.tsindex dc8d923a4..a85d43555 100644--- a/shared/src/i18n/ar/assistantJourney.ts+++ b/shared/src/i18n/ar/assistantJourney.ts@@ -1,4 +1,43 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'مدخلات اليوميات',+ 'assistant.card.journey.open': 'افتح في اليوميات',+ 'assistant.card.journey.entries': '{count} مدخل',+ 'assistant.card.journey.entries.zero': '{count} مدخلات',+ 'assistant.card.journey.entries.one': '{count} مدخل',+ 'assistant.card.journey.entries.two': '{count} مدخلان',+ 'assistant.card.journey.entries.few': '{count} مدخلات',+ 'assistant.card.journey.entries.many': '{count} مدخلًا',+ 'assistant.card.journey.more': '{count} أخرى في اليوميات',+ 'assistant.card.journey.more.zero': '{count} أخرى في اليوميات',+ 'assistant.card.journey.more.one': '{count} أخرى في اليوميات',+ 'assistant.card.journey.more.two': '{count} أخرى في اليوميات',+ 'assistant.card.journey.more.few': '{count} أخرى في اليوميات',+ 'assistant.card.journey.more.many': '{count} أخرى في اليوميات',+ 'assistant.card.journey.photos': '{count} صورة',+ 'assistant.card.journey.photos.zero': '{count} صور',+ 'assistant.card.journey.photos.one': '{count} صورة',+ 'assistant.card.journey.photos.two': '{count} صورتان',+ 'assistant.card.journey.photos.few': '{count} صور',+ 'assistant.card.journey.photos.many': '{count} صورة',+ 'assistant.card.journey.toSuggestion': 'تعود اقتراحًا',+ 'assistant.card.journey.video': 'يبدأ بفيديو',+ 'assistant.card.journey.typeEntry': 'تدوينة مكتوبة',+ 'assistant.card.journey.typeCheckin': 'تسجيل وصول',+ 'assistant.card.journey.notDraft': 'لم تعد مسودة',+ 'assistant.card.journey.onRoute': 'عادت إلى المسار',+ 'assistant.card.journey.restored': 'أُعيد الاقتراح',+ 'assistant.change.verb.addJournalEntry': 'إضافة مدخل في اليوميات',+ 'assistant.change.verb.updateJournalEntry': 'تغيير مدخل اليوميات',+ 'assistant.change.verb.removeJournalEntry': 'حذف مدخل اليوميات',+ 'assistant.step.readingJournal': 'قراءة اليوميات',+ 'assistant.tool.create_journey': 'بدء يوميات',+ 'assistant.tool.update_journey': 'تغيير اليوميات',+ 'assistant.tool.add_journey_trip': 'إضافة الرحلة إلى اليوميات',+ 'assistant.tool.link_trip_journal': 'عرض اليوميات في هذه الرحلة',+ 'assistant.tool.reorder_journey_entries': 'إعادة ترتيب اليوميات',+ 'assistant.followUp.journalToday': 'اكتب مدخلًا لليوم',+ 'assistant.followUp.journalSummary': 'لخّص هذه الأيام',+};export default assistantJourney;diff --git a/shared/src/i18n/az/assistantJourney.ts b/shared/src/i18n/az/assistantJourney.tsindex dc8d923a4..9b05ec093 100644--- a/shared/src/i18n/az/assistantJourney.ts+++ b/shared/src/i18n/az/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Gündəlik qeydləri',+ 'assistant.card.journey.open': 'Gündəlikdə aç',+ 'assistant.card.journey.entries': '{count} qeyd',+ 'assistant.card.journey.entries.one': '{count} qeyd',+ 'assistant.card.journey.more': 'gündəlikdə daha {count}',+ 'assistant.card.journey.more.one': 'gündəlikdə daha {count}',+ 'assistant.card.journey.photos': '{count} foto',+ 'assistant.card.journey.photos.one': '{count} foto',+ 'assistant.card.journey.toSuggestion': 'Yenidən təklifə çevrilir',+ 'assistant.card.journey.video': 'Videoyla başlayır',+ 'assistant.card.journey.typeEntry': 'Yazılmış qeyd',+ 'assistant.card.journey.typeCheckin': 'Məkanda qeydiyyat',+ 'assistant.card.journey.notDraft': 'Artıq qaralama deyil',+ 'assistant.card.journey.onRoute': 'Yenidən marşrutda',+ 'assistant.card.journey.restored': 'Təklif geri qaytarıldı',+ 'assistant.change.verb.addJournalEntry': 'Gündəlik qeydi əlavə et',+ 'assistant.change.verb.updateJournalEntry': 'Gündəlik qeydini dəyiş',+ 'assistant.change.verb.removeJournalEntry': 'Gündəlik qeydini sil',+ 'assistant.step.readingJournal': 'Gündəlik oxunur',+ 'assistant.tool.create_journey': 'Gündəlik başlat',+ 'assistant.tool.update_journey': 'Gündəliyi dəyiş',+ 'assistant.tool.add_journey_trip': 'Səfəri gündəliyə əlavə et',+ 'assistant.tool.link_trip_journal': 'Gündəliyi bu səfərdə göstər',+ 'assistant.tool.reorder_journey_entries': 'Gündəliyi yenidən sırala',+ 'assistant.followUp.journalToday': 'Bu gün üçün qeyd yaz',+ 'assistant.followUp.journalSummary': 'Bu günləri yekunlaşdır',+};export default assistantJourney;diff --git a/shared/src/i18n/br/assistantJourney.ts b/shared/src/i18n/br/assistantJourney.tsindex dc8d923a4..2adfd875c 100644--- a/shared/src/i18n/br/assistantJourney.ts+++ b/shared/src/i18n/br/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Entradas do diário',+ 'assistant.card.journey.open': 'Abrir no diário',+ 'assistant.card.journey.entries': '{count} entradas',+ 'assistant.card.journey.entries.one': '{count} entrada',+ 'assistant.card.journey.more': 'mais {count} no diário',+ 'assistant.card.journey.more.one': 'mais {count} no diário',+ 'assistant.card.journey.photos': '{count} fotos',+ 'assistant.card.journey.photos.one': '{count} foto',+ 'assistant.card.journey.toSuggestion': 'Volta a ser uma sugestão',+ 'assistant.card.journey.video': 'Começa com um vídeo',+ 'assistant.card.journey.typeEntry': 'Entrada escrita',+ 'assistant.card.journey.typeCheckin': 'Registro de chegada',+ 'assistant.card.journey.notDraft': 'Não é mais rascunho',+ 'assistant.card.journey.onRoute': 'De volta à rota',+ 'assistant.card.journey.restored': 'Sugestão recuperada',+ 'assistant.change.verb.addJournalEntry': 'Adicionar uma entrada no diário',+ 'assistant.change.verb.updateJournalEntry': 'Alterar a entrada do diário',+ 'assistant.change.verb.removeJournalEntry': 'Excluir a entrada do diário',+ 'assistant.step.readingJournal': 'Lendo o diário',+ 'assistant.tool.create_journey': 'Criar um diário',+ 'assistant.tool.update_journey': 'Alterar o diário',+ 'assistant.tool.add_journey_trip': 'Adicionar a viagem ao diário',+ 'assistant.tool.link_trip_journal': 'Mostrar o diário nesta viagem',+ 'assistant.tool.reorder_journey_entries': 'Reordenar o diário',+ 'assistant.followUp.journalToday': 'Escrever uma entrada para hoje',+ 'assistant.followUp.journalSummary': 'Resumir estes dias',+};export default assistantJourney;diff --git a/shared/src/i18n/ca/assistantJourney.ts b/shared/src/i18n/ca/assistantJourney.tsindex dc8d923a4..c111a8094 100644--- a/shared/src/i18n/ca/assistantJourney.ts+++ b/shared/src/i18n/ca/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Entrades del diari',+ 'assistant.card.journey.open': 'Obre al diari',+ 'assistant.card.journey.entries': '{count} entrades',+ 'assistant.card.journey.entries.one': '{count} entrada',+ 'assistant.card.journey.more': '{count} més al diari',+ 'assistant.card.journey.more.one': '{count} més al diari',+ 'assistant.card.journey.photos': '{count} fotos',+ 'assistant.card.journey.photos.one': '{count} foto',+ 'assistant.card.journey.toSuggestion': 'Torna a ser un suggeriment',+ 'assistant.card.journey.video': 'Comença amb un vídeo',+ 'assistant.card.journey.typeEntry': 'Entrada escrita',+ 'assistant.card.journey.typeCheckin': 'Registre d’arribada',+ 'assistant.card.journey.notDraft': 'Ja no és un esborrany',+ 'assistant.card.journey.onRoute': 'De nou a la ruta',+ 'assistant.card.journey.restored': 'Suggeriment recuperat',+ 'assistant.change.verb.addJournalEntry': 'Afegeix una entrada al diari',+ 'assistant.change.verb.updateJournalEntry': 'Canvia l’entrada del diari',+ 'assistant.change.verb.removeJournalEntry': 'Suprimeix l’entrada del diari',+ 'assistant.step.readingJournal': 'Llegint el diari',+ 'assistant.tool.create_journey': 'Comença un diari',+ 'assistant.tool.update_journey': 'Canvia el diari',+ 'assistant.tool.add_journey_trip': 'Afegeix el viatge al diari',+ 'assistant.tool.link_trip_journal': 'Mostra el diari en aquest viatge',+ 'assistant.tool.reorder_journey_entries': 'Reordena el diari',+ 'assistant.followUp.journalToday': 'Escriu una entrada per a avui',+ 'assistant.followUp.journalSummary': 'Resumeix aquests dies',+};export default assistantJourney;diff --git a/shared/src/i18n/cs/assistantJourney.ts b/shared/src/i18n/cs/assistantJourney.tsindex dc8d923a4..d43a5223b 100644--- a/shared/src/i18n/cs/assistantJourney.ts+++ b/shared/src/i18n/cs/assistantJourney.ts@@ -1,4 +1,34 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Záznamy v deníku',+ 'assistant.card.journey.open': 'Otevřít v deníku',+ 'assistant.card.journey.entries': '{count} záznamů',+ 'assistant.card.journey.entries.one': '{count} záznam',+ 'assistant.card.journey.entries.few': '{count} záznamy',+ 'assistant.card.journey.more': '{count} dalších v deníku',+ 'assistant.card.journey.more.one': '{count} další v deníku',+ 'assistant.card.journey.more.few': '{count} další v deníku',+ 'assistant.card.journey.photos': '{count} fotek',+ 'assistant.card.journey.photos.one': '{count} fotka',+ 'assistant.card.journey.photos.few': '{count} fotky',+ 'assistant.card.journey.toSuggestion': 'Vrátí se mezi návrhy',+ 'assistant.card.journey.video': 'Začíná videem',+ 'assistant.card.journey.typeEntry': 'Napsaný záznam',+ 'assistant.card.journey.typeCheckin': 'Přihlášení na místě',+ 'assistant.card.journey.notDraft': 'Už není koncept',+ 'assistant.card.journey.onRoute': 'Opět na trase',+ 'assistant.card.journey.restored': 'Návrh obnoven',+ 'assistant.change.verb.addJournalEntry': 'Přidat záznam do deníku',+ 'assistant.change.verb.updateJournalEntry': 'Změnit záznam v deníku',+ 'assistant.change.verb.removeJournalEntry': 'Smazat záznam z deníku',+ 'assistant.step.readingJournal': 'Čtu deník',+ 'assistant.tool.create_journey': 'Založit deník',+ 'assistant.tool.update_journey': 'Změnit deník',+ 'assistant.tool.add_journey_trip': 'Přidat cestu do deníku',+ 'assistant.tool.link_trip_journal': 'Zobrazit deník v této cestě',+ 'assistant.tool.reorder_journey_entries': 'Přeuspořádat deník',+ 'assistant.followUp.journalToday': 'Napsat záznam za dnešek',+ 'assistant.followUp.journalSummary': 'Shrnout tyto dny',+};export default assistantJourney;diff --git a/shared/src/i18n/de/assistantJourney.ts b/shared/src/i18n/de/assistantJourney.tsindex dc8d923a4..6fb76563d 100644--- a/shared/src/i18n/de/assistantJourney.ts+++ b/shared/src/i18n/de/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Journal-Einträge',+ 'assistant.card.journey.open': 'Im Journal öffnen',+ 'assistant.card.journey.entries': '{count} Einträge',+ 'assistant.card.journey.entries.one': '{count} Eintrag',+ 'assistant.card.journey.more': '{count} weitere im Journal',+ 'assistant.card.journey.more.one': '{count} weiterer im Journal',+ 'assistant.card.journey.photos': '{count} Fotos',+ 'assistant.card.journey.photos.one': '{count} Foto',+ 'assistant.card.journey.toSuggestion': 'Wird wieder zum Vorschlag',+ 'assistant.card.journey.video': 'Beginnt mit einem Video',+ 'assistant.card.journey.typeEntry': 'Geschriebener Eintrag',+ 'assistant.card.journey.typeCheckin': 'Check-in vor Ort',+ 'assistant.card.journey.notDraft': 'Kein Entwurf mehr',+ 'assistant.card.journey.onRoute': 'Wieder auf der Route',+ 'assistant.card.journey.restored': 'Vorschlag zurückgeholt',+ 'assistant.change.verb.addJournalEntry': 'Journal-Eintrag hinzufügen',+ 'assistant.change.verb.updateJournalEntry': 'Journal-Eintrag ändern',+ 'assistant.change.verb.removeJournalEntry': 'Journal-Eintrag löschen',+ 'assistant.step.readingJournal': 'Liest das Journal',+ 'assistant.tool.create_journey': 'Journal anlegen',+ 'assistant.tool.update_journey': 'Journal ändern',+ 'assistant.tool.add_journey_trip': 'Reise zum Journal hinzufügen',+ 'assistant.tool.link_trip_journal': 'Journal in dieser Reise zeigen',+ 'assistant.tool.reorder_journey_entries': 'Journal neu ordnen',+ 'assistant.followUp.journalToday': 'Eintrag für heute schreiben',+ 'assistant.followUp.journalSummary': 'Diese Tage zusammenfassen',+};export default assistantJourney;diff --git a/shared/src/i18n/en/assistantJourney.ts b/shared/src/i18n/en/assistantJourney.tsindex dc8d923a4..229a2593e 100644--- a/shared/src/i18n/en/assistantJourney.ts+++ b/shared/src/i18n/en/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Journal entries',+ 'assistant.card.journey.open': 'Open in the journal',+ 'assistant.card.journey.entries': '{count} entries',+ 'assistant.card.journey.entries.one': '{count} entry',+ 'assistant.card.journey.more': '{count} more in the journal',+ 'assistant.card.journey.more.one': '{count} more in the journal',+ 'assistant.card.journey.photos': '{count} photos',+ 'assistant.card.journey.photos.one': '{count} photo',+ 'assistant.card.journey.toSuggestion': 'Goes back to a suggestion',+ 'assistant.card.journey.video': 'Opens with a video',+ 'assistant.card.journey.typeEntry': 'Written entry',+ 'assistant.card.journey.typeCheckin': 'Check-in',+ 'assistant.card.journey.notDraft': 'No longer a draft',+ 'assistant.card.journey.onRoute': 'Back on the route',+ 'assistant.card.journey.restored': 'Suggestion brought back',+ 'assistant.change.verb.addJournalEntry': 'Add a journal entry',+ 'assistant.change.verb.updateJournalEntry': 'Change the journal entry',+ 'assistant.change.verb.removeJournalEntry': 'Delete the journal entry',+ 'assistant.step.readingJournal': 'Reading the journal',+ 'assistant.tool.create_journey': 'Start a journal',+ 'assistant.tool.update_journey': 'Change the journal',+ 'assistant.tool.add_journey_trip': 'Add the trip to the journal',+ 'assistant.tool.link_trip_journal': 'Show the journal in this trip',+ 'assistant.tool.reorder_journey_entries': 'Reorder the journal',+ 'assistant.followUp.journalToday': 'Write an entry for today',+ 'assistant.followUp.journalSummary': 'Sum up these days',+};export default assistantJourney;diff --git a/shared/src/i18n/es/assistantJourney.ts b/shared/src/i18n/es/assistantJourney.tsindex dc8d923a4..f99e25ea5 100644--- a/shared/src/i18n/es/assistantJourney.ts+++ b/shared/src/i18n/es/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Entradas del diario',+ 'assistant.card.journey.open': 'Abrir en el diario',+ 'assistant.card.journey.entries': '{count} entradas',+ 'assistant.card.journey.entries.one': '{count} entrada',+ 'assistant.card.journey.more': '{count} más en el diario',+ 'assistant.card.journey.more.one': '{count} más en el diario',+ 'assistant.card.journey.photos': '{count} fotos',+ 'assistant.card.journey.photos.one': '{count} foto',+ 'assistant.card.journey.toSuggestion': 'Vuelve a ser una sugerencia',+ 'assistant.card.journey.video': 'Empieza con un vídeo',+ 'assistant.card.journey.typeEntry': 'Entrada escrita',+ 'assistant.card.journey.typeCheckin': 'Registro de llegada',+ 'assistant.card.journey.notDraft': 'Ya no es un borrador',+ 'assistant.card.journey.onRoute': 'De nuevo en la ruta',+ 'assistant.card.journey.restored': 'Sugerencia recuperada',+ 'assistant.change.verb.addJournalEntry': 'Añadir una entrada al diario',+ 'assistant.change.verb.updateJournalEntry': 'Cambiar la entrada del diario',+ 'assistant.change.verb.removeJournalEntry': 'Eliminar la entrada del diario',+ 'assistant.step.readingJournal': 'Leyendo el diario',+ 'assistant.tool.create_journey': 'Crear un diario',+ 'assistant.tool.update_journey': 'Cambiar el diario',+ 'assistant.tool.add_journey_trip': 'Añadir el viaje al diario',+ 'assistant.tool.link_trip_journal': 'Mostrar el diario en este viaje',+ 'assistant.tool.reorder_journey_entries': 'Reordenar el diario',+ 'assistant.followUp.journalToday': 'Escribir una entrada para hoy',+ 'assistant.followUp.journalSummary': 'Resumir estos días',+};export default assistantJourney;diff --git a/shared/src/i18n/et/assistantJourney.ts b/shared/src/i18n/et/assistantJourney.tsindex dc8d923a4..102207cf0 100644--- a/shared/src/i18n/et/assistantJourney.ts+++ b/shared/src/i18n/et/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Päeviku sissekanded',+ 'assistant.card.journey.open': 'Ava päevikus',+ 'assistant.card.journey.entries': '{count} sissekannet',+ 'assistant.card.journey.entries.one': '{count} sissekanne',+ 'assistant.card.journey.more': 'päevikus veel {count}',+ 'assistant.card.journey.more.one': 'päevikus veel {count}',+ 'assistant.card.journey.photos': '{count} fotot',+ 'assistant.card.journey.photos.one': '{count} foto',+ 'assistant.card.journey.toSuggestion': 'Muutub taas soovituseks',+ 'assistant.card.journey.video': 'Algab videoga',+ 'assistant.card.journey.typeEntry': 'Kirjutatud sissekanne',+ 'assistant.card.journey.typeCheckin': 'Kohal registreerimine',+ 'assistant.card.journey.notDraft': 'Pole enam mustand',+ 'assistant.card.journey.onRoute': 'Taas marsruudil',+ 'assistant.card.journey.restored': 'Soovitus taastatud',+ 'assistant.change.verb.addJournalEntry': 'Lisa päevikusse sissekanne',+ 'assistant.change.verb.updateJournalEntry': 'Muuda päeviku sissekannet',+ 'assistant.change.verb.removeJournalEntry': 'Kustuta päeviku sissekanne',+ 'assistant.step.readingJournal': 'Loen päevikut',+ 'assistant.tool.create_journey': 'Alusta päevikut',+ 'assistant.tool.update_journey': 'Muuda päevikut',+ 'assistant.tool.add_journey_trip': 'Lisa reis päevikusse',+ 'assistant.tool.link_trip_journal': 'Näita päevikut selles reisis',+ 'assistant.tool.reorder_journey_entries': 'Järjesta päevik ümber',+ 'assistant.followUp.journalToday': 'Kirjuta tänane sissekanne',+ 'assistant.followUp.journalSummary': 'Võta need päevad kokku',+};export default assistantJourney;diff --git a/shared/src/i18n/fr/assistantJourney.ts b/shared/src/i18n/fr/assistantJourney.tsindex dc8d923a4..881a65735 100644--- a/shared/src/i18n/fr/assistantJourney.ts+++ b/shared/src/i18n/fr/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Entrées du journal',+ 'assistant.card.journey.open': 'Ouvrir dans le journal',+ 'assistant.card.journey.entries': '{count} entrées',+ 'assistant.card.journey.entries.one': '{count} entrée',+ 'assistant.card.journey.more': '{count} de plus dans le journal',+ 'assistant.card.journey.more.one': '{count} de plus dans le journal',+ 'assistant.card.journey.photos': '{count} photos', // same-as-en+ 'assistant.card.journey.photos.one': '{count} photo', // same-as-en+ 'assistant.card.journey.toSuggestion': 'Redevient une suggestion',+ 'assistant.card.journey.video': 'Commence par une vidéo',+ 'assistant.card.journey.typeEntry': 'Entrée rédigée',+ 'assistant.card.journey.typeCheckin': 'Enregistrement sur place',+ 'assistant.card.journey.notDraft': 'Plus un brouillon',+ 'assistant.card.journey.onRoute': 'De retour sur l’itinéraire',+ 'assistant.card.journey.restored': 'Suggestion rétablie',+ 'assistant.change.verb.addJournalEntry': 'Ajouter une entrée au journal',+ 'assistant.change.verb.updateJournalEntry': 'Modifier l’entrée du journal',+ 'assistant.change.verb.removeJournalEntry': 'Supprimer l’entrée du journal',+ 'assistant.step.readingJournal': 'Lecture du journal',+ 'assistant.tool.create_journey': 'Créer un journal',+ 'assistant.tool.update_journey': 'Modifier le journal',+ 'assistant.tool.add_journey_trip': 'Ajouter le voyage au journal',+ 'assistant.tool.link_trip_journal': 'Afficher le journal dans ce voyage',+ 'assistant.tool.reorder_journey_entries': 'Réordonner le journal',+ 'assistant.followUp.journalToday': 'Écrire une entrée pour aujourd’hui',+ 'assistant.followUp.journalSummary': 'Résumer ces jours',+};export default assistantJourney;diff --git a/shared/src/i18n/gr/assistantJourney.ts b/shared/src/i18n/gr/assistantJourney.tsindex dc8d923a4..fed7110f7 100644--- a/shared/src/i18n/gr/assistantJourney.ts+++ b/shared/src/i18n/gr/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Καταχωρίσεις ημερολογίου',+ 'assistant.card.journey.open': 'Άνοιγμα στο ημερολόγιο',+ 'assistant.card.journey.entries': '{count} καταχωρίσεις',+ 'assistant.card.journey.entries.one': '{count} καταχώριση',+ 'assistant.card.journey.more': '{count} ακόμη στο ημερολόγιο',+ 'assistant.card.journey.more.one': '{count} ακόμη στο ημερολόγιο',+ 'assistant.card.journey.photos': '{count} φωτογραφίες',+ 'assistant.card.journey.photos.one': '{count} φωτογραφία',+ 'assistant.card.journey.toSuggestion': 'Γίνεται ξανά πρόταση',+ 'assistant.card.journey.video': 'Ξεκινά με βίντεο',+ 'assistant.card.journey.typeEntry': 'Γραπτή καταχώριση',+ 'assistant.card.journey.typeCheckin': 'Δήλωση άφιξης',+ 'assistant.card.journey.notDraft': 'Δεν είναι πλέον πρόχειρο',+ 'assistant.card.journey.onRoute': 'Ξανά στη διαδρομή',+ 'assistant.card.journey.restored': 'Η πρόταση επανήλθε',+ 'assistant.change.verb.addJournalEntry': 'Προσθήκη καταχώρισης στο ημερολόγιο',+ 'assistant.change.verb.updateJournalEntry': 'Αλλαγή της καταχώρισης ημερολογίου',+ 'assistant.change.verb.removeJournalEntry': 'Διαγραφή της καταχώρισης ημερολογίου',+ 'assistant.step.readingJournal': 'Διαβάζω το ημερολόγιο',+ 'assistant.tool.create_journey': 'Δημιουργία ημερολογίου',+ 'assistant.tool.update_journey': 'Αλλαγή του ημερολογίου',+ 'assistant.tool.add_journey_trip': 'Προσθήκη του ταξιδιού στο ημερολόγιο',+ 'assistant.tool.link_trip_journal': 'Εμφάνιση του ημερολογίου σε αυτό το ταξίδι',+ 'assistant.tool.reorder_journey_entries': 'Αναδιάταξη του ημερολογίου',+ 'assistant.followUp.journalToday': 'Γράψε μια καταχώριση για σήμερα',+ 'assistant.followUp.journalSummary': 'Σύνοψη αυτών των ημερών',+};export default assistantJourney;diff --git a/shared/src/i18n/hu/assistantJourney.ts b/shared/src/i18n/hu/assistantJourney.tsindex dc8d923a4..06e10f62e 100644--- a/shared/src/i18n/hu/assistantJourney.ts+++ b/shared/src/i18n/hu/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Naplóbejegyzések',+ 'assistant.card.journey.open': 'Megnyitás a naplóban',+ 'assistant.card.journey.entries': '{count} bejegyzés',+ 'assistant.card.journey.entries.one': '{count} bejegyzés',+ 'assistant.card.journey.more': 'még {count} a naplóban',+ 'assistant.card.journey.more.one': 'még {count} a naplóban',+ 'assistant.card.journey.photos': '{count} fotó',+ 'assistant.card.journey.photos.one': '{count} fotó',+ 'assistant.card.journey.toSuggestion': 'Újra javaslat lesz belőle',+ 'assistant.card.journey.video': 'Videóval kezdődik',+ 'assistant.card.journey.typeEntry': 'Megírt bejegyzés',+ 'assistant.card.journey.typeCheckin': 'Bejelentkezés a helyszínen',+ 'assistant.card.journey.notDraft': 'Már nem piszkozat',+ 'assistant.card.journey.onRoute': 'Újra az útvonalon',+ 'assistant.card.journey.restored': 'Javaslat visszahozva',+ 'assistant.change.verb.addJournalEntry': 'Naplóbejegyzés hozzáadása',+ 'assistant.change.verb.updateJournalEntry': 'Naplóbejegyzés módosítása',+ 'assistant.change.verb.removeJournalEntry': 'Naplóbejegyzés törlése',+ 'assistant.step.readingJournal': 'A napló olvasása',+ 'assistant.tool.create_journey': 'Napló indítása',+ 'assistant.tool.update_journey': 'Napló módosítása',+ 'assistant.tool.add_journey_trip': 'Az utazás hozzáadása a naplóhoz',+ 'assistant.tool.link_trip_journal': 'A napló megjelenítése ebben az utazásban',+ 'assistant.tool.reorder_journey_entries': 'A napló átrendezése',+ 'assistant.followUp.journalToday': 'Bejegyzés írása mára',+ 'assistant.followUp.journalSummary': 'Ezeknek a napoknak az összefoglalása',+};export default assistantJourney;diff --git a/shared/src/i18n/id/assistantJourney.ts b/shared/src/i18n/id/assistantJourney.tsindex dc8d923a4..d9218f7e4 100644--- a/shared/src/i18n/id/assistantJourney.ts+++ b/shared/src/i18n/id/assistantJourney.ts@@ -1,4 +1,28 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Entri jurnal',+ 'assistant.card.journey.open': 'Buka di jurnal',+ 'assistant.card.journey.entries': '{count} entri',+ 'assistant.card.journey.more': '{count} lagi di jurnal',+ 'assistant.card.journey.photos': '{count} foto',+ 'assistant.card.journey.toSuggestion': 'Kembali menjadi saran',+ 'assistant.card.journey.video': 'Dimulai dengan video',+ 'assistant.card.journey.typeEntry': 'Entri tertulis',+ 'assistant.card.journey.typeCheckin': 'Lapor kehadiran',+ 'assistant.card.journey.notDraft': 'Bukan draf lagi',+ 'assistant.card.journey.onRoute': 'Kembali di rute',+ 'assistant.card.journey.restored': 'Saran dikembalikan',+ 'assistant.change.verb.addJournalEntry': 'Tambahkan entri jurnal',+ 'assistant.change.verb.updateJournalEntry': 'Ubah entri jurnal',+ 'assistant.change.verb.removeJournalEntry': 'Hapus entri jurnal',+ 'assistant.step.readingJournal': 'Membaca jurnal',+ 'assistant.tool.create_journey': 'Mulai jurnal',+ 'assistant.tool.update_journey': 'Ubah jurnal',+ 'assistant.tool.add_journey_trip': 'Tambahkan perjalanan ke jurnal',+ 'assistant.tool.link_trip_journal': 'Tampilkan jurnal di perjalanan ini',+ 'assistant.tool.reorder_journey_entries': 'Urutkan ulang jurnal',+ 'assistant.followUp.journalToday': 'Tulis entri untuk hari ini',+ 'assistant.followUp.journalSummary': 'Rangkum hari-hari ini',+};export default assistantJourney;diff --git a/shared/src/i18n/it/assistantJourney.ts b/shared/src/i18n/it/assistantJourney.tsindex dc8d923a4..b85daac1d 100644--- a/shared/src/i18n/it/assistantJourney.ts+++ b/shared/src/i18n/it/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Voci del diario',+ 'assistant.card.journey.open': 'Apri nel diario',+ 'assistant.card.journey.entries': '{count} voci',+ 'assistant.card.journey.entries.one': '{count} voce',+ 'assistant.card.journey.more': 'ancora {count} nel diario',+ 'assistant.card.journey.more.one': 'ancora {count} nel diario',+ 'assistant.card.journey.photos': '{count} foto',+ 'assistant.card.journey.photos.one': '{count} foto',+ 'assistant.card.journey.toSuggestion': 'Torna a essere un suggerimento',+ 'assistant.card.journey.video': 'Inizia con un video',+ 'assistant.card.journey.typeEntry': 'Voce scritta',+ 'assistant.card.journey.typeCheckin': 'Registrazione sul posto',+ 'assistant.card.journey.notDraft': 'Non più una bozza',+ 'assistant.card.journey.onRoute': 'Di nuovo sul percorso',+ 'assistant.card.journey.restored': 'Suggerimento ripristinato',+ 'assistant.change.verb.addJournalEntry': 'Aggiungi una voce al diario',+ 'assistant.change.verb.updateJournalEntry': 'Modifica la voce del diario',+ 'assistant.change.verb.removeJournalEntry': 'Elimina la voce del diario',+ 'assistant.step.readingJournal': 'Leggo il diario',+ 'assistant.tool.create_journey': 'Crea un diario',+ 'assistant.tool.update_journey': 'Modifica il diario',+ 'assistant.tool.add_journey_trip': 'Aggiungi il viaggio al diario',+ 'assistant.tool.link_trip_journal': 'Mostra il diario in questo viaggio',+ 'assistant.tool.reorder_journey_entries': 'Riordina il diario',+ 'assistant.followUp.journalToday': 'Scrivi una voce per oggi',+ 'assistant.followUp.journalSummary': 'Riassumi questi giorni',+};export default assistantJourney;diff --git a/shared/src/i18n/ja/assistantJourney.ts b/shared/src/i18n/ja/assistantJourney.tsindex dc8d923a4..eb1237e80 100644--- a/shared/src/i18n/ja/assistantJourney.ts+++ b/shared/src/i18n/ja/assistantJourney.ts@@ -1,4 +1,28 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'ジャーナルのエントリー',+ 'assistant.card.journey.open': 'ジャーナルで開く',+ 'assistant.card.journey.entries': '{count} 件のエントリー',+ 'assistant.card.journey.more': 'ジャーナルにあと {count} 件',+ 'assistant.card.journey.photos': '写真 {count} 枚',+ 'assistant.card.journey.toSuggestion': '提案に戻ります',+ 'assistant.card.journey.video': '動画から始まります',+ 'assistant.card.journey.typeEntry': '書いた記録',+ 'assistant.card.journey.typeCheckin': 'チェックイン',+ 'assistant.card.journey.notDraft': '下書きではなくなります',+ 'assistant.card.journey.onRoute': 'ルートに戻ります',+ 'assistant.card.journey.restored': '提案を戻しました',+ 'assistant.change.verb.addJournalEntry': 'ジャーナルにエントリーを追加',+ 'assistant.change.verb.updateJournalEntry': 'ジャーナルのエントリーを変更',+ 'assistant.change.verb.removeJournalEntry': 'ジャーナルのエントリーを削除',+ 'assistant.step.readingJournal': 'ジャーナルを読み込み中',+ 'assistant.tool.create_journey': 'ジャーナルを作成',+ 'assistant.tool.update_journey': 'ジャーナルを変更',+ 'assistant.tool.add_journey_trip': '旅行をジャーナルに追加',+ 'assistant.tool.link_trip_journal': 'この旅行にジャーナルを表示',+ 'assistant.tool.reorder_journey_entries': 'ジャーナルを並べ替え',+ 'assistant.followUp.journalToday': '今日のエントリーを書く',+ 'assistant.followUp.journalSummary': 'この数日をまとめる',+};export default assistantJourney;diff --git a/shared/src/i18n/ko/assistantJourney.ts b/shared/src/i18n/ko/assistantJourney.tsindex dc8d923a4..5ac513777 100644--- a/shared/src/i18n/ko/assistantJourney.ts+++ b/shared/src/i18n/ko/assistantJourney.ts@@ -1,4 +1,28 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': '저널 항목',+ 'assistant.card.journey.open': '저널에서 열기',+ 'assistant.card.journey.entries': '항목 {count}개',+ 'assistant.card.journey.more': '저널에 {count}개 더',+ 'assistant.card.journey.photos': '사진 {count}장',+ 'assistant.card.journey.toSuggestion': '다시 제안으로 돌아갑니다',+ 'assistant.card.journey.video': '동영상으로 시작합니다',+ 'assistant.card.journey.typeEntry': '작성한 기록',+ 'assistant.card.journey.typeCheckin': '체크인',+ 'assistant.card.journey.notDraft': '더 이상 초안 아님',+ 'assistant.card.journey.onRoute': '다시 경로에 포함',+ 'assistant.card.journey.restored': '제안을 되돌림',+ 'assistant.change.verb.addJournalEntry': '저널 항목 추가',+ 'assistant.change.verb.updateJournalEntry': '저널 항목 변경',+ 'assistant.change.verb.removeJournalEntry': '저널 항목 삭제',+ 'assistant.step.readingJournal': '저널을 읽는 중',+ 'assistant.tool.create_journey': '저널 시작',+ 'assistant.tool.update_journey': '저널 변경',+ 'assistant.tool.add_journey_trip': '여행을 저널에 추가',+ 'assistant.tool.link_trip_journal': '이 여행에 저널 표시',+ 'assistant.tool.reorder_journey_entries': '저널 순서 변경',+ 'assistant.followUp.journalToday': '오늘 항목 쓰기',+ 'assistant.followUp.journalSummary': '이 며칠 요약하기',+};export default assistantJourney;diff --git a/shared/src/i18n/nl/assistantJourney.ts b/shared/src/i18n/nl/assistantJourney.tsindex dc8d923a4..4b7207a68 100644--- a/shared/src/i18n/nl/assistantJourney.ts+++ b/shared/src/i18n/nl/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Dagboekberichten',+ 'assistant.card.journey.open': 'Openen in het dagboek',+ 'assistant.card.journey.entries': '{count} berichten',+ 'assistant.card.journey.entries.one': '{count} bericht',+ 'assistant.card.journey.more': 'nog {count} in het dagboek',+ 'assistant.card.journey.more.one': 'nog {count} in het dagboek',+ 'assistant.card.journey.photos': '{count} foto’s',+ 'assistant.card.journey.photos.one': '{count} foto',+ 'assistant.card.journey.toSuggestion': 'Wordt weer een suggestie',+ 'assistant.card.journey.video': 'Begint met een video',+ 'assistant.card.journey.typeEntry': 'Geschreven bericht',+ 'assistant.card.journey.typeCheckin': 'Inchecken',+ 'assistant.card.journey.notDraft': 'Geen concept meer',+ 'assistant.card.journey.onRoute': 'Weer op de route',+ 'assistant.card.journey.restored': 'Suggestie teruggehaald',+ 'assistant.change.verb.addJournalEntry': 'Dagboekbericht toevoegen',+ 'assistant.change.verb.updateJournalEntry': 'Dagboekbericht wijzigen',+ 'assistant.change.verb.removeJournalEntry': 'Dagboekbericht verwijderen',+ 'assistant.step.readingJournal': 'Het dagboek lezen',+ 'assistant.tool.create_journey': 'Dagboek beginnen',+ 'assistant.tool.update_journey': 'Dagboek wijzigen',+ 'assistant.tool.add_journey_trip': 'Reis aan het dagboek toevoegen',+ 'assistant.tool.link_trip_journal': 'Dagboek in deze reis tonen',+ 'assistant.tool.reorder_journey_entries': 'Dagboek herschikken',+ 'assistant.followUp.journalToday': 'Schrijf een bericht voor vandaag',+ 'assistant.followUp.journalSummary': 'Vat deze dagen samen',+};export default assistantJourney;diff --git a/shared/src/i18n/pl/assistantJourney.ts b/shared/src/i18n/pl/assistantJourney.tsindex dc8d923a4..c0782f7af 100644--- a/shared/src/i18n/pl/assistantJourney.ts+++ b/shared/src/i18n/pl/assistantJourney.ts@@ -1,4 +1,37 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Wpisy w dzienniku',+ 'assistant.card.journey.open': 'Otwórz w dzienniku',+ 'assistant.card.journey.entries': '{count} wpisu',+ 'assistant.card.journey.entries.one': '{count} wpis',+ 'assistant.card.journey.entries.few': '{count} wpisy',+ 'assistant.card.journey.entries.many': '{count} wpisów',+ 'assistant.card.journey.more': 'jeszcze {count} w dzienniku',+ 'assistant.card.journey.more.one': 'jeszcze {count} w dzienniku',+ 'assistant.card.journey.more.few': 'jeszcze {count} w dzienniku',+ 'assistant.card.journey.more.many': 'jeszcze {count} w dzienniku',+ 'assistant.card.journey.photos': '{count} zdjęcia',+ 'assistant.card.journey.photos.one': '{count} zdjęcie',+ 'assistant.card.journey.photos.few': '{count} zdjęcia',+ 'assistant.card.journey.photos.many': '{count} zdjęć',+ 'assistant.card.journey.toSuggestion': 'Wraca do propozycji',+ 'assistant.card.journey.video': 'Zaczyna się od filmu',+ 'assistant.card.journey.typeEntry': 'Napisany wpis',+ 'assistant.card.journey.typeCheckin': 'Zameldowanie',+ 'assistant.card.journey.notDraft': 'Już nie szkic',+ 'assistant.card.journey.onRoute': 'Znów na trasie',+ 'assistant.card.journey.restored': 'Przywrócono sugestię',+ 'assistant.change.verb.addJournalEntry': 'Dodaj wpis do dziennika',+ 'assistant.change.verb.updateJournalEntry': 'Zmień wpis w dzienniku',+ 'assistant.change.verb.removeJournalEntry': 'Usuń wpis z dziennika',+ 'assistant.step.readingJournal': 'Czytam dziennik',+ 'assistant.tool.create_journey': 'Załóż dziennik',+ 'assistant.tool.update_journey': 'Zmień dziennik',+ 'assistant.tool.add_journey_trip': 'Dodaj podróż do dziennika',+ 'assistant.tool.link_trip_journal': 'Pokaż dziennik w tej podróży',+ 'assistant.tool.reorder_journey_entries': 'Zmień kolejność dziennika',+ 'assistant.followUp.journalToday': 'Napisz wpis na dziś',+ 'assistant.followUp.journalSummary': 'Podsumuj te dni',+};export default assistantJourney;diff --git a/shared/src/i18n/ru/assistantJourney.ts b/shared/src/i18n/ru/assistantJourney.tsindex dc8d923a4..c9abd4d25 100644--- a/shared/src/i18n/ru/assistantJourney.ts+++ b/shared/src/i18n/ru/assistantJourney.ts@@ -1,4 +1,37 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Записи дневника',+ 'assistant.card.journey.open': 'Открыть в дневнике',+ 'assistant.card.journey.entries': '{count} записи',+ 'assistant.card.journey.entries.one': '{count} запись',+ 'assistant.card.journey.entries.few': '{count} записи',+ 'assistant.card.journey.entries.many': '{count} записей',+ 'assistant.card.journey.more': 'ещё {count} в дневнике',+ 'assistant.card.journey.more.one': 'ещё {count} в дневнике',+ 'assistant.card.journey.more.few': 'ещё {count} в дневнике',+ 'assistant.card.journey.more.many': 'ещё {count} в дневнике',+ 'assistant.card.journey.photos': '{count} фото',+ 'assistant.card.journey.photos.one': '{count} фото',+ 'assistant.card.journey.photos.few': '{count} фото',+ 'assistant.card.journey.photos.many': '{count} фото',+ 'assistant.card.journey.toSuggestion': 'Снова станет предложением',+ 'assistant.card.journey.video': 'Начинается с видео',+ 'assistant.card.journey.typeEntry': 'Написанная запись',+ 'assistant.card.journey.typeCheckin': 'Отметка на месте',+ 'assistant.card.journey.notDraft': 'Больше не черновик',+ 'assistant.card.journey.onRoute': 'Снова на маршруте',+ 'assistant.card.journey.restored': 'Предложение возвращено',+ 'assistant.change.verb.addJournalEntry': 'Добавить запись в дневник',+ 'assistant.change.verb.updateJournalEntry': 'Изменить запись дневника',+ 'assistant.change.verb.removeJournalEntry': 'Удалить запись дневника',+ 'assistant.step.readingJournal': 'Читаю дневник',+ 'assistant.tool.create_journey': 'Создать дневник',+ 'assistant.tool.update_journey': 'Изменить дневник',+ 'assistant.tool.add_journey_trip': 'Добавить поездку в дневник',+ 'assistant.tool.link_trip_journal': 'Показать дневник в этой поездке',+ 'assistant.tool.reorder_journey_entries': 'Изменить порядок дневника',+ 'assistant.followUp.journalToday': 'Написать запись за сегодня',+ 'assistant.followUp.journalSummary': 'Подвести итог этих дней',+};export default assistantJourney;diff --git a/shared/src/i18n/sk/assistantJourney.ts b/shared/src/i18n/sk/assistantJourney.tsindex dc8d923a4..cf18b5301 100644--- a/shared/src/i18n/sk/assistantJourney.ts+++ b/shared/src/i18n/sk/assistantJourney.ts@@ -1,4 +1,34 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Záznamy v denníku',+ 'assistant.card.journey.open': 'Otvoriť v denníku',+ 'assistant.card.journey.entries': '{count} záznamov',+ 'assistant.card.journey.entries.one': '{count} záznam',+ 'assistant.card.journey.entries.few': '{count} záznamy',+ 'assistant.card.journey.more': '{count} ďalších v denníku',+ 'assistant.card.journey.more.one': '{count} ďalší v denníku',+ 'assistant.card.journey.more.few': '{count} ďalšie v denníku',+ 'assistant.card.journey.photos': '{count} fotiek',+ 'assistant.card.journey.photos.one': '{count} fotka',+ 'assistant.card.journey.photos.few': '{count} fotky',+ 'assistant.card.journey.toSuggestion': 'Vráti sa medzi návrhy',+ 'assistant.card.journey.video': 'Začína videom',+ 'assistant.card.journey.typeEntry': 'Napísaný záznam',+ 'assistant.card.journey.typeCheckin': 'Prihlásenie na mieste',+ 'assistant.card.journey.notDraft': 'Už nie je koncept',+ 'assistant.card.journey.onRoute': 'Opäť na trase',+ 'assistant.card.journey.restored': 'Návrh obnovený',+ 'assistant.change.verb.addJournalEntry': 'Pridať záznam do denníka',+ 'assistant.change.verb.updateJournalEntry': 'Zmeniť záznam v denníku',+ 'assistant.change.verb.removeJournalEntry': 'Zmazať záznam z denníka',+ 'assistant.step.readingJournal': 'Čítam denník',+ 'assistant.tool.create_journey': 'Založiť denník',+ 'assistant.tool.update_journey': 'Zmeniť denník',+ 'assistant.tool.add_journey_trip': 'Pridať cestu do denníka',+ 'assistant.tool.link_trip_journal': 'Zobraziť denník v tejto ceste',+ 'assistant.tool.reorder_journey_entries': 'Preusporiadať denník',+ 'assistant.followUp.journalToday': 'Napísať záznam za dnešok',+ 'assistant.followUp.journalSummary': 'Zhrnúť tieto dni',+};export default assistantJourney;diff --git a/shared/src/i18n/sv/assistantJourney.ts b/shared/src/i18n/sv/assistantJourney.tsindex dc8d923a4..6b0734c60 100644--- a/shared/src/i18n/sv/assistantJourney.ts+++ b/shared/src/i18n/sv/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Dagboksinlägg',+ 'assistant.card.journey.open': 'Öppna i dagboken',+ 'assistant.card.journey.entries': '{count} inlägg',+ 'assistant.card.journey.entries.one': '{count} inlägg',+ 'assistant.card.journey.more': '{count} till i dagboken',+ 'assistant.card.journey.more.one': '{count} till i dagboken',+ 'assistant.card.journey.photos': '{count} foton',+ 'assistant.card.journey.photos.one': '{count} foto',+ 'assistant.card.journey.toSuggestion': 'Blir ett förslag igen',+ 'assistant.card.journey.video': 'Börjar med en video',+ 'assistant.card.journey.typeEntry': 'Skrivet inlägg',+ 'assistant.card.journey.typeCheckin': 'Incheckning',+ 'assistant.card.journey.notDraft': 'Inte längre ett utkast',+ 'assistant.card.journey.onRoute': 'Tillbaka på rutten',+ 'assistant.card.journey.restored': 'Förslaget återställt',+ 'assistant.change.verb.addJournalEntry': 'Lägg till ett dagboksinlägg',+ 'assistant.change.verb.updateJournalEntry': 'Ändra dagboksinlägget',+ 'assistant.change.verb.removeJournalEntry': 'Ta bort dagboksinlägget',+ 'assistant.step.readingJournal': 'Läser dagboken',+ 'assistant.tool.create_journey': 'Skapa en dagbok',+ 'assistant.tool.update_journey': 'Ändra dagboken',+ 'assistant.tool.add_journey_trip': 'Lägg till resan i dagboken',+ 'assistant.tool.link_trip_journal': 'Visa dagboken i den här resan',+ 'assistant.tool.reorder_journey_entries': 'Ordna om dagboken',+ 'assistant.followUp.journalToday': 'Skriv ett inlägg för i dag',+ 'assistant.followUp.journalSummary': 'Sammanfatta de här dagarna',+};export default assistantJourney;diff --git a/shared/src/i18n/th/assistantJourney.ts b/shared/src/i18n/th/assistantJourney.tsindex dc8d923a4..4feb92b84 100644--- a/shared/src/i18n/th/assistantJourney.ts+++ b/shared/src/i18n/th/assistantJourney.ts@@ -1,4 +1,28 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'รายการบันทึก',+ 'assistant.card.journey.open': 'เปิดในบันทึก',+ 'assistant.card.journey.entries': '{count} รายการ',+ 'assistant.card.journey.more': 'อีก {count} รายการในบันทึก',+ 'assistant.card.journey.photos': 'รูปภาพ {count} รูป',+ 'assistant.card.journey.toSuggestion': 'จะกลับไปเป็นคำแนะนำ',+ 'assistant.card.journey.video': 'เริ่มต้นด้วยวิดีโอ',+ 'assistant.card.journey.typeEntry': 'บันทึกที่เขียนแล้ว',+ 'assistant.card.journey.typeCheckin': 'เช็กอิน',+ 'assistant.card.journey.notDraft': 'ไม่ใช่ฉบับร่างอีกต่อไป',+ 'assistant.card.journey.onRoute': 'กลับมาอยู่ในเส้นทาง',+ 'assistant.card.journey.restored': 'นำคำแนะนำกลับมาแล้ว',+ 'assistant.change.verb.addJournalEntry': 'เพิ่มรายการบันทึก',+ 'assistant.change.verb.updateJournalEntry': 'แก้ไขรายการบันทึก',+ 'assistant.change.verb.removeJournalEntry': 'ลบรายการบันทึก',+ 'assistant.step.readingJournal': 'กำลังอ่านบันทึก',+ 'assistant.tool.create_journey': 'เริ่มบันทึก',+ 'assistant.tool.update_journey': 'แก้ไขบันทึก',+ 'assistant.tool.add_journey_trip': 'เพิ่มทริปลงในบันทึก',+ 'assistant.tool.link_trip_journal': 'แสดงบันทึกในทริปนี้',+ 'assistant.tool.reorder_journey_entries': 'จัดลำดับบันทึกใหม่',+ 'assistant.followUp.journalToday': 'เขียนรายการสำหรับวันนี้',+ 'assistant.followUp.journalSummary': 'สรุปวันเหล่านี้',+};export default assistantJourney;diff --git a/shared/src/i18n/tr/assistantJourney.ts b/shared/src/i18n/tr/assistantJourney.tsindex dc8d923a4..04520250c 100644--- a/shared/src/i18n/tr/assistantJourney.ts+++ b/shared/src/i18n/tr/assistantJourney.ts@@ -1,4 +1,31 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Günlük kayıtları',+ 'assistant.card.journey.open': 'Günlükte aç',+ 'assistant.card.journey.entries': '{count} kayıt',+ 'assistant.card.journey.entries.one': '{count} kayıt',+ 'assistant.card.journey.more': 'günlükte {count} tane daha',+ 'assistant.card.journey.more.one': 'günlükte {count} tane daha',+ 'assistant.card.journey.photos': '{count} fotoğraf',+ 'assistant.card.journey.photos.one': '{count} fotoğraf',+ 'assistant.card.journey.toSuggestion': 'Yeniden öneriye döner',+ 'assistant.card.journey.video': 'Bir videoyla başlar',+ 'assistant.card.journey.typeEntry': 'Yazılmış kayıt',+ 'assistant.card.journey.typeCheckin': 'Giriş kaydı',+ 'assistant.card.journey.notDraft': 'Artık taslak değil',+ 'assistant.card.journey.onRoute': 'Yeniden rotada',+ 'assistant.card.journey.restored': 'Öneri geri getirildi',+ 'assistant.change.verb.addJournalEntry': 'Günlüğe kayıt ekle',+ 'assistant.change.verb.updateJournalEntry': 'Günlük kaydını değiştir',+ 'assistant.change.verb.removeJournalEntry': 'Günlük kaydını sil',+ 'assistant.step.readingJournal': 'Günlük okunuyor',+ 'assistant.tool.create_journey': 'Günlük başlat',+ 'assistant.tool.update_journey': 'Günlüğü değiştir',+ 'assistant.tool.add_journey_trip': 'Geziyi günlüğe ekle',+ 'assistant.tool.link_trip_journal': 'Günlüğü bu gezide göster',+ 'assistant.tool.reorder_journey_entries': 'Günlüğü yeniden sırala',+ 'assistant.followUp.journalToday': 'Bugün için bir kayıt yaz',+ 'assistant.followUp.journalSummary': 'Bu günleri özetle',+};export default assistantJourney;diff --git a/shared/src/i18n/uk/assistantJourney.ts b/shared/src/i18n/uk/assistantJourney.tsindex dc8d923a4..2d672dfaf 100644--- a/shared/src/i18n/uk/assistantJourney.ts+++ b/shared/src/i18n/uk/assistantJourney.ts@@ -1,4 +1,37 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Записи щоденника',+ 'assistant.card.journey.open': 'Відкрити в щоденнику',+ 'assistant.card.journey.entries': '{count} запису',+ 'assistant.card.journey.entries.one': '{count} запис',+ 'assistant.card.journey.entries.few': '{count} записи',+ 'assistant.card.journey.entries.many': '{count} записів',+ 'assistant.card.journey.more': 'ще {count} у щоденнику',+ 'assistant.card.journey.more.one': 'ще {count} у щоденнику',+ 'assistant.card.journey.more.few': 'ще {count} у щоденнику',+ 'assistant.card.journey.more.many': 'ще {count} у щоденнику',+ 'assistant.card.journey.photos': '{count} фото',+ 'assistant.card.journey.photos.one': '{count} фото',+ 'assistant.card.journey.photos.few': '{count} фото',+ 'assistant.card.journey.photos.many': '{count} фото',+ 'assistant.card.journey.toSuggestion': 'Знову стане пропозицією',+ 'assistant.card.journey.video': 'Починається з відео',+ 'assistant.card.journey.typeEntry': 'Написаний запис',+ 'assistant.card.journey.typeCheckin': 'Відмітка на місці',+ 'assistant.card.journey.notDraft': 'Більше не чернетка',+ 'assistant.card.journey.onRoute': 'Знову на маршруті',+ 'assistant.card.journey.restored': 'Пропозицію повернуто',+ 'assistant.change.verb.addJournalEntry': 'Додати запис до щоденника',+ 'assistant.change.verb.updateJournalEntry': 'Змінити запис щоденника',+ 'assistant.change.verb.removeJournalEntry': 'Видалити запис щоденника',+ 'assistant.step.readingJournal': 'Читаю щоденник',+ 'assistant.tool.create_journey': 'Створити щоденник',+ 'assistant.tool.update_journey': 'Змінити щоденник',+ 'assistant.tool.add_journey_trip': 'Додати поїздку до щоденника',+ 'assistant.tool.link_trip_journal': 'Показати щоденник у цій поїздці',+ 'assistant.tool.reorder_journey_entries': 'Змінити порядок щоденника',+ 'assistant.followUp.journalToday': 'Написати запис за сьогодні',+ 'assistant.followUp.journalSummary': 'Підсумувати ці дні',+};export default assistantJourney;diff --git a/shared/src/i18n/vi/assistantJourney.ts b/shared/src/i18n/vi/assistantJourney.tsindex dc8d923a4..4ab426856 100644--- a/shared/src/i18n/vi/assistantJourney.ts+++ b/shared/src/i18n/vi/assistantJourney.ts@@ -1,4 +1,28 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': 'Mục nhật ký',+ 'assistant.card.journey.open': 'Mở trong nhật ký',+ 'assistant.card.journey.entries': '{count} mục',+ 'assistant.card.journey.more': 'thêm {count} mục trong nhật ký',+ 'assistant.card.journey.photos': '{count} ảnh',+ 'assistant.card.journey.toSuggestion': 'Trở lại thành gợi ý',+ 'assistant.card.journey.video': 'Bắt đầu bằng một video',+ 'assistant.card.journey.typeEntry': 'Mục đã viết',+ 'assistant.card.journey.typeCheckin': 'Ghé thăm',+ 'assistant.card.journey.notDraft': 'Không còn là bản nháp',+ 'assistant.card.journey.onRoute': 'Trở lại lộ trình',+ 'assistant.card.journey.restored': 'Đã khôi phục gợi ý',+ 'assistant.change.verb.addJournalEntry': 'Thêm mục nhật ký',+ 'assistant.change.verb.updateJournalEntry': 'Thay đổi mục nhật ký',+ 'assistant.change.verb.removeJournalEntry': 'Xóa mục nhật ký',+ 'assistant.step.readingJournal': 'Đang đọc nhật ký',+ 'assistant.tool.create_journey': 'Bắt đầu nhật ký',+ 'assistant.tool.update_journey': 'Thay đổi nhật ký',+ 'assistant.tool.add_journey_trip': 'Thêm chuyến đi vào nhật ký',+ 'assistant.tool.link_trip_journal': 'Hiển thị nhật ký trong chuyến đi này',+ 'assistant.tool.reorder_journey_entries': 'Sắp xếp lại nhật ký',+ 'assistant.followUp.journalToday': 'Viết mục cho hôm nay',+ 'assistant.followUp.journalSummary': 'Tóm tắt những ngày này',+};export default assistantJourney;diff --git a/shared/src/i18n/zh-TW/assistantJourney.ts b/shared/src/i18n/zh-TW/assistantJourney.tsindex dc8d923a4..bad6e5729 100644--- a/shared/src/i18n/zh-TW/assistantJourney.ts+++ b/shared/src/i18n/zh-TW/assistantJourney.ts@@ -1,4 +1,28 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': '日誌條目',+ 'assistant.card.journey.open': '在日誌中開啟',+ 'assistant.card.journey.entries': '{count} 則條目',+ 'assistant.card.journey.more': '日誌中還有 {count} 則',+ 'assistant.card.journey.photos': '{count} 張照片',+ 'assistant.card.journey.toSuggestion': '將變回建議',+ 'assistant.card.journey.video': '以影片開頭',+ 'assistant.card.journey.typeEntry': '已撰寫的紀錄',+ 'assistant.card.journey.typeCheckin': '打卡',+ 'assistant.card.journey.notDraft': '不再是草稿',+ 'assistant.card.journey.onRoute': '重新計入路線',+ 'assistant.card.journey.restored': '已恢復建議',+ 'assistant.change.verb.addJournalEntry': '新增日誌條目',+ 'assistant.change.verb.updateJournalEntry': '變更日誌條目',+ 'assistant.change.verb.removeJournalEntry': '刪除日誌條目',+ 'assistant.step.readingJournal': '正在讀取日誌',+ 'assistant.tool.create_journey': '建立日誌',+ 'assistant.tool.update_journey': '變更日誌',+ 'assistant.tool.add_journey_trip': '將行程加入日誌',+ 'assistant.tool.link_trip_journal': '在此行程中顯示日誌',+ 'assistant.tool.reorder_journey_entries': '重新排列日誌',+ 'assistant.followUp.journalToday': '寫一則今天的條目',+ 'assistant.followUp.journalSummary': '總結這幾天',+};export default assistantJourney;diff --git a/shared/src/i18n/zh/assistantJourney.ts b/shared/src/i18n/zh/assistantJourney.tsindex dc8d923a4..a2acd2f22 100644--- a/shared/src/i18n/zh/assistantJourney.ts+++ b/shared/src/i18n/zh/assistantJourney.ts@@ -1,4 +1,28 @@import type { TranslationStrings } from '../types';-const assistantJourney: TranslationStrings = {};+const assistantJourney: TranslationStrings = {+ 'assistant.card.journey.label': '日志条目',+ 'assistant.card.journey.open': '在日志中打开',+ 'assistant.card.journey.entries': '{count} 条条目',+ 'assistant.card.journey.more': '日志中还有 {count} 条',+ 'assistant.card.journey.photos': '{count} 张照片',+ 'assistant.card.journey.toSuggestion': '将变回建议',+ 'assistant.card.journey.video': '以视频开头',+ 'assistant.card.journey.typeEntry': '已撰写的记录',+ 'assistant.card.journey.typeCheckin': '签到',+ 'assistant.card.journey.notDraft': '不再是草稿',+ 'assistant.card.journey.onRoute': '重新计入路线',+ 'assistant.card.journey.restored': '已恢复建议',+ 'assistant.change.verb.addJournalEntry': '添加日志条目',+ 'assistant.change.verb.updateJournalEntry': '更改日志条目',+ 'assistant.change.verb.removeJournalEntry': '删除日志条目',+ 'assistant.step.readingJournal': '正在读取日志',+ 'assistant.tool.create_journey': '新建日志',+ 'assistant.tool.update_journey': '更改日志',+ 'assistant.tool.add_journey_trip': '将行程添加到日志',+ 'assistant.tool.link_trip_journal': '在此行程中显示日志',+ 'assistant.tool.reorder_journey_entries': '重新排序日志',+ 'assistant.followUp.journalToday': '写一条今天的条目',+ 'assistant.followUp.journalSummary': '总结这几天',+};export default assistantJourney;diff --git a/shared/src/index.ts b/shared/src/index.tsindex 52b2ab01d..258a827fb 100644--- a/shared/src/index.ts+++ b/shared/src/index.ts@@ -11,6 +11,7 @@export * from './common/primitives.schema';export * from './common/pagination.schema';export * from './common/compare';+export * from './common/strip-markdown';// Domain contractsexport * from './weather/weather.schema';@@ -41,6 +42,7 @@ export * from './budget/receipt-scan.schema';export * from './reservation/reservation.schema';export * from './reservation/reservation-types';export * from './reservation/ki-reservation.schema';+export * from './reservation/reservation-read.schema';export * from './datetime/datetime-normalize';export * from './airtrail/airtrail.schema';export * from './dawarich/dawarich.schema';@@ -135,6 +137,7 @@ export * from './book/book-ops';export * from './book/book-page-ops';export * from './book/book-findings';export * from './book/describe-spread';+export * from './book/photo-pick';export * from './share/share.schema';export * from './storage/storage.schema';export * from './settings/settings.schema';diff --git a/shared/src/journey/journey.schema.spec.ts b/shared/src/journey/journey.schema.spec.tsindex 8edfb787e..d953d5885 100644--- a/shared/src/journey/journey.schema.spec.ts+++ b/shared/src/journey/journey.schema.spec.ts@@ -8,6 +8,10 @@ import {journeyUpdateRequestSchema,journeyPreferencesRequestSchema,journeyLinkPhotoRequestSchema,+ journeyEntriesRangeSchema,+ journeyEntryProsConsSchema,+ journeyEntryTypeSchema,+ journeyEntryVisibilitySchema,} from './journey.schema';import { describe, it, expect } from 'vitest';@@ -113,3 +117,26 @@ describe('the free-form bodies keep their unknown keys', () => {});});});++describe('the entry enums and the range of a read', () => {+ it('JRNSCH-001: names the entry types and visibilities a row can hold, nothing else', () => {+ expect(journeyEntryTypeSchema.options).toEqual(['entry', 'checkin', 'skeleton']);+ expect(journeyEntryVisibilitySchema.options).toEqual(['private', 'shared', 'public']);+ expect(journeyEntryVisibilitySchema.safeParse('friends-only').success).toBe(false);+ });++ it('JRNSCH-002: a verdict sent half fills the other half with an empty list and refuses extra keys', () => {+ expect(journeyEntryProsConsSchema.parse({ pros: ['view'] })).toEqual({ pros: ['view'], cons: [] });+ expect(journeyEntryProsConsSchema.safeParse({ pros: [], cons: [], extra: 1 }).success).toBe(false);+ });++ it('JRNSCH-003: a range takes calendar days at either end, both optional', () => {+ expect(journeyEntriesRangeSchema.parse({})).toEqual({});+ expect(journeyEntriesRangeSchema.parse({ from: '2026-10-21', to: '2026-10-22' })).toEqual({+ from: '2026-10-21',+ to: '2026-10-22',+ });+ expect(journeyEntriesRangeSchema.safeParse({ from: '2026-02-30' }).success).toBe(false);+ expect(journeyEntriesRangeSchema.safeParse({ to: 'yesterday' }).success).toBe(false);+ });+});diff --git a/shared/src/journey/journey.schema.ts b/shared/src/journey/journey.schema.tsindex d80a08c9d..c6d8fac30 100644--- a/shared/src/journey/journey.schema.ts+++ b/shared/src/journey/journey.schema.ts@@ -1,3 +1,5 @@+import { journeyRecordingDateSchema } from './journey-recordings.schema';+import { z } from 'zod';/**@@ -130,6 +132,41 @@ export const journalPluginPhotoInputSchema = z.strictObject({});export type JournalPluginPhotoInput = z.infer<typeof journalPluginPhotoInputSchema>;+/*+ * The three entry fields with a fixed set of values. `journey_entries.type` and+ * `.visibility` are plain TEXT columns and the REST route forwards whatever the+ * client sent, but the row type (JourneyEntry on the server) only ever models+ * these, so the MCP tools and the assistant's cards name them rather than take+ * a free string: a model that invents "friends-only" would write a value+ * nothing reads.+ */+export const journeyEntryTypeSchema = z.enum(['entry', 'checkin', 'skeleton']);+export type JourneyEntryType = z.infer<typeof journeyEntryTypeSchema>;+export const journeyEntryVisibilitySchema = z.enum(['private', 'shared', 'public']);+export type JourneyEntryVisibility = z.infer<typeof journeyEntryVisibilitySchema>;++/**+ * The verdict on a place. Either side defaults to empty so a caller can send+ * only the half it has, which is what the entry editor does when a place was+ * all good or all bad. The service stores nothing when both come back empty.+ */+export const journeyEntryProsConsSchema = z.strictObject({+ pros: z.array(z.string()).default([]),+ cons: z.array(z.string()).default([]),+});+export type JourneyEntryProsCons = z.infer<typeof journeyEntryProsConsSchema>;++/**+ * The days a read of a journal's entries keeps, both ends included; either end+ * left out is open. What the assistant asks for when it shows the entries of+ * one day ("what did I write yesterday"), so it reads that day and no more.+ */+export const journeyEntriesRangeSchema = z.object({+ from: journeyRecordingDateSchema.optional().describe('First day to include (YYYY-MM-DD); open when left out'),+ to: journeyRecordingDateSchema.optional().describe('Last day to include (YYYY-MM-DD); open when left out'),+});+export type JourneyEntriesRange = z.infer<typeof journeyEntriesRangeSchema>;+/** Free-form plus the entry_date the handler demands itself. */export const journeyEntryCreateRequestSchema = z.looseObject({entry_date: z.unknown().optional(),