Files
cobble/src/utils/last-visited-bot-cookies.ts
T
tben 63a93a4262
CI / check (push) Canceled after 0s
Keep only the bot cookie for the last visited bot
A workspace conversation is never remembered, so /admin/bots always
reopens the bot's own chat.
2026-10-22 13:39:36 +01:00

29 lines
905 B
TypeScript

import { AppData } from "@/src/data/app-data";
import type { CookieOptions } from "./cookies";
type Params = {
bot_id: number | string;
/**
* From `isSecureRequest`, so plain HTTP over a VPN still keeps it.
*/
secure: boolean;
};
/**
* The cookie that remembers the bot this browser is in, for `setCookies`:
* read back by `readLastVisitedBot` on the bots' landing page. `HttpOnly`,
* since only the server reads it, and it holds nothing but an id. A
* conversation inside a workspace is never remembered, so the landing page
* always reopens the bot's own chat.
*/
export default function lastVisitedBotCookies({ bot_id, secure }: Params): CookieOptions[] {
return [
{
name: AppData["LastVisitedBotCookieName"],
value: String(bot_id),
secure,
maxAge: AppData["LastVisitedCookieMaxAgeSeconds"],
},
];
}