mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
feat(assistant): hike, walk and route cards with their lines on the map, and "Plan this"
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* FE-AI-TOURLINK-001 to FE-AI-TOURLINK-005
|
||||
*
|
||||
* The chat's link to a saved tour (`?tour=`) on the desktop planner: the
|
||||
* Tours tab opens and then the tour, a tour the loaded list does not hold
|
||||
* yet is asked for once more and given up after three seconds, a tour being edited
|
||||
* is never discarded for it, and with Tours off or on the phone the tour
|
||||
* shows as its place. The link always leaves the URL.
|
||||
*/
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import type { DeepLinkProps } from './deepLinkTypes';
|
||||
import { useTourDeepLink } from './useTourDeepLink';
|
||||
|
||||
interface Setup {
|
||||
query?: string;
|
||||
activeTab?: string;
|
||||
tours?: { place_id: number }[];
|
||||
toursOn?: boolean;
|
||||
isMobile?: boolean;
|
||||
unsaved?: boolean;
|
||||
ready?: boolean;
|
||||
}
|
||||
|
||||
function setup(over: Setup = {}) {
|
||||
const params = new URLSearchParams(over.query ?? '?tour=41');
|
||||
const setSearchParams = vi.fn((update: (current: URLSearchParams) => URLSearchParams) => {
|
||||
update(params);
|
||||
});
|
||||
const planner = {
|
||||
activeTab: over.activeTab ?? 'tour-planner',
|
||||
enabledAddons: { tours: over.toursOn ?? true },
|
||||
handleTabChange: vi.fn(),
|
||||
invalidateTourPlaceIds: vi.fn(),
|
||||
isMobile: over.isMobile ?? false,
|
||||
setSelectedPlaceId: vi.fn(),
|
||||
t: (key: string) => key,
|
||||
toast: { success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn() },
|
||||
tours: over.tours ?? [{ place_id: 41 }],
|
||||
tourDataReady: over.ready ?? true,
|
||||
};
|
||||
const workspace = { openTourInPlanner: vi.fn(), tourPlanner: { hasUnsavedChanges: over.unsaved ?? false } };
|
||||
const props = (): DeepLinkProps => ({
|
||||
planner: planner as unknown as DeepLinkProps['planner'],
|
||||
workspace: workspace as unknown as DeepLinkProps['workspace'],
|
||||
searchParams: params,
|
||||
setSearchParams: setSearchParams as unknown as DeepLinkProps['setSearchParams'],
|
||||
});
|
||||
const hook = renderHook(() => useTourDeepLink(props()));
|
||||
return { params, planner, workspace, hook };
|
||||
}
|
||||
|
||||
beforeEach(() => vi.useFakeTimers());
|
||||
afterEach(() => vi.useRealTimers());
|
||||
|
||||
describe('useTourDeepLink', () => {
|
||||
it('FE-AI-TOURLINK-001: on the Tours tab the tour opens and the link leaves the URL', () => {
|
||||
const { params, workspace } = setup();
|
||||
expect(workspace.openTourInPlanner).toHaveBeenCalledWith(41);
|
||||
expect(params.get('tour')).toBeNull();
|
||||
});
|
||||
|
||||
it("FE-AI-TOURLINK-002: on another tab the Tours tab opens first, unless the chat's tab link is switching already", () => {
|
||||
const away = setup({ activeTab: 'plan' });
|
||||
expect(away.planner.handleTabChange).toHaveBeenCalledWith('tour-planner');
|
||||
expect(away.workspace.openTourInPlanner).not.toHaveBeenCalled();
|
||||
expect(away.params.get('tour')).toBe('41');
|
||||
|
||||
away.planner.activeTab = 'tour-planner';
|
||||
away.hook.rerender();
|
||||
expect(away.workspace.openTourInPlanner).toHaveBeenCalledWith(41);
|
||||
|
||||
const switching = setup({ activeTab: 'plan', query: '?tab=tour-planner&tour=41' });
|
||||
expect(switching.planner.handleTabChange).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('FE-AI-TOURLINK-003: a tour not in the list yet is asked for once, opens when it arrives, and is given up after three seconds', () => {
|
||||
const late = setup({ tours: [] });
|
||||
expect(late.planner.invalidateTourPlaceIds).toHaveBeenCalledTimes(1);
|
||||
late.planner.tours = [{ place_id: 41 }];
|
||||
late.hook.rerender();
|
||||
expect(late.workspace.openTourInPlanner).toHaveBeenCalledWith(41);
|
||||
act(() => vi.advanceTimersByTime(3000));
|
||||
expect(late.planner.toast.error).not.toHaveBeenCalled();
|
||||
|
||||
const loading = setup({ tours: [], ready: false });
|
||||
act(() => vi.advanceTimersByTime(5000));
|
||||
expect(loading.planner.invalidateTourPlaceIds).not.toHaveBeenCalled();
|
||||
expect(loading.planner.toast.error).not.toHaveBeenCalled();
|
||||
expect(loading.params.get('tour')).toBe('41');
|
||||
|
||||
const missing = setup({ tours: [] });
|
||||
missing.hook.rerender();
|
||||
expect(missing.planner.invalidateTourPlaceIds).toHaveBeenCalledTimes(1);
|
||||
act(() => vi.advanceTimersByTime(3000));
|
||||
expect(missing.planner.toast.error).toHaveBeenCalledWith('tours.planner.openFailed');
|
||||
expect(missing.params.get('tour')).toBeNull();
|
||||
expect(missing.workspace.openTourInPlanner).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('FE-AI-TOURLINK-004: a tour being edited is kept, and the planner says to save or discard it first', () => {
|
||||
const { planner, workspace, params } = setup({ unsaved: true });
|
||||
expect(planner.toast.warning).toHaveBeenCalledWith('assistant.card.tour.unsaved');
|
||||
expect(workspace.openTourInPlanner).not.toHaveBeenCalled();
|
||||
expect(params.get('tour')).toBeNull();
|
||||
});
|
||||
|
||||
it('FE-AI-TOURLINK-005: with Tours off or on the phone the tour shows as its place; a broken link is only dropped', () => {
|
||||
const off = setup({ toursOn: false });
|
||||
expect(off.planner.setSelectedPlaceId).toHaveBeenCalledWith(41);
|
||||
expect(off.planner.handleTabChange).not.toHaveBeenCalled();
|
||||
expect(off.params.get('tour')).toBeNull();
|
||||
|
||||
const phone = setup({ isMobile: true, activeTab: 'plan' });
|
||||
expect(phone.planner.setSelectedPlaceId).toHaveBeenCalledWith(41);
|
||||
|
||||
const broken = setup({ query: '?tour=abc' });
|
||||
expect(broken.params.get('tour')).toBeNull();
|
||||
expect(broken.workspace.openTourInPlanner).not.toHaveBeenCalled();
|
||||
expect(broken.planner.setSelectedPlaceId).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -1,9 +1,102 @@
|
||||
import { useCallback, useEffect, useRef } from 'react';
|
||||
|
||||
import type { DeepLinkProps } from './deepLinkTypes';
|
||||
|
||||
/** How long a tour the chat just made may take to reach the tour list before the link gives up on it. */
|
||||
const LATE_TOUR_MS = 3000;
|
||||
|
||||
/**
|
||||
* Where the tours open a tour the chat points at (`?tour=`). Nothing yet: the tour cards
|
||||
* fill it in, and until then the planner keeps its own links.
|
||||
* A tour the chat points at (`?tour=<placeId>`, from "Open in Tours"), on
|
||||
* the desktop planner: the Tours tab opens and the tour opens in it, in the
|
||||
* editor or as it came in, as a click on it in the tour list does. A tour
|
||||
* the chat has only just made can beat the broadcast that brings it into the
|
||||
* list, so once the list has loaded it is asked for once more, and only a
|
||||
* tour still missing three seconds later says it could not be opened. A
|
||||
* tour being edited is never discarded for it: the planner says to save or
|
||||
* discard first. With Tours switched off, or on the phone, the tour shows
|
||||
* as its place on the plan instead. The link leaves the URL once taken,
|
||||
* whichever way.
|
||||
*/
|
||||
export function useTourDeepLink(_links: DeepLinkProps): void {
|
||||
// Filled in by the tour cards.
|
||||
export function useTourDeepLink({ planner, workspace, searchParams, setSearchParams }: DeepLinkProps): void {
|
||||
const raw = searchParams.get('tour');
|
||||
const placeId = raw !== null && /^\d{1,12}$/.test(raw) ? Number(raw) : null;
|
||||
const tabPending = searchParams.get('tab') === 'tour-planner';
|
||||
const { activeTab, enabledAddons, handleTabChange, invalidateTourPlaceIds, isMobile, setSelectedPlaceId } = planner;
|
||||
const { t, toast, tourDataReady, tours } = planner;
|
||||
const { openTourInPlanner, tourPlanner } = workspace;
|
||||
const unsaved = tourPlanner.hasUnsavedChanges;
|
||||
const known = placeId !== null && tours.some((tour) => tour.place_id === placeId);
|
||||
/** The tour the list was asked for again, and until when it may still arrive. */
|
||||
const asked = useRef<{ placeId: number; until: number } | null>(null);
|
||||
|
||||
const drop = useCallback(() => {
|
||||
setSearchParams(
|
||||
(current) => {
|
||||
current.delete('tour');
|
||||
return current;
|
||||
},
|
||||
{ replace: true }
|
||||
);
|
||||
}, [setSearchParams]);
|
||||
|
||||
useEffect(() => {
|
||||
if (raw === null) return;
|
||||
if (placeId === null) {
|
||||
drop();
|
||||
return;
|
||||
}
|
||||
if (!enabledAddons.tours || isMobile) {
|
||||
setSelectedPlaceId(placeId);
|
||||
drop();
|
||||
return;
|
||||
}
|
||||
if (activeTab !== 'tour-planner') {
|
||||
// The chat's `?tab=` link is switching already; otherwise this link switches itself.
|
||||
if (!tabPending) handleTabChange('tour-planner');
|
||||
return;
|
||||
}
|
||||
if (unsaved) {
|
||||
toast.warning(t('assistant.card.tour.unsaved'));
|
||||
drop();
|
||||
return;
|
||||
}
|
||||
if (known) {
|
||||
asked.current = null;
|
||||
openTourInPlanner(placeId);
|
||||
drop();
|
||||
return;
|
||||
}
|
||||
// The list itself is still on its way: wait for it before counting the tour late.
|
||||
if (!tourDataReady) return;
|
||||
if (asked.current?.placeId !== placeId) {
|
||||
asked.current = { placeId, until: Date.now() + LATE_TOUR_MS };
|
||||
invalidateTourPlaceIds();
|
||||
}
|
||||
const timer = window.setTimeout(
|
||||
() => {
|
||||
asked.current = null;
|
||||
toast.error(t('tours.planner.openFailed'));
|
||||
drop();
|
||||
},
|
||||
Math.max(0, asked.current.until - Date.now())
|
||||
);
|
||||
return () => window.clearTimeout(timer);
|
||||
}, [
|
||||
activeTab,
|
||||
drop,
|
||||
enabledAddons.tours,
|
||||
handleTabChange,
|
||||
invalidateTourPlaceIds,
|
||||
isMobile,
|
||||
known,
|
||||
openTourInPlanner,
|
||||
placeId,
|
||||
raw,
|
||||
setSelectedPlaceId,
|
||||
t,
|
||||
tabPending,
|
||||
toast,
|
||||
tourDataReady,
|
||||
unsaved,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
/**
|
||||
* FE-PLANNER-AI-MAP-001 to FE-PLANNER-AI-MAP-006
|
||||
* FE-PLANNER-AI-MAP-001 to FE-PLANNER-AI-MAP-009
|
||||
*
|
||||
* The planner's link between the assistant and its map: which suggestions
|
||||
* stand as ghosts and which mark a real pin, when the map may move on its
|
||||
* own (setting, lock, reduced motion, the phone's folded chat), the "before"
|
||||
* view of an applied block, and the pop of a place that arrives.
|
||||
* view of an applied block, the pop of a place that arrives, and the routes
|
||||
* the chat's cards draw beside them.
|
||||
*/
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import type { AssistantMessage, AssistantMessagePart, Trip } from '@trek/shared';
|
||||
import type { AssistantMessage, AssistantMessagePart, TourRouteCard, Trip } from '@trek/shared';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { HIKE } from '../../../tests/helpers/assistantTour';
|
||||
import { chatOf, useAssistantStore } from '../../store/assistantStore';
|
||||
import { useSettingsStore } from '../../store/settingsStore';
|
||||
import { useTripStore } from '../../store/tripStore';
|
||||
@@ -27,7 +30,7 @@ function visit(id: number, dayId: number, placeId = id * 10): Assignment {
|
||||
return { id, day_id: dayId, place_id: placeId, order_index: 0, place: stop } as Assignment;
|
||||
}
|
||||
|
||||
function held(id: string, effect: object, approval: object = {}): AssistantMessagePart[] {
|
||||
function held(id: string, effect: object, approval: object = {}, card?: TourRouteCard): AssistantMessagePart[] {
|
||||
return [
|
||||
{ type: 'tool-call', toolCallId: id, toolName: 'x', args: {}, approval: { id, ...approval } },
|
||||
{
|
||||
@@ -41,6 +44,7 @@ function held(id: string, effect: object, approval: object = {}): AssistantMessa
|
||||
placeIds: [],
|
||||
undoable: true,
|
||||
effect,
|
||||
...(card ? { card } : {}),
|
||||
},
|
||||
} as AssistantMessagePart,
|
||||
];
|
||||
@@ -304,3 +308,30 @@ describe('useAssistantCompareView', () => {
|
||||
expect(before.result.current.places.map((p) => p.id)).toEqual([1]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("useAssistantMapLink: the chat's routes", () => {
|
||||
it('FE-PLANNER-AI-MAP-008: a held tour whose card draws its way stands as that line, not as a pin at its start', () => {
|
||||
setMessages([...held('t1', NEW, {}, { ...HIKE, source: 'pending' }), ...held('a', NEW)]);
|
||||
const { result } = link();
|
||||
expect(result.current.assistantGhosts?.map((g) => g.id)).toEqual(['a']);
|
||||
expect(result.current.assistantRouteLines?.map((line) => line.id)).toEqual(['t1:pending:route']);
|
||||
expect(result.current.routeProfileFocus).toBeNull();
|
||||
|
||||
act(() => result.current.onAssistantRouteHover?.('t1'));
|
||||
expect(useAssistantStore.getState().mapLink).toEqual({ tripId: TRIP, hoveredId: 't1', source: 'map' });
|
||||
expect(result.current.assistantRouteLines?.[0]?.hot).toBe(true);
|
||||
});
|
||||
|
||||
it('FE-PLANNER-AI-MAP-009: a trip place a card points at pulses its own pin; one off the map shows as a pin of its own', () => {
|
||||
const { result } = link();
|
||||
const spot = { tripId: TRIP, ref: 'r:0', lat: 41.01, lng: 12, name: 'Place 1' };
|
||||
act(() => useAssistantStore.getState().setPreviewPin({ ...spot, placeId: 1 }));
|
||||
expect(result.current.assistantGhosts).toEqual([]);
|
||||
expect(result.current.assistantPulsePlaceId).toBe(1);
|
||||
expect(result.current.assistantHoveredId).toBeNull();
|
||||
|
||||
act(() => useAssistantStore.getState().setPreviewPin({ ...spot, placeId: 2 }));
|
||||
expect(result.current.assistantGhosts).toEqual([{ id: 'preview:r:0', lat: 41.01, lng: 12, name: 'Place 1' }]);
|
||||
expect(result.current.assistantPulsePlaceId).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,6 +18,7 @@ import { useSettingsStore } from '../../store/settingsStore';
|
||||
import { useTripStore } from '../../store/tripStore';
|
||||
import type { AssignmentsMap, Category, Place } from '../../types';
|
||||
import { prefersReducedMotion } from '../../utils/reducedMotion';
|
||||
import { useAssistantRouteLines } from './useAssistantRouteLines';
|
||||
|
||||
/** Moves the map was not asked for come at most this often while the assistant works. */
|
||||
const AUTO_CAMERA_GAP_MS = 2000;
|
||||
@@ -73,8 +74,10 @@ interface MapLinkOptions {
|
||||
/**
|
||||
* Everything the assistant shows on the trip map, as props for MapViewAuto:
|
||||
* its waiting suggestions as ghosts tied to their rows in the chat, the
|
||||
* camera moves it asks for, and the pop of a place that arrives from an
|
||||
* applied suggestion. Desktop and phone both get it through useTripPlanner.
|
||||
* routes its cards show (useAssistantRouteLines), the camera moves it asks
|
||||
* for, and the pop of a place that arrives from an applied suggestion. A
|
||||
* spot a card points at is a pin of its own, or the pulse of a trip place's
|
||||
* own pin. Desktop and phone both get it through useTripPlanner.
|
||||
*/
|
||||
export function useAssistantMapLink(options: MapLinkOptions): AssistantMapProps {
|
||||
const { tripId, isMobile, mapLocked, mapPlaces, assignments, markersLocked, selectDay } = options;
|
||||
@@ -82,28 +85,38 @@ export function useAssistantMapLink(options: MapLinkOptions): AssistantMapProps
|
||||
const categories = useTripStore((s) => s.categories);
|
||||
const candidates = useGhostCandidates(tripId);
|
||||
const knownIds = useMemo(() => new Set(places.map((p) => p.id)), [places]);
|
||||
const live = useMemo(() => liveGhosts(candidates, knownIds), [candidates, knownIds]);
|
||||
const preview = useAssistantStore((s) => (s.preview?.tripId === tripId ? s.preview : null));
|
||||
const linkId = useAssistantStore((s) => (s.mapLink?.tripId === tripId ? s.mapLink.hoveredId : null));
|
||||
const setMapHover = useAssistantStore((s) => s.setMapHover);
|
||||
|
||||
const { ghosts, existing } = useMemo(
|
||||
() => ghostPins(live, { places, categories, onMap: new Set(mapPlaces.map((p) => p.id)) }),
|
||||
[categories, live, mapPlaces, places]
|
||||
const autoAllowed = useAutoCameraAllowed(isMobile, mapLocked);
|
||||
const route = useAssistantRouteLines({ tripId, isMobile, autoAllowed });
|
||||
const { hiddenGhosts, cardGhosts } = route;
|
||||
// A change whose card draws its own line stands on the map as that line, not as a pin at its start.
|
||||
const live = useMemo(
|
||||
() => liveGhosts(candidates, knownIds).filter((c) => !hiddenGhosts.has(c.toolCallId)),
|
||||
[candidates, hiddenGhosts, knownIds]
|
||||
);
|
||||
const previewId = preview ? `preview:${preview.ref}` : null;
|
||||
|
||||
const onMapIds = useMemo(() => new Set(mapPlaces.map((p) => p.id)), [mapPlaces]);
|
||||
const { ghosts, existing } = useMemo(
|
||||
() => ghostPins(live, { places, categories, onMap: onMapIds }),
|
||||
[categories, live, onMapIds, places]
|
||||
);
|
||||
const previewPlace = preview?.placeId !== undefined && onMapIds.has(preview.placeId) ? preview.placeId : null;
|
||||
const previewId = preview && previewPlace === null ? `preview:${preview.ref}` : null;
|
||||
const shownGhosts = useMemo(() => {
|
||||
if (!preview || !previewId) return ghosts;
|
||||
return [...ghosts, { id: previewId, lat: preview.lat, lng: preview.lng, name: preview.name }];
|
||||
}, [ghosts, preview, previewId]);
|
||||
const all = cardGhosts.length > 0 ? [...ghosts, ...cardGhosts] : ghosts;
|
||||
if (!preview || !previewId) return all;
|
||||
return [...all, { id: previewId, lat: preview.lat, lng: preview.lng, name: preview.name }];
|
||||
}, [cardGhosts, ghosts, preview, previewId]);
|
||||
|
||||
const onGhostHover = useCallback((id: string | null) => setMapHover(tripId, id, 'map'), [setMapHover, tripId]);
|
||||
const onGhostClick = useCallback((id: string) => setMapHover(tripId, id, 'map'), [setMapHover, tripId]);
|
||||
|
||||
const autoAllowed = useAutoCameraAllowed(isMobile, mapLocked);
|
||||
useAutoCamera({ tripId, live, ghosts, assignments, autoAllowed });
|
||||
const assistantCamera = useCameraProp(tripId, isMobile);
|
||||
const poppedPlaceIds = useArrivalPop(tripId, knownIds, selectDay, autoAllowed);
|
||||
const pulse = previewPlace ?? (linkId ? (existing.get(linkId) ?? null) : null);
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
@@ -111,20 +124,28 @@ export function useAssistantMapLink(options: MapLinkOptions): AssistantMapProps
|
||||
assistantHoveredId: previewId ?? linkId,
|
||||
onAssistantGhostHover: onGhostHover,
|
||||
onAssistantGhostClick: onGhostClick,
|
||||
assistantPulsePlaceId: linkId ? (existing.get(linkId) ?? null) : null,
|
||||
assistantPulsePlaceId: pulse,
|
||||
assistantCamera,
|
||||
poppedPlaceIds,
|
||||
markersLocked,
|
||||
assistantRouteLines: route.assistantRouteLines,
|
||||
onAssistantRouteHover: route.onAssistantRouteHover,
|
||||
onAssistantRoutePoint: route.onAssistantRoutePoint,
|
||||
routeProfileFocus: route.routeProfileFocus,
|
||||
}),
|
||||
[
|
||||
assistantCamera,
|
||||
existing,
|
||||
linkId,
|
||||
markersLocked,
|
||||
onGhostClick,
|
||||
onGhostHover,
|
||||
poppedPlaceIds,
|
||||
previewId,
|
||||
pulse,
|
||||
route.assistantRouteLines,
|
||||
route.onAssistantRouteHover,
|
||||
route.onAssistantRoutePoint,
|
||||
route.routeProfileFocus,
|
||||
shownGhosts,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* FE-PLANNER-AI-ROUTE-001 to FE-PLANNER-AI-ROUTE-007
|
||||
*
|
||||
* The chat's routes on the plan's map: answers laid out as the chat lays
|
||||
* them out, the ways in the theme's colours with the chosen one solid, the
|
||||
* pointer lighting a route's card and moving its profile's spot (once a
|
||||
* frame), a tap on the phone opening the route's peek, a saved tour and a
|
||||
* pointed-at drive drawn while lit, and one move of the map per new answer
|
||||
* (none for what the chat showed when the planner opened).
|
||||
*/
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import type { AssistantMessage, AssistantMessagePart, TourRouteCard, Trip } from '@trek/shared';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { GENTLE, HIKE, HIKE_LINE, SAVED, TOUR_LIST } from '../../../tests/helpers/assistantTour';
|
||||
import { chatOf, useAssistantStore } from '../../store/assistantStore';
|
||||
import { useTripStore } from '../../store/tripStore';
|
||||
import type { Place } from '../../types';
|
||||
import { answerLayout, routeFocusAt, useAssistantRouteLines } from './useAssistantRouteLines';
|
||||
|
||||
const TRIP = 4;
|
||||
const ASSISTANT = useAssistantStore.getState();
|
||||
const TRIPS = useTripStore.getState();
|
||||
const PAINT = {
|
||||
'--hike-variant-current': '#0a84ff',
|
||||
'--hike-variant-a': '#f97316',
|
||||
'--hike-variant-b': '#d946ef',
|
||||
'--bike-highlight-casing': '#ffffff',
|
||||
};
|
||||
|
||||
function read(toolCallId: string, card: TourRouteCard): AssistantMessagePart[] {
|
||||
return [
|
||||
{ type: 'tool-call', toolCallId, toolName: 'propose_hike', args: {}, result: {} },
|
||||
{ type: 'data-trek-card', data: { toolCallId, card } },
|
||||
];
|
||||
}
|
||||
|
||||
function setMessages(parts: AssistantMessagePart[], over: Partial<ReturnType<typeof chatOf>> = {}) {
|
||||
const message: AssistantMessage = {
|
||||
id: 'msg-1',
|
||||
role: 'assistant',
|
||||
parts,
|
||||
status: 'complete',
|
||||
createdAt: '2026-10-21T08:00:00.000Z',
|
||||
};
|
||||
useAssistantStore.setState((s) => ({ byTrip: { [TRIP]: { ...chatOf(s, TRIP), messages: [message], ...over } } }));
|
||||
}
|
||||
|
||||
const WAYS = [...read('call_1', HIKE), ...read('call_2', GENTLE)];
|
||||
|
||||
function lines(props: { isMobile?: boolean; autoAllowed?: boolean } = {}) {
|
||||
return renderHook(
|
||||
(p: { isMobile?: boolean; autoAllowed?: boolean }) =>
|
||||
useAssistantRouteLines({ tripId: TRIP, isMobile: p.isMobile ?? false, autoAllowed: p.autoAllowed ?? true }),
|
||||
{ initialProps: props }
|
||||
);
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
for (const [token, value] of Object.entries(PAINT)) document.documentElement.style.setProperty(token, value);
|
||||
useTripStore.setState({ trip: { id: TRIP } as Trip, places: [] });
|
||||
// One frame at once: what the pointer asks for lands before the assertion.
|
||||
vi.stubGlobal('requestAnimationFrame', (run: FrameRequestCallback) => {
|
||||
run(0);
|
||||
return 1;
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
for (const token of Object.keys(PAINT)) document.documentElement.style.removeProperty(token);
|
||||
vi.unstubAllGlobals();
|
||||
useAssistantStore.setState(ASSISTANT, true);
|
||||
useTripStore.setState(TRIPS, true);
|
||||
});
|
||||
|
||||
describe('useAssistantRouteLines', () => {
|
||||
it('FE-PLANNER-AI-ROUTE-001: proposals of one activity are one choice of ways, anything else a card of its own', () => {
|
||||
const entries = [
|
||||
{ toolCallId: 'a', card: HIKE },
|
||||
{ toolCallId: 'b', card: GENTLE },
|
||||
{ toolCallId: 'c', card: SAVED },
|
||||
{ toolCallId: 'd', card: TOUR_LIST },
|
||||
];
|
||||
expect(answerLayout(entries).map((group) => group.map((entry) => entry.toolCallId))).toEqual([
|
||||
['a', 'b'],
|
||||
['c'],
|
||||
['d'],
|
||||
]);
|
||||
});
|
||||
|
||||
it('FE-PLANNER-AI-ROUTE-002: the spot of a route nearest a point is measured as its card measures it, with the height there', () => {
|
||||
const [lat, lng] = HIKE_LINE[5] as [number, number, number];
|
||||
const spot = routeFocusAt(HIKE, lat, lng);
|
||||
expect(spot?.elevationMeters).toBeCloseTo(1400, 0);
|
||||
expect(spot?.distanceMeters).toBeGreaterThan(3700);
|
||||
expect(spot?.distanceMeters).toBeLessThan(3900);
|
||||
expect(routeFocusAt({ ...HIKE, routed: false }, lat, lng)).toBeNull();
|
||||
expect(routeFocusAt(TOUR_LIST, lat, lng)).toBeNull();
|
||||
});
|
||||
|
||||
it("FE-PLANNER-AI-ROUTE-003: an answer's ways are drawn in the theme's colours, the chosen one solid, the lit one on top", () => {
|
||||
setMessages(WAYS, { picks: { 'tour:call_1': 'call_2' } });
|
||||
const { result } = lines();
|
||||
const [wayA, wayB] = result.current.assistantRouteLines;
|
||||
expect(wayA).toMatchObject({ ref: 'call_1', color: '#f97316', casing: '#ffffff', dashed: true });
|
||||
expect(wayB).toMatchObject({ ref: 'call_2', color: '#d946ef' });
|
||||
expect(wayB?.dashed).toBeUndefined();
|
||||
|
||||
act(() => useAssistantStore.getState().setMapHover(TRIP, 'call_1', 'card'));
|
||||
const lit = result.current.assistantRouteLines;
|
||||
expect(lit[lit.length - 1]).toMatchObject({ ref: 'call_1', hot: true });
|
||||
});
|
||||
|
||||
it("FE-PLANNER-AI-ROUTE-004: the pointer on a route lights its card and moves its profile's spot; leaving puts both out", () => {
|
||||
setMessages(read('call_9', HIKE));
|
||||
const { result } = lines();
|
||||
const [lat, lng] = HIKE_LINE[5] as [number, number, number];
|
||||
act(() => result.current.onAssistantRouteHover('call_9'));
|
||||
act(() => result.current.onAssistantRoutePoint('call_9', lat, lng));
|
||||
expect(useAssistantStore.getState().mapLink).toEqual({ tripId: TRIP, hoveredId: 'call_9', source: 'map' });
|
||||
expect(useAssistantStore.getState().routeFocus).toMatchObject({ tripId: TRIP, ref: 'call_9', source: 'map' });
|
||||
expect(result.current.routeProfileFocus?.elevationMeters).toBeCloseTo(1400, 0);
|
||||
expect(useAssistantStore.getState().routePeek).toBeNull();
|
||||
|
||||
act(() => result.current.onAssistantRouteHover(null));
|
||||
expect(useAssistantStore.getState().mapLink?.hoveredId).toBeNull();
|
||||
expect(useAssistantStore.getState().routeFocus).toBeNull();
|
||||
|
||||
// On the phone a tap does what the pointer does, and opens the route's peek over the map.
|
||||
const phone = lines({ isMobile: true });
|
||||
act(() => phone.result.current.onAssistantRoutePoint('call_9', lat, lng));
|
||||
expect(useAssistantStore.getState().routePeek).toEqual({ tripId: TRIP, toolCallId: 'call_9' });
|
||||
expect(useAssistantStore.getState().mapLink).toEqual({ tripId: TRIP, hoveredId: 'call_9', source: 'map' });
|
||||
});
|
||||
|
||||
it('FE-PLANNER-AI-ROUTE-005: a saved tour lit from its row and a drive a card points at are drawn while lit', () => {
|
||||
const geometry = JSON.stringify(HIKE_LINE.map(([lat, lng]) => [lat, lng]));
|
||||
const tour = { id: 41, trip_id: TRIP, name: 'Hochfelln', route_geometry: geometry } as Place;
|
||||
useTripStore.setState({ places: [tour] });
|
||||
const { result } = lines();
|
||||
expect(result.current.assistantRouteLines).toEqual([]);
|
||||
|
||||
act(() => useAssistantStore.getState().setMapHover(TRIP, 'tour:41', 'card'));
|
||||
expect(result.current.assistantRouteLines).toEqual([
|
||||
expect.objectContaining({ id: 'tour:41', ref: 'tour:41', color: '#0a84ff', casing: '#ffffff', hot: true }),
|
||||
]);
|
||||
|
||||
const driven = HIKE_LINE.map(([la, ln]): [number, number] => [la, ln]);
|
||||
const drive = { tripId: TRIP, ref: 'day:3', lines: [driven], color: '#22c55e' };
|
||||
act(() => useAssistantStore.getState().setRoutePreview(drive));
|
||||
expect(result.current.assistantRouteLines[1]).toMatchObject({ id: 'preview:day:3', color: '#22c55e', hot: true });
|
||||
});
|
||||
|
||||
it('FE-PLANNER-AI-ROUTE-006: a new answer of routes frames the map once it is complete; one there at mount does not', () => {
|
||||
setMessages(read('old', SAVED));
|
||||
const { rerender } = lines();
|
||||
expect(useAssistantStore.getState().camera).toBeNull();
|
||||
|
||||
act(() => setMessages(WAYS, { isRunning: true }));
|
||||
rerender({});
|
||||
expect(useAssistantStore.getState().camera).toBeNull();
|
||||
|
||||
act(() => setMessages(WAYS, { isRunning: false }));
|
||||
rerender({});
|
||||
expect(useAssistantStore.getState().camera).toMatchObject({ tripId: TRIP, mode: 'fit', why: 'auto' });
|
||||
expect(useAssistantStore.getState().camera?.points).toHaveLength(HIKE_LINE.length * 2);
|
||||
|
||||
const seq = useAssistantStore.getState().camera?.seq;
|
||||
rerender({});
|
||||
expect(useAssistantStore.getState().camera?.seq).toBe(seq);
|
||||
});
|
||||
|
||||
it('FE-PLANNER-AI-ROUTE-007: opened while the chat writes, the map stays put when the new answer draws no routes', () => {
|
||||
setMessages(read('old', SAVED), { isRunning: true });
|
||||
const { rerender } = lines();
|
||||
act(() => setMessages(read('old', SAVED), { isRunning: false }));
|
||||
rerender({});
|
||||
expect(useAssistantStore.getState().camera).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,293 @@
|
||||
import { cumulativeMetres, nearestAlongM, type TrekCard } from '@trek/shared';
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
|
||||
|
||||
import { CARD_MAP_LOOK, CARD_RULES } from '../../components/Assistant/cards/cardLooks';
|
||||
import { alongOf, profileSamples, routeEntries, wayGroups } from '../../components/Assistant/cards/tour/tourRouteModel';
|
||||
import { useMapPaint } from '../../components/Map/mapPaint';
|
||||
import type { AssistantGhost } from '../../components/Map/mapViewContract';
|
||||
import {
|
||||
type AnswerLayout,
|
||||
cardGhosts,
|
||||
cardHiddenGhosts,
|
||||
lookPoints,
|
||||
type RouteCardEntry,
|
||||
routeLines,
|
||||
type RouteRef,
|
||||
routeRefs,
|
||||
} from '../../store/assistantRouteModel';
|
||||
import { chatOf, useAssistantStore } from '../../store/assistantStore';
|
||||
import { useTripStore } from '../../store/tripStore';
|
||||
import type { Place } from '../../types';
|
||||
import type { AssistantRouteLine } from '../../types/assistantMap';
|
||||
import {
|
||||
focusRouteProfileAtDistance,
|
||||
parseRenderableRouteGeometry,
|
||||
type RouteProfileFocus,
|
||||
} from '../../utils/routeGeometry';
|
||||
|
||||
/**
|
||||
* The chat's routes on the plan's map, the one channel the tour and road
|
||||
* trip cards share: what the cards draw (through their map looks), lit with
|
||||
* their cards both ways, the spot of a route in focus shown on the map and
|
||||
* picked from it, and the drive or saved tour a card points at. Desktop and
|
||||
* phone both get it through useAssistantMapLink.
|
||||
*/
|
||||
|
||||
/** A saved tour's key on the map, as the tour list lights it. */
|
||||
const SAVED_TOUR = 'tour:';
|
||||
/** The colours a lit saved tour and a pointed-at drive are drawn in, the planner's own (styles/hike.css). */
|
||||
const SAVED_PAINT = { line: 'var(--hike-variant-current)', casing: 'var(--bike-highlight-casing)' } as const;
|
||||
const PREVIEW_CASING = 'var(--bg-card)';
|
||||
/** Two tokens that change with the theme, so the resolved colours follow a light or dark switch. */
|
||||
const THEME_PROBE = { accent: '--accent', card: '--bg-card' } as const;
|
||||
|
||||
/**
|
||||
* How an answer lays out its cards, as the chat does: consecutive cards of
|
||||
* one group show as one, and the tours' proposals of one activity as a
|
||||
* choice of up to three ways.
|
||||
*/
|
||||
export const answerLayout: AnswerLayout = (entries) => {
|
||||
const runs: { group: string; entries: RouteCardEntry[] }[] = [];
|
||||
for (const entry of entries) {
|
||||
const group = CARD_RULES.group(entry.card);
|
||||
const run = runs[runs.length - 1];
|
||||
if (run?.group === group) run.entries.push(entry);
|
||||
else runs.push({ group, entries: [entry] });
|
||||
}
|
||||
return runs.flatMap((run) => {
|
||||
const routes = routeEntries(run.entries);
|
||||
return routes.length === run.entries.length ? wayGroups(routes) : run.entries.map((entry) => [entry]);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* The spot of a route nearest to a point on the map, as the route's card
|
||||
* measures it: metres along its line scaled to its own length, with the
|
||||
* height there. Only a route with a height profile has one.
|
||||
*/
|
||||
export function routeFocusAt(card: TrekCard, lat: number, lng: number): RouteProfileFocus | null {
|
||||
if (card.kind !== 'tourRoute') return null;
|
||||
const samples = profileSamples(card);
|
||||
if (samples.length < 2) return null;
|
||||
const raw = cumulativeMetres(card.line);
|
||||
const scaled = alongOf(card);
|
||||
const rawTotal = raw[raw.length - 1] ?? 0;
|
||||
const scale = rawTotal > 0 ? (scaled[scaled.length - 1] ?? 0) / rawTotal : 1;
|
||||
return focusRouteProfileAtDistance(samples, nearestAlongM(card.line, lat, lng) * scale);
|
||||
}
|
||||
|
||||
/** A saved tour of the trip lit from the chat (its row in a tour list), drawn over its own track. */
|
||||
function savedTourLine(places: readonly Place[], hoveredId: string | null): AssistantRouteLine[] {
|
||||
if (!hoveredId?.startsWith(SAVED_TOUR)) return [];
|
||||
const placeId = Number(hoveredId.slice(SAVED_TOUR.length));
|
||||
const points = parseRenderableRouteGeometry(places.find((place) => place.id === placeId)?.route_geometry);
|
||||
if (!points) return [];
|
||||
const line = points.map(([lat, lng]): [number, number] => [lat, lng]);
|
||||
const { line: color, casing } = SAVED_PAINT;
|
||||
return [{ id: hoveredId, ref: hoveredId, lines: [line], color, casing, hot: true }];
|
||||
}
|
||||
|
||||
/** The theme's colour for a CSS value (`var(--token)`), read again when the theme changes; other values as they are. */
|
||||
function useCssColor(): (value: string) => string {
|
||||
const theme = useMapPaint(THEME_PROBE);
|
||||
return useMemo(() => {
|
||||
const style = typeof document === 'undefined' ? null : getComputedStyle(document.documentElement);
|
||||
const resolved = new Map<string, string>();
|
||||
return (value: string) => {
|
||||
const token = /^var\((--[\w-]+)\)$/.exec(value.trim())?.[1];
|
||||
if (!token) return value;
|
||||
let color = resolved.get(token);
|
||||
if (color === undefined) {
|
||||
color = style?.getPropertyValue(token).trim() || theme.accent;
|
||||
resolved.set(token, color);
|
||||
}
|
||||
return color;
|
||||
};
|
||||
}, [theme]);
|
||||
}
|
||||
|
||||
/** A line with its colours resolved, as both map renderers need them. */
|
||||
function painted(line: AssistantRouteLine, color: (value: string) => string): AssistantRouteLine {
|
||||
const next = { ...line, color: color(line.color), casing: color(line.casing) };
|
||||
if (line.tints) next.tints = line.tints.map((tint) => ({ ...tint, color: color(tint.color) }));
|
||||
return next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Each card object the map has seen, by a number of its own. A streamed text
|
||||
* delta leaves the cards' objects alone and a card that changes (a change's
|
||||
* applied card replacing its preview) is a new object, so the number tells
|
||||
* whether the map must redraw without comparing the cards. A weak cache: a
|
||||
* card the chat let go of leaves it.
|
||||
*/
|
||||
const cardSerials = new WeakMap<object, number>();
|
||||
let lastSerial = 0;
|
||||
|
||||
function serialOf(card: object): number {
|
||||
let serial = cardSerials.get(card);
|
||||
if (serial === undefined) {
|
||||
lastSerial += 1;
|
||||
serial = lastSerial;
|
||||
cardSerials.set(card, serial);
|
||||
}
|
||||
return serial;
|
||||
}
|
||||
|
||||
function refsNow(state: Parameters<typeof chatOf>[0], tripId: number, knownIds: ReadonlySet<number>): RouteRef[] {
|
||||
const chat = chatOf(state, tripId);
|
||||
return routeRefs(chat.messages, chat.picks, knownIds, CARD_MAP_LOOK, answerLayout);
|
||||
}
|
||||
|
||||
/**
|
||||
* The cards the map draws now, re-read only when one of them changes. The
|
||||
* selector hands back a key, so a streamed answer does not render the
|
||||
* planner on every frame.
|
||||
*/
|
||||
function useRouteRefs(tripId: number, knownIds: ReadonlySet<number>): RouteRef[] {
|
||||
const signature = useAssistantStore((s) =>
|
||||
refsNow(s, tripId, knownIds)
|
||||
.map((ref) => `${ref.toolCallId}|${ref.use}|${ref.way ?? ''}|${ref.picked ? 1 : 0}|${serialOf(ref.card)}`)
|
||||
.join(';')
|
||||
);
|
||||
return useMemo(
|
||||
() => (signature === '' ? [] : refsNow(useAssistantStore.getState(), tripId, knownIds)),
|
||||
[signature, knownIds, tripId]
|
||||
);
|
||||
}
|
||||
|
||||
interface RouteLinesOptions {
|
||||
tripId: number;
|
||||
isMobile: boolean;
|
||||
/** Whether the map may move without being asked (see useAssistantMapLink). */
|
||||
autoAllowed: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Everything the chat's routes put on the plan's map: the lines, the spots
|
||||
* the waiting changes' cards mark (and the changes whose pin their own line
|
||||
* replaces), the focus pin, and the pointer's way back to the cards. A
|
||||
* pointer on a line lights its card; moving along it moves the card's
|
||||
* profile; leaving puts both out. On the phone a tap does what the pointer
|
||||
* does, and opens the route's peek over the map.
|
||||
*/
|
||||
export function useAssistantRouteLines({ tripId, isMobile, autoAllowed }: RouteLinesOptions) {
|
||||
const places = useTripStore((s) => s.places);
|
||||
const knownIds = useMemo(() => new Set(places.map((place) => place.id)), [places]);
|
||||
const refs = useRouteRefs(tripId, knownIds);
|
||||
const hoveredId = useAssistantStore((s) => (s.mapLink?.tripId === tripId ? s.mapLink.hoveredId : null));
|
||||
const preview = useAssistantStore((s) => (s.routePreview?.tripId === tripId ? s.routePreview : null));
|
||||
const focus = useAssistantStore((s) => (s.routeFocus?.tripId === tripId ? s.routeFocus.focus : null));
|
||||
const setMapHover = useAssistantStore((s) => s.setMapHover);
|
||||
const setRouteFocus = useAssistantStore((s) => s.setRouteFocus);
|
||||
const setRoutePeek = useAssistantStore((s) => s.setRoutePeek);
|
||||
const color = useCssColor();
|
||||
|
||||
const assistantRouteLines = useMemo(() => {
|
||||
const drawn = [...routeLines(refs, CARD_MAP_LOOK, hoveredId), ...savedTourLine(places, hoveredId)];
|
||||
if (preview) {
|
||||
const { ref, lines } = preview;
|
||||
drawn.push({ id: `preview:${ref}`, ref, lines, color: preview.color, casing: PREVIEW_CASING, hot: true });
|
||||
}
|
||||
return drawn.map((line) => painted(line, color));
|
||||
}, [color, hoveredId, places, preview, refs]);
|
||||
|
||||
const ghosts = useMemo(
|
||||
() =>
|
||||
cardGhosts(refs, CARD_MAP_LOOK).map(
|
||||
(ghost): AssistantGhost => ({
|
||||
id: ghost.id,
|
||||
ref: ghost.ref,
|
||||
lat: ghost.lat,
|
||||
lng: ghost.lng,
|
||||
name: ghost.name,
|
||||
variant: ghost.variant ?? 'pin',
|
||||
})
|
||||
),
|
||||
[refs]
|
||||
);
|
||||
const hiddenGhosts = useMemo(() => cardHiddenGhosts(refs, CARD_MAP_LOOK), [refs]);
|
||||
|
||||
const latestRefs = useRef(refs);
|
||||
useLayoutEffect(() => {
|
||||
latestRefs.current = refs;
|
||||
});
|
||||
const frame = useRef<number | null>(null);
|
||||
const pointed = useRef<{ ref: string; lat: number; lng: number } | null>(null);
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (frame.current !== null) cancelAnimationFrame(frame.current);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const onAssistantRouteHover = useCallback(
|
||||
(ref: string | null) => {
|
||||
setMapHover(tripId, ref, 'map');
|
||||
if (ref !== null) return;
|
||||
const current = useAssistantStore.getState().routeFocus;
|
||||
if (current?.tripId === tripId && current.source === 'map') setRouteFocus(null);
|
||||
},
|
||||
[setMapHover, setRouteFocus, tripId]
|
||||
);
|
||||
|
||||
// Pointer moves come many per frame; the focus follows once a frame.
|
||||
const onAssistantRoutePoint = useCallback(
|
||||
(ref: string, lat: number, lng: number) => {
|
||||
pointed.current = { ref, lat, lng };
|
||||
if (frame.current !== null) return;
|
||||
frame.current = requestAnimationFrame(() => {
|
||||
frame.current = null;
|
||||
const point = pointed.current;
|
||||
pointed.current = null;
|
||||
if (!point) return;
|
||||
const card = latestRefs.current.find((r) => r.toolCallId === point.ref && r.use !== 'before')?.card ?? null;
|
||||
const spot = card ? routeFocusAt(card, point.lat, point.lng) : null;
|
||||
if (spot) setRouteFocus({ tripId, ref: point.ref, focus: spot, source: 'map' });
|
||||
// The light goes on only with the peek, whose closing puts it out again (moveRoutePeek).
|
||||
if (!isMobile || card?.kind !== 'tourRoute') return;
|
||||
setMapHover(tripId, point.ref, 'map');
|
||||
setRoutePeek({ tripId, toolCallId: point.ref });
|
||||
});
|
||||
},
|
||||
[isMobile, setMapHover, setRouteFocus, setRoutePeek, tripId]
|
||||
);
|
||||
|
||||
useRouteAutoCamera(tripId, refs, autoAllowed);
|
||||
|
||||
return {
|
||||
assistantRouteLines,
|
||||
onAssistantRouteHover,
|
||||
onAssistantRoutePoint,
|
||||
routeProfileFocus: focus,
|
||||
cardGhosts: ghosts,
|
||||
hiddenGhosts,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* One move of its own per new answer that draws routes: once the answer is
|
||||
* complete, the map frames all its ways, where the map may move by itself.
|
||||
* An answer already there when the planner opens is left where it is, even
|
||||
* when the planner opens while the chat is still writing and the new answer
|
||||
* draws no routes of its own.
|
||||
*/
|
||||
function useRouteAutoCamera(tripId: number, refs: readonly RouteRef[], autoAllowed: boolean): void {
|
||||
const requestCamera = useAssistantStore((s) => s.requestCamera);
|
||||
const isRunning = useAssistantStore((s) => chatOf(s, tripId).isRunning);
|
||||
const firstKey = refs.find((ref) => ref.use === 'look')?.toolCallId ?? null;
|
||||
const blockKey = isRunning ? null : firstKey;
|
||||
const seen = useRef<string | null | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
if (seen.current === undefined) {
|
||||
// What the chat shows at mount counts as seen, finished or not.
|
||||
seen.current = firstKey;
|
||||
return;
|
||||
}
|
||||
if (blockKey === null || blockKey === seen.current) return;
|
||||
seen.current = blockKey;
|
||||
if (!autoAllowed) return;
|
||||
const points = lookPoints(refs, CARD_MAP_LOOK);
|
||||
if (points.length > 0) requestCamera(tripId, points, 'fit', 'auto');
|
||||
}, [autoAllowed, blockKey, firstKey, refs, requestCamera, tripId]);
|
||||
}
|
||||
@@ -167,6 +167,8 @@ export function useTourWorkspace(planner: TripPlanner, canPlaceEdit: boolean, ca
|
||||
return {
|
||||
tourPlanner,
|
||||
viewImportedTour,
|
||||
// A saved tour opened in the editor, or shown as it came in; the chat's `?tour=` link opens it this way.
|
||||
openTourInPlanner,
|
||||
tourGpxImport,
|
||||
wandererBrowser,
|
||||
tourConversion,
|
||||
|
||||
Reference in New Issue
Block a user