Load a conversation's history on the client
The conversation pages rendered their messages on the server, so a page the back button restored from the back-forward cache showed an old thread. The server now renders everything else (rail, header, composer) and the history (active session, latest messages, active task) loads from api/admin/bots/conversation-history once the page is on screen, with a loading line under the header, and again on a pageshow restore. Messages sent or pushed while it loads are merged with it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+26
-13
@@ -1080,6 +1080,32 @@ export type BotTextModel = {
|
||||
provider_name: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* A conversation's history, which its page loads on the client once it
|
||||
* renders (`grabConversationHistory`): the active session, its latest
|
||||
* messages, whether it has older ones, and the bot's active task in it.
|
||||
*/
|
||||
export type ConversationHistory = {
|
||||
session: BUN_SQLITE_COBBLE_BOT_SESSIONS;
|
||||
messages: BotMessageWithAttachments[];
|
||||
has_more: boolean;
|
||||
/**
|
||||
* The bot's active task in the session and what its job has done so
|
||||
* far.
|
||||
*/
|
||||
task: BotTaskWithSteps | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* What `api/admin/bots/conversation-history` answers: the history, or
|
||||
* where to go instead when the user can't chat with the bot there any
|
||||
* more.
|
||||
*/
|
||||
export type ConversationHistoryPayload = {
|
||||
history?: ConversationHistory;
|
||||
redirect?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* One build's `.bunext/public` files, downloaded by the service worker
|
||||
* before the app runs (`grabPrecacheManifest`).
|
||||
@@ -1107,15 +1133,6 @@ export type PagePropsType = {
|
||||
crew_workspaces?: BUN_SQLITE_COBBLE_WORKSPACES[] | null;
|
||||
bots?: BotWithLastMessage[] | null;
|
||||
bot?: BotWithLastMessage | null;
|
||||
bot_messages?: BotMessageWithAttachments[] | null;
|
||||
/**
|
||||
* The session has messages older than `bot_messages`.
|
||||
*/
|
||||
bot_messages_more?: boolean | null;
|
||||
/**
|
||||
* The open conversation's active session.
|
||||
*/
|
||||
bot_session?: BUN_SQLITE_COBBLE_BOT_SESSIONS | null;
|
||||
/**
|
||||
* The user's workspaces, for the rail.
|
||||
*/
|
||||
@@ -1158,10 +1175,6 @@ export type PagePropsType = {
|
||||
* The open bot's computers, the one it's on first.
|
||||
*/
|
||||
bot_computers?: ComputerWithStatus[] | null;
|
||||
/**
|
||||
* The open bot's active task and what its job has done so far.
|
||||
*/
|
||||
bot_task?: BotTaskWithSteps | null;
|
||||
/**
|
||||
* The routines page: every schedule the user's bots have.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user