feat(assistant): the journey page gets a journal chat that offers its tools by role

Asked on a journey page to write an entry, the assistant said it could not:
the only journey chat was the Studio's, which keeps the journey's writes
out. A journey session now holds what either page offers and shows the
model only the asking page's tools. The journal page offers a viewer the
reads, an editor the entry, photo, recorded day and day import writes, and
the owner also the journey's own settings and trips; delete_journey stays
out of the journey's own chat. A few reads that name no journey come along
(place search, the photo libraries, Dawarich stays), the Dawarich journal
entry is pinned through its journalId, and an entry an argument names must
belong to the conversation's journey before the tool runs. The turn reads a
journal card and instructions of its own; the Studio keeps exactly what it
offered before.
This commit is contained in:
Maurice
2026-10-24 21:08:48 +02:00
parent 2508fd8624
commit c0ec8e567b
14 changed files with 830 additions and 39 deletions
@@ -0,0 +1,110 @@
/**
* What a journey's conversation offers on each of its pages, in its pure
* parts: the journal page by the user's role, the Studio as it always was,
* what a session holds for both, and the boot check of the journal's lists.
*/
import {
checkJournalTools,
heldInJourney,
isHeldInJourney,
JOURNAL_DENIED_TOOLS,
JOURNAL_UNPINNED_READS,
JOURNEY_OWNER_TOOLS,
JOURNEY_PART_READ,
JOURNEY_PIN_ARGS,
keptInJournal,
offeredInJourney,
type JourneyListedTool,
} from '../../../../src/nest/assistant/assistant-journey-offer';
import { describe, expect, it } from 'vitest';
function tool(name: string, className: string | undefined, over: Partial<JourneyListedTool> = {}): JourneyListedTool {
return { name, className, kind: 'write', pinned: true, onPart: false, ...over };
}
const ENTRY_WRITE = tool('update_journey_entry', 'JourneyMcp', { pinned: false, onPart: true });
const JOURNEY_WRITE = tool('update_journey', 'JourneyMcp');
const ENTRY_READ = tool('get_journey_entry', 'JourneyMcp', { kind: 'read', pinned: false, onPart: true });
const BOOK_WRITE = tool('edit_book_page', 'JourneyBookMcp');
const RECORDING_WRITE = tool('save_journey_recorded_day', 'JourneyRecordingsMcp');
describe('the journal page offer', () => {
it('ASTJOFF-001: a viewer reads, an editor also writes the journal, the owner also the journey itself', () => {
expect(keptInJournal(ENTRY_READ, 'viewer')).toBe(true);
expect(keptInJournal(ENTRY_WRITE, 'viewer')).toBe(false);
expect(keptInJournal(ENTRY_WRITE, 'editor')).toBe(true);
expect(keptInJournal(RECORDING_WRITE, 'editor')).toBe(true);
expect(keptInJournal(JOURNEY_WRITE, 'editor')).toBe(false);
expect(keptInJournal(JOURNEY_WRITE, 'owner')).toBe(true);
for (const name of JOURNEY_OWNER_TOOLS) expect(keptInJournal(tool(name, 'JourneyMcp'), 'editor'), name).toBe(false);
});
it('ASTJOFF-002: keeps only tools on the journey, but the reads the journal needs that name none', () => {
expect(keptInJournal(tool('list_journeys', 'JourneyMcp', { kind: 'read', pinned: false }), 'owner')).toBe(false);
expect(keptInJournal(tool('create_journey', 'JourneyMcp', { pinned: false }), 'owner')).toBe(false);
expect(keptInJournal(tool('search_place', 'PlacesMcp', { kind: 'read', pinned: false }), 'viewer')).toBe(true);
for (const name of JOURNAL_UNPINNED_READS) {
expect(keptInJournal(tool(name, undefined, { kind: 'read', pinned: false }), 'viewer'), name).toBe(true);
}
// A read the journal names that turned into a write would wait on a card it was never meant to.
expect(keptInJournal(tool('search_place', 'PlacesMcp', { pinned: false }), 'owner')).toBe(false);
expect(keptInJournal(tool('create_place', 'PlacesMcp'), 'owner')).toBe(false);
});
it('ASTJOFF-003: never offers the book, the denied tools or what the journey chat leaves to others', () => {
expect(keptInJournal(BOOK_WRITE, 'owner')).toBe(false);
for (const name of Object.keys(JOURNAL_DENIED_TOOLS)) {
expect(keptInJournal(tool(name, 'JourneyMcp'), 'owner'), name).toBe(false);
}
expect(keptInJournal(tool('add_journey_contributor', 'JourneyMcp'), 'owner')).toBe(false);
expect(keptInJournal(tool('create_journey_share_link', 'JourneyMcp'), 'owner')).toBe(false);
expect(keptInJournal(tool('link_trip_journal', 'TripJournalLinkMcp', { pinned: false }), 'owner')).toBe(false);
const dawarich = tool('accept_dawarich_suggestion_as_journal_entry', 'DawarichMcp');
expect(keptInJournal(dawarich, 'editor')).toBe(true);
expect(keptInJournal(tool('accept_dawarich_suggestion_as_place', 'DawarichMcp'), 'owner')).toBe(false);
});
});
describe('a journey session over both pages', () => {
it('ASTJOFF-010: attaches what either page offers, and nothing of a trip', () => {
expect(isHeldInJourney('edit_book_page', 'JourneyBookMcp')).toBe(true);
expect(isHeldInJourney('create_journey_entry', 'JourneyMcp')).toBe(true);
expect(isHeldInJourney('save_journey_recorded_day', 'JourneyRecordingsMcp')).toBe(true);
expect(isHeldInJourney('search_place', 'PlacesMcp')).toBe(true);
expect(isHeldInJourney('create_place', 'PlacesMcp')).toBe(false);
expect(isHeldInJourney('delete_journey', 'JourneyMcp')).toBe(false);
expect(isHeldInJourney('restore_book_page', 'JourneyBookMcp')).toBe(false);
});
it('ASTJOFF-011: holds the tools of both pages but offers the model only the asking page own', () => {
expect(heldInJourney(BOOK_WRITE, 'owner')).toBe(true);
expect(heldInJourney(ENTRY_WRITE, 'owner')).toBe(true);
expect(offeredInJourney(BOOK_WRITE, { role: 'owner', surface: 'studio' })).toBe(true);
expect(offeredInJourney(BOOK_WRITE, { role: 'owner', surface: 'journal' })).toBe(false);
expect(offeredInJourney(ENTRY_WRITE, { role: 'owner', surface: 'studio' })).toBe(false);
expect(offeredInJourney(ENTRY_WRITE, { role: 'owner', surface: 'journal' })).toBe(true);
// The Studio keeps what it always offered, recorded days and the journal's writes left out.
expect(
offeredInJourney(tool('list_journey_recorded_days', 'JourneyRecordingsMcp', { kind: 'read' }), {
role: 'owner',
surface: 'studio',
}),
).toBe(false);
expect(heldInJourney(BOOK_WRITE, 'viewer')).toBe(false);
});
it('ASTJOFF-012: pins the journey under its alias too, and names every list entry the registry lacks', () => {
expect(JOURNEY_PIN_ARGS).toEqual(['journeyId', 'journalId']);
const all = new Set([
...JOURNAL_UNPINNED_READS,
...JOURNEY_OWNER_TOOLS,
...Object.keys(JOURNAL_DENIED_TOOLS),
'accept_dawarich_suggestion_as_journal_entry',
JOURNEY_PART_READ,
]);
expect(checkJournalTools(all)).toEqual([]);
all.delete('search_place');
expect(checkJournalTools(all)).toEqual(['journal tool "search_place" is not registered']);
});
});
@@ -8,7 +8,7 @@
import { McpRegistryService } from '../../../../src/nest-mcp';
import { isOfferedInJourney } from '../../../../src/nest/assistant/assistant-tool-offer';
import { AssistantToolsService } from '../../../../src/nest/assistant/assistant-tools.service';
import { addJourneyContributor, makeJourney } from '../../../helpers/factories/journeys';
import { addJourneyContributor, makeJourney, makeJourneyEntry } from '../../../helpers/factories/journeys';
import { setAddonEnabled } from '../../../helpers/factories/settings';
import { makeUser } from '../../../helpers/factories/users';
import { FakeRealtimeService } from '../../../helpers/fake-realtime';
@@ -31,6 +31,9 @@ beforeAll(async () => {
await setAddonEnabled(orm, 'journey', true);
});
const STUDIO_OWNER = { role: 'owner', surface: 'studio' } as const;
const STUDIO_VIEWER = { role: 'viewer', surface: 'studio' } as const;
const BOOK_WRITES = ['create_book', 'add_book_pages', 'move_book_page', 'delete_book_pages', 'edit_book_page'];
async function ownerWithJourneys() {
@@ -43,7 +46,7 @@ async function ownerWithJourneys() {
describe('a Studio tool session', () => {
it('ASTJSES-001: offers the book tools and the journey reads at once, on this journey, and nothing of a trip', async () => {
const { userId, journeyId } = await ownerWithJourneys();
const session = await tools.openJourney(userId, journeyId, true);
const session = await tools.openJourney(userId, journeyId, STUDIO_OWNER);
try {
const specs = session.specs();
const names = specs.map((spec) => spec.name);
@@ -79,7 +82,7 @@ describe('a Studio tool session', () => {
const { journeyId } = await ownerWithJourneys();
const { user: viewer } = await makeUser(orm);
await addJourneyContributor(orm, journeyId, viewer.id, 'viewer');
const session = await tools.openJourney(viewer.id, journeyId, false);
const session = await tools.openJourney(viewer.id, journeyId, STUDIO_VIEWER);
try {
const names = session.specs().map((spec) => spec.name);
expect(names).toEqual(expect.arrayContaining(['get_book', 'describe_book_page', 'list_journey_entries']));
@@ -97,7 +100,7 @@ describe('a Studio tool session', () => {
it('ASTJSES-003: a call runs on the conversation journey, and another journey id is refused', async () => {
const { userId, journeyId, otherId } = await ownerWithJourneys();
const session = await tools.openJourney(userId, journeyId, true);
const session = await tools.openJourney(userId, journeyId, STUDIO_OWNER);
try {
const run = await session.call('list_journey_entries', {});
expect(run).toMatchObject({ ok: true, value: { journey: { id: journeyId, title: 'Lisbon' } } });
@@ -116,7 +119,7 @@ describe('a Studio tool session', () => {
it('ASTJSES-004: a stranger gets the tool refusal, not the journey', async () => {
const { journeyId } = await ownerWithJourneys();
const { user: stranger } = await makeUser(orm);
const session = await tools.openJourney(stranger.id, journeyId, false);
const session = await tools.openJourney(stranger.id, journeyId, STUDIO_VIEWER);
try {
expect(await session.call('get_book', {})).toEqual({ ok: false, value: 'Journey not found or access denied.' });
} finally {
@@ -126,7 +129,7 @@ describe('a Studio tool session', () => {
it('ASTJSES-005: an undo session holds its target and nothing else', async () => {
const { userId, journeyId } = await ownerWithJourneys();
const session = await tools.openJourney(userId, journeyId, true, new Set(['restore_book_page']));
const session = await tools.openJourney(userId, journeyId, STUDIO_OWNER, new Set(['restore_book_page']));
try {
expect(session.specs().map((spec) => spec.name)).toEqual(['restore_book_page']);
expect(session.kindOf('restore_book_page')).toBe('write');
@@ -136,3 +139,103 @@ describe('a Studio tool session', () => {
}
});
});
const journal = (role: 'owner' | 'editor' | 'viewer') => ({ role, surface: 'journal' }) as const;
const ENTRY_WRITES = [
'create_journey_entry',
'update_journey_entry',
'delete_journey_entry',
'reorder_journey_entries',
];
describe('a journal tool session, on the journey page', () => {
it('ASTJSES-006: offers the owner the journal tools on this journey, and neither the book nor what is denied there', async () => {
const { userId, journeyId } = await ownerWithJourneys();
const session = await tools.openJourney(userId, journeyId, journal('owner'));
try {
const specs = session.specs();
const names = specs.map((spec) => spec.name);
expect(names).toEqual(
expect.arrayContaining([...ENTRY_WRITES, 'update_journey', 'remove_journey_trip', 'add_journey_trip']),
);
expect(names).toEqual(expect.arrayContaining(['get_journey', 'get_journey_entry', 'search_place']));
const left = ['delete_journey', 'list_journeys', 'create_journey', 'add_journey_contributor', 'get_book'];
for (const name of [...left, ...BOOK_WRITES, 'get_journey_share_link', 'use_addon_tools']) {
expect(names, name).not.toContain(name);
}
expect(names).toContain(ASSISTANT_FOLLOW_UPS_TOOL);
for (const spec of specs) {
const properties = Object.keys((spec.parameters.properties as Record<string, unknown> | undefined) ?? {});
expect(properties, spec.name).not.toContain('journeyId');
expect(properties, spec.name).not.toContain('journalId');
}
expect(session.kindOf('create_journey_entry')).toBe('write');
expect(session.kindOf('get_journey')).toBe('read');
// The Studio's tools stay held for a decision made there, but the model is not offered them here.
expect(session.kindOf('get_book')).toBeNull();
expect(await session.call('get_book', {})).toMatchObject({ ok: true, value: { exists: false } });
} finally {
await session.close();
}
});
it('ASTJSES-007: an editor writes entries but not the journey itself, and a viewer only reads', async () => {
const { journeyId } = await ownerWithJourneys();
const { user: editor } = await makeUser(orm);
const { user: viewer } = await makeUser(orm);
await addJourneyContributor(orm, journeyId, editor.id, 'editor');
await addJourneyContributor(orm, journeyId, viewer.id, 'viewer');
const editing = await tools.openJourney(editor.id, journeyId, journal('editor'));
try {
const names = editing.specs().map((spec) => spec.name);
expect(names).toEqual(expect.arrayContaining(ENTRY_WRITES));
for (const name of ['update_journey', 'remove_journey_trip']) expect(names, name).not.toContain(name);
} finally {
await editing.close();
}
const viewing = await tools.openJourney(viewer.id, journeyId, journal('viewer'));
try {
const names = viewing.specs().map((spec) => spec.name);
expect(names).toEqual(expect.arrayContaining(['get_journey', 'list_journey_entries']));
for (const name of names) expect(viewing.kindOf(name), name).toBe('read');
} finally {
await viewing.close();
}
});
it('ASTJSES-008: an entry of another journey is refused, one of this journey runs', async () => {
const { userId, journeyId, otherId } = await ownerWithJourneys();
const own = await makeJourneyEntry(orm, journeyId, userId, { title: 'Alfama' });
const foreign = await makeJourneyEntry(orm, otherId, userId, { title: 'Ribeira' });
const session = await tools.openJourney(userId, journeyId, journal('owner'));
try {
expect(await session.call('get_journey_entry', { entryId: own.id })).toMatchObject({
ok: true,
value: { entry: { id: own.id }, journey: { id: journeyId } },
});
expect(await session.call('update_journey_entry', { entryId: foreign.id, title: 'Not here' })).toEqual({
ok: false,
value: 'This conversation is about one journey; that entry is not one of its entries.',
});
expect(await session.read('get_journey_entry', { entryId: foreign.id })).toMatchObject({ ok: false });
} finally {
await session.close();
}
});
it('ASTJSES-009: a journal named by its alias is pinned and hidden like the journey id', async () => {
const { userId, journeyId, otherId } = await ownerWithJourneys();
const session = await tools.openJourney(userId, journeyId, journal('owner'));
try {
expect(session.pinArgs('accept_dawarich_suggestion_as_journal_entry', { journalId: otherId })).toEqual({
error: 'This conversation is about one journey; its id is set by the app and cannot be changed.',
});
expect(
session.pinArgs('accept_dawarich_suggestion_as_journal_entry', { journalId: journeyId, suggestionId: 4 }),
).toEqual({ args: { suggestionId: 4 } });
} finally {
await session.close();
}
});
});
@@ -16,6 +16,7 @@ import {
} from '../../../../src/nest/assistant/assistant-book-context';
import type { AssistantBookGate } from '../../../../src/nest/assistant/assistant-book-gate';
import { homePrompt } from '../../../../src/nest/assistant/assistant-home';
import { journalTurnContext, renderJournalCard } from '../../../../src/nest/assistant/assistant-journal-context';
import {
AssistantScopes,
findScopedCall,
@@ -30,7 +31,7 @@ import {
} from '../../../../src/nest/assistant/assistant-tool-offer';
import type { AssistantToolsService } from '../../../../src/nest/assistant/assistant-tools.service';
import { readTripCard, tripCardFrom } from '../../../../src/nest/assistant/assistant-trip-scope';
import { studioPrompt, systemPrompt } from '../../../../src/nest/assistant/assistant.prompt';
import { journalPrompt, studioPrompt, systemPrompt } from '../../../../src/nest/assistant/assistant.prompt';
import type { JourneyAiPhotosService } from '../../../../src/nest/journey/journey-ai-photos.service';
import type { JourneyBookEditService } from '../../../../src/nest/journey/journey-book-edit.service';
import type { JourneyDomainService } from '../../../../src/nest/journey/journey-domain.service';
@@ -348,6 +349,16 @@ describe('the book context', () => {
isOwner: vi.fn(async () => role === 'owner'),
canEdit: vi.fn(async () => role === 'owner' || role === 'editor'),
listEntries: vi.fn(async () => entries.map((entry) => ({ ...entry, location_name: null }))),
getJourneyFull: vi.fn(async () =>
role === 'none'
? null
: {
...journey,
entries: entries.map((entry) => ({ ...entry, entry_time: '18:30', location_lat: 38.71, is_draft: true })),
trips: [{ trip_id: 5, title: 'Lisbon days', start_date: '2026-04-01', end_date: '2026-04-05' }],
gallery: [{}, {}, {}],
},
),
};
}
@@ -389,6 +400,44 @@ describe('the book context', () => {
expect((await contextWith('viewer').context.cardOf(7, 12, null)).role).toBe('viewer');
});
it('ASTSCP-043: reads the journal card with the user rights, and the role of the user in the journey', async () => {
const suggestion = { ...ALFAMA, id: 41, type: 'skeleton' };
const dismissed = { ...ALFAMA, id: 42, dismissed: true };
const { context, journeys } = contextWith('editor', [ALFAMA, suggestion, dismissed]);
const read = await context.journalCardOf(7, 12);
expect(journeys.getJourneyFull).toHaveBeenCalledWith(12, 7);
expect(read).toMatchObject({ journeyId: 12, title: 'Portugal', role: 'editor', galleryPhotos: 3 });
expect(read.trips).toEqual([{ id: 5, title: 'Lisbon days', startDate: '2026-04-01', endDate: '2026-04-05' }]);
expect(read.entries).toEqual([
{
id: 40,
date: '2026-04-02',
time: '18:30',
title: 'Alfama',
place: null,
photos: 2,
draft: true,
suggestion: false,
mapped: true,
},
{
id: 41,
date: '2026-04-02',
time: '18:30',
title: 'Alfama',
place: null,
photos: 2,
draft: true,
suggestion: true,
mapped: true,
},
]);
expect(await contextWith('owner').context.roleIn(7, 12)).toBe('owner');
expect(await contextWith('viewer').context.roleIn(7, 12)).toBe('viewer');
const none = await contextWith('none').context.journalCardOf(7, 12);
expect(none).toMatchObject({ title: '', trips: [], entries: [], galleryPhotos: 0, role: 'viewer' });
});
it('ASTSCP-042: lists no entry waved away, and the suggestions only while nothing is written', async () => {
const suggestion = { ...ALFAMA, id: 41, type: 'skeleton' };
const dismissed = { ...ALFAMA, id: 42, dismissed: true };
@@ -425,7 +474,17 @@ describe('a scope opens its session and writes its turn', () => {
};
const books = {
canEdit: vi.fn(async () => canWrite),
roleIn: vi.fn(async () => (canWrite ? 'editor' : 'viewer')),
cardOf: vi.fn(async () => card({ role: canWrite ? 'editor' : 'viewer' })),
journalCardOf: vi.fn(async () => ({
journeyId: 12,
title: 'Lisbon',
subtitle: null,
role: canWrite ? 'editor' : 'viewer',
trips: [],
galleryPhotos: 3,
entries: [],
})),
};
const settings = { getUserSettings: vi.fn(async () => ({ temperature_unit: 'celsius' })) };
const studioGate = { refusalOf: vi.fn(async () => 'faults'), reader: session };
@@ -460,7 +519,7 @@ describe('a scope opens its session and writes its turn', () => {
session.read.mockClear();
const editor = scopesWith(true);
const opened = await editor.scopes.open(7, { kind: 'journey', journeyId: 12 });
expect(editor.tools.openJourney).toHaveBeenCalledWith(7, 12, true, undefined);
expect(editor.tools.openJourney).toHaveBeenCalledWith(7, 12, { role: 'editor', surface: 'studio' }, undefined);
const targets = new Set(['restore_book_page']);
const read = await editor.scopes.turnOf(opened, { kind: 'journey', journeyId: 12 }, turn);
expect(editor.books.cardOf).toHaveBeenCalledWith(7, 12, null);
@@ -474,12 +533,30 @@ describe('a scope opens its session and writes its turn', () => {
const viewer = scopesWith(false);
const viewing = await viewer.scopes.open(7, { kind: 'journey', journeyId: 12 }, targets);
expect(viewer.tools.openJourney).toHaveBeenCalledWith(7, 12, false, targets);
expect(viewer.tools.openJourney).toHaveBeenCalledWith(7, 12, { role: 'viewer', surface: 'studio' }, targets);
// A viewer's turn reads the instructions without the designer's rules.
const viewed = await viewer.scopes.turnOf(viewing, { kind: 'journey', journeyId: 12 }, turn);
expect(viewed.system).toBe(studioPrompt('English', false));
});
it('ASTSCP-054: a turn on the journal page opens its session and reads the journal card and instructions', async () => {
const { tools, scopes, books, gate } = scopesWith(true);
const scope = { kind: 'journey', journeyId: 12, surface: 'journal' } as const;
const opened = await scopes.open(7, scope);
expect(tools.openJourney).toHaveBeenCalledWith(7, 12, { role: 'editor', surface: 'journal' }, undefined);
const read = await scopes.turnOf(opened, scope, turn);
expect(books.journalCardOf).toHaveBeenCalledWith(7, 12);
expect(books.cardOf).not.toHaveBeenCalled();
expect(read.system).toBe(journalPrompt('English'));
expect(read.context).toContain('<journal_card>');
expect(read.context).toContain('Journey: Lisbon');
expect(read.card.tripId).toBe(0);
// No book on this page: held calls pass as a trip's do, read through the session itself.
expect(gate.forTurn).not.toHaveBeenCalled();
expect(read.gate.reader).toBe(opened);
expect(await read.gate.refusalOf('create_journey_entry', { entry_date: '2026-10-24' })).toBeNull();
});
it('ASTSCP-053: a home turn opens the home session, reads the user trips through it and the home prompt', async () => {
const { tools, scopes, books } = scopesWith(true);
const targets = new Set(['delete_collection']);
@@ -516,3 +593,72 @@ describe('a scope opens its session and writes its turn', () => {
expect(session.close).toHaveBeenCalledTimes(1);
});
});
describe('the journal card', () => {
it('ASTSCP-060: names the journey, the role, the trips, the gallery and each entry with its id and state', () => {
const text = journalTurnContext(
{
journeyId: 12,
title: 'Portugal',
subtitle: 'Spring',
role: 'editor',
trips: [{ id: 5, title: 'Lisbon days', startDate: '2026-04-01', endDate: null }],
galleryPhotos: 3,
entries: [
{
id: 40,
date: '2026-04-02',
time: null,
title: 'Alfama',
place: 'Lisbon',
photos: 2,
draft: false,
suggestion: false,
mapped: true,
},
{
id: 41,
date: '2026-04-03',
time: '09:00',
title: null,
place: null,
photos: 0,
draft: true,
suggestion: true,
mapped: false,
},
],
},
'UTC',
NOW,
);
expect(text).toContain('Today is 2026-07-03 (time zone UTC).');
expect(text).toContain('<journal_card>');
expect(text).toContain('Subtitle: Spring');
expect(text).toContain('Your role: editor (you may change the entries and the photos, not the journal itself)');
expect(text).toContain('5 | Lisbon days | 2026-04-01 to ?');
expect(text).toContain('Gallery: 3 photos and videos.');
expect(text).toContain('40 | 2026-04-02 | | Alfama | Lisbon | 2 | published, on the map');
expect(text).toContain('41 | 2026-04-03 | 09:00 | | | 0 | draft, suggestion from a trip place, no coordinates');
});
it('ASTSCP-061: says when there are no trips or entries, and counts the entries past the ones it lists', () => {
const many = Array.from({ length: 203 }, (_, index) => ({
id: index + 1,
date: '2026-04-02',
time: null,
title: null,
place: null,
photos: 0,
draft: false,
suggestion: false,
mapped: false,
}));
const base = { journeyId: 1, title: 'X', subtitle: null, role: 'viewer' as const, trips: [], galleryPhotos: 0 };
expect(renderJournalCard({ ...base, entries: [] })).toContain('(no entries yet)');
expect(renderJournalCard({ ...base, entries: [] })).toContain('Trips: none linked.');
expect(renderJournalCard({ ...base, entries: many })).toContain('and 3 more; list_journey_entries lists them all.');
expect(journalPrompt('German')).toContain('in German.');
expect(journalPrompt('German')).toContain('search_place');
});
});
@@ -239,6 +239,15 @@ describe('the change cards', () => {
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();
// A journey's own conversation pins the journey, so the arguments name none: the pinned read does.
const pinned = readerOf({ get_journey: { journey: { id: 8, title: 'Lisbon' } } });
expect(await loadJournal('create_journey_entry', { entry_date: '2026-10-22' }, pinned.read)).toEqual({
entry: null,
journeyId: 8,
title: 'Lisbon',
tripJournal: false,
});
});
it('ASTCARD-JRN-010: a change merges its arguments over the entry: a named key wins, null clears, the rest stays', async () => {
@@ -276,6 +276,7 @@ describe('calculate_roadtrip card', () => {
kind: 'read',
pinned: true,
hint: { destructive: false, creates: false, group: 'roadtrip' },
offered: true,
};
const tools = new Map([['calculate_roadtrip', tool]]);
const audit = () => undefined;
@@ -53,6 +53,7 @@ function sessionWith(found: unknown, kept: KeptItineraries, names = BOTH) {
kind: name.startsWith('search') ? 'read' : 'write',
pinned: false,
hint: { destructive: false, creates: false, group: 'roadtrip' },
offered: true,
});
const tools = new Map(names.map((name) => [name, tool(name)]));
const client = { callTool };