mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 17:41:51 +00:00
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:
@@ -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 })
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
Reference in New Issue
Block a user