feat(frontend): open a live session straight to its pending gate
Opening an in-progress session that has a live Pi runtime now reconnects to its pending gate instead of the empty landing screen that read as "stopped". Cold/completed sessions keep the read-only documents panel with its explicit Resume, so a mere click never spawns a runtime. Backend GET /sessions now reports a per-session `active` flag (live runtime bound) to drive this. Also: - "New session" now closes any open session detail panel (left box). - The model-activity separator can be dragged to a full 50/50 split (was capped at 576px); central-min still guards narrow viewports. Test fixes uncovered along the way: - Node 25 ships an experimental global localStorage that shadows jsdom's and lacks clear(), failing every jsdom test at setup; install a spec-compliant in-memory Storage (feature-detected, inert on CI/LTS). - Fix 4 pre-existing session-mgmt tests that used an ambiguous getByText for a session shown in both nav and header; target the nav item by test id. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,26 @@
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { server } from "./msw";
|
||||
|
||||
// Node 25 ships an experimental global `localStorage` that shadows jsdom's Storage and
|
||||
// lacks spec methods like clear(), so tests calling localStorage.clear()/setItem() throw.
|
||||
// Swap in a spec-compliant in-memory Storage. Feature-detected: inert on runtimes whose
|
||||
// localStorage already implements clear() (e.g. CI on an LTS Node with working jsdom).
|
||||
if (typeof localStorage === "undefined" || typeof localStorage.clear !== "function") {
|
||||
const store = new Map<string, string>();
|
||||
const storage: Storage = {
|
||||
get length() { return store.size; },
|
||||
clear() { store.clear(); },
|
||||
getItem(key: string) { return store.has(key) ? store.get(key)! : null; },
|
||||
key(index: number) { return Array.from(store.keys())[index] ?? null; },
|
||||
removeItem(key: string) { store.delete(key); },
|
||||
setItem(key: string, value: string) { store.set(String(key), String(value)); },
|
||||
};
|
||||
Object.defineProperty(globalThis, "localStorage", { value: storage, configurable: true, writable: true });
|
||||
if (typeof window !== "undefined") {
|
||||
Object.defineProperty(window, "localStorage", { value: storage, configurable: true, writable: true });
|
||||
}
|
||||
}
|
||||
|
||||
// jsdom lacks matchMedia; sonner's <Toaster> (mounted in AppShell) needs it.
|
||||
if (!window.matchMedia) {
|
||||
window.matchMedia = (query: string) =>
|
||||
|
||||
Reference in New Issue
Block a user