List the open bot's recent sessions in the rail

Show the latest five sessions under the active bot, with All sessions opening the existing modal once there are more. Share the session modal, row and hook outside the conversation page, and mark the current session with a muted row.
This commit is contained in:
2026-10-19 17:27:57 +01:00
parent dbfe48796b
commit 53cf054d70
18 changed files with 236 additions and 39 deletions
@@ -14,6 +14,10 @@ type Params = {
*/
query?: string;
page?: number;
/**
* How many to return; a page by default.
*/
limit?: number;
};
/**
@@ -27,10 +31,11 @@ export default async function grabBotSessions({
workspace_id,
query,
page = 1,
limit,
}: Params): Promise<BotSessionListItem[]> {
const search = query?.trim();
const like = search ? `%${search.replace(/[\\%_]/g, (c) => `\\${c}`)}%` : null;
const limit = AppData.BotSessionsPageSize;
const page_size = limit || AppData.BotSessionsPageSize;
let sql = ``;
@@ -56,8 +61,8 @@ export default async function grabBotSessions({
bot_id,
workspace_id ? Number(workspace_id) : null,
...(like ? [like, like, like] : []),
limit,
(Math.max(1, page) - 1) * limit,
page_size,
(Math.max(1, page) - 1) * page_size,
],
});
@@ -0,0 +1,20 @@
import fetchApi from "@moduletrace/twui/utils/fetch/fetchApi";
import type { APIResponseObject } from "@moduletrace/bunext/types";
type Params = {
/**
* Under `/api/admin/bots/`.
*/
path: "list-sessions" | "new-session" | "reopen-session" | "session-messages";
body: Record<string, unknown>;
};
/**
* Posts to a conversation-session API route.
*/
export default async function postSessionApi<T extends { [k: string]: any }>({ path, body }: Params) {
return await fetchApi<Record<string, unknown>, APIResponseObject<T>>(`/api/admin/bots/${path}`, {
method: "POST",
body,
});
}