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
@@ -6,30 +6,20 @@ type Params = {
req: Request;
res: Response;
bot_id: number | string;
/**
* Null or undefined: the bot's own chat.
*/
workspace_id?: number | string | null;
};
/**
* The page's response with the last-visited cookies set, so `/admin/bots`
* opens this conversation again next time. Called from the conversation
* The page's response with the last-visited cookie set, so `/admin/bots`
* opens this bot's own chat again next time. Called from the conversation
* pages' `res_transform`, which is why it takes and returns the response.
*/
export default function withLastVisitedBotCookies({
req,
res,
bot_id,
workspace_id,
}: Params): Response {
export default function withLastVisitedBotCookies({ req, res, bot_id }: Params): Response {
const new_res = res.clone();
setCookies(
new_res,
lastVisitedBotCookies({
bot_id,
workspace_id,
secure: isSecureRequest({ req }),
}),
);