Files
TREK/client/src/components/Assistant/AssistantSurface.tsx
T
Maurice 6d841f98e0 fix(assistant): a book page card draws the page after as the server's trial made it
The Studio drew the page after a held edit or cover change by running the
card's operations on its own book, which knows nothing of the journey's
photos, words and figures, so a caption from a photo, a text from an entry
or a map from the route came out differently or not at all. The card now
carries the page the server's trial made with the full context, read with
the book's schema and within the card's size, and the Studio draws it while
its book stands at the version the trial ran on. A book that moved on, a
card from before and a page too heavy to carry still run the operations on
the book on screen, the book the change will run on. The receipt leaves the
page out, since an applied change is drawn from the book itself.
2026-10-23 02:29:04 +00:00

55 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,
}: 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,
}),
[tripId, variant, density, onOpen, onFocusDay, onRevealMap, bookVersion]
);
return (
<AssistantRuntimeProvider runtime={runtime}>
<AssistantViewContext.Provider value={view}>
<AssistantThread tripTitle={tripTitle} />
</AssistantViewContext.Provider>
</AssistantRuntimeProvider>
);
}