feat(tours): assistant takes found places into saved tours and route files from the chat

P6: insert_tour_stop and remove_tour_stop take a place into a saved hike or
city walk as one stop and out again, each the other's undo, with change
cards in the chat. The planner's insertion rule (poiInsertion) moved to
shared so the planner and the server place a stop the same way. "+ Tour" on
a found place holds it as a stop of the saved tour open in the planner.

P7: GPX, KML and KMZ files attached in the chat are read into their tracks
and each is held as a change that takes it in as a hike through
import_tour_gpx, undoable per track; the GPX text stays on the held call.
This commit is contained in:
Maurice
2026-10-23 21:18:19 +02:00
parent 454fc1a5f4
commit cd60d4d859
92 changed files with 3257 additions and 111 deletions
+6
View File
@@ -228,6 +228,8 @@ interface AssistantState {
* thread changed under it, and always skipped under a journey key.
*/
takeProposal: (key: AssistantChatKey, toolCallId: string) => Promise<HoldOutcome>;
/** Takes a found place into the saved tour open in the planner as a stop ("+ Tour"), held as a change to decide. */
insertFoundPlace: (key: AssistantChatKey, ref: string, tourId: number) => Promise<HoldOutcome>;
}
/** What came of a change the server was asked to hold without a model turn. */
@@ -772,6 +774,10 @@ function compareActions(ctx: Ctx) {
holdWithoutTurn(ctx, tripId, (threadId) =>
assistantRepo.takeProposal(tripId, threadId, { ...clientContext(), toolCallId })
),
insertFoundPlace: (tripId: number, ref: string, tourId: number) =>
holdWithoutTurn(ctx, tripId, (threadId) =>
assistantRepo.insertFoundPlace(tripId, threadId, { ...clientContext(), ref, tourId })
),
};
}
+32
View File
@@ -0,0 +1,32 @@
import { create } from 'zustand';
/** The saved tour open in the planner's editor, as the chat may take a found place into it. */
interface OpenTour {
tripId: number;
placeId: number;
name: string;
}
interface OpenTourState {
/** Null while no saved hike or city walk is open, or while its editor holds changes not yet saved. */
open: OpenTour | null;
}
/**
* P6: which saved tour the planner has open, for "+ Tour" on a place the
* assistant found. The planner writes it (usePublishOpenTour), the chat's
* place cards read it; nothing else is kept here.
*/
export const useOpenTourStore = create<OpenTourState>(() => ({ open: null }));
export function setOpenTour(open: OpenTour | null): void {
const current = useOpenTourStore.getState().open;
const same =
current === open ||
(!!current &&
!!open &&
current.tripId === open.tripId &&
current.placeId === open.placeId &&
current.name === open.name);
if (!same) useOpenTourStore.setState({ open });
}