Sessions no longer take their title from the first message: once the first exchange is sent, the text model writes the title and summary, which the rail and sessions list show. The summary records how many messages it covers so a stale one is rewritten before it is carried into the next session. The sessions hook now reloads on live message and session events, so a session started by the first message, a rollover or another tab appears without a reload. New sessions are pushed as server:bot-session, both from the process that changed them and through the live relay.
30 lines
787 B
TypeScript
30 lines
787 B
TypeScript
import type { BotSessionChangedData } from "@/src/types";
|
|
import pushToSessionUser from "./push-to-session-user";
|
|
|
|
type Params = {
|
|
session_id: number | string;
|
|
bot_id: number | string;
|
|
workspace_id?: number | string | null;
|
|
};
|
|
|
|
/**
|
|
* Tells the open tabs of the user a session belongs to that it started or
|
|
* changed, so the rail and the sessions list reload it.
|
|
*/
|
|
export default async function pushBotSession({
|
|
session_id,
|
|
bot_id,
|
|
workspace_id,
|
|
}: Params) {
|
|
const data: BotSessionChangedData = {
|
|
session_id: Number(session_id),
|
|
bot_id: Number(bot_id),
|
|
workspace_id: workspace_id ? Number(workspace_id) : null,
|
|
};
|
|
|
|
await pushToSessionUser({
|
|
session_id,
|
|
data: { event: "server:bot-session", data },
|
|
});
|
|
}
|