mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 09:22:15 +00:00
feat(assistant): trip assistant chat with your own AI connection
Adds an in-app assistant that reads and plans the open trip. Users connect their own provider (Sign in with ChatGPT, or an Anthropic, OpenAI, Gemini or OpenRouter key) or use the one the admin set up, including a custom OpenAI-compatible server. It is an addon and only shows while a connection is usable. The chat runs on the existing MCP tools, pinned to the trip. Every change is held as a change card the user applies or discards, and applied changes can be undone. On the desktop it is a floating window that can be moved and resized; on the phone it is fullscreen. Search results show as place cards that can go onto a day, weather lookups as a strip, proposed places as ghost markers on the map with a before/after switch, and an answer can be shared into the trip chat. Booking files can be dropped in and are read into change cards.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import type { AssistantApplied } from '@trek/shared';
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
/** What the parts deep inside a chat need from whoever shows it. */
|
||||
export interface AssistantView {
|
||||
tripId: number;
|
||||
/** 'window' on the desktop, 'fullscreen' on the phone. */
|
||||
variant: 'window' | 'fullscreen';
|
||||
/** How much room the chat has: a narrow window and the phone are 'compact'. */
|
||||
density?: 'compact' | 'roomy';
|
||||
/** Shows an applied change in the planner; the button is left out where nothing can show it. */
|
||||
onShowOnMap?: (applied: AssistantApplied) => void;
|
||||
/** Selects a day in the planner, from its weather; left out where no planner can show it. */
|
||||
onFocusDay?: (dayId: number) => void;
|
||||
/** Brings the map into view where the chat covers it (the phone), before the map moves. */
|
||||
onRevealMap?: () => void;
|
||||
}
|
||||
|
||||
export const AssistantViewContext = createContext<AssistantView | null>(null);
|
||||
|
||||
export function useAssistantView(): AssistantView {
|
||||
const view = useContext(AssistantViewContext);
|
||||
if (!view) throw new Error('useAssistantView outside AssistantSurface');
|
||||
return view;
|
||||
}
|
||||
Reference in New Issue
Block a user