List the last visited workspace first in the rail

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-28 19:48:38 +01:00
co-authored by Claude Opus 5.5
parent c1c866876e
commit d352ac924a
17 changed files with 190 additions and 20 deletions
@@ -0,0 +1,27 @@
import { AppData } from "@/src/data/app-data";
import type { CookieOptions } from "./cookies";
type Params = {
workspace_id: number | string;
/**
* From `isSecureRequest`, so plain HTTP over a VPN still keeps it.
*/
secure: boolean;
};
/**
* The cookie that remembers the workspace this browser was last in, for
* `setCookies`: read back by `readLastVisitedWorkspace` in the root, so the
* rail lists that workspace first. It never decides where `/admin/bots`
* lands. `HttpOnly`, since only the server reads it.
*/
export default function lastVisitedWorkspaceCookies({ workspace_id, secure }: Params): CookieOptions[] {
return [
{
name: AppData["LastVisitedWorkspaceCookieName"],
value: String(workspace_id),
secure,
maxAge: AppData["LastVisitedCookieMaxAgeSeconds"],
},
];
}