Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
perf(web): parallelize room landing loader and trim room-chat closure
shoudi zhengb997585ea1b9
diff --git a/apps/web/src/app/router.test.tsx b/apps/web/src/app/router.test.tsxindex fbabe055..7657d87f 100644--- a/apps/web/src/app/router.test.tsx+++ b/apps/web/src/app/router.test.tsx@@ -9,7 +9,11 @@ import { afterEach, describe, expect, it, vi } from "vitest";import { createTestTeamHubRuntime } from "@/test/teamhub-test-runtime";import { teamHubErrorResponse } from "@/test/teamhub-test-server";-import { teamHubSessionQueryKey } from "@/features/rooms/room-queries";+import {+ teamHubIdentityQueryKey,+ teamHubSessionQueryKey,+ teamHubTenantQueryKey,+} from "@/features/rooms/room-queries";import { createAppRoutes } from "./router";@@ -155,6 +159,181 @@ describe("Web app route contract", () => {"/t/tenant-a/settings/models?computer=comp-1",);});++ it("starts /v0/session and /v0/tenants concurrently and backfills identity + tenant caches", async () => {+ const runtime = createTestTeamHubRuntime();+ let sessionInFlight = false;+ let tenantsInFlight = false;+ let bothInFlight = false;+ let releaseSession!: () => void;+ let releaseTenants!: () => void;+ const sessionGate = new Promise<void>((resolve) => {+ releaseSession = resolve;+ });+ const tenantsGate = new Promise<void>((resolve) => {+ releaseTenants = resolve;+ });+ runtime.server.on("GET", "/v0/session", async () => {+ sessionInFlight = true;+ if (tenantsInFlight) bothInFlight = true;+ await sessionGate;+ return {+ account_id: runtime.seed.identity.account.id,+ created_at: "2026-10-15T00:00:00Z",+ expires_at: "2026-10-16T00:00:00Z",+ id: "session-test",+ identity: runtime.seed.identity,+ };+ });+ runtime.server.on("GET", "/v0/tenants", async () => {+ tenantsInFlight = true;+ if (sessionInFlight) bothInFlight = true;+ await tenantsGate;+ return { items: [runtime.seed.tenant] };+ });++ const queryClient = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ const routes = createAppRoutes(queryClient, runtime);+ const indexLoader = routes.find((route) => route.path === "/")!+ .loader as LoaderFunction;+ const pendingRedirect = Promise.resolve(+ indexLoader({+ request: new Request("http://localhost/"),+ url: new URL("http://localhost/"),+ pattern: "/",+ params: {},+ context: new RouterContextProvider(),+ }),+ ).catch((thrown) => thrown);++ await vi.waitFor(() => expect(bothInFlight).toBe(true));+ releaseSession();+ releaseTenants();++ const thrown = await pendingRedirect;+ expect(thrown).toBeInstanceOf(Response);+ expect((thrown as Response).headers.get("Location")).toBe(+ `/t/${runtime.seed.tenant.id}/rooms/room-another-me/chat`,+ );+ expect(queryClient.getQueryData(teamHubIdentityQueryKey)).toEqual(+ runtime.seed.identity,+ );+ expect(+ queryClient.getQueryData(teamHubTenantQueryKey(runtime.seed.tenant.id)),+ ).toEqual(runtime.seed.tenant);++ // Entering /t/:tenantId uses the backfilled caches with 0 /v0/me or /v0/tenants/:id calls.+ const tenantLoader = routes.find((route) => route.path === "/t/:tenantId")!+ .loader as LoaderFunction;+ await tenantLoader({+ request: new Request(`http://localhost/t/${runtime.seed.tenant.id}`),+ url: new URL(`http://localhost/t/${runtime.seed.tenant.id}`),+ pattern: "/t/:tenantId",+ params: { tenantId: runtime.seed.tenant.id },+ context: new RouterContextProvider(),+ });+ expect(runtime.server.requestsTo("GET", "/v0/me")).toHaveLength(0);+ expect(+ runtime.server.requestsTo("GET", "/v0/tenants/{tenantId}"),+ ).toHaveLength(0);+ queryClient.clear();+ });++ it("redirects to /login when session returns 401 even if tenants rejected first with 500", async () => {+ const runtime = createTestTeamHubRuntime();+ let releaseSession!: () => void;+ const sessionGate = new Promise<void>((resolve) => {+ releaseSession = resolve;+ });+ runtime.server.on("GET", "/v0/tenants", () =>+ teamHubErrorResponse(500, "INTERNAL_ERROR", "Tenants failed"),+ );+ runtime.server.on("GET", "/v0/session", async () => {+ await sessionGate;+ return teamHubErrorResponse(401, "UNAUTHENTICATED", "Sign in required");+ });++ const queryClient = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ const indexLoader = createAppRoutes(queryClient, runtime).find(+ (route) => route.path === "/",+ )!.loader as LoaderFunction;+ const resultPromise = Promise.resolve(+ indexLoader({+ request: new Request("http://localhost/"),+ url: new URL("http://localhost/"),+ pattern: "/",+ params: {},+ context: new RouterContextProvider(),+ }),+ ).catch((thrown) => thrown);++ await vi.waitFor(() =>+ expect(runtime.server.requestsTo("GET", "/v0/tenants")).toHaveLength(1),+ );+ releaseSession();++ const thrown = await resultPromise;+ expect(thrown).toBeInstanceOf(Response);+ expect((thrown as Response).headers.get("Location")).toBe("/login");+ queryClient.clear();+ });++ it("preserves 0-Space error and 1-Space + 0-Room redirect branches", async () => {+ const emptySpaceRuntime = createTestTeamHubRuntime();+ emptySpaceRuntime.server.on("GET", "/v0/tenants", () => ({ items: [] }));+ const queryClient = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ const emptySpaceLoader = createAppRoutes(+ queryClient,+ emptySpaceRuntime,+ ).find((route) => route.path === "/")!.loader as LoaderFunction;++ await expect(+ emptySpaceLoader({+ request: new Request("http://localhost/"),+ url: new URL("http://localhost/"),+ pattern: "/",+ params: {},+ context: new RouterContextProvider(),+ }),+ ).rejects.toThrow("This Account has no Space.");++ const emptyRoomRuntime = createTestTeamHubRuntime();+ emptyRoomRuntime.server.on("GET", "/v0/tenants/{tenantId}/rooms", () => ({+ items: [],+ page: { has_more: false },+ }));+ const emptyRoomQueryClient = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ const emptyRoomLoader = createAppRoutes(+ emptyRoomQueryClient,+ emptyRoomRuntime,+ ).find((route) => route.path === "/")!.loader as LoaderFunction;+ let thrown: unknown;+ try {+ await emptyRoomLoader({+ request: new Request("http://localhost/"),+ url: new URL("http://localhost/"),+ pattern: "/",+ params: {},+ context: new RouterContextProvider(),+ });+ } catch (error) {+ thrown = error;+ }+ expect(thrown).toBeInstanceOf(Response);+ expect((thrown as Response).headers.get("Location")).toBe(+ `/t/${emptyRoomRuntime.seed.tenant.id}/rooms`,+ );+ emptyRoomQueryClient.clear();+ queryClient.clear();+ });});function routePaths() {diff --git a/apps/web/src/app/router.tsx b/apps/web/src/app/router.tsxindex f63fa5b9..c2711cee 100644--- a/apps/web/src/app/router.tsx+++ b/apps/web/src/app/router.tsx@@ -1,6 +1,6 @@/* oxlint-disable react-doctor/only-export-components -- Route factories and route surfaces share one app-owned interface. */import type { QueryClient } from "@tanstack/react-query";-import { lazy, Suspense, useEffect } from "react";+import { Suspense, useEffect } from "react";import {redirect,type RouteObject,@@ -34,7 +34,11 @@ import {} from "@/features/rooms/room-queries";import { requireRoomRouteParam } from "@/features/rooms/room-route-params";import { RoomShell } from "@/features/rooms/room-shell";-import { RoomSurface } from "@/features/rooms/room-surface";+import {+ LazyRoomChat,+ preloadRoomChat,+ RoomSurface,+} from "@/features/rooms/room-surface";import { routeLayoutKey } from "@/features/rooms/route-layout-key";import { RoomChatLoading } from "@/features/rooms/route-loading-surface";import {@@ -66,22 +70,54 @@ export function createAppRoutes(HydrateFallback: InitialAppLoading,loader: withAuthenticationDeadline(async ({ request }) => {try {- await queryClient.ensureQueryData(teamHubSessionQueryOptions(client));- const tenants = await queryClient.ensureQueryData(- teamHubTenantsQueryOptions(client),- );- const tenant = tenants.items[0];+ const [sessionResult, tenantsResult] = await Promise.allSettled([+ queryClient.fetchQuery(teamHubSessionQueryOptions(client)),+ queryClient.fetchQuery(teamHubTenantsQueryOptions(client)),+ ]);++ // Inspect session before tenants so a 401 always redirects to /login+ // even when a parallel tenants request failed first with a 5xx/network error.+ if (sessionResult.status === "rejected") {+ request.signal.throwIfAborted();+ redirectAuthenticationError(sessionResult.reason, queryClient);+ throw sessionResult.reason;+ }+ if (tenantsResult.status === "rejected") {+ request.signal.throwIfAborted();+ redirectAuthenticationError(tenantsResult.reason, queryClient);+ throw tenantsResult.reason;+ }++ const session = sessionResult.value;+ const tenants = tenantsResult.value;+ const targetTenant = tenants.items[0];- if (!tenant) {+ if (!targetTenant) {throw new Error("This Account has no Space.");}- const roomId = await landingRoomId(queryClient, client, tenant.id);+ if (!request.signal.aborted) {+ queryClient.setQueryData(+ teamHubIdentityQueryOptions(client).queryKey,+ session.identity,+ );+ queryClient.setQueryData(+ teamHubTenantQueryOptions(client, targetTenant.id).queryKey,+ targetTenant,+ );+ }++ void preloadRoomChat();+ const roomId = await landingRoomId(+ queryClient,+ client,+ targetTenant.id,+ );throw redirect(roomId- ? `/t/${tenant.id}/rooms/${roomId}/chat`- : `/t/${tenant.id}/rooms`,+ ? `/t/${targetTenant.id}/rooms/${roomId}/chat`+ : `/t/${targetTenant.id}/rooms`,);} catch (error) {request.signal.throwIfAborted();@@ -169,6 +205,7 @@ export function createAppRoutes(ErrorBoundary: PanelRouteErrorSurface,loader: withAuthenticationDeadline(async ({ params, request }) => {const tenantId = requireRoomRouteParam(params.tenantId, "Tenant");+ void preloadRoomChat();const roomId = await landingRoomId(queryClient, client, tenantId);if (roomId) {@@ -188,6 +225,7 @@ export function createAppRoutes(loader: ({ params }) => {const tenantId = requireRoomRouteParam(params.tenantId, "Tenant");const roomId = requireRoomRouteParam(params.roomId, "Room");+ void preloadRoomChat();// Direct-room composers need this directory. Start it alongside// the authoritative Room requests without making it a route gate.void queryClient.prefetchQuery(@@ -385,10 +423,6 @@ async function loadMeetingPage() {return { Component: MeetingPage };}-const LazyRoomChat = lazy(async () => ({- default: (await import("@/features/rooms/chat/room-chat")).RoomChat,-}));-interface RoomBootstrapData {initialRoomSeq: number;}diff --git a/apps/web/src/app/teamhub-router.test.tsx b/apps/web/src/app/teamhub-router.test.tsxindex 12c06818..b3e8c314 100644--- a/apps/web/src/app/teamhub-router.test.tsx+++ b/apps/web/src/app/teamhub-router.test.tsx@@ -18,7 +18,10 @@ import {import { createAppRoutes } from "./router";-const routeFixture = vi.hoisted(() => ({ chatError: null as Error | null }));+const routeFixture = vi.hoisted(() => ({+ chatError: null as Error | null,+ preloadRoomChat: vi.fn(() => Promise.resolve()),+}));vi.mock("@/features/auth/teamhub-login-page", () => ({TeamHubLoginPage: () => <h1>TeamHub sign in</h1>,@@ -38,9 +41,16 @@ vi.mock("@/features/rooms/room-shell", () => ({</div>),}));-vi.mock("@/features/rooms/room-surface", () => ({- RoomSurface: () => <Outlet />,-}));+vi.mock("@/features/rooms/room-surface", async () => {+ const { lazy } = await import("react");+ return {+ LazyRoomChat: lazy(async () => ({+ default: (await import("@/features/rooms/chat/room-chat")).RoomChat,+ })),+ preloadRoomChat: routeFixture.preloadRoomChat,+ RoomSurface: () => <Outlet />,+ };+});vi.mock("@/features/rooms/chat/room-chat", () => ({RoomChat: () => {if (routeFixture.chatError) throw routeFixture.chatError;@@ -117,6 +127,7 @@ describe("TeamHub routes", () => {beforeEach(() => {routeFixture.chatError = null;+ routeFixture.preloadRoomChat.mockClear();});it("keeps the Composio OAuth completion route public", async () => {@@ -601,6 +612,30 @@ describe("TeamHub routes", () => {).toBeVisible();expect(screen.getByRole("button", { name: "Open Messages" })).toBeVisible();});++ it("preloads the Room chat chunk from /, /t/:tenantId/rooms, and /t/:tenantId/rooms/:roomId loaders", async () => {+ const runtime = createTestTeamHubRuntime();+ const queryClient = testQueryClient();+ const router = createMemoryRouter(createAppRoutes(queryClient, runtime), {+ initialEntries: ["/"],+ });++ renderApp(queryClient, runtime, router);+ expect(+ await screen.findByRole("heading", { name: "Fixture Room Chat" }),+ ).toBeVisible();+ // Both `/` and `/t/:tenantId/rooms/:roomId` loaders trigger preloadRoomChat.+ expect(routeFixture.preloadRoomChat).toHaveBeenCalledTimes(2);++ routeFixture.preloadRoomChat.mockClear();+ await router.navigate(`/t/${runtime.seed.tenant.id}/rooms`);+ await waitFor(() =>+ expect(routeFixture.preloadRoomChat).toHaveBeenCalled(),+ );++ router.dispose();+ queryClient.clear();+ });});function renderApp(diff --git a/apps/web/src/features/rooms/agent-templates/create-agent-from-template-dialog.tsx b/apps/web/src/features/rooms/agent-templates/create-agent-from-template-dialog.tsxindex d22d9e87..74590b7d 100644--- a/apps/web/src/features/rooms/agent-templates/create-agent-from-template-dialog.tsx+++ b/apps/web/src/features/rooms/agent-templates/create-agent-from-template-dialog.tsx@@ -32,7 +32,7 @@ import {storeAgentAvatarKey,} from "../members/agent-avatar";import { AgentPlacementFields } from "../members/agent-placement-fields";-import { loadAllManifestPages } from "../members/agent-resource-catalog";+import { loadAllManifestPages } from "../members/manifest-pages";import {reasoningEffortLabel,useAgentModelSelection,diff --git a/apps/web/src/features/rooms/chat/background-tasks-indicator.tsx b/apps/web/src/features/rooms/chat/background-tasks-indicator.tsxindex 16a86689..bbad7866 100644--- a/apps/web/src/features/rooms/chat/background-tasks-indicator.tsx+++ b/apps/web/src/features/rooms/chat/background-tasks-indicator.tsx@@ -1,17 +1,22 @@import { ArrowUp01Icon } from "@hugeicons/core-free-icons";-import { useEffect, useId, useRef, useState } from "react";+import { lazy, Suspense, useEffect, useId, useRef, useState } from "react";import { Icon } from "@/components/ui/icon";import { cn } from "@/lib/cn";import type { TeamHubClient } from "@/features/teamhub/teamhub-client";import type { TeamHubRoomBackgroundTask } from "@/features/teamhub/teamhub-types";-import { TaskConversationDialog } from "../task-sidebar/adapters/task-conversation-dialog";import { CancelTaskButton } from "./cancel-task-button";import {useCancelRoomBackgroundTask,useRoomBackgroundTasks,} from "./use-room-background-tasks";+const TaskConversationDialog = lazy(() =>+ import("../task-sidebar/adapters/task-conversation-dialog").then((m) => ({+ default: m.TaskConversationDialog,+ })),+);+/*** One floating line above the composer while this Room's Meta has background* Tasks running. It opens a short list of what each one is doing, where@@ -43,13 +48,15 @@ export function BackgroundTasksIndicator({</div>) : null}{opened ? (- <TaskConversationDialog- onClose={() => setOpened(undefined)}- originRoomId={roomId}- taskId={opened.id}- tenantId={tenantId}- title={opened.title}- />+ <Suspense fallback={null}>+ <TaskConversationDialog+ onClose={() => setOpened(undefined)}+ originRoomId={roomId}+ taskId={opened.id}+ tenantId={tenantId}+ title={opened.title}+ />+ </Suspense>) : null}</>);diff --git a/apps/web/src/features/rooms/chat/room-chat-closure.build.test.ts b/apps/web/src/features/rooms/chat/room-chat-closure.build.test.tsnew file mode 100644index 00000000..b5f14a66--- /dev/null+++ b/apps/web/src/features/rooms/chat/room-chat-closure.build.test.ts@@ -0,0 +1,76 @@+// @vitest-environment node++import { fileURLToPath } from "node:url";+import { build } from "vite";+import { describe, expect, it, vi } from "vitest";++import viteConfig from "../../../../vite.config";++vi.mock("vite", async (importOriginal) => ({+ ...(await importOriginal<typeof import("vite")>()),+ loadEnv: vi.fn(() => ({})),+}));++describe("room-chat static import closure", () => {+ it("excludes ajv and @mantine/core from the room-chat static closure", async () => {+ const root = fileURLToPath(new URL("../../../..", import.meta.url));+ const roomChatEntry = fileURLToPath(+ new URL("./room-chat.tsx", import.meta.url),+ );+ const config = viteConfig({ command: "build", mode: "production" });+ const result = await build({+ ...config,+ configFile: false,+ root,+ logLevel: "silent",+ build: {+ ...config.build,+ write: false,+ minify: false,+ rolldownOptions: {+ input: roomChatEntry,+ },+ },+ });+ if (!("output" in result)) {+ throw new Error("Expected a single Rollup/Rolldown build output");+ }++ const chunksByFile = new Map(+ result.output+ .filter((item) => item.type === "chunk")+ .map((chunk) => [chunk.fileName, chunk]),+ );+ const entryChunk = [...chunksByFile.values()].find(+ (chunk) => chunk.isEntry,+ );+ expect(entryChunk).toBeDefined();++ // Walk only static imports (chunk.imports), never chunk.dynamicImports.+ const visited = new Set<string>();+ const queue = [entryChunk!.fileName];+ const staticModuleIds: string[] = [];++ while (queue.length > 0) {+ const fileName = queue.shift()!;+ if (visited.has(fileName)) continue;+ visited.add(fileName);+ const chunk = chunksByFile.get(fileName);+ if (!chunk) continue;+ staticModuleIds.push(...Object.keys(chunk.modules));+ for (const imported of chunk.imports) {+ if (!visited.has(imported)) {+ queue.push(imported);+ }+ }+ }++ const forbidden = staticModuleIds.filter(+ (id) =>+ id.includes("/node_modules/ajv/") ||+ id.includes("/node_modules/ajv-draft-04/") ||+ id.includes("/node_modules/@mantine/core/"),+ );+ expect(forbidden).toEqual([]);+ });+});diff --git a/apps/web/src/features/rooms/chat/room-chat-impl.tsx b/apps/web/src/features/rooms/chat/room-chat-impl.tsxindex 8ccb00f0..6cb60a9f 100644--- a/apps/web/src/features/rooms/chat/room-chat-impl.tsx+++ b/apps/web/src/features/rooms/chat/room-chat-impl.tsx@@ -1,3 +1,5 @@+import { useEffect, useRef } from "react";+import { FileDropTarget } from "@/components/ui/file-drop-target";import { MessageForwardDialog } from "./message-forward-dialog";@@ -18,6 +20,14 @@ export function RoomChatImpl() {const actions = useRoomChatTimelineActions(data, state);const { client, forwardMessage, roomId, setForwardMessage, tenantId } = data;const { currentActor, interactions, onboarding, timeline } = state;+ const markedRoomIdRef = useRef<string | null>(null);+ useEffect(() => {+ if (markedRoomIdRef.current === roomId) return;+ markedRoomIdRef.current = roomId;+ if (typeof performance?.mark === "function") {+ performance.mark("room.chat_ready");+ }+ }, [roomId]);return (<div className="room-chat-layout flex min-h-0 flex-1">{onboarding.introPlaying && onboarding.agent ? (diff --git a/apps/web/src/features/rooms/chat/room-chat.test.tsx b/apps/web/src/features/rooms/chat/room-chat.test.tsxindex e0f07e3c..c41e692a 100644--- a/apps/web/src/features/rooms/chat/room-chat.test.tsx+++ b/apps/web/src/features/rooms/chat/room-chat.test.tsx@@ -691,4 +691,27 @@ describe("Room Chat replied Run", () => {expect(screen.queryByText("Queued")).not.toBeInTheDocument();},);++ it.each([+ { empty: false, label: "non-empty" },+ { empty: true, label: "empty" },+ ])("records room.chat_ready on mount for $label Rooms", async ({ empty }) => {+ const markSpy = vi.spyOn(performance, "mark");+ const runtime = createTestTeamHubRuntime();+ if (empty) {+ runtime.server.on("GET", "/v0/rooms/{roomId}/messages", () => ({+ items: [],+ page: { has_more: false },+ snapshot_room_seq: 0,+ }));+ }+ const queryClient = await loadedRoomChatQueryClient(runtime);+ await act(async () => {+ await renderRoomChat(runtime, queryClient);+ });+ await waitFor(() =>+ expect(markSpy).toHaveBeenCalledWith("room.chat_ready"),+ );+ markSpy.mockRestore();+ });});diff --git a/apps/web/src/features/rooms/chat/use-room-chat-data.ts b/apps/web/src/features/rooms/chat/use-room-chat-data.tsindex cad6c549..1287ac61 100644--- a/apps/web/src/features/rooms/chat/use-room-chat-data.ts+++ b/apps/web/src/features/rooms/chat/use-room-chat-data.ts@@ -7,7 +7,7 @@ import {import { useEffect, useState } from "react";import { useNavigate, useParams } from "react-router";-import { loadAllManifestPages } from "@/features/rooms/members/agent-resource-catalog";+import { loadAllManifestPages } from "../members/manifest-pages";import { teamHubData } from "@/features/teamhub/teamhub-api";import { useTeamHubRuntime } from "@/features/teamhub/teamhub-runtime";import type {diff --git a/apps/web/src/features/rooms/members/agent-resource-catalog.test.ts b/apps/web/src/features/rooms/members/agent-resource-catalog.test.tsindex a165112b..319a6e37 100644--- a/apps/web/src/features/rooms/members/agent-resource-catalog.test.ts+++ b/apps/web/src/features/rooms/members/agent-resource-catalog.test.ts@@ -1,9 +1,7 @@import { describe, expect, it, vi } from "vitest";-import {- acceptsEmptySkillConfig,- loadAllManifestPages,-} from "./agent-resource-catalog";+import { acceptsEmptySkillConfig } from "./agent-resource-catalog";+import { loadAllManifestPages } from "./manifest-pages";describe("Agent resource catalog", () => {it("uses JSON Schema evaluation to decide whether empty Skill config is valid", () => {diff --git a/apps/web/src/features/rooms/members/agent-resource-catalog.ts b/apps/web/src/features/rooms/members/agent-resource-catalog.tsindex 0fee9e0f..ef61ba97 100644--- a/apps/web/src/features/rooms/members/agent-resource-catalog.ts+++ b/apps/web/src/features/rooms/members/agent-resource-catalog.ts@@ -6,11 +6,6 @@ import AjvDraft04 from "ajv-draft-04";import type { TeamHubSkillManifest } from "@/features/teamhub/teamhub-types";-interface ManifestPage<T> {- items: T[];- page: { has_more: boolean; next_cursor?: string };-}-const draft7 = new Ajv({allErrors: true,strict: false,@@ -89,29 +84,3 @@ function selectSchemaDialect(dialect: unknown) {return undefined;}}--export async function loadAllManifestPages<T>(- loadPage: (page: {- cursor?: string;- limit: number;- }) => Promise<ManifestPage<T>>,-) {- const items: T[] = [];- const seenCursors = new Set<string>();- let cursor: string | undefined;-- do {- const current = await loadPage({ cursor, limit: 100 });- items.push(...current.items);- if (!current.page.has_more) return items;-- const nextCursor = current.page.next_cursor;- if (!nextCursor || seenCursors.has(nextCursor)) {- throw new Error("TeamHub returned an invalid catalog cursor.");- }- seenCursors.add(nextCursor);- cursor = nextCursor;- } while (cursor);-- return items;-}diff --git a/apps/web/src/features/rooms/members/manifest-pages.ts b/apps/web/src/features/rooms/members/manifest-pages.tsnew file mode 100644index 00000000..306bdeec--- /dev/null+++ b/apps/web/src/features/rooms/members/manifest-pages.ts@@ -0,0 +1,31 @@+export interface ManifestPage<T> {+ items: T[];+ page: { has_more: boolean; next_cursor?: string };+}++/** Collects every cursor page from a TeamHub manifest list endpoint. */+export async function loadAllManifestPages<T>(+ loadPage: (page: {+ cursor?: string;+ limit: number;+ }) => Promise<ManifestPage<T>>,+): Promise<T[]> {+ const items: T[] = [];+ const seenCursors = new Set<string>();+ let cursor: string | undefined;++ do {+ const current = await loadPage({ cursor, limit: 100 });+ items.push(...current.items);+ if (!current.page.has_more) return items;++ const nextCursor = current.page.next_cursor;+ if (!nextCursor || seenCursors.has(nextCursor)) {+ throw new Error("TeamHub returned an invalid catalog cursor.");+ }+ seenCursors.add(nextCursor);+ cursor = nextCursor;+ } while (cursor);++ return items;+}diff --git a/apps/web/src/features/rooms/room-shell.test.tsx b/apps/web/src/features/rooms/room-shell.test.tsxindex c457d9cb..089295bc 100644--- a/apps/web/src/features/rooms/room-shell.test.tsx+++ b/apps/web/src/features/rooms/room-shell.test.tsx@@ -708,6 +708,14 @@ describe("Room shell Tenant transition", () => {await act(async () => releaseProfile());await waitFor(() => expect(router.state.navigation.state).toBe("idle"));});++ it("records room.shell_visible on first shell commit", async () => {+ const markSpy = vi.spyOn(performance, "mark");+ await renderAccountShell({+ initialEntry: "/t/tenant-northstar/rooms/room-all/chat",+ });+ expect(markSpy).toHaveBeenCalledWith("room.shell_visible");+ });});function VoiceTargetProbe() {diff --git a/apps/web/src/features/rooms/room-shell.tsx b/apps/web/src/features/rooms/room-shell.tsxindex 50851491..2cdbc679 100644--- a/apps/web/src/features/rooms/room-shell.tsx+++ b/apps/web/src/features/rooms/room-shell.tsx@@ -141,6 +141,15 @@ function RoomShellReady({open: openRoom,});+ const shellMarked = useRef(false);+ useEffect(() => {+ if (shellMarked.current) return;+ shellMarked.current = true;+ if (typeof performance?.mark === "function") {+ performance.mark("room.shell_visible");+ }+ }, []);+useEffect(() => {document.title = `${spaceOwnerName}'s space`;}, [spaceOwnerName]);diff --git a/apps/web/src/features/rooms/room-surface.tsx b/apps/web/src/features/rooms/room-surface.tsxindex 0fb0769f..f65c9ada 100644--- a/apps/web/src/features/rooms/room-surface.tsx+++ b/apps/web/src/features/rooms/room-surface.tsx@@ -128,6 +128,19 @@ const ActorProfilePanel = lazy(async () => ({default: (await import("./members/actor-profile")).ActorProfilePanel,}));+function loadRoomChatModule() {+ return import("./chat/room-chat");+}++/** Preloads the Room chat chunk without surfacing rejections to route loaders. */+export function preloadRoomChat(): Promise<unknown> {+ return loadRoomChatModule().catch(() => {});+}++export const LazyRoomChat = lazy(async () => ({+ default: (await loadRoomChatModule()).RoomChat,+}));+const EMPTY_ACTORS: TeamHubActor[] = [];const EMPTY_TENANT_AGENTS: TeamHubTenantAgent[] = [];const EMPTY_AVAILABILITY: TeamHubTenantAgentAvailabilitySnapshot[] = [];