// Production CSS is part of the behavior under test because row height depends on it. import "../index.css"; import { ORCHESTRATION_WS_METHODS, type MessageId, type OrchestrationReadModel, type ProjectId, type ServerConfig, type ThreadId, type WsWelcomePayload, WS_CHANNELS, WS_METHODS, } from "@t3tools/contracts"; import { RouterProvider, createMemoryHistory } from "@tanstack/react-router"; import { HttpResponse, http, ws } from "msw"; import { setupWorker } from "msw/browser"; import { page } from "vitest/browser"; import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { render } from "vitest-browser-react"; import { useComposerDraftStore } from "../composerDraftStore"; import { getRouter } from "../router"; import { useStore } from "../store"; import { estimateTimelineMessageHeight } from "./timelineHeight"; const THREAD_ID = "thread-browser-test" as ThreadId; const PROJECT_ID = "project-1" as ProjectId; const NOW_ISO = "2026-03-04T12:00:00.000Z"; const BASE_TIME_MS = Date.parse(NOW_ISO); const ATTACHMENT_SVG = ""; interface WsRequestEnvelope { id: string; body: { _tag: string; [key: string]: unknown; }; } interface TestFixture { snapshot: OrchestrationReadModel; serverConfig: ServerConfig; welcome: WsWelcomePayload; } let fixture: TestFixture; const wsRequests: WsRequestEnvelope["body"][] = []; const wsLink = ws.link(/ws(s)?:\/\/.*/); interface ViewportSpec { name: string; width: number; height: number; textTolerancePx: number; attachmentTolerancePx: number; } const DEFAULT_VIEWPORT: ViewportSpec = { name: "desktop", width: 960, height: 1_100, textTolerancePx: 44, attachmentTolerancePx: 56, }; const TEXT_VIEWPORT_MATRIX = [ DEFAULT_VIEWPORT, { name: "tablet", width: 720, height: 1_024, textTolerancePx: 44, attachmentTolerancePx: 56 }, { name: "mobile", width: 430, height: 932, textTolerancePx: 56, attachmentTolerancePx: 56 }, { name: "narrow", width: 320, height: 700, textTolerancePx: 84, attachmentTolerancePx: 56 }, ] as const satisfies readonly ViewportSpec[]; const ATTACHMENT_VIEWPORT_MATRIX = [ DEFAULT_VIEWPORT, { name: "mobile", width: 430, height: 932, textTolerancePx: 56, attachmentTolerancePx: 56 }, { name: "narrow", width: 320, height: 700, textTolerancePx: 84, attachmentTolerancePx: 56 }, ] as const satisfies readonly ViewportSpec[]; interface UserRowMeasurement { measuredRowHeightPx: number; timelineWidthMeasuredPx: number; renderedInVirtualizedRegion: boolean; } interface MountedChatView { cleanup: () => Promise; measureUserRow: (targetMessageId: MessageId) => Promise; setViewport: (viewport: ViewportSpec) => Promise; } function isoAt(offsetSeconds: number): string { return new Date(BASE_TIME_MS + offsetSeconds * 1_000).toISOString(); } function createBaseServerConfig(): ServerConfig { return { cwd: "/repo/project", keybindingsConfigPath: "/repo/project/.t3code-keybindings.json", keybindings: [], issues: [], providers: [ { provider: "codex", status: "ready", available: true, authStatus: "authenticated", checkedAt: NOW_ISO, }, ], availableEditors: [], }; } function createUserMessage(options: { id: MessageId; text: string; offsetSeconds: number; attachments?: Array<{ type: "image"; id: string; name: string; mimeType: string; sizeBytes: number; }>; }) { return { id: options.id, role: "user" as const, text: options.text, ...(options.attachments ? { attachments: options.attachments } : {}), turnId: null, streaming: false, createdAt: isoAt(options.offsetSeconds), updatedAt: isoAt(options.offsetSeconds + 1), }; } function createAssistantMessage(options: { id: MessageId; text: string; offsetSeconds: number }) { return { id: options.id, role: "assistant" as const, text: options.text, turnId: null, streaming: false, createdAt: isoAt(options.offsetSeconds), updatedAt: isoAt(options.offsetSeconds + 1), }; } function createSnapshotForTargetUser(options: { targetMessageId: MessageId; targetText: string; targetAttachmentCount?: number; }): OrchestrationReadModel { const messages: Array = []; for (let index = 0; index < 22; index += 1) { const isTarget = index === 3; const userId = `msg-user-${index}` as MessageId; const assistantId = `msg-assistant-${index}` as MessageId; const attachments = isTarget && (options.targetAttachmentCount ?? 0) > 0 ? Array.from({ length: options.targetAttachmentCount ?? 0 }, (_, attachmentIndex) => ({ type: "image" as const, id: `attachment-${attachmentIndex + 1}`, name: `attachment-${attachmentIndex + 1}.png`, mimeType: "image/png", sizeBytes: 128, })) : undefined; messages.push( createUserMessage({ id: isTarget ? options.targetMessageId : userId, text: isTarget ? options.targetText : `filler user message ${index}`, offsetSeconds: messages.length * 3, ...(attachments ? { attachments } : {}), }), ); messages.push( createAssistantMessage({ id: assistantId, text: `assistant filler ${index}`, offsetSeconds: messages.length * 3, }), ); } return { snapshotSequence: 1, projects: [ { id: PROJECT_ID, title: "Project", workspaceRoot: "/repo/project", defaultModel: "gpt-5", scripts: [], createdAt: NOW_ISO, updatedAt: NOW_ISO, deletedAt: null, }, ], threads: [ { id: THREAD_ID, projectId: PROJECT_ID, title: "Browser test thread", model: "gpt-5", interactionMode: "default", runtimeMode: "full-access", branch: "main", worktreePath: null, latestTurn: null, createdAt: NOW_ISO, updatedAt: NOW_ISO, deletedAt: null, messages, activities: [], proposedPlans: [], checkpoints: [], session: { threadId: THREAD_ID, status: "ready", providerName: "codex", runtimeMode: "full-access", activeTurnId: null, lastError: null, updatedAt: NOW_ISO, }, }, ], updatedAt: NOW_ISO, }; } function buildFixture(snapshot: OrchestrationReadModel): TestFixture { return { snapshot, serverConfig: createBaseServerConfig(), welcome: { cwd: "/repo/project", projectName: "Project", bootstrapProjectId: PROJECT_ID, bootstrapThreadId: THREAD_ID, }, }; } function createDraftOnlySnapshot(): OrchestrationReadModel { const snapshot = createSnapshotForTargetUser({ targetMessageId: "msg-user-draft-target" as MessageId, targetText: "draft thread", }); return { ...snapshot, threads: [], }; } function createSnapshotWithLongProposedPlan(): OrchestrationReadModel { const snapshot = createSnapshotForTargetUser({ targetMessageId: "msg-user-plan-target" as MessageId, targetText: "plan thread", }); const planMarkdown = [ "# Ship plan mode follow-up", "", "- Step 1: capture the thread-open trace", "- Step 2: identify the main-thread bottleneck", "- Step 3: keep collapsed cards cheap", "- Step 4: render the full markdown only on demand", "- Step 5: preserve export and save actions", "- Step 6: add regression coverage", "- Step 7: verify route transitions stay responsive", "- Step 8: confirm no server-side work changed", "- Step 9: confirm short plans still render normally", "- Step 10: confirm long plans stay collapsed by default", "- Step 11: confirm preview text is still useful", "- Step 12: confirm plan follow-up flow still works", "- Step 13: confirm timeline virtualization still behaves", "- Step 14: confirm theme styling still looks correct", "- Step 15: confirm save dialog behavior is unchanged", "- Step 16: confirm download behavior is unchanged", "- Step 17: confirm code fences do not parse until expand", "- Step 18: confirm preview truncation ends cleanly", "- Step 19: confirm markdown links still open in editor after expand", "- Step 20: confirm deep hidden detail only appears after expand", "", "```ts", "export const hiddenPlanImplementationDetail = 'deep hidden detail only after expand';", "```", ].join("\n"); return { ...snapshot, threads: snapshot.threads.map((thread) => thread.id === THREAD_ID ? Object.assign({}, thread, { proposedPlans: [ { id: "plan-browser-test", turnId: null, planMarkdown, createdAt: isoAt(1_000), updatedAt: isoAt(1_001), }, ], updatedAt: isoAt(1_001), }) : thread, ), }; } function resolveWsRpc(tag: string): unknown { if (tag === ORCHESTRATION_WS_METHODS.getSnapshot) { return fixture.snapshot; } if (tag === WS_METHODS.serverGetConfig) { return fixture.serverConfig; } if (tag === WS_METHODS.gitListBranches) { return { isRepo: true, branches: [ { name: "main", current: true, isDefault: true, worktreePath: null, }, ], }; } if (tag === WS_METHODS.gitStatus) { return { branch: "main", hasWorkingTreeChanges: false, workingTree: { files: [], insertions: 0, deletions: 0, }, hasUpstream: true, aheadCount: 0, behindCount: 0, pr: null, }; } if (tag === WS_METHODS.projectsSearchEntries) { return { entries: [], truncated: false, }; } return {}; } const worker = setupWorker( wsLink.addEventListener("connection", ({ client }) => { client.send( JSON.stringify({ type: "push", channel: WS_CHANNELS.serverWelcome, data: fixture.welcome, }), ); client.addEventListener("message", (event) => { const rawData = event.data; if (typeof rawData !== "string") return; let request: WsRequestEnvelope; try { request = JSON.parse(rawData) as WsRequestEnvelope; } catch { return; } const method = request.body?._tag; if (typeof method !== "string") return; wsRequests.push(request.body); client.send( JSON.stringify({ id: request.id, result: resolveWsRpc(method), }), ); }); }), http.get("*/attachments/:attachmentId", () => HttpResponse.text(ATTACHMENT_SVG, { headers: { "Content-Type": "image/svg+xml", }, }), ), http.get("*/api/project-favicon", () => new HttpResponse(null, { status: 204 })), ); async function nextFrame(): Promise { await new Promise((resolve) => { window.requestAnimationFrame(() => resolve()); }); } async function waitForLayout(): Promise { await nextFrame(); await nextFrame(); await nextFrame(); } async function setViewport(viewport: ViewportSpec): Promise { await page.viewport(viewport.width, viewport.height); await waitForLayout(); } async function waitForProductionStyles(): Promise { await vi.waitFor( () => { expect(getComputedStyle(document.documentElement).getPropertyValue("--background").trim()).not.toBe( "", ); expect(getComputedStyle(document.body).marginTop).toBe("0px"); }, { timeout: 4_000, interval: 16, }, ); } async function waitForElement( query: () => T | null, errorMessage: string, ): Promise { let element: T | null = null; await vi.waitFor( () => { element = query(); expect(element, errorMessage).toBeTruthy(); }, { timeout: 8_000, interval: 16, }, ); if (!element) { throw new Error(errorMessage); } return element; } async function waitForComposerEditor(): Promise { return waitForElement( () => document.querySelector('[contenteditable="true"]'), "Unable to find composer editor.", ); } async function waitForInteractionModeButton(expectedLabel: "Chat" | "Plan"): Promise { return waitForElement( () => Array.from(document.querySelectorAll("button")).find( (button) => button.textContent?.trim() === expectedLabel, ) as HTMLButtonElement | null, `Unable to find ${expectedLabel} interaction mode button.`, ); } async function waitForImagesToLoad(scope: ParentNode): Promise { const images = Array.from(scope.querySelectorAll("img")); if (images.length === 0) { return; } await Promise.all( images.map( (image) => new Promise((resolve) => { if (image.complete) { resolve(); return; } image.addEventListener("load", () => resolve(), { once: true }); image.addEventListener("error", () => resolve(), { once: true }); }), ), ); await waitForLayout(); } async function measureUserRow(options: { host: HTMLElement; targetMessageId: MessageId; }): Promise { const { host, targetMessageId } = options; const rowSelector = `[data-message-id="${targetMessageId}"][data-message-role="user"]`; const scrollContainer = await waitForElement( () => host.querySelector("div.overflow-y-auto.overscroll-y-contain"), "Unable to find ChatView message scroll container.", ); let row: HTMLElement | null = null; await vi.waitFor( async () => { scrollContainer.scrollTop = 0; scrollContainer.dispatchEvent(new Event("scroll")); await waitForLayout(); row = host.querySelector(rowSelector); expect(row, "Unable to locate targeted user message row.").toBeTruthy(); }, { timeout: 8_000, interval: 16, }, ); await waitForImagesToLoad(row!); scrollContainer.scrollTop = 0; scrollContainer.dispatchEvent(new Event("scroll")); await nextFrame(); const timelineRoot = row!.closest('[data-timeline-root="true"]') ?? host.querySelector('[data-timeline-root="true"]'); if (!(timelineRoot instanceof HTMLElement)) { throw new Error("Unable to locate timeline root container."); } let timelineWidthMeasuredPx = 0; let measuredRowHeightPx = 0; let renderedInVirtualizedRegion = false; await vi.waitFor( async () => { scrollContainer.scrollTop = 0; scrollContainer.dispatchEvent(new Event("scroll")); await nextFrame(); const measuredRow = host.querySelector(rowSelector); expect(measuredRow, "Unable to measure targeted user row height.").toBeTruthy(); timelineWidthMeasuredPx = timelineRoot.getBoundingClientRect().width; measuredRowHeightPx = measuredRow!.getBoundingClientRect().height; renderedInVirtualizedRegion = measuredRow!.closest("[data-index]") instanceof HTMLElement; expect(timelineWidthMeasuredPx, "Unable to measure timeline width.").toBeGreaterThan(0); expect(measuredRowHeightPx, "Unable to measure targeted user row height.").toBeGreaterThan(0); }, { timeout: 4_000, interval: 16, }, ); return { measuredRowHeightPx, timelineWidthMeasuredPx, renderedInVirtualizedRegion }; } async function mountChatView(options: { viewport: ViewportSpec; snapshot: OrchestrationReadModel; configureFixture?: (fixture: TestFixture) => void; }): Promise { fixture = buildFixture(options.snapshot); options.configureFixture?.(fixture); await setViewport(options.viewport); await waitForProductionStyles(); const host = document.createElement("div"); host.style.position = "fixed"; host.style.inset = "0"; host.style.width = "100vw"; host.style.height = "100vh"; host.style.display = "grid"; host.style.overflow = "hidden"; document.body.append(host); const router = getRouter( createMemoryHistory({ initialEntries: [`/${THREAD_ID}`], }), ); const screen = await render(, { container: host, }); await waitForLayout(); return { cleanup: async () => { await screen.unmount(); host.remove(); }, measureUserRow: async (targetMessageId: MessageId) => measureUserRow({ host, targetMessageId }), setViewport: async (viewport: ViewportSpec) => { await setViewport(viewport); await waitForProductionStyles(); }, }; } async function measureUserRowAtViewport(options: { snapshot: OrchestrationReadModel; targetMessageId: MessageId; viewport: ViewportSpec; }): Promise { const mounted = await mountChatView({ viewport: options.viewport, snapshot: options.snapshot, }); try { return await mounted.measureUserRow(options.targetMessageId); } finally { await mounted.cleanup(); } } describe("ChatView timeline estimator parity (full app)", () => { beforeAll(async () => { fixture = buildFixture( createSnapshotForTargetUser({ targetMessageId: "msg-user-bootstrap" as MessageId, targetText: "bootstrap", }), ); await worker.start({ onUnhandledRequest: "bypass", quiet: true, serviceWorker: { url: "/mockServiceWorker.js", }, }); }); afterAll(async () => { await worker.stop(); }); beforeEach(async () => { await setViewport(DEFAULT_VIEWPORT); localStorage.clear(); document.body.innerHTML = ""; wsRequests.length = 0; useComposerDraftStore.setState({ draftsByThreadId: {}, draftThreadsByThreadId: {}, projectDraftThreadIdByProjectId: {}, }); useStore.setState({ projects: [], threads: [], threadsHydrated: false, }); }); afterEach(() => { document.body.innerHTML = ""; }); it.each(TEXT_VIEWPORT_MATRIX)( "keeps long user message estimate close at the $name viewport", async (viewport) => { const userText = "x".repeat(3_200); const targetMessageId = `msg-user-target-long-${viewport.name}` as MessageId; const mounted = await mountChatView({ viewport, snapshot: createSnapshotForTargetUser({ targetMessageId, targetText: userText, }), }); try { const { measuredRowHeightPx, timelineWidthMeasuredPx, renderedInVirtualizedRegion } = await mounted.measureUserRow(targetMessageId); expect(renderedInVirtualizedRegion).toBe(true); const estimatedHeightPx = estimateTimelineMessageHeight( { role: "user", text: userText, attachments: [] }, { timelineWidthPx: timelineWidthMeasuredPx }, ); expect(Math.abs(measuredRowHeightPx - estimatedHeightPx)).toBeLessThanOrEqual( viewport.textTolerancePx, ); } finally { await mounted.cleanup(); } }, ); it("tracks wrapping parity while resizing an existing ChatView across the viewport matrix", async () => { const userText = "x".repeat(3_200); const targetMessageId = "msg-user-target-resize" as MessageId; const mounted = await mountChatView({ viewport: TEXT_VIEWPORT_MATRIX[0], snapshot: createSnapshotForTargetUser({ targetMessageId, targetText: userText, }), }); try { const measurements: Array = []; for (const viewport of TEXT_VIEWPORT_MATRIX) { await mounted.setViewport(viewport); const measurement = await mounted.measureUserRow(targetMessageId); const estimatedHeightPx = estimateTimelineMessageHeight( { role: "user", text: userText, attachments: [] }, { timelineWidthPx: measurement.timelineWidthMeasuredPx }, ); expect(measurement.renderedInVirtualizedRegion).toBe(true); expect(Math.abs(measurement.measuredRowHeightPx - estimatedHeightPx)).toBeLessThanOrEqual( viewport.textTolerancePx, ); measurements.push({ ...measurement, viewport, estimatedHeightPx }); } expect(new Set(measurements.map((measurement) => Math.round(measurement.timelineWidthMeasuredPx))).size).toBeGreaterThanOrEqual(3); const byMeasuredWidth = measurements.toSorted( (left, right) => left.timelineWidthMeasuredPx - right.timelineWidthMeasuredPx, ); const narrowest = byMeasuredWidth[0]!; const widest = byMeasuredWidth.at(-1)!; expect(narrowest.timelineWidthMeasuredPx).toBeLessThan(widest.timelineWidthMeasuredPx); expect(narrowest.measuredRowHeightPx).toBeGreaterThan(widest.measuredRowHeightPx); expect(narrowest.estimatedHeightPx).toBeGreaterThan(widest.estimatedHeightPx); } finally { await mounted.cleanup(); } }); it("tracks additional rendered wrapping when ChatView width narrows between desktop and mobile viewports", async () => { const userText = "x".repeat(2_400); const targetMessageId = "msg-user-target-wrap" as MessageId; const snapshot = createSnapshotForTargetUser({ targetMessageId, targetText: userText, }); const desktopMeasurement = await measureUserRowAtViewport({ viewport: TEXT_VIEWPORT_MATRIX[0], snapshot, targetMessageId, }); const mobileMeasurement = await measureUserRowAtViewport({ viewport: TEXT_VIEWPORT_MATRIX[2], snapshot, targetMessageId, }); const estimatedDesktopPx = estimateTimelineMessageHeight( { role: "user", text: userText, attachments: [] }, { timelineWidthPx: desktopMeasurement.timelineWidthMeasuredPx }, ); const estimatedMobilePx = estimateTimelineMessageHeight( { role: "user", text: userText, attachments: [] }, { timelineWidthPx: mobileMeasurement.timelineWidthMeasuredPx }, ); const measuredDeltaPx = mobileMeasurement.measuredRowHeightPx - desktopMeasurement.measuredRowHeightPx; const estimatedDeltaPx = estimatedMobilePx - estimatedDesktopPx; expect(measuredDeltaPx).toBeGreaterThan(0); expect(estimatedDeltaPx).toBeGreaterThan(0); const ratio = estimatedDeltaPx / measuredDeltaPx; expect(ratio).toBeGreaterThan(0.65); expect(ratio).toBeLessThan(1.35); }); it.each(ATTACHMENT_VIEWPORT_MATRIX)( "keeps user attachment estimate close at the $name viewport", async (viewport) => { const targetMessageId = `msg-user-target-attachments-${viewport.name}` as MessageId; const userText = "message with image attachments"; const mounted = await mountChatView({ viewport, snapshot: createSnapshotForTargetUser({ targetMessageId, targetText: userText, targetAttachmentCount: 3, }), }); try { const { measuredRowHeightPx, timelineWidthMeasuredPx, renderedInVirtualizedRegion } = await mounted.measureUserRow(targetMessageId); expect(renderedInVirtualizedRegion).toBe(true); const estimatedHeightPx = estimateTimelineMessageHeight( { role: "user", text: userText, attachments: [{ id: "attachment-1" }, { id: "attachment-2" }, { id: "attachment-3" }], }, { timelineWidthPx: timelineWidthMeasuredPx }, ); expect(Math.abs(measuredRowHeightPx - estimatedHeightPx)).toBeLessThanOrEqual( viewport.attachmentTolerancePx, ); } finally { await mounted.cleanup(); } }, ); it("opens the project cwd for draft threads without a worktree path", async () => { useComposerDraftStore.setState({ draftThreadsByThreadId: { [THREAD_ID]: { projectId: PROJECT_ID, createdAt: NOW_ISO, runtimeMode: "full-access", interactionMode: "default", branch: null, worktreePath: null, envMode: "local", }, }, projectDraftThreadIdByProjectId: { [PROJECT_ID]: THREAD_ID, }, }); const mounted = await mountChatView({ viewport: DEFAULT_VIEWPORT, snapshot: createDraftOnlySnapshot(), configureFixture: (nextFixture) => { nextFixture.serverConfig = { ...nextFixture.serverConfig, availableEditors: ["vscode"], }; }, }); try { const openButton = await waitForElement( () => Array.from(document.querySelectorAll("button")).find( (button) => button.textContent?.trim() === "Open", ) as HTMLButtonElement | null, "Unable to find Open button.", ); openButton.click(); await vi.waitFor( () => { const openRequest = wsRequests.find((request) => request._tag === WS_METHODS.shellOpenInEditor); expect(openRequest).toMatchObject({ _tag: WS_METHODS.shellOpenInEditor, cwd: "/repo/project", editor: "vscode", }); }, { timeout: 8_000, interval: 16 }, ); } finally { await mounted.cleanup(); } }); it("toggles plan mode with Shift+Tab only while the composer is focused", async () => { const mounted = await mountChatView({ viewport: DEFAULT_VIEWPORT, snapshot: createSnapshotForTargetUser({ targetMessageId: "msg-user-target-hotkey" as MessageId, targetText: "hotkey target", }), }); try { const initialModeButton = await waitForInteractionModeButton("Chat"); expect(initialModeButton.title).toContain("enter plan mode"); window.dispatchEvent( new KeyboardEvent("keydown", { key: "Tab", shiftKey: true, bubbles: true, cancelable: true, }), ); await waitForLayout(); expect((await waitForInteractionModeButton("Chat")).title).toContain("enter plan mode"); const composerEditor = await waitForComposerEditor(); composerEditor.focus(); composerEditor.dispatchEvent( new KeyboardEvent("keydown", { key: "Tab", shiftKey: true, bubbles: true, cancelable: true, }), ); await vi.waitFor( async () => { expect((await waitForInteractionModeButton("Plan")).title).toContain( "return to normal chat mode", ); }, { timeout: 8_000, interval: 16 }, ); composerEditor.dispatchEvent( new KeyboardEvent("keydown", { key: "Tab", shiftKey: true, bubbles: true, cancelable: true, }), ); await vi.waitFor( async () => { expect((await waitForInteractionModeButton("Chat")).title).toContain("enter plan mode"); }, { timeout: 8_000, interval: 16 }, ); } finally { await mounted.cleanup(); } }); it("keeps long proposed plans lightweight until the user expands them", async () => { const mounted = await mountChatView({ viewport: DEFAULT_VIEWPORT, snapshot: createSnapshotWithLongProposedPlan(), }); try { await waitForElement( () => Array.from(document.querySelectorAll("button")).find( (button) => button.textContent?.trim() === "Expand plan", ) as HTMLButtonElement | null, "Unable to find Expand plan button.", ); expect(document.body.textContent).not.toContain("deep hidden detail only after expand"); const expandButton = await waitForElement( () => Array.from(document.querySelectorAll("button")).find( (button) => button.textContent?.trim() === "Expand plan", ) as HTMLButtonElement | null, "Unable to find Expand plan button.", ); expandButton.click(); await vi.waitFor( () => { expect(document.body.textContent).toContain("deep hidden detail only after expand"); }, { timeout: 8_000, interval: 16 }, ); } finally { await mounted.cleanup(); } }); });