feat(assistant): the assistant opens outside a trip, as a home chat about all trips

A third scope, home, next to trip and journey: threads that name neither a
trip nor a journey (the CHECK now only forbids both), reached under
/api/assistant by their owner only. A home turn reads the user's trips
through list_trips into a short card (under way, next, later, behind,
undated), offers every read (a trip's on the id the model names, checked by
the tool with the user's rights) and only the writes that take no trip or
journey (atlas, vacation planner, collections, tour library, settings), all
held as change cards. open_trip_chat answers with a card that goes on in
that trip's own chat with the question waiting in its composer.

On the desktop the window opens on the home chat outside a trip; its head
lists the trips to switch into and a switched trip chat has the way back.
On the phone the home chat opens full screen from the dashboard head and the
dock's More list, and the card opens the trip with its chat. Both run on
useAssistantHome.
This commit is contained in:
Maurice
2026-10-23 21:19:25 +02:00
parent cd60d4d859
commit 5d334d7ec8
117 changed files with 3770 additions and 174 deletions
+15 -7
View File
@@ -3,19 +3,27 @@ import { idSchema } from '../common/primitives.schema';
import { z } from 'zod';
/**
* What an assistant conversation is about: a trip (the planner's chat) or a
* journey (the chat in TREK Studio, which works on the journey's book). A
* thread belongs to exactly one of them, and the tools a turn offers, the
* context it reads and the routes it is reached under follow from it:
* `/api/trips/:tripId/assistant` and `/api/journeys/:journeyId/assistant`.
* What an assistant conversation is about: a trip (the planner's chat), a
* journey (the chat in TREK Studio, which works on the journey's book) or no
* single one (`home`, the chat on the dashboard, Vacay, Atlas, collections and
* settings, which knows all of the user's trips and works on what belongs to
* none of them). A thread belongs to exactly one of them, and the tools a turn
* offers, the context it reads and the routes it is reached under follow from
* it: `/api/trips/:tripId/assistant`, `/api/journeys/:journeyId/assistant` and
* `/api/assistant`.
*/
export const assistantScopeSchema = z.discriminatedUnion('kind', [
z.object({ kind: z.literal('trip'), tripId: idSchema }).strict(),
z.object({ kind: z.literal('journey'), journeyId: idSchema }).strict(),
z.object({ kind: z.literal('home') }).strict(),
]);
export type AssistantScope = z.infer<typeof assistantScopeSchema>;
/** The key a scope's conversations are kept under on a client: `trip:5`, `journey:12`. */
/** The scope of the chat outside any one trip or journey. */
export const HOME_ASSISTANT_SCOPE: AssistantScope = { kind: 'home' };
/** The key a scope's conversations are kept under on a client: `trip:5`, `journey:12`, `home`. */
export function assistantScopeKey(scope: AssistantScope): string {
return scope.kind === 'trip' ? `trip:${scope.tripId}` : `journey:${scope.journeyId}`;
if (scope.kind === 'trip') return `trip:${scope.tripId}`;
return scope.kind === 'journey' ? `journey:${scope.journeyId}` : 'home';
}