fix(fleet): the active project is never a lane alias (#913)

The workspace strip (Profile · Chat · Control · Terminal) showed
"skif~d0a14b69" on every page after a parallel run's tab was opened:
the terminal remembered the raw tab as the fleet project. asFleetProject
normalises through baseProjectKey on the route parser, the stored read
and the write, so a stale stored alias heals on read.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
CatoandClaude Opus 5.5 authored and GitHub committed 2026-09-25 05:33:22 -07:00
1 parent f2f6206bcf
commit 46228690c9
2 files changed
+31 -4

No files matched your search

+14 -1
View File
@@ -1,4 +1,4 @@
import { fleetSurfaceHref, projectFromFleetRoute } from "@/lib/fleet-context";
import { asFleetProject, fleetSurfaceHref, projectFromFleetRoute } from "@/lib/fleet-context";
const project = "BiasLens alpha";
if (fleetSurfaceHref("profile", project) !== "/projects?project=BiasLens%20alpha") {
@@ -32,4 +32,17 @@ if (projectFromFleetRoute("/projects", new URLSearchParams("open=123")) !== null
throw new Error("catalog must not masquerade as workspace context");
}
// A parallel run's tab is a lane of a project, never the project: the strip
// showed "skif~d0a14b69" on every page (2026-09-25).
if (projectFromFleetRoute("/terminal", new URLSearchParams("tab=skif~d0a14b69")) !== "skif") {
throw new Error("a lane tab in the URL must read as its project");
}
if (
asFleetProject(" Skif~d0a14b69 ") !== "Skif" ||
asFleetProject("") !== null ||
asFleetProject(null) !== null
) {
throw new Error("asFleetProject must strip the lane and treat blanks as none");
}
console.log("✓ fleet-context tests passed");
+17 -3
View File
@@ -1,3 +1,5 @@
import { baseProjectKey } from "@/lib/run-tab";
export const FLEET_PROJECT_STORAGE_KEY = "loki:active-project";
export const FLEET_PROJECT_EVENT = "loki:project-context";
@@ -53,6 +55,18 @@ export function injectWatchUrls(
};
}
/**
* The fleet project is a PROJECT: the one Profile, Chat, Control and Terminal
* all show. A parallel run's tab (`<project>~<runId8>`, lib/run-tab.ts) is a
* lane of a project, never a project, and remembering it raw put
* "skif~d0a14b69" in the workspace strip on every page (2026-09-25). Every
* read and write goes through this, so a stale stored alias heals on read.
*/
export function asFleetProject(value: string | null | undefined): string | null {
const v = value?.trim();
return v ? baseProjectKey(v) || null : null;
}
export function projectFromFleetRoute(pathname: string, search: URLSearchParams): string | null {
const value =
pathname === "/projects"
@@ -66,13 +80,13 @@ export function projectFromFleetRoute(pathname: string, search: URLSearchParams)
: pathname.startsWith("/activity")
? search.get("project")
: null;
return value?.trim() || null;
return asFleetProject(value);
}
export function readRememberedFleetProject(): string | null {
if (typeof window === "undefined") return null;
try {
return window.localStorage.getItem(FLEET_PROJECT_STORAGE_KEY)?.trim() || null;
return asFleetProject(window.localStorage.getItem(FLEET_PROJECT_STORAGE_KEY));
} catch {
return null;
}
@@ -80,7 +94,7 @@ export function readRememberedFleetProject(): string | null {
export function rememberFleetProject(project: string | null): void {
if (typeof window === "undefined") return;
const value = project?.trim() || null;
const value = asFleetProject(project);
try {
if (value) window.localStorage.setItem(FLEET_PROJECT_STORAGE_KEY, value);
else window.localStorage.removeItem(FLEET_PROJECT_STORAGE_KEY);