mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-05 20:15:59 +00:00
8433251c86
The welcome chose the journal's words whenever the Studio had not registered as the chat's host, which also hit the Studio's own panel before (or without) that registration. A journey's chat now speaks of the journal only where the window or the phone's chat screen say they show it for its journal; everywhere else, the Studio included, it stays the book's. AssistantWindow had gone past the complexity limit choosing between the planner's trip, the journal on screen, a picked chat and the home chat; that choice now lives in windowChat.
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import './assistant.css';
|
|
|
|
import { AssistantRuntimeProvider } from '@assistant-ui/react';
|
|
import { useMemo } from 'react';
|
|
|
|
import AssistantThread from './AssistantThread';
|
|
import { type AssistantView, AssistantViewContext } from './assistantViewContext';
|
|
import { useAssistantRuntime } from './useAssistantRuntime';
|
|
|
|
export interface AssistantSurfaceProps extends AssistantView {
|
|
/** Named in the composer's placeholder: the trip's title, or the journey's in TREK Studio. */
|
|
tripTitle: string;
|
|
}
|
|
|
|
/**
|
|
* The chat for one trip, the same on the desktop window and the phone screen,
|
|
* and for one journey in TREK Studio: `tripId` is the chat's key, so the
|
|
* Studio passes `assistantChatKey({ kind: 'journey', journeyId })` and gets
|
|
* the journey's conversations, with the parts that need a trip left empty.
|
|
* Its own chunk: this is the only module tree that pulls in @assistant-ui, so
|
|
* nobody downloads the chat runtime before opening the assistant.
|
|
*/
|
|
export default function AssistantSurface({
|
|
tripId,
|
|
tripTitle,
|
|
variant,
|
|
density,
|
|
onOpen,
|
|
onFocusDay,
|
|
onRevealMap,
|
|
bookVersion,
|
|
onOpenTripChat,
|
|
journal,
|
|
}: AssistantSurfaceProps) {
|
|
const runtime = useAssistantRuntime(tripId);
|
|
// The phone is always compact; a window is what its width says.
|
|
const view = useMemo(
|
|
() => ({
|
|
tripId,
|
|
variant,
|
|
density: variant === 'fullscreen' ? ('compact' as const) : (density ?? 'roomy'),
|
|
onOpen,
|
|
onFocusDay,
|
|
onRevealMap,
|
|
bookVersion,
|
|
onOpenTripChat,
|
|
journal,
|
|
}),
|
|
[tripId, variant, density, onOpen, onFocusDay, onRevealMap, bookVersion, onOpenTripChat, journal]
|
|
);
|
|
return (
|
|
<AssistantRuntimeProvider runtime={runtime}>
|
|
<AssistantViewContext.Provider value={view}>
|
|
<AssistantThread tripTitle={tripTitle} />
|
|
</AssistantViewContext.Provider>
|
|
</AssistantRuntimeProvider>
|
|
);
|
|
}
|