Keep only the bot cookie for the last visited bot
CI / check (push) Canceled after 0s

A workspace conversation is never remembered, so /admin/bots always
reopens the bot's own chat.
This commit is contained in:
2026-10-22 13:39:36 +01:00
parent 133e6b87c9
commit 63a93a4262
13 changed files with 48 additions and 147 deletions
+7 -20
View File
@@ -4,26 +4,19 @@ import type { CookieOptions } from "./cookies";
type Params = {
bot_id: number | string;
/**
* Null or undefined: the bot's own chat.
*/
workspace_id?: number | string | null;
/**
* From `isSecureRequest`, so plain HTTP over a VPN still keeps them.
* From `isSecureRequest`, so plain HTTP over a VPN still keeps it.
*/
secure: boolean;
};
/**
* The cookies that remember the conversation this browser is in, for
* `setCookies`: read back by `readLastVisitedBot` on the bots' landing page.
* `HttpOnly`, since only the server reads them, and they hold nothing but
* two ids.
* 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,
workspace_id,
secure,
}: Params): CookieOptions[] {
export default function lastVisitedBotCookies({ bot_id, secure }: Params): CookieOptions[] {
return [
{
name: AppData["LastVisitedBotCookieName"],
@@ -31,11 +24,5 @@ export default function lastVisitedBotCookies({
secure,
maxAge: AppData["LastVisitedCookieMaxAgeSeconds"],
},
// {
// name: AppData["LastVisitedWorkspaceCookieName"],
// value: workspace_id ? String(workspace_id) : "",
// secure,
// maxAge: AppData["LastVisitedCookieMaxAgeSeconds"],
// },
];
}