diff --git a/apps/desktop/scripts/electron-launcher.mjs b/apps/desktop/scripts/electron-launcher.mjs index 69df02fb80..cfe110f0e3 100644 --- a/apps/desktop/scripts/electron-launcher.mjs +++ b/apps/desktop/scripts/electron-launcher.mjs @@ -100,25 +100,41 @@ function shellSingleQuote(value) { return `'${value.replaceAll("'", "'\\''")}'`; } -function writeDevelopmentLauncherScript(targetBinaryPath, electronBinaryPath) { - const mainEntryPath = NodePath.join(desktopDir, "dist-electron", "main.cjs"); +export function makeDevelopmentLauncherScript({ + electronBinaryPath, + mainEntryPath, + desktopRoot, + environment, +}) { const envEntries = [ - ["VITE_DEV_SERVER_URL", process.env.VITE_DEV_SERVER_URL], - ["T3CODE_PORT", process.env.T3CODE_PORT], - ["T3CODE_HOME", process.env.T3CODE_HOME], - ["T3CODE_COMMIT_HASH", process.env.T3CODE_COMMIT_HASH], - ["T3CODE_OTLP_TRACES_URL", process.env.T3CODE_OTLP_TRACES_URL], - ["T3CODE_OTLP_EXPORT_INTERVAL_MS", process.env.T3CODE_OTLP_EXPORT_INTERVAL_MS], + ["VITE_DEV_SERVER_URL", environment.VITE_DEV_SERVER_URL], + ["T3CODE_PORT", environment.T3CODE_PORT], + ["T3CODE_HOME", environment.T3CODE_HOME], + ["T3CODE_COMMIT_HASH", environment.T3CODE_COMMIT_HASH], + ["T3CODE_OTLP_TRACES_URL", environment.T3CODE_OTLP_TRACES_URL], + ["T3CODE_OTLP_EXPORT_INTERVAL_MS", environment.T3CODE_OTLP_EXPORT_INTERVAL_MS], ["T3CODE_DESKTOP_APP_USER_MODEL_ID", APP_BUNDLE_ID], ].filter((entry) => typeof entry[1] === "string" && entry[1].trim().length > 0); + return [ + "#!/bin/sh", + ...envEntries.map( + ([name, value]) => + `if [ -z "\${${name}:-}" ]; then export ${name}=${shellSingleQuote(value)}; fi`, + ), + `exec ${shellSingleQuote(electronBinaryPath)} --t3code-dev-root=${shellSingleQuote(desktopRoot)} ${shellSingleQuote(mainEntryPath)} "$@"`, + "", + ].join("\n"); +} + +function writeDevelopmentLauncherScript(targetBinaryPath, electronBinaryPath) { NodeFS.writeFileSync( targetBinaryPath, - [ - "#!/bin/sh", - ...envEntries.map(([name, value]) => `export ${name}=${shellSingleQuote(value)}`), - `exec ${shellSingleQuote(electronBinaryPath)} --t3code-dev-root=${shellSingleQuote(desktopDir)} ${shellSingleQuote(mainEntryPath)} "$@"`, - "", - ].join("\n"), + makeDevelopmentLauncherScript({ + electronBinaryPath, + mainEntryPath: NodePath.join(desktopDir, "dist-electron", "main.cjs"), + desktopRoot: desktopDir, + environment: process.env, + }), ); NodeFS.chmodSync(targetBinaryPath, 0o755); } @@ -286,6 +302,12 @@ function buildMacLauncher(electronBinaryPath) { currentMetadata && JSON.stringify(currentMetadata) === JSON.stringify(expectedMetadata) ) { + if (isDevelopment) { + // The launcher also handles protocol activations outside the dev runner, + // so refresh its fallback environment on every launch. Never let a value + // captured by an older parent app override the live dev-runner environment. + writeDevelopmentLauncherScript(targetBinaryPath, electronBinaryPath); + } registerMacLauncherBundle(targetAppBundlePath); return targetBinaryPath; } diff --git a/apps/desktop/scripts/electron-launcher.test.mjs b/apps/desktop/scripts/electron-launcher.test.mjs new file mode 100644 index 0000000000..5a1df0ec66 --- /dev/null +++ b/apps/desktop/scripts/electron-launcher.test.mjs @@ -0,0 +1,28 @@ +import { assert, describe, it } from "vite-plus/test"; + +import { makeDevelopmentLauncherScript } from "./electron-launcher.mjs"; + +describe("electron development launcher", () => { + it("uses captured values only as fallbacks for a live runner environment", () => { + const script = makeDevelopmentLauncherScript({ + electronBinaryPath: "/repo/node_modules/electron/Electron", + mainEntryPath: "/repo/apps/desktop/dist-electron/main.cjs", + desktopRoot: "/repo/apps/desktop", + environment: { + VITE_DEV_SERVER_URL: "http://127.0.0.1:8526", + T3CODE_PORT: "16566", + T3CODE_HOME: "/tmp/t3", + }, + }); + + assert.include( + script, + "if [ -z \"${VITE_DEV_SERVER_URL:-}\" ]; then export VITE_DEV_SERVER_URL='http://127.0.0.1:8526'; fi", + ); + assert.notInclude(script, "\nexport VITE_DEV_SERVER_URL="); + assert.include( + script, + "exec '/repo/node_modules/electron/Electron' --t3code-dev-root='/repo/apps/desktop' '/repo/apps/desktop/dist-electron/main.cjs' \"$@\"", + ); + }); +}); diff --git a/apps/desktop/src/electron/ElectronProtocol.test.ts b/apps/desktop/src/electron/ElectronProtocol.test.ts index 56fe009fee..92e3000042 100644 --- a/apps/desktop/src/electron/ElectronProtocol.test.ts +++ b/apps/desktop/src/electron/ElectronProtocol.test.ts @@ -43,7 +43,16 @@ describe("ElectronProtocol", () => { assert.isDefined(handler); const response = yield* Effect.promise(() => - handler!(new Request("t3code-dev://app/api/health?verbose=1")), + handler!( + new Request("t3code-dev://app/api/health?verbose=1", { + headers: { + accept: "application/json", + origin: "t3code-dev://app", + referer: "t3code-dev://app/", + "sec-fetch-site": "same-origin", + }, + }), + ), ); assert.equal(yield* Effect.promise(() => response.text()), "ok"); assert.include( @@ -70,6 +79,11 @@ describe("ElectronProtocol", () => { ["t3code-dev"], ); assert.equal(netFetchMock.mock.calls[0]?.[0], "http://127.0.0.1:3773/api/health?verbose=1"); + const forwardedHeaders = new Headers(netFetchMock.mock.calls[0]?.[1]?.headers); + assert.equal(forwardedHeaders.get("accept"), "application/json"); + assert.isNull(forwardedHeaders.get("origin")); + assert.isNull(forwardedHeaders.get("referer")); + assert.isNull(forwardedHeaders.get("sec-fetch-site")); assert.deepEqual(unhandleMock.mock.calls, [["t3code-dev"]]); }).pipe(Effect.provide(ElectronProtocol.layer)), ); @@ -99,6 +113,34 @@ describe("ElectronProtocol", () => { }).pipe(Effect.provide(ElectronProtocol.layer)), ); + it.effect("retries transient renderer target failures", () => + Effect.gen(function* () { + let handler: ((request: Request) => Promise) | undefined; + handleMock.mockImplementation((_scheme, nextHandler) => { + handler = nextHandler; + }); + netFetchMock + .mockRejectedValueOnce(new Error("connect ECONNREFUSED 127.0.0.1:5733")) + .mockResolvedValueOnce(new Response("ready")); + + const response = yield* Effect.scoped( + Effect.gen(function* () { + const protocol = yield* ElectronProtocol.ElectronProtocol; + yield* protocol.registerDesktopProtocol({ + scheme: "t3code-dev", + targetOrigin: new URL("http://127.0.0.1:5733/"), + backendOrigin: new URL("http://127.0.0.1:3773/"), + clerkFrontendApiHostname: undefined, + }); + return yield* Effect.promise(() => handler!(new Request("t3code-dev://app/"))); + }), + ); + + assert.equal(yield* Effect.promise(() => response.text()), "ready"); + assert.equal(netFetchMock.mock.calls.length, 2); + }).pipe(Effect.provide(ElectronProtocol.layer)), + ); + it.effect("preserves protocol registration failures", () => Effect.gen(function* () { const cause = new Error("protocol registration failed"); diff --git a/apps/desktop/src/electron/ElectronProtocol.ts b/apps/desktop/src/electron/ElectronProtocol.ts index 757c26178d..03c7ef64fd 100644 --- a/apps/desktop/src/electron/ElectronProtocol.ts +++ b/apps/desktop/src/electron/ElectronProtocol.ts @@ -1,6 +1,7 @@ import * as Context from "effect/Context"; import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; +import * as NodeTimersPromises from "node:timers/promises"; import * as Ref from "effect/Ref"; import * as Schema from "effect/Schema"; import * as Scope from "effect/Scope"; @@ -114,18 +115,60 @@ async function proxyRequest( } const targetUrl = new URL(`${requestUrl.pathname}${requestUrl.search}`, targetOrigin); + const headers = new Headers(request.headers); + const headersToRemove: string[] = []; + for (const name of headers.keys()) { + if ( + name === "host" || + name === "origin" || + name === "referer" || + name === "connection" || + name === "content-length" || + name === "accept-encoding" || + name === "upgrade-insecure-requests" || + name.startsWith("sec-fetch-") + ) { + headersToRemove.push(name); + } + } + for (const name of headersToRemove) { + headers.delete(name); + } const init: RequestInit = { method: request.method, - headers: request.headers, + headers, }; if (request.method !== "GET" && request.method !== "HEAD") { init.body = request.body; (init as RequestInit & { duplex: "half" }).duplex = "half"; } - const response = await Electron.net.fetch(targetUrl.toString(), init); + const response = + request.method === "GET" || request.method === "HEAD" + ? await fetchWithTransientRetry(targetUrl.toString(), init) + : await Electron.net.fetch(targetUrl.toString(), init); return withContentSecurityPolicy(response, contentSecurityPolicy); } +const TRANSIENT_FETCH_RETRY_DELAYS_MS = [0, 50, 150] as const; + +async function fetchWithTransientRetry(url: string, init: RequestInit): Promise { + let lastError: unknown; + + for (const delayMs of TRANSIENT_FETCH_RETRY_DELAYS_MS) { + if (delayMs > 0) { + await NodeTimersPromises.setTimeout(delayMs); + } + + try { + return await Electron.net.fetch(url, init); + } catch (error) { + lastError = error; + } + } + + throw lastError; +} + export const make = Effect.gen(function* () { const registered = yield* Ref.make(false); diff --git a/apps/desktop/src/preview/Manager.test.ts b/apps/desktop/src/preview/Manager.test.ts index acb0d783a8..ab76e4a3f2 100644 --- a/apps/desktop/src/preview/Manager.test.ts +++ b/apps/desktop/src/preview/Manager.test.ts @@ -18,16 +18,25 @@ import * as ElectronWindow from "../electron/ElectronWindow.ts"; import * as BrowserSession from "./BrowserSession.ts"; import * as PreviewManager from "./Manager.ts"; -const { createFromPath, fromId, mkdir, showItemInFolder, webviewSend, writeFile, writeImage } = - vi.hoisted(() => ({ - createFromPath: vi.fn((): { readonly isEmpty: () => boolean } => ({ isEmpty: () => false })), - fromId: vi.fn(() => null), - mkdir: vi.fn((_path: string) => undefined), - showItemInFolder: vi.fn(), - webviewSend: vi.fn(), - writeFile: vi.fn((_path: string, _data: Uint8Array) => undefined), - writeImage: vi.fn(), - })); +const { + createFromPath, + fromId, + getFocusedWebContents, + mkdir, + showItemInFolder, + webviewSend, + writeFile, + writeImage, +} = vi.hoisted(() => ({ + createFromPath: vi.fn((): { readonly isEmpty: () => boolean } => ({ isEmpty: () => false })), + fromId: vi.fn(() => null), + getFocusedWebContents: vi.fn(() => null), + mkdir: vi.fn((_path: string) => undefined), + showItemInFolder: vi.fn(), + webviewSend: vi.fn(), + writeFile: vi.fn((_path: string, _data: Uint8Array) => undefined), + writeImage: vi.fn(), +})); vi.mock("electron", () => ({ clipboard: { @@ -44,6 +53,7 @@ vi.mock("electron", () => ({ }, webContents: { fromId, + getFocusedWebContents, }, })); @@ -97,6 +107,8 @@ const withManager = ( describe("PreviewManager", () => { beforeEach(() => { fromId.mockClear(); + getFocusedWebContents.mockReset(); + getFocusedWebContents.mockReturnValue(null); mkdir.mockClear(); writeFile.mockClear(); showItemInFolder.mockClear(); @@ -250,6 +262,197 @@ describe("PreviewManager", () => { ), ); + effectIt.effect("mirrors Electron's effective zoom across registration and navigation", () => + withManager((manager) => + Effect.gen(function* () { + let effectiveZoom = 0.9; + let zoomReadable = true; + let url = "https://example.com"; + const listeners = new Map void>(); + const setZoomFactor = vi.fn(); + fromId.mockReturnValue({ + id: 42, + isDestroyed: () => false, + getType: () => "webview", + getURL: () => url, + getTitle: () => "Example", + isLoading: () => false, + getZoomFactor: () => { + if (!zoomReadable) throw new Error("zoom unavailable"); + return effectiveZoom; + }, + setZoomFactor, + on: vi.fn((event: string, listener: (...args: unknown[]) => void) => { + listeners.set(event, listener); + }), + off: vi.fn(), + ipc: { on: vi.fn(), off: vi.fn() }, + send: webviewSend, + navigationHistory: { canGoBack: () => false, canGoForward: () => false }, + setWindowOpenHandler: vi.fn(), + debugger: { + isAttached: () => false, + attach: vi.fn(), + sendCommand: vi.fn(async () => undefined), + on: vi.fn(), + off: vi.fn(), + }, + } as never); + const states: PreviewManager.PreviewTabState[] = []; + + yield* manager.subscribeStateChanges((_tabId, state) => + Effect.sync(() => { + states.push(state); + }), + ); + yield* manager.createTab("tab_zoom"); + yield* manager.registerWebview("tab_zoom", 42); + + expect(states.at(-1)?.zoomFactor).toBe(0.9); + expect(setZoomFactor).not.toHaveBeenCalled(); + + effectiveZoom = 1.25; + listeners.get("did-navigate")?.(); + yield* Effect.yieldNow; + + expect(states.at(-1)?.zoomFactor).toBe(1.25); + expect(setZoomFactor).not.toHaveBeenCalled(); + + zoomReadable = false; + url = "https://example.com/after-zoom-read-failed"; + listeners.get("did-navigate")?.(); + yield* Effect.yieldNow; + + expect(states.at(-1)?.navStatus).toEqual({ + kind: "Success", + url, + title: "Example", + }); + expect(states.at(-1)?.zoomFactor).toBe(1.25); + + const replacementSetZoomFactor = vi.fn(); + fromId.mockReturnValue({ + id: 43, + isDestroyed: () => false, + getType: () => "webview", + getURL: () => url, + getTitle: () => "Example", + isLoading: () => false, + getZoomFactor: () => 1, + setZoomFactor: replacementSetZoomFactor, + on: vi.fn(), + off: vi.fn(), + ipc: { on: vi.fn(), off: vi.fn() }, + send: webviewSend, + navigationHistory: { canGoBack: () => false, canGoForward: () => false }, + setWindowOpenHandler: vi.fn(), + debugger: { + isAttached: () => false, + attach: vi.fn(), + sendCommand: vi.fn(async () => undefined), + on: vi.fn(), + off: vi.fn(), + }, + } as never); + + yield* manager.registerWebview("tab_zoom", 43); + + expect(replacementSetZoomFactor).toHaveBeenCalledWith(1.25); + expect(states.at(-1)?.zoomFactor).toBe(1.25); + }), + ), + ); + + effectIt.effect("keeps a main-frame load failure visible until a retry starts", () => + withManager((manager) => + Effect.gen(function* () { + const url = "http://localhost:5733/"; + let loading = false; + const listeners = new Map void>(); + fromId.mockReturnValue({ + id: 42, + isDestroyed: () => false, + getType: () => "webview", + getURL: () => url, + getTitle: () => "localhost:5733", + isLoading: () => loading, + getZoomFactor: () => 1, + setZoomFactor: vi.fn(), + on: vi.fn((event: string, listener: (...args: unknown[]) => void) => { + listeners.set(event, listener); + }), + off: vi.fn(), + ipc: { on: vi.fn(), off: vi.fn() }, + send: webviewSend, + navigationHistory: { canGoBack: () => false, canGoForward: () => false }, + setWindowOpenHandler: vi.fn(), + debugger: { + isAttached: () => false, + attach: vi.fn(), + sendCommand: vi.fn(async () => undefined), + on: vi.fn(), + off: vi.fn(), + }, + } as never); + const statuses: PreviewManager.PreviewNavStatus[] = []; + + yield* manager.subscribeStateChanges((_tabId, state) => + Effect.sync(() => { + statuses.push(state.navStatus); + }), + ); + yield* manager.createTab("tab_failed"); + yield* manager.registerWebview("tab_failed", 42); + + listeners.get("did-fail-load")?.( + {}, + -105, + "ERR_NAME_NOT_RESOLVED", + "https://missing-frame.example/", + false, + ); + yield* Effect.yieldNow; + expect(statuses.at(-1)?.kind).toBe("Success"); + + loading = true; + listeners.get("did-start-loading")?.(); + yield* Effect.yieldNow; + expect(statuses.at(-1)?.kind).toBe("Loading"); + + loading = false; + listeners.get("did-fail-load")?.({}, -102, "ERR_CONNECTION_REFUSED", url, true); + listeners.get("did-stop-loading")?.(); + listeners.get("page-title-updated")?.(); + yield* Effect.yieldNow; + expect(statuses.at(-1)).toEqual({ + kind: "LoadFailed", + url, + title: "localhost:5733", + code: -102, + description: "ERR_CONNECTION_REFUSED", + }); + + loading = true; + listeners.get("did-start-loading")?.(); + yield* Effect.yieldNow; + expect(statuses.at(-1)?.kind).toBe("Loading"); + + loading = false; + listeners.get("did-stop-loading")?.(); + yield* Effect.yieldNow; + expect(statuses.at(-1)?.kind).toBe("Success"); + + listeners.get("did-fail-load")?.({}, -102, "ERR_CONNECTION_REFUSED", url, true); + yield* Effect.yieldNow; + expect(statuses.at(-1)?.kind).toBe("LoadFailed"); + + listeners.get("did-navigate")?.(); + yield* Effect.yieldNow; + expect(statuses.at(-1)?.kind).toBe("Success"); + }), + ), + ); + effectIt.effect("captures a PNG screenshot into browser artifacts", () => withManager((manager) => Effect.gen(function* () { @@ -511,6 +714,178 @@ describe("PreviewManager", () => { ), ); + effectIt.effect("types in background webviews and enables native key input", () => + withManager((manager) => + Effect.gen(function* () { + let failKeyDown = false; + let humanInput: ((_event: unknown, signal: unknown) => void) | undefined; + const sendCommand = vi.fn(async (method: string, params?: Record) => { + if ( + failKeyDown && + method === "Input.dispatchKeyEvent" && + (params?.["type"] === "keyDown" || params?.["type"] === "rawKeyDown") + ) { + throw new Error("key dispatch failed"); + } + if ( + method === "Input.dispatchKeyEvent" && + (params?.["type"] === "keyDown" || params?.["type"] === "rawKeyDown") + ) { + humanInput?.( + {}, + { + kind: "key", + key: params["key"], + code: params["code"] ?? "Digit1", + }, + ); + } + return method === "Runtime.evaluate" ? { result: { value: { ok: true } } } : undefined; + }); + const restoreFocus = vi.fn(); + const focus = vi.fn(); + getFocusedWebContents.mockReturnValue({ + id: 7, + isDestroyed: () => false, + focus: restoreFocus, + } as never); + fromId.mockReturnValue({ + id: 42, + isDestroyed: () => false, + getType: () => "webview", + getURL: () => "https://example.com", + getTitle: () => "Example", + isLoading: () => false, + isDevToolsOpened: () => false, + focus, + getZoomFactor: () => 1, + setZoomFactor: vi.fn(), + on: vi.fn(), + off: vi.fn(), + ipc: { + on: vi.fn((channel: string, listener: typeof humanInput) => { + if (channel === "preview:human-input") humanInput = listener; + }), + off: vi.fn(), + }, + send: webviewSend, + navigationHistory: { canGoBack: () => false, canGoForward: () => false }, + setWindowOpenHandler: vi.fn(), + debugger: { + isAttached: () => false, + attach: vi.fn(), + sendCommand, + on: vi.fn(), + off: vi.fn(), + }, + } as never); + + yield* manager.createTab("tab_input"); + yield* manager.registerWebview("tab_input", 42); + yield* manager.automationType("tab_input", { text: "hello", clear: true }); + yield* manager.automationType("tab_input", { text: "", clear: true }); + yield* manager.automationPress("tab_input", { key: "x" }); + + const calls = sendCommand.mock.calls; + const methods = calls.map(([method]) => method); + const enableIndex = methods.indexOf("Input.setIgnoreInputEvents"); + const focusOnIndex = calls.findIndex( + ([method, params]) => + method === "Emulation.setFocusEmulationEnabled" && params?.["enabled"] === true, + ); + const keyDownIndex = calls.findIndex( + ([method, params]) => + method === "Input.dispatchKeyEvent" && params?.["type"] === "keyDown", + ); + const keyUpIndex = calls.findIndex( + ([method, params]) => method === "Input.dispatchKeyEvent" && params?.["type"] === "keyUp", + ); + const focusOffIndex = calls.findIndex( + ([method, params]) => + method === "Emulation.setFocusEmulationEnabled" && params?.["enabled"] === false, + ); + const typeEvaluation = sendCommand.mock.calls.find( + ([method, params]) => + method === "Runtime.evaluate" && + typeof params === "object" && + params !== null && + "expression" in params && + typeof params.expression === "string" && + params.expression.includes('document.execCommand("insertText"'), + ); + expect(typeEvaluation).toBeDefined(); + const clearOnlyEvaluation = sendCommand.mock.calls.find( + ([method, params]) => + method === "Runtime.evaluate" && + typeof params === "object" && + params !== null && + "expression" in params && + typeof params.expression === "string" && + params.expression.includes('const text = ""') && + params.expression.includes("Object.getOwnPropertyDescriptor"), + ); + expect(clearOnlyEvaluation).toBeDefined(); + expect(methods).not.toContain("Input.insertText"); + expect(enableIndex).toBeGreaterThanOrEqual(0); + expect(focus).toHaveBeenCalledOnce(); + expect(restoreFocus).toHaveBeenCalledOnce(); + expect(methods).toContain("Page.bringToFront"); + expect(enableIndex).toBeLessThan(focusOnIndex); + expect(focusOnIndex).toBeLessThan(keyDownIndex); + expect(keyDownIndex).toBeLessThan(keyUpIndex); + expect(keyUpIndex).toBeLessThan(focusOffIndex); + expect( + calls.filter( + ([method, params]) => + method === "Input.dispatchKeyEvent" && params?.["type"] === "keyUp", + ), + ).toHaveLength(1); + expect(sendCommand).toHaveBeenCalledWith("Input.setIgnoreInputEvents", { ignore: false }); + + sendCommand.mockClear(); + failKeyDown = true; + const failedPress = yield* Effect.exit(manager.automationPress("tab_input", { key: "y" })); + + expect(Exit.isFailure(failedPress)).toBe(true); + expect(sendCommand).toHaveBeenCalledWith("Input.dispatchKeyEvent", { + type: "keyUp", + key: "y", + code: "KeyY", + modifiers: 0, + windowsVirtualKeyCode: 89, + location: 0, + isKeypad: false, + }); + expect(sendCommand).toHaveBeenCalledWith("Emulation.setFocusEmulationEnabled", { + enabled: false, + }); + expect(restoreFocus).toHaveBeenCalledTimes(2); + expect( + sendCommand.mock.calls.filter( + ([method, params]) => + method === "Input.dispatchKeyEvent" && params?.["type"] === "keyUp", + ), + ).toHaveLength(1); + + sendCommand.mockClear(); + failKeyDown = false; + yield* manager.automationPress("tab_input", { key: "!" }); + expect(sendCommand).toHaveBeenCalledWith("Input.dispatchKeyEvent", { + type: "keyDown", + key: "!", + code: "Digit1", + modifiers: 0, + windowsVirtualKeyCode: 49, + location: 0, + isKeypad: false, + text: "!", + unmodifiedText: "!", + }); + expect(restoreFocus).toHaveBeenCalledTimes(3); + }), + ), + ); + effectIt.effect("still interrupts agent control for a different human pointer event", () => withManager((manager) => Effect.gen(function* () { diff --git a/apps/desktop/src/preview/Manager.ts b/apps/desktop/src/preview/Manager.ts index 6fd65cd25b..43b2259ead 100644 --- a/apps/desktop/src/preview/Manager.ts +++ b/apps/desktop/src/preview/Manager.ts @@ -62,6 +62,7 @@ import { } from "./GuestProtocol.ts"; import { isPreviewAnnotationPayload } from "./PickedElementPayload.ts"; import { playwrightInjectedRuntimeInstallExpression } from "./PlaywrightInjectedRuntime.ts"; +import { makePreviewAutomationKeySequence } from "./PreviewKeyboard.ts"; export type PreviewNavStatus = | { kind: "Idle" } @@ -854,11 +855,24 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function commandParams?: Record, ) => Effect.Effect; + const prepareAutomationInput = Effect.fn("PreviewManager.prepareAutomationInput")(function* ( + send: SendCommand, + enableRuntime: boolean, + ) { + yield* Effect.all( + [ + ...(enableRuntime ? [send("Runtime.enable")] : []), + send("Input.setIgnoreInputEvents", { ignore: false }), + ], + { concurrency: 2, discard: true }, + ); + }); + const withControlSession = Effect.fn("PreviewManager.withControlSession")(function* ( tabId: string, wc: Electron.WebContents, action: string, - use: (send: SendCommand) => Effect.Effect, + use: (send: SendCommand, sendCleanup: SendCommand) => Effect.Effect, ) { const sequence = yield* nextCounter(actionSequenceRef); const startedAt = yield* currentIso; @@ -899,7 +913,22 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function return result; }, ); - return yield* use(send); + // Cleanup commands must still run after human input invalidates the action's + // control epoch. Otherwise a partially dispatched input can leave Chromium + // with a held key or focus emulation enabled for subsequent actions. + const sendCleanup: SendCommand = Effect.fn("PreviewManager.sendCleanupCommand")( + function* (method, commandParams) { + return yield* attemptPromise( + { + operation: `${action}.cleanup.${method}`, + tabId, + webContentsId: wc.id, + }, + () => wc.debugger.sendCommand(method, commandParams), + ); + }, + ); + return yield* use(send, sendCleanup); }); const finalize = Effect.fn("PreviewManager.finalizeControlAction")(function* ( exit: Exit.Exit, @@ -1091,22 +1120,62 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function wc: Electron.WebContents, ) { const scope = yield* Scope.fork(parentScope, "sequential"); - const syncState = Effect.fn("PreviewManager.syncWebContentsState")(function* () { + const syncState = Effect.fn("PreviewManager.syncWebContentsState")(function* ( + preserveLoadFailure: boolean, + ) { if (wc.isDestroyed()) return; - yield* update(tabId, { - navStatus: computeNavStatus(wc), - canGoBack: wc.navigationHistory.canGoBack(), - canGoForward: wc.navigationHistory.canGoForward(), + const zoomFactor = yield* attempt( + { operation: "syncWebContentsState.getZoomFactor", tabId, webContentsId: wc.id }, + () => wc.getZoomFactor(), + ).pipe(Effect.option); + const computedNavStatus = computeNavStatus(wc); + const canGoBack = wc.navigationHistory.canGoBack(); + const canGoForward = wc.navigationHistory.canGoForward(); + const updatedAt = yield* currentIso; + const next = yield* SynchronizedRef.modify(tabsRef, (tabs) => { + const current = tabs.get(tabId); + if (!current) return [Option.none(), tabs] as const; + // Electron emits did-stop-loading after did-fail-load. At that point the + // failed guest is no longer "loading", but it has not successfully + // navigated anywhere. Keep the failure until a new load actually starts. + const navStatus = + preserveLoadFailure && + current.navStatus.kind === "LoadFailed" && + computedNavStatus.kind === "Success" + ? current.navStatus + : computedNavStatus; + const state: PreviewTabState = { + ...current, + navStatus, + canGoBack, + canGoForward, + ...(Option.isSome(zoomFactor) ? { zoomFactor: zoomFactor.value } : {}), + updatedAt, + }; + return [ + Option.some(state), + replaceMap(tabs, (copy) => { + copy.set(tabId, state); + }), + ] as const; }); + if (Option.isSome(next)) yield* emit(tabId, next.value); }); - const sync = () => runFork(syncState()); - const failed = (_event: Event, code: number, description: string): void => { - if (code === -3) return; + const sync = () => runFork(syncState(true)); + const syncNavigation = () => runFork(syncState(false)); + const failed = ( + _event: Event, + code: number, + description: string, + validatedUrl: string, + isMainFrame: boolean, + ): void => { + if (code === -3 || !isMainFrame) return; runFork( update(tabId, { navStatus: { kind: "LoadFailed", - url: wc.getURL(), + url: validatedUrl || wc.getURL(), title: wc.getTitle(), code, description, @@ -1161,8 +1230,8 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function yield* Scope.addFinalizer( scope, attempt({ operation: "detachListeners", tabId, webContentsId: wc.id }, () => { - wc.off("did-navigate", sync); - wc.off("did-navigate-in-page", sync); + wc.off("did-navigate", syncNavigation); + wc.off("did-navigate-in-page", syncNavigation); wc.off("page-title-updated", sync); wc.off("did-start-loading", sync); wc.off("did-stop-loading", sync); @@ -1173,8 +1242,8 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function ); const install = Effect.fn("PreviewManager.installWebContentsListeners")(function* () { yield* attempt({ operation: "attachListeners", tabId, webContentsId: wc.id }, () => { - wc.on("did-navigate", sync); - wc.on("did-navigate-in-page", sync); + wc.on("did-navigate", syncNavigation); + wc.on("did-navigate-in-page", syncNavigation); wc.on("page-title-updated", sync); wc.on("did-start-loading", sync); wc.on("did-stop-loading", sync); @@ -1280,21 +1349,40 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function const attached = yield* Ref.get(attachedRef); const annotationTheme = yield* Ref.get(annotationThemeRef); if (tab.webContentsId === webContentsId && attached.has(webContentsId)) { + const zoomFactor = yield* attempt( + { operation: "registerWebview.getZoomFactor", tabId, webContentsId }, + () => wc.getZoomFactor(), + ); + yield* update(tabId, { zoomFactor }); yield* attempt({ operation: "registerWebview.sendTheme", tabId, webContentsId }, () => wc.send(ANNOTATION_THEME_CHANNEL, annotationTheme), ); return; } - if (tab.webContentsId != null && tab.webContentsId !== webContentsId) { + const replacedWebContentsId = + tab.webContentsId != null && tab.webContentsId !== webContentsId ? tab.webContentsId : null; + if (replacedWebContentsId !== null) { yield* Effect.all( [ - detachControlSession(tab.webContentsId), - detachListeners(tab.webContentsId), + detachControlSession(replacedWebContentsId), + detachListeners(replacedWebContentsId), cancelPickElement(tabId), ], { concurrency: 3, discard: true }, ); } + const zoomFactor = + replacedWebContentsId !== null + ? yield* attempt( + { operation: "registerWebview.restoreZoomFactor", tabId, webContentsId }, + () => { + wc.setZoomFactor(tab.zoomFactor); + return tab.zoomFactor; + }, + ) + : yield* attempt({ operation: "registerWebview.getZoomFactor", tabId, webContentsId }, () => + wc.getZoomFactor(), + ); yield* attachListeners(tabId, wc); runFork(ensureControlSession(wc).pipe(Effect.ignore)); const registeredAt = yield* currentIso; @@ -1313,6 +1401,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function navStatus: pendingUrl === null ? computeNavStatus(wc) : current.navStatus, canGoBack: wc.navigationHistory.canGoBack(), canGoForward: wc.navigationHistory.canGoForward(), + zoomFactor, updatedAt: registeredAt, }; return [ @@ -1330,11 +1419,6 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function } const { state: registered, pendingUrl } = registration.value; yield* emit(tabId, registered); - if (Math.abs(registered.zoomFactor - DEFAULT_ZOOM_FACTOR) > ZOOM_EPSILON) { - yield* attempt({ operation: "registerWebview.restoreZoom", tabId, webContentsId }, () => - wc.setZoomFactor(registered.zoomFactor), - ).pipe(Effect.ignore); - } yield* attempt({ operation: "registerWebview.sendTheme", tabId, webContentsId }, () => wc.send(ANNOTATION_THEME_CHANNEL, annotationTheme), ); @@ -1946,10 +2030,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function input: PreviewAutomationClickInput, send: SendCommand, ) { - yield* Effect.all( - [send("Runtime.enable"), send("Input.setIgnoreInputEvents", { ignore: false })], - { concurrency: 2, discard: true }, - ); + yield* prepareAutomationInput(send, true); const point = yield* resolveClickPoint(tabId, send, input); const viewport = yield* evaluateWithDebugger<{ width: number; height: number }>( tabId, @@ -2011,7 +2092,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function ); }); - const focusAutomationTarget = Effect.fn("PreviewManager.focusAutomationTarget")(function* ( + const typeIntoAutomationTarget = Effect.fn("PreviewManager.typeIntoAutomationTarget")(function* ( tabId: string, send: SendCommand, input: PreviewAutomationTypeInput, @@ -2021,8 +2102,15 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function const locatorJson = locator ? yield* encodeJson({ operation: "automationType.encodeLocator", tabId }, locator) : null; + const textJson = yield* encodeJson( + { operation: "automationType.encodeText", tabId }, + input.text, + ); const result = yield* evaluateWithDebugger< - { ok: true } | { invalidSelector: true; message: string } | { notFound: true } + | { ok: true } + | { invalidSelector: true; message: string } + | { notEditable: true } + | { notFound: true } >( tabId, send, @@ -2030,12 +2118,54 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function try { const element = ${locatorJson ? `(() => { const injected = globalThis.__t3PlaywrightInjected; return injected.querySelector(injected.parseSelector(${locatorJson}), document, true); })()` : "document.activeElement"}; if (!element) return { notFound: true }; + const textControl = + element instanceof HTMLTextAreaElement || + (element instanceof HTMLInputElement && + !new Set(["button", "checkbox", "color", "file", "hidden", "image", "radio", "range", "reset", "submit"]).has(element.type)); + const editable = textControl || element.isContentEditable; + if (!editable || element.disabled || element.readOnly) return { notEditable: true }; element.focus(); - if (${input.clear ?? false}) { - if ("value" in element) element.value = ""; - else if (element.isContentEditable) element.textContent = ""; - element.dispatchEvent(new InputEvent("input", { bubbles: true, inputType: "deleteContentBackward" })); + if (document.activeElement !== element) return { notEditable: true }; + const clear = ${input.clear ?? false}; + if (clear) { + if (textControl) { + element.select(); + } else { + const range = document.createRange(); + range.selectNodeContents(element); + const selection = document.getSelection(); + selection?.removeAllRanges(); + selection?.addRange(range); + } } + const text = ${textJson}; + let inserted = true; + if (text.length > 0) { + inserted = document.execCommand("insertText", false, text); + } else if (clear) { + document.execCommand("delete", false); + const cleared = textControl + ? element.value.length === 0 + : (element.textContent ?? "").length === 0; + if (!cleared) { + if (textControl) { + const prototype = element instanceof HTMLTextAreaElement + ? HTMLTextAreaElement.prototype + : HTMLInputElement.prototype; + const valueSetter = Object.getOwnPropertyDescriptor(prototype, "value")?.set; + if (valueSetter) valueSetter.call(element, ""); + else element.value = ""; + } else { + element.replaceChildren(); + } + element.dispatchEvent(new InputEvent("input", { + bubbles: true, + inputType: "deleteContentBackward", + })); + } + } + if (!inserted) return { notEditable: true }; + element.dispatchEvent(new Event("change", { bubbles: true })); return { ok: true }; } catch (error) { return { invalidSelector: true, message: String(error) }; @@ -2059,6 +2189,12 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function ...automationSelectorDiagnostics(input), }); } + if ("notEditable" in result) { + return yield* new PreviewAutomationTargetNotEditableError({ + tabId, + ...automationSelectorDiagnostics(input), + }); + } }); const performAutomationType = Effect.fn("PreviewManager.performAutomationType")(function* ( @@ -2066,23 +2202,10 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function input: PreviewAutomationTypeInput, send: SendCommand, ) { - yield* send("Runtime.enable"); - yield* focusAutomationTarget(tabId, send, input); - yield* send("Input.insertText", { text: input.text }); - const textJson = yield* encodeJson( - { operation: "automationType.encodeText", tabId }, - input.text, - ); - yield* evaluateWithDebugger( - tabId, - send, - `(() => { - const element = document.activeElement; - element?.dispatchEvent(new InputEvent("input", { bubbles: true, inputType: "insertText", data: ${textJson} })); - element?.dispatchEvent(new Event("change", { bubbles: true })); - })()`, - false, - ); + // CDP Input.insertText silently drops text until Electron has activated a hidden + // guest WebContents with a pointer event. Editing in the page runtime keeps + // background automation deterministic without stealing foreground app focus. + yield* typeIntoAutomationTarget(tabId, send, input); }); const automationType = Effect.fn("PreviewManager.automationType")(function* ( @@ -2097,32 +2220,52 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function const performAutomationPress = Effect.fn("PreviewManager.performAutomationPress")(function* ( tabId: string, + wc: Electron.WebContents, input: PreviewAutomationPressInput, send: SendCommand, + sendCleanup: SendCommand, ) { - const modifiers = (input.modifiers ?? []).reduce((value, modifier) => { - switch (modifier) { - case "Alt": - return value | 1; - case "Control": - return value | 2; - case "Meta": - return value | 4; - case "Shift": - return value | 8; + yield* prepareAutomationInput(send, false); + const keySequence = makePreviewAutomationKeySequence(input); + const previouslyFocused = yield* attempt( + { operation: "automationPress.getFocusedWebContents", tabId, webContentsId: wc.id }, + () => webContents.getFocusedWebContents(), + ); + let keyDownAttempted = false; + const releaseInput = Effect.gen(function* () { + if (keyDownAttempted) { + yield* sendCleanup("Input.dispatchKeyEvent", keySequence.keyUp).pipe(Effect.ignore); } - }, 0); - const key = input.key; - const text = key.length === 1 ? key : undefined; - const params = { - key, - code: key.length === 1 ? `Key${key.toUpperCase()}` : key, - modifiers, - ...(text ? { text, unmodifiedText: text } : {}), - }; - yield* expectAgentInput(tabId, { kind: "key", key, code: params.code }); - yield* send("Input.dispatchKeyEvent", { type: "keyDown", ...params }); - yield* send("Input.dispatchKeyEvent", { type: "keyUp", ...params }); + yield* sendCleanup("Emulation.setFocusEmulationEnabled", { enabled: false }).pipe( + Effect.ignore, + ); + if (previouslyFocused && previouslyFocused.id !== wc.id && !previouslyFocused.isDestroyed()) { + yield* attempt( + { + operation: "automationPress.restoreFocusedWebContents", + tabId, + webContentsId: previouslyFocused.id, + }, + () => previouslyFocused.focus(), + ).pipe(Effect.ignore); + } + }); + + // Focus the guest WebContents itself, not its containing BrowserWindow. This + // activates native keyboard behavior for hidden/background previews without + // changing which thread is mounted in the UI. Restore the previous renderer + // after dispatch so automation never leaves the app's input focus behind. + yield* Effect.gen(function* () { + yield* attempt( + { operation: "automationPress.focusWebContents", tabId, webContentsId: wc.id }, + () => wc.focus(), + ); + yield* send("Page.bringToFront"); + yield* send("Emulation.setFocusEmulationEnabled", { enabled: true }); + yield* expectAgentInput(tabId, keySequence.signal); + keyDownAttempted = true; + yield* send("Input.dispatchKeyEvent", keySequence.keyDown); + }).pipe(Effect.ensuring(releaseInput)); }); const automationPress = Effect.fn("PreviewManager.automationPress")(function* ( @@ -2130,8 +2273,8 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function input: PreviewAutomationPressInput, ) { const wc = yield* requireWebContents(tabId); - yield* withControlSession(tabId, wc, "press", (send) => - performAutomationPress(tabId, input, send), + yield* withControlSession(tabId, wc, "press", (send, sendCleanup) => + performAutomationPress(tabId, wc, input, send, sendCleanup), ); }); @@ -2529,6 +2672,20 @@ export class PreviewAutomationTargetNotFoundError extends Schema.TaggedErrorClas } } +export class PreviewAutomationTargetNotEditableError extends Schema.TaggedErrorClass()( + "PreviewAutomationTargetNotEditableError", + { + tabId: Schema.String, + selectorKind: PreviewAutomationSelectorKind, + selectorLength: Schema.optionalKey(Schema.Number), + }, +) { + override get message(): string { + const target = previewAutomationTargetLabel(this.selectorKind, this.selectorLength); + return `Preview automation type found ${target}, but it is not editable in tab ${this.tabId}`; + } +} + export class PreviewAutomationCoordinatesOutsideViewportError extends Schema.TaggedErrorClass()( "PreviewAutomationCoordinatesOutsideViewportError", { @@ -2631,6 +2788,7 @@ export const PreviewManagerError = Schema.Union([ PreviewAutomationDebuggerAttachedError, PreviewAutomationEvaluationError, PreviewAutomationTargetNotFoundError, + PreviewAutomationTargetNotEditableError, PreviewAutomationCoordinatesOutsideViewportError, PreviewAutomationInvalidSelectorError, PreviewAutomationResultTooLargeError, diff --git a/apps/desktop/src/preview/PreviewKeyboard.test.ts b/apps/desktop/src/preview/PreviewKeyboard.test.ts new file mode 100644 index 0000000000..3acdcf0d1e --- /dev/null +++ b/apps/desktop/src/preview/PreviewKeyboard.test.ts @@ -0,0 +1,84 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { makePreviewAutomationKeySequence } from "./PreviewKeyboard.ts"; + +describe("preview keyboard packets", () => { + it("includes the Chromium virtual key code and Enter text", () => { + expect(makePreviewAutomationKeySequence({ key: "Enter" })).toEqual({ + keyDown: { + type: "keyDown", + key: "Enter", + code: "Enter", + modifiers: 0, + windowsVirtualKeyCode: 13, + location: 0, + isKeypad: false, + text: "\r", + unmodifiedText: "\r", + }, + keyUp: { + type: "keyUp", + key: "Enter", + code: "Enter", + modifiers: 0, + windowsVirtualKeyCode: 13, + location: 0, + isKeypad: false, + }, + signal: { kind: "key", key: "Enter", code: "Enter" }, + }); + }); + + it("dispatches printable keys as text key-down events", () => { + const sequence = makePreviewAutomationKeySequence({ key: "z" }); + expect(sequence.keyDown).toMatchObject({ + type: "keyDown", + key: "z", + code: "KeyZ", + windowsVirtualKeyCode: 90, + text: "z", + }); + expect(sequence.keyUp).not.toHaveProperty("text"); + }); + + it("suppresses text and uses raw key-down for shortcuts", () => { + expect(makePreviewAutomationKeySequence({ key: "a", modifiers: ["Meta"] }).keyDown).toEqual({ + type: "rawKeyDown", + key: "a", + code: "KeyA", + modifiers: 4, + windowsVirtualKeyCode: 65, + location: 0, + isKeypad: false, + }); + }); + + it("resolves shifted printable keys to their browser values", () => { + const sequence = makePreviewAutomationKeySequence({ key: "1", modifiers: ["Shift"] }); + expect(sequence.keyDown).toMatchObject({ + key: "!", + code: "Digit1", + modifiers: 8, + windowsVirtualKeyCode: 49, + text: "!", + }); + expect(sequence.signal).toEqual({ kind: "key", key: "!", code: "Digit1" }); + }); + + it("keeps shifted key values while suppressing text for modified chords", () => { + const sequence = makePreviewAutomationKeySequence({ + key: "1", + modifiers: ["Control", "Shift"], + }); + expect(sequence.keyDown).toEqual({ + type: "rawKeyDown", + key: "!", + code: "Digit1", + modifiers: 10, + windowsVirtualKeyCode: 49, + location: 0, + isKeypad: false, + }); + expect(sequence.signal).toEqual({ kind: "key", key: "!", code: "Digit1" }); + }); +}); diff --git a/apps/desktop/src/preview/PreviewKeyboard.ts b/apps/desktop/src/preview/PreviewKeyboard.ts new file mode 100644 index 0000000000..6246cf5e55 --- /dev/null +++ b/apps/desktop/src/preview/PreviewKeyboard.ts @@ -0,0 +1,163 @@ +import type { PreviewAutomationPressInput } from "@t3tools/contracts"; + +interface KeyDefinition { + readonly code: string; + readonly key: string; + readonly keyCode: number; + readonly text?: string; + readonly location?: number; + readonly shiftedKey?: string; +} + +export interface PreviewAutomationKeyEvent { + readonly [key: string]: unknown; + readonly type: "keyDown" | "rawKeyDown" | "keyUp"; + readonly key: string; + readonly code: string; + readonly modifiers: number; + readonly windowsVirtualKeyCode: number; + readonly location: number; + readonly isKeypad: boolean; + readonly text?: string; + readonly unmodifiedText?: string; +} + +export interface PreviewAutomationKeySequence { + readonly keyDown: PreviewAutomationKeyEvent; + readonly keyUp: PreviewAutomationKeyEvent; + readonly signal: { + readonly kind: "key"; + readonly key: string; + readonly code: string; + }; +} + +const NAMED_KEYS: Readonly> = { + Escape: { code: "Escape", key: "Escape", keyCode: 27 }, + Backspace: { code: "Backspace", key: "Backspace", keyCode: 8 }, + Tab: { code: "Tab", key: "Tab", keyCode: 9 }, + Enter: { code: "Enter", key: "Enter", keyCode: 13, text: "\r" }, + Shift: { code: "ShiftLeft", key: "Shift", keyCode: 16, location: 1 }, + Control: { code: "ControlLeft", key: "Control", keyCode: 17, location: 1 }, + Alt: { code: "AltLeft", key: "Alt", keyCode: 18, location: 1 }, + Meta: { code: "MetaLeft", key: "Meta", keyCode: 91, location: 1 }, + CapsLock: { code: "CapsLock", key: "CapsLock", keyCode: 20 }, + Space: { code: "Space", key: " ", keyCode: 32, text: " " }, + PageUp: { code: "PageUp", key: "PageUp", keyCode: 33 }, + PageDown: { code: "PageDown", key: "PageDown", keyCode: 34 }, + End: { code: "End", key: "End", keyCode: 35 }, + Home: { code: "Home", key: "Home", keyCode: 36 }, + ArrowLeft: { code: "ArrowLeft", key: "ArrowLeft", keyCode: 37 }, + ArrowUp: { code: "ArrowUp", key: "ArrowUp", keyCode: 38 }, + ArrowRight: { code: "ArrowRight", key: "ArrowRight", keyCode: 39 }, + ArrowDown: { code: "ArrowDown", key: "ArrowDown", keyCode: 40 }, + Insert: { code: "Insert", key: "Insert", keyCode: 45 }, + Delete: { code: "Delete", key: "Delete", keyCode: 46 }, +}; + +const PRINTABLE_KEYS: ReadonlyArray = [ + { code: "Backquote", key: "`", shiftedKey: "~", keyCode: 192 }, + { code: "Digit1", key: "1", shiftedKey: "!", keyCode: 49 }, + { code: "Digit2", key: "2", shiftedKey: "@", keyCode: 50 }, + { code: "Digit3", key: "3", shiftedKey: "#", keyCode: 51 }, + { code: "Digit4", key: "4", shiftedKey: "$", keyCode: 52 }, + { code: "Digit5", key: "5", shiftedKey: "%", keyCode: 53 }, + { code: "Digit6", key: "6", shiftedKey: "^", keyCode: 54 }, + { code: "Digit7", key: "7", shiftedKey: "&", keyCode: 55 }, + { code: "Digit8", key: "8", shiftedKey: "*", keyCode: 56 }, + { code: "Digit9", key: "9", shiftedKey: "(", keyCode: 57 }, + { code: "Digit0", key: "0", shiftedKey: ")", keyCode: 48 }, + { code: "Minus", key: "-", shiftedKey: "_", keyCode: 189 }, + { code: "Equal", key: "=", shiftedKey: "+", keyCode: 187 }, + { code: "Backslash", key: "\\", shiftedKey: "|", keyCode: 220 }, + { code: "BracketLeft", key: "[", shiftedKey: "{", keyCode: 219 }, + { code: "BracketRight", key: "]", shiftedKey: "}", keyCode: 221 }, + { code: "Semicolon", key: ";", shiftedKey: ":", keyCode: 186 }, + { code: "Quote", key: "'", shiftedKey: '"', keyCode: 222 }, + { code: "Comma", key: ",", shiftedKey: "<", keyCode: 188 }, + { code: "Period", key: ".", shiftedKey: ">", keyCode: 190 }, + { code: "Slash", key: "/", shiftedKey: "?", keyCode: 191 }, +]; + +const modifierMask = (modifiers: PreviewAutomationPressInput["modifiers"]): number => + (modifiers ?? []).reduce((value, modifier) => { + switch (modifier) { + case "Alt": + return value | 1; + case "Control": + return value | 2; + case "Meta": + return value | 4; + case "Shift": + return value | 8; + } + }, 0); + +function resolveKeyDefinition(input: PreviewAutomationPressInput): KeyDefinition { + const named = NAMED_KEYS[input.key]; + if (named) return named; + + const functionKey = /^F([1-9]|1[0-2])$/.exec(input.key); + if (functionKey) { + const number = Number(functionKey[1]); + return { code: input.key, key: input.key, keyCode: 111 + number }; + } + + if (/^[a-z]$/i.test(input.key)) { + const upper = input.key.toUpperCase(); + const shifted = input.modifiers?.includes("Shift") ?? false; + const key = shifted || input.key === upper ? upper : input.key; + return { code: `Key${upper}`, key, keyCode: upper.charCodeAt(0), text: key }; + } + + const printable = PRINTABLE_KEYS.find( + (definition) => definition.key === input.key || definition.shiftedKey === input.key, + ); + if (printable) { + const shifted = input.modifiers?.includes("Shift") ?? false; + const key = + printable.shiftedKey && (shifted || input.key === printable.shiftedKey) + ? printable.shiftedKey + : printable.key; + return { ...printable, key, text: key }; + } + + return { + code: input.key.length > 1 ? input.key : "", + key: input.key, + keyCode: 0, + ...(input.key.length === 1 ? { text: input.key } : {}), + }; +} + +/** + * Build Chromium CDP key packets using the same required fields and down-event + * choice as Playwright's pinned Chromium keyboard implementation. + */ +export function makePreviewAutomationKeySequence( + input: PreviewAutomationPressInput, +): PreviewAutomationKeySequence { + const definition = resolveKeyDefinition(input); + const modifiers = modifierMask(input.modifiers); + const suppressText = input.modifiers?.some((modifier) => modifier !== "Shift") ?? false; + const text = suppressText ? "" : (definition.text ?? ""); + const location = definition.location ?? 0; + const shared = { + key: definition.key, + code: definition.code, + modifiers, + windowsVirtualKeyCode: definition.keyCode, + location, + isKeypad: location === 3, + }; + + return { + keyDown: { + type: text ? "keyDown" : "rawKeyDown", + ...shared, + ...(text ? { text, unmodifiedText: text } : {}), + }, + keyUp: { type: "keyUp", ...shared }, + signal: { kind: "key", key: definition.key, code: definition.code }, + }; +} diff --git a/apps/desktop/src/window/DesktopWindow.test.ts b/apps/desktop/src/window/DesktopWindow.test.ts index 76413dd0b5..7b9bdaf088 100644 --- a/apps/desktop/src/window/DesktopWindow.test.ts +++ b/apps/desktop/src/window/DesktopWindow.test.ts @@ -4,6 +4,7 @@ import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; import * as Option from "effect/Option"; import * as Ref from "effect/Ref"; +import * as TestClock from "effect/testing/TestClock"; import type * as Electron from "electron"; import { vi } from "vite-plus/test"; @@ -47,12 +48,14 @@ function makeFakeBrowserWindow() { const webContentsListeners = new Map void>(); const webContents = { copyImageAt: vi.fn(), + getURL: vi.fn(() => "t3code-dev://app/"), isLoadingMainFrame: vi.fn(() => false), on: vi.fn((eventName: string, listener: (...args: readonly unknown[]) => void) => { webContentsListeners.set(eventName, listener); }), once: vi.fn(), openDevTools: vi.fn(), + reload: vi.fn(), replaceMisspelling: vi.fn(), send: vi.fn(), setWindowOpenHandler: vi.fn(), @@ -79,6 +82,7 @@ function makeFakeBrowserWindow() { window: window as unknown as Electron.BrowserWindow, loadURL: window.loadURL, openDevTools: webContents.openDevTools, + reload: webContents.reload, setAutoHideCursor: window.setAutoHideCursor, webContentsListeners, }; @@ -237,6 +241,73 @@ describe("DesktopWindow", () => { }), ); + it.effect("recovers when the development renderer is temporarily unreachable", () => + Effect.gen(function* () { + const fakeWindow = makeFakeBrowserWindow(); + const createCount = yield* Ref.make(0); + const mainWindow = yield* Ref.make>(Option.none()); + const layer = makeTestLayer({ + window: fakeWindow.window, + createCount, + mainWindow, + }); + + yield* Effect.gen(function* () { + const desktopWindow = yield* DesktopWindow.DesktopWindow; + yield* desktopWindow.handleBackendReady; + + const didFailLoad = fakeWindow.webContentsListeners.get("did-fail-load"); + const didFinishLoad = fakeWindow.webContentsListeners.get("did-finish-load"); + if (!didFailLoad || !didFinishLoad) { + return yield* Effect.die("renderer load listeners were not registered"); + } + + didFailLoad({}, -9, "ERR_UNEXPECTED", "t3code-dev://app/", true); + assert.equal(fakeWindow.loadURL.mock.calls.length, 1); + + yield* TestClock.adjust(100); + assert.deepEqual(fakeWindow.loadURL.mock.calls, [ + ["t3code-dev://app/"], + ["t3code-dev://app/"], + ]); + assert.equal(fakeWindow.reload.mock.calls.length, 0); + + didFailLoad({}, -9, "ERR_UNEXPECTED", "t3code-dev://app/", true); + didFinishLoad(); + yield* TestClock.adjust(250); + assert.equal(fakeWindow.loadURL.mock.calls.length, 2); + assert.equal(fakeWindow.reload.mock.calls.length, 0); + }).pipe(Effect.provide(layer)); + }), + ); + + it("retries only transient failures for the development renderer", () => { + assert.isTrue( + DesktopWindow.isRetryableDevelopmentRendererLoadFailure({ + applicationUrl: "t3code-dev://app/", + errorCode: -102, + isMainFrame: true, + validatedUrl: "t3code-dev://app/", + }), + ); + assert.isFalse( + DesktopWindow.isRetryableDevelopmentRendererLoadFailure({ + applicationUrl: "t3code-dev://app/", + errorCode: -3, + isMainFrame: true, + validatedUrl: "t3code-dev://app/", + }), + ); + assert.isFalse( + DesktopWindow.isRetryableDevelopmentRendererLoadFailure({ + applicationUrl: "t3code-dev://app/", + errorCode: -102, + isMainFrame: true, + validatedUrl: "https://example.com/", + }), + ); + }); + it.effect("opens safe off-origin renderer navigations in the system browser", () => Effect.gen(function* () { const fakeWindow = makeFakeBrowserWindow(); diff --git a/apps/desktop/src/window/DesktopWindow.ts b/apps/desktop/src/window/DesktopWindow.ts index e6cfce3c54..41bbbfd594 100644 --- a/apps/desktop/src/window/DesktopWindow.ts +++ b/apps/desktop/src/window/DesktopWindow.ts @@ -1,5 +1,6 @@ import * as Context from "effect/Context"; import * as Effect from "effect/Effect"; +import * as Fiber from "effect/Fiber"; import * as Layer from "effect/Layer"; import * as Option from "effect/Option"; import * as Ref from "effect/Ref"; @@ -22,6 +23,16 @@ const TITLEBAR_HEIGHT = 40; const TITLEBAR_COLOR = "#01000000"; // #00000000 does not work correctly on Linux const TITLEBAR_LIGHT_SYMBOL_COLOR = "#1f2937"; const TITLEBAR_DARK_SYMBOL_COLOR = "#f8fafc"; +const DEVELOPMENT_LOAD_RETRY_DELAYS_MS = [100, 250, 500, 1_000, 2_000] as const; +const DEVELOPMENT_RETRYABLE_LOAD_ERROR_CODES = new Set([ + -2, // ERR_FAILED + -7, // ERR_TIMED_OUT + -9, // ERR_UNEXPECTED (custom protocol handler rejected) + -102, // ERR_CONNECTION_REFUSED + -105, // ERR_NAME_NOT_RESOLVED + -106, // ERR_INTERNET_DISCONNECTED + -118, // ERR_CONNECTION_TIMED_OUT +]); type WindowTitleBarOptions = Pick< Electron.BrowserWindowConstructorOptions, @@ -86,6 +97,22 @@ export function isSameOriginRendererNavigation(input: { } } +export function isRetryableDevelopmentRendererLoadFailure(input: { + readonly applicationUrl: string; + readonly errorCode: number; + readonly isMainFrame: boolean; + readonly validatedUrl: string; +}): boolean { + return ( + input.isMainFrame && + DEVELOPMENT_RETRYABLE_LOAD_ERROR_CODES.has(input.errorCode) && + isSameOriginRendererNavigation({ + applicationUrl: input.applicationUrl, + navigationUrl: input.validatedUrl, + }) + ); +} + function getWindowTitleBarOptions( shouldUseDarkColors: boolean, platform: NodeJS.Platform, @@ -152,6 +179,7 @@ export const make = Effect.gen(function* () { const previewManager = yield* PreviewManager.PreviewManager; const state = yield* DesktopState.DesktopState; const context = yield* Effect.context(); + const runFork = Effect.runForkWith(context); const runPromise = Effect.runPromiseWith(context); const createWindow = Effect.fn("desktop.window.createWindow")(function* (): Effect.fn.Return< @@ -277,7 +305,61 @@ export const make = Effect.gen(function* () { event.preventDefault(); window.setTitle(environment.displayName); }); + + let developmentLoadRetryIndex = 0; + let developmentLoadRetryFiber: Fiber.Fiber | undefined; + const clearDevelopmentLoadRetry = () => { + if (developmentLoadRetryFiber === undefined) { + return; + } + const retryFiber = developmentLoadRetryFiber; + developmentLoadRetryFiber = undefined; + runFork(Fiber.interrupt(retryFiber)); + }; + const loadApplication = () => { + if (window.isDestroyed()) { + return; + } + void window.loadURL(applicationUrl).catch(() => undefined); + }; + const scheduleDevelopmentLoadRetry = () => { + if (developmentLoadRetryFiber !== undefined || window.isDestroyed()) { + return undefined; + } + + const retryIndex = Math.min( + developmentLoadRetryIndex, + DEVELOPMENT_LOAD_RETRY_DELAYS_MS.length - 1, + ); + const retryInMs = DEVELOPMENT_LOAD_RETRY_DELAYS_MS[retryIndex] ?? 2_000; + developmentLoadRetryIndex += 1; + developmentLoadRetryFiber = runFork( + Effect.sleep(retryInMs).pipe( + Effect.andThen( + Effect.sync(() => { + developmentLoadRetryFiber = undefined; + if (!window.isDestroyed()) { + loadApplication(); + } + }), + ), + ), + ); + return retryInMs; + }; + window.webContents.on("did-finish-load", () => { + if ( + environment.isDevelopment && + !isSameOriginRendererNavigation({ + applicationUrl, + navigationUrl: window.webContents.getURL(), + }) + ) { + return; + } + clearDevelopmentLoadRetry(); + developmentLoadRetryIndex = 0; window.setTitle(environment.displayName); }); window.webContents.on( @@ -286,11 +368,22 @@ export const make = Effect.gen(function* () { if (!isMainFrame) { return; } + const retryInMs = + environment.isDevelopment && + isRetryableDevelopmentRendererLoadFailure({ + applicationUrl, + errorCode, + isMainFrame, + validatedUrl: validatedURL, + }) + ? scheduleDevelopmentLoadRetry() + : undefined; void runPromise( logWindowWarning("main window failed to load", { errorCode, errorDescription, url: validatedURL, + ...(retryInMs === undefined ? {} : { retryInMs }), }), ); }, @@ -312,14 +405,13 @@ export const make = Effect.gen(function* () { void runPromise(electronWindow.reveal(window)); }); + loadApplication(); if (environment.isDevelopment) { - void window.loadURL(applicationUrl); window.webContents.openDevTools({ mode: "detach" }); - } else { - void window.loadURL(applicationUrl); } window.on("closed", () => { + clearDevelopmentLoadRetry(); void runPromise(electronWindow.clearMain(Option.some(window))); }); diff --git a/apps/marketing/package.json b/apps/marketing/package.json index 4e01829b7f..d122dac3c5 100644 --- a/apps/marketing/package.json +++ b/apps/marketing/package.json @@ -10,7 +10,7 @@ "typecheck": "astro check" }, "dependencies": { - "astro": "^6.0.4" + "astro": "^7.0.3" }, "devDependencies": { "@astrojs/check": "^0.9.7", diff --git a/apps/server/src/http.ts b/apps/server/src/http.ts index ce9b498cb1..fc7a9ef13a 100644 --- a/apps/server/src/http.ts +++ b/apps/server/src/http.ts @@ -44,13 +44,18 @@ import { browserApiCorsAllowedHeaders, browserApiCorsAllowedMethods } from "./ht const OTLP_TRACES_PROXY_PATH = "/api/observability/v1/traces"; const LOOPBACK_HOSTNAMES = new Set(["127.0.0.1", "::1", "localhost"]); +const DESKTOP_RENDERER_ORIGINS = ["t3code://app", "t3code-dev://app"]; export const browserApiCorsLayer = Layer.unwrap( Effect.gen(function* () { const config = yield* ServerConfig.ServerConfig; const devOrigin = config.devUrl?.origin; + // Dev uses credentialed requests from Vite or the Electron custom origin, so both must be + // explicit. Packaged desktop omits credentials and uses Effect's default wildcard origin. return HttpRouter.cors({ - ...(devOrigin ? { allowedOrigins: [devOrigin], credentials: true } : {}), + ...(devOrigin + ? { allowedOrigins: [devOrigin, ...DESKTOP_RENDERER_ORIGINS], credentials: true } + : {}), allowedMethods: browserApiCorsAllowedMethods, allowedHeaders: browserApiCorsAllowedHeaders, maxAge: 600, diff --git a/apps/server/src/mcp/McpHttpServer.test.ts b/apps/server/src/mcp/McpHttpServer.test.ts index 74ac293143..2e2195fdac 100644 --- a/apps/server/src/mcp/McpHttpServer.test.ts +++ b/apps/server/src/mcp/McpHttpServer.test.ts @@ -1,5 +1,6 @@ import { expect, it } from "@effect/vitest"; import { NodeHttpServer } from "@effect/platform-node"; +import * as NodeServices from "@effect/platform-node/NodeServices"; import { EnvironmentId, PreviewTabId, ProviderInstanceId, ThreadId } from "@t3tools/contracts"; import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; @@ -33,7 +34,7 @@ const client = McpSchema.McpServerClient.of({ }); const TestLayer = McpHttpServer.PreviewToolkitRegistrationLive.pipe( Layer.provideMerge(McpServer.McpServer.layer), - Layer.provideMerge(PreviewAutomationBroker.layer), + Layer.provideMerge(PreviewAutomationBroker.layer.pipe(Layer.provide(NodeServices.layer))), ); it("normalizes empty successful notification responses to accepted", () => { @@ -53,36 +54,26 @@ it.effect("returns bounded structural preview snapshot failures", () => Effect.gen(function* () { const server = yield* McpServer.McpServer; const broker = yield* PreviewAutomationBroker.PreviewAutomationBroker; - const requests = yield* broker.connect({ + const events = yield* broker.connect({ clientId: "mcp-failure-client", environmentId, - threadId, - tabId, - visible: true, - supportsAutomation: true, - focusedAt: "2026-06-11T00:00:00.000Z", }); - yield* Stream.runForEach(requests, (request) => - broker.respond({ - requestId: request.requestId, - ok: false, - error: { - _tag: "PreviewAutomationExecutionError", - message: "sensitive renderer failure", - detail: { consoleOutput: "sensitive browser output" }, - }, - }), + yield* Stream.runForEach(events, (event) => + event.type === "connected" + ? Effect.void + : broker.respond({ + clientId: "mcp-failure-client", + connectionId: event.connectionId, + requestId: event.request.requestId, + ok: false, + error: { + _tag: "PreviewAutomationExecutionError", + message: "sensitive renderer failure", + detail: { consoleOutput: "sensitive browser output" }, + }, + }), ).pipe(Effect.forkScoped); yield* Effect.yieldNow; - yield* broker.reportOwner({ - clientId: "mcp-failure-client", - environmentId, - threadId, - tabId, - visible: true, - supportsAutomation: true, - focusedAt: "2026-06-11T00:00:00.000Z", - }); const snapshot = yield* server .callTool({ name: "preview_snapshot", arguments: {} }) @@ -162,60 +153,50 @@ it.effect("registers annotated tools and preserves authenticated request context Effect.gen(function* () { const server = yield* McpServer.McpServer; const broker = yield* PreviewAutomationBroker.PreviewAutomationBroker; - const requests = yield* broker.connect({ + const events = yield* broker.connect({ clientId: "mcp-test-client", environmentId, - threadId, - tabId, - visible: true, - supportsAutomation: true, - focusedAt: "2026-06-11T00:00:00.000Z", }); - yield* Stream.runForEach(requests, (request) => - broker.respond({ - requestId: request.requestId, - ok: true, - result: - request.operation === "snapshot" - ? { - url: "http://example.test/", - title: "Example", - loading: false, - visibleText: "Example", - interactiveElements: [], - accessibilityTree: {}, - consoleEntries: [], - networkEntries: [], - actionTimeline: [], - screenshot: { - mimeType: "image/png", - data: Buffer.from("png").toString("base64"), - width: 10, - height: 5, - }, - } - : request.operation === "press" - ? undefined - : { - available: true, - visible: true, - tabId, - url: "http://example.test/", - title: "Example", - loading: false, - }, - }), + yield* Stream.runForEach(events, (event) => + event.type === "connected" + ? Effect.void + : broker.respond({ + clientId: "mcp-test-client", + connectionId: event.connectionId, + requestId: event.request.requestId, + ok: true, + result: + event.request.operation === "snapshot" + ? { + url: "http://example.test/", + title: "Example", + loading: false, + visibleText: "Example", + interactiveElements: [], + accessibilityTree: {}, + consoleEntries: [], + networkEntries: [], + actionTimeline: [], + screenshot: { + mimeType: "image/png", + data: Buffer.from("png").toString("base64"), + width: 10, + height: 5, + }, + } + : event.request.operation === "press" + ? undefined + : { + available: true, + visible: true, + tabId, + url: "http://example.test/", + title: "Example", + loading: false, + }, + }), ).pipe(Effect.forkScoped); yield* Effect.yieldNow; - yield* broker.reportOwner({ - clientId: "mcp-test-client", - environmentId, - threadId, - tabId, - visible: true, - supportsAutomation: true, - focusedAt: "2026-06-11T00:00:00.000Z", - }); const statusTool = server.tools.find(({ tool }) => tool.name === "preview_status"); expect(statusTool?.tool.annotations?.readOnlyHint).toBe(true); diff --git a/apps/server/src/mcp/McpHttpServer.ts b/apps/server/src/mcp/McpHttpServer.ts index 9e04ec5f98..01f58d0701 100644 --- a/apps/server/src/mcp/McpHttpServer.ts +++ b/apps/server/src/mcp/McpHttpServer.ts @@ -225,4 +225,4 @@ const McpTransportLive = McpServer.layerHttp({ export const layer = Layer.mergeAll( PreviewToolkitRegistrationLive, OrchestratorToolkitRegistrationLive, -).pipe(Layer.provideMerge(McpTransportLive), Layer.provide(PreviewAutomationBroker.layer)); +).pipe(Layer.provideMerge(McpTransportLive)); diff --git a/apps/server/src/mcp/PreviewAutomationBroker.test.ts b/apps/server/src/mcp/PreviewAutomationBroker.test.ts index e415620b00..6c110cdbd8 100644 --- a/apps/server/src/mcp/PreviewAutomationBroker.test.ts +++ b/apps/server/src/mcp/PreviewAutomationBroker.test.ts @@ -1,20 +1,28 @@ +import * as NodeServices from "@effect/platform-node/NodeServices"; import { expect, it } from "@effect/vitest"; import { EnvironmentId, PreviewAutomationClientDisconnectedError, PreviewAutomationInvalidSelectorError, PreviewAutomationMalformedResponseError, - PreviewAutomationNoFocusedOwnerError, + PreviewAutomationNoAvailableHostError, + PreviewAutomationTargetNotEditableError, + PreviewTabId, ProviderInstanceId, ThreadId, - type PreviewAutomationOwner, + type PreviewAutomationHost, + type PreviewAutomationRequest, + type PreviewAutomationStreamEvent, } from "@t3tools/contracts"; import * as Effect from "effect/Effect"; import * as Fiber from "effect/Fiber"; +import * as Result from "effect/Result"; import * as Stream from "effect/Stream"; import * as PreviewAutomationBroker from "./PreviewAutomationBroker.ts"; +const makeBroker = PreviewAutomationBroker.make.pipe(Effect.provide(NodeServices.layer)); + const scope = { environmentId: EnvironmentId.make("environment-1"), threadId: ThreadId.make("thread-1"), @@ -24,24 +32,39 @@ const scope = { issuedAt: 1, }; -const makeOwner = (overrides: Partial = {}): PreviewAutomationOwner => ({ +const makeHost = (overrides: Partial = {}): PreviewAutomationHost => ({ clientId: "client-1", environmentId: scope.environmentId, - threadId: scope.threadId, - tabId: null, - visible: false, - supportsAutomation: true, - focusedAt: "2026-06-11T00:00:00.000Z", ...overrides, }); -it.effect("atomically registers a connected owner and correlates its response", () => +type RoutedRequest = PreviewAutomationRequest & { + readonly connectionId: PreviewAutomationStreamEvent["connectionId"]; +}; + +const requestsFrom = ( + events: Stream.Stream, + onConnected: (connectionId: PreviewAutomationStreamEvent["connectionId"]) => void = () => {}, +): Stream.Stream => + events.pipe( + Stream.filterMap((event) => { + if (event.type === "connected") { + onConnected(event.connectionId); + return Result.failVoid; + } + return Result.succeed({ ...event.request, connectionId: event.connectionId }); + }), + ); + +it.effect("atomically registers a connected host and correlates its response", () => Effect.scoped( Effect.gen(function* () { - const broker = yield* PreviewAutomationBroker.make; - const requests = yield* broker.connect(makeOwner()); + const broker = yield* makeBroker; + const requests = requestsFrom(yield* broker.connect(makeHost())); yield* Stream.runForEach(requests, (request) => broker.respond({ + clientId: "client-1", + connectionId: request.connectionId, requestId: request.requestId, ok: true, result: { available: true }, @@ -60,6 +83,39 @@ it.effect("atomically registers a connected owner and correlates its response", ), ); +it.effect("announces a live replacement stream before delivering requests", () => + Effect.scoped( + Effect.gen(function* () { + const broker = yield* makeBroker; + const events = yield* broker.connect(makeHost()); + const receivedTypes: PreviewAutomationStreamEvent["type"][] = []; + const consumer = yield* events.pipe( + Stream.take(2), + Stream.runForEach((event) => { + receivedTypes.push(event.type); + return event.type === "connected" + ? Effect.void + : broker.respond({ + clientId: "client-1", + connectionId: event.connectionId, + requestId: event.request.requestId, + ok: true, + result: "ready", + }); + }), + Effect.forkScoped, + ); + yield* Effect.yieldNow; + + const result = yield* broker.invoke({ scope, operation: "status", input: {} }); + yield* Fiber.join(consumer); + + expect(receivedTypes).toEqual(["connected", "request"]); + expect(result).toBe("ready"); + }), + ), +); + it.effect("preserves bounded request and remote selector diagnostics", () => { const locator = "role=button[name='request-secret']"; const remoteMessage = "Unexpected token near remote-secret."; @@ -71,10 +127,12 @@ it.effect("preserves bounded request and remote selector diagnostics", () => { return Effect.scoped( Effect.gen(function* () { - const broker = yield* PreviewAutomationBroker.make; - const requests = yield* broker.connect(makeOwner({ tabId: "tab-1" })); + const broker = yield* makeBroker; + const requests = requestsFrom(yield* broker.connect(makeHost())); yield* Stream.runForEach(requests, (request) => broker.respond({ + clientId: "client-1", + connectionId: request.connectionId, requestId: request.requestId, ok: false, error: remoteError, @@ -87,6 +145,7 @@ it.effect("preserves bounded request and remote selector diagnostics", () => { scope, operation: "click", input: { locator }, + tabId: PreviewTabId.make("tab-1"), timeoutMs: 1_234, }) .pipe(Effect.flip); @@ -120,13 +179,61 @@ it.effect("preserves bounded request and remote selector diagnostics", () => { ); }); +it.effect("classifies a remote non-editable target without collapsing it to execution", () => { + const remoteError = { + _tag: "PreviewAutomationTargetNotEditableError", + message: "remote target details", + detail: { selectorKind: "focused-element" }, + } as const; + + return Effect.scoped( + Effect.gen(function* () { + const broker = yield* makeBroker; + const requests = requestsFrom(yield* broker.connect(makeHost())); + yield* Stream.runForEach(requests, (request) => + broker.respond({ + clientId: "client-1", + connectionId: request.connectionId, + requestId: request.requestId, + ok: false, + error: remoteError, + }), + ).pipe(Effect.forkScoped); + yield* Effect.yieldNow; + + const error = yield* broker + .invoke({ + scope, + operation: "type", + input: { text: "hello" }, + tabId: PreviewTabId.make("tab-1"), + }) + .pipe(Effect.flip); + + expect(error).toBeInstanceOf(PreviewAutomationTargetNotEditableError); + expect(error).toMatchObject({ + operation: "type", + tabId: "tab-1", + selectorKind: "focused-element", + remoteTag: "PreviewAutomationTargetNotEditableError", + }); + expect(error.message).toBe("Preview automation type requires an editable focused element."); + }), + ); +}); + it.effect("distinguishes malformed remote failures", () => Effect.scoped( Effect.gen(function* () { - const broker = yield* PreviewAutomationBroker.make; - const requests = yield* broker.connect(makeOwner()); + const broker = yield* makeBroker; + const requests = requestsFrom(yield* broker.connect(makeHost())); yield* Stream.runForEach(requests, (request) => - broker.respond({ requestId: request.requestId, ok: false }), + broker.respond({ + clientId: "client-1", + connectionId: request.connectionId, + requestId: request.requestId, + ok: false, + }), ).pipe(Effect.forkScoped); yield* Effect.yieldNow; @@ -149,13 +256,14 @@ it.effect("distinguishes malformed remote failures", () => ), ); -it.effect("rejects calls when no focused owner exists", () => +it.effect("rejects calls when no connected host exists", () => Effect.gen(function* () { - const broker = yield* PreviewAutomationBroker.make; + const broker = yield* makeBroker; const error = yield* broker .invoke({ scope, operation: "status", input: {} }) .pipe(Effect.flip); - expect(error).toBeInstanceOf(PreviewAutomationNoFocusedOwnerError); + + expect(error).toBeInstanceOf(PreviewAutomationNoAvailableHostError); expect(error).toMatchObject({ operation: "status", environmentId: scope.environmentId, @@ -166,32 +274,425 @@ it.effect("rejects calls when no focused owner exists", () => }), ); -it.effect("routes interactive commands to a hidden durable browser host", () => +it.effect("does not create host state from focus updates without a live stream", () => + Effect.gen(function* () { + const broker = yield* makeBroker; + yield* broker.focusHost({ + clientId: "client-1", + environmentId: scope.environmentId, + connectionId: "connection-missing", + focused: true, + }); + + const error = yield* broker + .invoke({ scope, operation: "status", input: {} }) + .pipe(Effect.flip); + expect(error).toBeInstanceOf(PreviewAutomationNoAvailableHostError); + }), +); + +it.effect("removes host availability when the authoritative request stream disconnects", () => Effect.scoped( Effect.gen(function* () { - const broker = yield* PreviewAutomationBroker.make; - const requests = yield* broker.connect( - makeOwner({ clientId: "client-hidden", tabId: "tab-hidden" }), - ); - yield* Stream.runForEach(requests, (request) => - broker.respond({ requestId: request.requestId, ok: true }), - ).pipe(Effect.forkScoped); - yield* Effect.yieldNow; + const broker = yield* makeBroker; + const requests = requestsFrom(yield* broker.connect(makeHost())); + const beforeAcquisition = yield* broker + .invoke({ scope, operation: "status", input: {} }) + .pipe(Effect.flip); + expect(beforeAcquisition).toBeInstanceOf(PreviewAutomationNoAvailableHostError); - yield* broker.invoke({ scope, operation: "click", input: { x: 10, y: 10 } }); + const consumer = yield* Stream.runDrain(requests).pipe(Effect.forkScoped); + yield* Effect.yieldNow; + yield* Fiber.interrupt(consumer); + + const error = yield* broker + .invoke({ scope, operation: "status", input: {} }) + .pipe(Effect.flip); + expect(error).toBeInstanceOf(PreviewAutomationNoAvailableHostError); }), ), ); -it.effect("lets the browser host resolve an active tab that has not been reported yet", () => +it.effect("routes requests for background threads through an environment-level host", () => Effect.scoped( Effect.gen(function* () { - const broker = yield* PreviewAutomationBroker.make; - const requests = yield* broker.connect(makeOwner({ tabId: null })); + const broker = yield* makeBroker; + const backgroundThreadId = ThreadId.make("thread-background"); + const requests = requestsFrom(yield* broker.connect(makeHost())); + let routedThreadId: string | undefined; + yield* Stream.runForEach(requests, (request) => { + routedThreadId = request.threadId; + return broker.respond({ + clientId: "client-1", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "background", + }); + }).pipe(Effect.forkScoped); + yield* Effect.yieldNow; + + const result = yield* broker.invoke({ + scope: { + ...scope, + threadId: backgroundThreadId, + providerSessionId: "provider-session-background", + }, + operation: "status", + input: {}, + }); + + expect(result).toBe("background"); + expect(routedThreadId).toBe(backgroundThreadId); + }), + ), +); + +it.effect("never routes a provider session to a host from another environment", () => + Effect.scoped( + Effect.gen(function* () { + const broker = yield* makeBroker; + const matchingRequests = requestsFrom( + yield* broker.connect(makeHost({ clientId: "client-matching" })), + ); + const foreignRequests = requestsFrom( + yield* broker.connect( + makeHost({ + clientId: "client-foreign", + environmentId: EnvironmentId.make("environment-foreign"), + }), + ), + ); + yield* Stream.runForEach(matchingRequests, (request) => + broker.respond({ + clientId: "client-matching", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "matching", + }), + ).pipe(Effect.forkScoped); + yield* Stream.runForEach(foreignRequests, (request) => + broker.respond({ + clientId: "client-foreign", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "foreign", + }), + ).pipe(Effect.forkScoped); + yield* Effect.yieldNow; + + expect(yield* broker.invoke({ scope, operation: "status", input: {} })).toBe( + "matching", + ); + }), + ), +); + +it.effect("pins a provider session to its initial host despite later focus changes", () => + Effect.scoped( + Effect.gen(function* () { + const broker = yield* makeBroker; + let firstConnectionId = ""; + let secondConnectionId = ""; + const firstRequests = requestsFrom( + yield* broker.connect(makeHost({ clientId: "client-first" })), + (connectionId) => { + firstConnectionId = connectionId; + }, + ); + const secondRequests = requestsFrom( + yield* broker.connect(makeHost({ clientId: "client-second" })), + (connectionId) => { + secondConnectionId = connectionId; + }, + ); + yield* Stream.runForEach(firstRequests, (request) => + broker.respond({ + clientId: "client-first", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "first", + }), + ).pipe(Effect.forkScoped); + yield* Stream.runForEach(secondRequests, (request) => + broker.respond({ + clientId: "client-second", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "second", + }), + ).pipe(Effect.forkScoped); + yield* Effect.yieldNow; + + yield* broker.focusHost({ + clientId: "client-first", + environmentId: scope.environmentId, + connectionId: "connection-stale", + focused: true, + }); + expect(yield* broker.invoke({ scope, operation: "status", input: {} })).toBe( + "second", + ); + yield* broker.focusHost({ + clientId: "client-first", + environmentId: scope.environmentId, + connectionId: firstConnectionId, + focused: true, + }); + + const firstPinnedScope = { + ...scope, + providerSessionId: "provider-session-first-pinned", + }; + expect( + yield* broker.invoke({ scope: firstPinnedScope, operation: "status", input: {} }), + ).toBe("first"); + + yield* broker.focusHost({ + clientId: "client-second", + environmentId: scope.environmentId, + connectionId: secondConnectionId, + focused: true, + }); + + expect( + yield* broker.invoke({ scope: firstPinnedScope, operation: "status", input: {} }), + ).toBe("first"); + expect( + yield* broker.invoke({ + scope: { ...scope, providerSessionId: "provider-session-second-pinned" }, + operation: "status", + input: {}, + }), + ).toBe("second"); + }), + ), +); + +it.effect("does not route new operations to legacy hosts that did not advertise support", () => + Effect.scoped( + Effect.gen(function* () { + const broker = yield* makeBroker; + const legacyEvents = yield* broker.connect(makeHost()); + yield* Stream.runDrain(legacyEvents).pipe(Effect.forkScoped); + yield* Effect.yieldNow; + + const error = yield* broker + .invoke({ scope, operation: "resize", input: { mode: "fill" } }) + .pipe(Effect.flip); + + expect(error).toBeInstanceOf(PreviewAutomationNoAvailableHostError); + expect(error).toMatchObject({ operation: "resize", environmentId: scope.environmentId }); + }), + ), +); + +it.effect("routes resize to a capable host instead of a newer legacy connection", () => + Effect.scoped( + Effect.gen(function* () { + const broker = yield* makeBroker; + const capableRequests = requestsFrom( + yield* broker.connect( + makeHost({ clientId: "client-capable", supportedOperations: ["resize"] }), + ), + ); + const legacyRequests = requestsFrom( + yield* broker.connect(makeHost({ clientId: "client-legacy" })), + ); + yield* Stream.runForEach(capableRequests, (request) => + broker.respond({ + clientId: "client-capable", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "capable", + }), + ).pipe(Effect.forkScoped); + yield* Stream.runForEach(legacyRequests, (request) => + broker.respond({ + clientId: "client-legacy", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "legacy", + }), + ).pipe(Effect.forkScoped); + yield* Effect.yieldNow; + + expect( + yield* broker.invoke({ scope, operation: "resize", input: { mode: "fill" } }), + ).toBe("capable"); + }), + ), +); + +it.effect("does not move a live legacy assignment to another runtime for resize", () => + Effect.scoped( + Effect.gen(function* () { + const broker = yield* makeBroker; + const legacyRequests = requestsFrom( + yield* broker.connect(makeHost({ clientId: "client-legacy" })), + ); + yield* Stream.runForEach(legacyRequests, (request) => + broker.respond({ + clientId: "client-legacy", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "legacy", + }), + ).pipe(Effect.forkScoped); + yield* Effect.yieldNow; + + expect(yield* broker.invoke({ scope, operation: "status", input: {} })).toBe( + "legacy", + ); + + const capableRequests = requestsFrom( + yield* broker.connect( + makeHost({ clientId: "client-capable", supportedOperations: ["resize"] }), + ), + ); + yield* Stream.runForEach(capableRequests, (request) => + broker.respond({ + clientId: "client-capable", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "capable", + }), + ).pipe(Effect.forkScoped); + yield* Effect.yieldNow; + + const error = yield* broker + .invoke({ scope, operation: "resize", input: { mode: "fill" } }) + .pipe(Effect.flip); + expect(error).toBeInstanceOf(PreviewAutomationNoAvailableHostError); + expect(yield* broker.invoke({ scope, operation: "status", input: {} })).toBe( + "legacy", + ); + }), + ), +); + +it.effect("ignores stale focus updates for a different environment", () => + Effect.scoped( + Effect.gen(function* () { + const broker = yield* makeBroker; + let firstConnectionId = ""; + const firstRequests = requestsFrom( + yield* broker.connect(makeHost({ clientId: "client-first" })), + (connectionId) => { + firstConnectionId = connectionId; + }, + ); + const secondRequests = requestsFrom( + yield* broker.connect(makeHost({ clientId: "client-second" })), + ); + yield* Stream.runForEach(firstRequests, (request) => + broker.respond({ + clientId: "client-first", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "first", + }), + ).pipe(Effect.forkScoped); + yield* Stream.runForEach(secondRequests, (request) => + broker.respond({ + clientId: "client-second", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "second", + }), + ).pipe(Effect.forkScoped); + yield* Effect.yieldNow; + + yield* broker.focusHost({ + clientId: "client-first", + environmentId: EnvironmentId.make("environment-stale"), + connectionId: firstConnectionId, + focused: true, + }); + + expect(yield* broker.invoke({ scope, operation: "status", input: {} })).toBe( + "second", + ); + }), + ), +); + +it.effect("fails over a pinned provider session only after its host disconnects", () => + Effect.scoped( + Effect.gen(function* () { + const broker = yield* makeBroker; + let firstConnectionId = ""; + const firstRequests = requestsFrom( + yield* broker.connect(makeHost({ clientId: "client-first" })), + (connectionId) => { + firstConnectionId = connectionId; + }, + ); + const secondRequests = requestsFrom( + yield* broker.connect(makeHost({ clientId: "client-second" })), + ); + const firstConsumer = yield* Stream.runForEach(firstRequests, (request) => + broker.respond({ + clientId: "client-first", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "first", + }), + ).pipe(Effect.forkScoped); + yield* Stream.runForEach(secondRequests, (request) => + broker.respond({ + clientId: "client-second", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "second", + }), + ).pipe(Effect.forkScoped); + yield* Effect.yieldNow; + + yield* broker.focusHost({ + clientId: "client-first", + environmentId: scope.environmentId, + connectionId: firstConnectionId, + focused: true, + }); + expect(yield* broker.invoke({ scope, operation: "status", input: {} })).toBe("first"); + + yield* Fiber.interrupt(firstConsumer); + yield* Effect.yieldNow; + + expect(yield* broker.invoke({ scope, operation: "status", input: {} })).toBe( + "second", + ); + }), + ), +); + +it.effect("lets the browser host resolve an active tab locally", () => + Effect.scoped( + Effect.gen(function* () { + const broker = yield* makeBroker; + const requests = requestsFrom(yield* broker.connect(makeHost())); let routedTabId: string | undefined; yield* Stream.runForEach(requests, (request) => { routedTabId = request.tabId; - return broker.respond({ requestId: request.requestId, ok: true }); + return broker.respond({ + clientId: "client-1", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + }); }).pipe(Effect.forkScoped); yield* Effect.yieldNow; @@ -202,61 +703,55 @@ it.effect("lets the browser host resolve an active tab that has not been reporte ), ); -it.effect("preserves current owner metadata when its request stream reconnects", () => +it.effect("keeps a replacement stream authoritative when the old stream finalizes", () => Effect.scoped( Effect.gen(function* () { - const broker = yield* PreviewAutomationBroker.make; - const firstRequests = yield* broker.connect(makeOwner()); + const broker = yield* makeBroker; + let firstConnectionId = ""; + let replacementConnectionId = ""; + const firstRequests = requestsFrom(yield* broker.connect(makeHost()), (connectionId) => { + firstConnectionId = connectionId; + }); yield* Stream.runDrain(firstRequests).pipe(Effect.forkScoped); - yield* broker.reportOwner(makeOwner({ tabId: "tab-current", visible: true })); - - const reconnectedRequests = yield* broker.connect(makeOwner()); - let routedTabId: string | undefined; - yield* Stream.runForEach(reconnectedRequests, (request) => { - routedTabId = request.tabId; - return broker.respond({ requestId: request.requestId, ok: true }); - }).pipe(Effect.forkScoped); yield* Effect.yieldNow; - yield* broker.invoke({ scope, operation: "click", input: { x: 10, y: 10 } }); - - expect(routedTabId).toBe("tab-current"); - }), - ), -); - -it.effect("ignores stale owner cleanup after the client moves to another thread", () => - Effect.scoped( - Effect.gen(function* () { - const broker = yield* PreviewAutomationBroker.make; - const requests = yield* broker.connect(makeOwner()); - yield* Stream.runForEach(requests, (request) => - broker.respond({ requestId: request.requestId, ok: true }), + const replacementRequests = requestsFrom( + yield* broker.connect(makeHost()), + (connectionId) => { + replacementConnectionId = connectionId; + }, + ); + yield* Stream.runForEach(replacementRequests, (request) => + broker.respond({ + clientId: "client-1", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "replacement", + }), ).pipe(Effect.forkScoped); yield* Effect.yieldNow; - yield* broker.clearOwner({ - clientId: "client-1", - environmentId: scope.environmentId, - threadId: ThreadId.make("thread-stale"), - }); - - yield* broker.invoke({ scope, operation: "status", input: {} }); + expect(replacementConnectionId).not.toBe(firstConnectionId); + const result = yield* broker.invoke({ scope, operation: "status", input: {} }); + expect(result).toBe("replacement"); }), ), ); -it.effect("fails requests assigned to a browser stream when that stream reconnects", () => +it.effect("fails requests assigned to the stream that is replaced", () => Effect.scoped( Effect.gen(function* () { - const broker = yield* PreviewAutomationBroker.make; - const _requests = yield* broker.connect(makeOwner()); + const broker = yield* makeBroker; + const requests = requestsFrom(yield* broker.connect(makeHost())); + yield* Stream.runDrain(requests).pipe(Effect.forkScoped); const pending = yield* broker .invoke({ scope, operation: "status", input: {} }) .pipe(Effect.flip, Effect.forkScoped); yield* Effect.yieldNow; - const _replacementRequests = yield* broker.connect(makeOwner()); + const replacementRequests = requestsFrom(yield* broker.connect(makeHost())); + yield* Stream.runDrain(replacementRequests).pipe(Effect.forkScoped); const error = yield* Fiber.join(pending); expect(error).toBeInstanceOf(PreviewAutomationClientDisconnectedError); @@ -274,25 +769,40 @@ it.effect("fails requests assigned to a browser stream when that stream reconnec ), ); -it.effect("falls back to an older connected owner when a newer report is not connected", () => +it.effect("accepts responses only from the host that received the request", () => Effect.scoped( Effect.gen(function* () { - const broker = yield* PreviewAutomationBroker.make; - const requests = yield* broker.connect(makeOwner({ clientId: "client-connected" })); + const broker = yield* makeBroker; + const requests = requestsFrom(yield* broker.connect(makeHost())); yield* Stream.runForEach(requests, (request) => - broker.respond({ requestId: request.requestId, ok: true, result: "connected" }), + Effect.gen(function* () { + yield* broker.respond({ + clientId: "client-foreign", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "foreign", + }); + yield* broker.respond({ + clientId: "client-1", + connectionId: "connection-stale", + requestId: request.requestId, + ok: true, + result: "stale", + }); + yield* broker.respond({ + clientId: "client-1", + connectionId: request.connectionId, + requestId: request.requestId, + ok: true, + result: "owner", + }); + }), ).pipe(Effect.forkScoped); yield* Effect.yieldNow; - yield* broker.reportOwner( - makeOwner({ - clientId: "client-report-only", - focusedAt: "2026-06-11T00:00:01.000Z", - }), - ); const result = yield* broker.invoke({ scope, operation: "status", input: {} }); - - expect(result).toBe("connected"); + expect(result).toBe("owner"); }), ), ); diff --git a/apps/server/src/mcp/PreviewAutomationBroker.ts b/apps/server/src/mcp/PreviewAutomationBroker.ts index a2bdb95f06..673aefb1ed 100644 --- a/apps/server/src/mcp/PreviewAutomationBroker.ts +++ b/apps/server/src/mcp/PreviewAutomationBroker.ts @@ -1,26 +1,28 @@ import { + PREVIEW_AUTOMATION_V1_OPERATIONS, PreviewAutomationClientDisconnectedError, PreviewAutomationControlInterruptedError, PreviewAutomationExecutionError, - PreviewAutomationHostNotConnectedError, PreviewAutomationInvalidSelectorError, PreviewAutomationMalformedResponseError, - PreviewAutomationNoFocusedOwnerError, + PreviewAutomationNoAvailableHostError, PreviewAutomationRemoteUnavailableError, PreviewAutomationRequestQueueClosedError, PreviewAutomationResultTooLargeError, PreviewAutomationTabNotFoundError, + PreviewAutomationTargetNotEditableError, PreviewAutomationTimeoutError, PreviewAutomationUnsupportedClientError, type PreviewAutomationError, type PreviewAutomationOperation, - type PreviewAutomationOwner, - type PreviewAutomationOwnerIdentity, - type PreviewAutomationRequest, + type PreviewAutomationHost, + type PreviewAutomationHostFocus, type PreviewAutomationResponse, + type PreviewAutomationStreamEvent, type PreviewTabId, } from "@t3tools/contracts"; import * as Context from "effect/Context"; +import * as Crypto from "effect/Crypto"; import * as Deferred from "effect/Deferred"; import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; @@ -43,12 +45,9 @@ export class PreviewAutomationBroker extends Context.Service< PreviewAutomationBroker, { readonly connect: ( - owner: PreviewAutomationOwner, - ) => Effect.Effect>; - readonly reportOwner: ( - owner: PreviewAutomationOwner, - ) => Effect.Effect; - readonly clearOwner: (owner: PreviewAutomationOwnerIdentity) => Effect.Effect; + host: PreviewAutomationHost, + ) => Effect.Effect>; + readonly focusHost: (host: PreviewAutomationHostFocus) => Effect.Effect; readonly respond: ( response: PreviewAutomationResponse, ) => Effect.Effect; @@ -60,7 +59,12 @@ export class PreviewAutomationBroker extends Context.Service< interface ClientConnection { readonly clientId: string; - readonly queue: Queue.Queue; + readonly connectionId: string; + readonly environmentId: PreviewAutomationHost["environmentId"]; + readonly supportedOperations: ReadonlySet; + readonly focused: boolean; + readonly focusOrder: number; + readonly queue: Queue.Queue; } interface PendingRequest { @@ -69,6 +73,12 @@ interface PendingRequest { readonly context: PreviewAutomationRequestErrorContext; } +interface HostAssignment { + readonly clientId: ClientConnection["clientId"]; + readonly connectionId: ClientConnection["connectionId"]; + readonly queue: ClientConnection["queue"]; +} + interface PreviewAutomationRequestErrorContext { readonly operation: PreviewAutomationOperation; readonly environmentId: McpInvocationContext.McpInvocationScope["environmentId"]; @@ -76,6 +86,7 @@ interface PreviewAutomationRequestErrorContext { readonly providerSessionId: string; readonly providerInstanceId: McpInvocationContext.McpInvocationScope["providerInstanceId"]; readonly clientId: string; + readonly connectionId: ClientConnection["connectionId"]; readonly requestId: string; readonly tabId?: PreviewTabId; readonly timeoutMs: number; @@ -85,11 +96,36 @@ interface PreviewAutomationRequestErrorContext { interface BrokerState { readonly clients: ReadonlyMap; - readonly owners: ReadonlyMap; + readonly assignments: ReadonlyMap; readonly pending: ReadonlyMap; readonly requestSequence: number; + readonly focusSequence: number; } +const removeConnectionFromState = ( + current: BrokerState, + clientId: string, + queue: ClientConnection["queue"], +): { readonly state: BrokerState; readonly disconnected: ReadonlyArray } => { + const clients = new Map(current.clients); + const assignments = new Map(current.assignments); + const pending = new Map(current.pending); + const disconnected: PendingRequest[] = []; + if (current.clients.get(clientId)?.queue === queue) clients.delete(clientId); + for (const [assignmentKey, assignment] of assignments) { + if (assignment.queue === queue) assignments.delete(assignmentKey); + } + for (const [requestId, entry] of pending) { + if (entry.queue !== queue) continue; + pending.delete(requestId); + disconnected.push(entry); + } + return { + state: { ...current, clients, assignments, pending }, + disconnected, + }; +}; + const selectorDiagnosticsFromInput = ( input: unknown, ): Pick => { @@ -103,6 +139,14 @@ const selectorDiagnosticsFromInput = ( return {}; }; +const hostAssignmentKey = (scope: McpInvocationContext.McpInvocationScope): string => + `${scope.environmentId}\u0000${scope.providerSessionId}`; + +const supportsOperation = ( + connection: ClientConnection, + operation: PreviewAutomationOperation, +): boolean => connection.supportedOperations.has(operation); + type RemoteDetailKind = "null" | "array" | "object" | "string" | "number" | "boolean"; function remoteDetailKind(detail: unknown): RemoteDetailKind { @@ -131,8 +175,8 @@ const classifyResponseError = ( cause: error, }; switch (error._tag) { - case "PreviewAutomationNoFocusedOwnerError": - return new PreviewAutomationNoFocusedOwnerError({ + case "PreviewAutomationNoAvailableHostError": + return new PreviewAutomationNoAvailableHostError({ ...context, ...remoteDiagnostics, }); @@ -162,6 +206,36 @@ const classifyResponseError = ( ...remoteDiagnostics, }); } + case "PreviewAutomationTargetNotEditableError": { + const detail = + typeof error.detail === "object" && error.detail !== null ? error.detail : undefined; + const remoteSelectorKind = + detail && + "selectorKind" in detail && + (detail.selectorKind === "focused-element" || + detail.selectorKind === "locator" || + detail.selectorKind === "selector") + ? detail.selectorKind + : undefined; + const remoteSelectorLength = + detail && + "selectorLength" in detail && + typeof detail.selectorLength === "number" && + Number.isInteger(detail.selectorLength) && + detail.selectorLength >= 0 + ? detail.selectorLength + : undefined; + return new PreviewAutomationTargetNotEditableError({ + ...context, + ...remoteDiagnostics, + ...(remoteSelectorKind === undefined && context.selectorKind === undefined + ? {} + : { selectorKind: remoteSelectorKind ?? context.selectorKind }), + ...(remoteSelectorLength === undefined && context.selectorLength === undefined + ? {} + : { selectorLength: remoteSelectorLength ?? context.selectorLength }), + }); + } case "PreviewAutomationResultTooLargeError": { const detail = typeof error.detail === "object" && error.detail !== null ? error.detail : undefined; @@ -193,36 +267,21 @@ const classifyResponseError = ( }; export const make = Effect.gen(function* PreviewAutomationBrokerMake() { + const crypto = yield* Crypto.Crypto; const state = yield* SynchronizedRef.make({ clients: new Map(), - owners: new Map(), + assignments: new Map(), pending: new Map(), requestSequence: 0, + focusSequence: 0, }); - const disconnect = Effect.fn("PreviewAutomationBroker.disconnect")(function* ( - clientId: string, + const closeConnection = Effect.fn("PreviewAutomationBroker.closeConnection")(function* ( queue: ClientConnection["queue"], + disconnected: ReadonlyArray, ) { - const toFail = yield* SynchronizedRef.modify(state, (current) => { - const clients = new Map(current.clients); - const owners = new Map(current.owners); - const pending = new Map(current.pending); - const disconnected: PendingRequest[] = []; - if (current.clients.get(clientId)?.queue === queue) { - clients.delete(clientId); - owners.delete(clientId); - } - for (const [requestId, entry] of pending) { - if (entry.queue === queue) { - pending.delete(requestId); - disconnected.push(entry); - } - } - return [disconnected, { ...current, clients, owners, pending }] as const; - }); yield* Effect.forEach( - toFail, + disconnected, ({ deferred, context }) => Deferred.fail(deferred, new PreviewAutomationClientDisconnectedError(context)), { discard: true }, @@ -230,54 +289,89 @@ export const make = Effect.gen(function* PreviewAutomationBrokerMake() { yield* Queue.shutdown(queue); }); + const disconnect = Effect.fn("PreviewAutomationBroker.disconnect")(function* ( + clientId: string, + queue: ClientConnection["queue"], + ) { + const disconnected = yield* SynchronizedRef.modify(state, (current) => { + const removed = removeConnectionFromState(current, clientId, queue); + return [removed.disconnected, removed.state] as const; + }); + yield* closeConnection(queue, disconnected); + }); + + const acquireConnection = Effect.fn("PreviewAutomationBroker.acquireConnection")(function* ( + host: PreviewAutomationHost, + ) { + const clientId = host.clientId; + const queue = yield* Queue.unbounded(); + const connectionId = yield* crypto.randomUUIDv4.pipe(Effect.orDie); + yield* Queue.offer(queue, { type: "connected", connectionId }); + const connection: ClientConnection = { + clientId, + connectionId, + environmentId: host.environmentId, + supportedOperations: new Set(host.supportedOperations ?? PREVIEW_AUTOMATION_V1_OPERATIONS), + focused: false, + focusOrder: 0, + queue, + }; + const registration = yield* SynchronizedRef.modify(state, (current) => { + const previousConnection = current.clients.get(clientId); + const removed = previousConnection + ? removeConnectionFromState(current, clientId, previousConnection.queue) + : { state: current, disconnected: [] }; + const clients = new Map(removed.state.clients); + const focusSequence = removed.state.focusSequence + 1; + const registeredConnection = { ...connection, focusOrder: focusSequence }; + clients.set(clientId, registeredConnection); + return [ + { + previousConnection, + disconnected: removed.disconnected, + registeredConnection, + }, + { ...removed.state, clients, focusSequence }, + ] as const; + }); + if (registration.previousConnection) { + yield* closeConnection(registration.previousConnection.queue, registration.disconnected); + } + return registration.registeredConnection; + }); + const connect: PreviewAutomationBroker["Service"]["connect"] = Effect.fn( "PreviewAutomationBroker.connect", - )(function* (owner) { - const clientId = owner.clientId; - const queue = yield* Queue.unbounded(); - const previous = yield* SynchronizedRef.modify(state, (current) => { - const clients = new Map(current.clients); - const owners = new Map(current.owners); - const existingOwner = current.owners.get(clientId); - clients.set(clientId, { clientId, queue }); - owners.set( - clientId, - existingOwner?.environmentId === owner.environmentId && - existingOwner.threadId === owner.threadId - ? { ...existingOwner, supportsAutomation: owner.supportsAutomation } - : owner, - ); - return [current.clients.get(clientId), { ...current, clients, owners }] as const; - }); - if (previous) yield* disconnect(clientId, previous.queue); - return Stream.fromQueue(queue).pipe(Stream.ensuring(disconnect(clientId, queue))); - }); + )((host) => + Effect.succeed( + Stream.unwrap( + Effect.acquireRelease(acquireConnection(host), (connection) => + disconnect(connection.clientId, connection.queue), + ).pipe(Effect.map((connection) => Stream.fromQueue(connection.queue))), + ), + ), + ); - const reportOwner: PreviewAutomationBroker["Service"]["reportOwner"] = Effect.fn( - "PreviewAutomationBroker.reportOwner", - )(function* (owner) { + const focusHost: PreviewAutomationBroker["Service"]["focusHost"] = Effect.fn( + "PreviewAutomationBroker.focusHost", + )(function* (host) { yield* SynchronizedRef.update(state, (current) => { - const owners = new Map(current.owners); - owners.set(owner.clientId, owner); - return { ...current, owners }; - }); - }); - - const clearOwner: PreviewAutomationBroker["Service"]["clearOwner"] = Effect.fn( - "PreviewAutomationBroker.clearOwner", - )(function* (owner) { - yield* SynchronizedRef.update(state, (current) => { - const currentOwner = current.owners.get(owner.clientId); + const currentHost = current.clients.get(host.clientId); if ( - !currentOwner || - currentOwner.environmentId !== owner.environmentId || - currentOwner.threadId !== owner.threadId + !currentHost || + currentHost.environmentId !== host.environmentId || + currentHost.connectionId !== host.connectionId ) { return current; } - const owners = new Map(current.owners); - owners.delete(owner.clientId); - return { ...current, owners }; + const clients = new Map(current.clients); + const focusSequence = host.focused ? current.focusSequence + 1 : current.focusSequence; + clients.set(host.clientId, { + ...currentHost, + focused: host.focused, + focusOrder: host.focused ? focusSequence : currentHost.focusOrder, + }); + return { ...current, clients, focusSequence }; }); }); @@ -286,7 +380,13 @@ export const make = Effect.gen(function* PreviewAutomationBrokerMake() { )(function* (response) { const pending = yield* SynchronizedRef.modify(state, (current) => { const entry = current.pending.get(response.requestId); - if (!entry) return [undefined, current] as const; + if ( + !entry || + entry.context.clientId !== response.clientId || + entry.context.connectionId !== response.connectionId + ) { + return [undefined, current] as const; + } const next = new Map(current.pending); next.delete(response.requestId); return [entry, { ...current, pending: next }] as const; @@ -307,52 +407,57 @@ export const make = Effect.gen(function* PreviewAutomationBrokerMake() { const invoke = Effect.fn("PreviewAutomationBroker.invoke")(function* ( input: Parameters[0], ): Effect.fn.Return { - const current = yield* SynchronizedRef.get(state); - const candidates = Array.from(current.owners.values()) - .filter( - (owner) => - owner.environmentId === input.scope.environmentId && - owner.threadId === input.scope.threadId && - owner.supportsAutomation, - ) - .sort((left, right) => right.focusedAt.localeCompare(left.focusedAt)); - const owner = candidates.find((candidate) => current.clients.has(candidate.clientId)); - if (!owner) { - const disconnectedOwner = candidates[0]; - if (disconnectedOwner) { - return yield* new PreviewAutomationHostNotConnectedError({ - operation: input.operation, - environmentId: input.scope.environmentId, - threadId: input.scope.threadId, - providerSessionId: input.scope.providerSessionId, - providerInstanceId: input.scope.providerInstanceId, - clientId: disconnectedOwner.clientId, - }); - } - return yield* new PreviewAutomationNoFocusedOwnerError({ - operation: input.operation, - environmentId: input.scope.environmentId, - threadId: input.scope.threadId, - providerSessionId: input.scope.providerSessionId, - providerInstanceId: input.scope.providerInstanceId, - }); - } - const connection = current.clients.get(owner.clientId); - if (!connection) { - return yield* new PreviewAutomationHostNotConnectedError({ - operation: input.operation, - environmentId: input.scope.environmentId, - threadId: input.scope.threadId, - providerSessionId: input.scope.providerSessionId, - providerInstanceId: input.scope.providerInstanceId, - clientId: owner.clientId, - }); - } const timeoutMs = input.timeoutMs ?? 15_000; const deferred = yield* Deferred.make(); - const [requestId, requestContext] = yield* SynchronizedRef.modify(state, (next) => { - const requestId = `preview-${next.requestSequence}`; - const tabId = input.tabId ?? owner.tabId ?? undefined; + const route = yield* SynchronizedRef.modify(state, (current) => { + const assignments = new Map( + Array.from(current.assignments).filter(([, assignment]) => { + const connection = current.clients.get(assignment.clientId); + return ( + connection?.connectionId === assignment.connectionId && + connection.queue === assignment.queue + ); + }), + ); + const assignmentKey = hostAssignmentKey(input.scope); + const assigned = assignments.get(assignmentKey); + const assignedConnection = assigned ? current.clients.get(assigned.clientId) : undefined; + const hasLiveAssignment = assignedConnection?.environmentId === input.scope.environmentId; + // Keep one provider session on one physical desktop runtime so a + // multi-step browser interaction cannot jump between independent + // Electron cookie/DOM state. A live assignment that predates an + // operation is not silently moved to a newer client: the caller gets a + // capability failure and can deliberately start a fresh provider + // session. A dead lease is pruned above and may fail over. + const connection = + hasLiveAssignment && supportsOperation(assignedConnection, input.operation) + ? assignedConnection + : hasLiveAssignment + ? undefined + : Array.from(current.clients.values()) + .filter( + (host) => + host.environmentId === input.scope.environmentId && + supportsOperation(host, input.operation), + ) + .sort( + (left, right) => + right.supportedOperations.size - left.supportedOperations.size || + Number(right.focused) - Number(left.focused) || + right.focusOrder - left.focusOrder, + )[0]; + if (!connection) { + if (!hasLiveAssignment) assignments.delete(assignmentKey); + return [undefined, { ...current, assignments }] as const; + } + assignments.set(assignmentKey, { + clientId: connection.clientId, + connectionId: connection.connectionId, + queue: connection.queue, + }); + + const requestId = `preview-${current.requestSequence}`; + const tabId = input.tabId; const selectorDiagnostics = selectorDiagnosticsFromInput(input.input); const context: PreviewAutomationRequestErrorContext = { operation: input.operation, @@ -360,19 +465,30 @@ export const make = Effect.gen(function* PreviewAutomationBrokerMake() { threadId: input.scope.threadId, providerSessionId: input.scope.providerSessionId, providerInstanceId: input.scope.providerInstanceId, - clientId: owner.clientId, + clientId: connection.clientId, + connectionId: connection.connectionId, requestId, ...(tabId === undefined ? {} : { tabId }), timeoutMs, ...selectorDiagnostics, }; - const pending = new Map(next.pending); + const pending = new Map(current.pending); pending.set(requestId, { queue: connection.queue, deferred, context }); return [ - [requestId, context] as const, - { ...next, pending, requestSequence: next.requestSequence + 1 }, + { connection, requestId, requestContext: context }, + { ...current, assignments, pending, requestSequence: current.requestSequence + 1 }, ] as const; }); + if (!route) { + return yield* new PreviewAutomationNoAvailableHostError({ + operation: input.operation, + environmentId: input.scope.environmentId, + threadId: input.scope.threadId, + providerSessionId: input.scope.providerSessionId, + providerInstanceId: input.scope.providerInstanceId, + }); + } + const { connection, requestId, requestContext } = route; const removePending = SynchronizedRef.update(state, (next) => { if (!next.pending.has(requestId)) return next; const pending = new Map(next.pending); @@ -381,12 +497,16 @@ export const make = Effect.gen(function* PreviewAutomationBrokerMake() { }); const awaitResponse = Effect.fn("PreviewAutomationBroker.awaitResponse")(function* () { const offered = yield* Queue.offer(connection.queue, { - requestId, - threadId: input.scope.threadId, - tabId: requestContext.tabId, - operation: input.operation, - input: input.input, - timeoutMs, + type: "request", + connectionId: connection.connectionId, + request: { + requestId, + threadId: input.scope.threadId, + tabId: requestContext.tabId, + operation: input.operation, + input: input.input, + timeoutMs, + }, }); if (!offered) { const completion = yield* Deferred.poll(deferred); @@ -404,7 +524,7 @@ export const make = Effect.gen(function* PreviewAutomationBrokerMake() { return yield* awaitResponse().pipe(Effect.ensuring(removePending)); }); - return PreviewAutomationBroker.of({ connect, reportOwner, clearOwner, respond, invoke }); + return PreviewAutomationBroker.of({ connect, focusHost, respond, invoke }); }).pipe(Effect.withSpan("PreviewAutomationBroker.make")); export const layer = Layer.effect(PreviewAutomationBroker, make); diff --git a/apps/server/src/mcp/toolkits/preview/handlers.ts b/apps/server/src/mcp/toolkits/preview/handlers.ts index 6013b1cac9..700b81a0bf 100644 --- a/apps/server/src/mcp/toolkits/preview/handlers.ts +++ b/apps/server/src/mcp/toolkits/preview/handlers.ts @@ -3,6 +3,7 @@ import type { PreviewAutomationOperation, PreviewAutomationRecordingArtifact, PreviewAutomationRecordingStatus, + PreviewAutomationResizeResult, PreviewAutomationSnapshot, PreviewAutomationStatus, } from "@t3tools/contracts"; @@ -39,6 +40,8 @@ const handlers = { reuseExistingTab: input.reuseExistingTab ?? true, }), preview_navigate: (input) => invoke("navigate", input, input.timeoutMs), + preview_resize: (input) => + invoke("resize", input, input.timeoutMs), preview_snapshot: () => invoke("snapshot", {}), preview_click: (input) => invoke("click", input, input.timeoutMs).pipe(Effect.as(null)), preview_type: (input) => invoke("type", input, input.timeoutMs).pipe(Effect.as(null)), diff --git a/apps/server/src/mcp/toolkits/preview/tools.ts b/apps/server/src/mcp/toolkits/preview/tools.ts index fd2fedbb36..d9567b01c3 100644 --- a/apps/server/src/mcp/toolkits/preview/tools.ts +++ b/apps/server/src/mcp/toolkits/preview/tools.ts @@ -7,6 +7,8 @@ import { PreviewAutomationPressInput, PreviewAutomationRecordingArtifact, PreviewAutomationRecordingStatus, + PreviewAutomationResizeInput, + PreviewAutomationResizeResult, PreviewAutomationScrollInput, PreviewAutomationSnapshot, PreviewAutomationStatus, @@ -35,7 +37,7 @@ const readonlyBrowserTool = (tool: T): T => export const PreviewStatusTool = Tool.make("preview_status", { description: - "Report whether the scoped thread has an automation-capable desktop preview, including its active tab, URL, title, visibility, and loading state.", + "Report whether the scoped thread has an automation-capable desktop preview, including its active tab, URL, title, visibility, loading state, viewport mode, and measured CSS-pixel size.", success: PreviewAutomationStatus, failure: PreviewAutomationError, dependencies, @@ -69,6 +71,19 @@ export const PreviewNavigateTool = safeBrowserTool( }).annotate(Tool.Title, "Navigate browser preview"), ); +export const PreviewResizeTool = safeBrowserTool( + Tool.make("preview_resize", { + description: + "Set the active collaborative browser tab to fill-panel sizing, an independently resizable freeform size, or a Chrome-standard device preset. Use {mode:'fill'}, {mode:'freeform',width:1024,height:768}, or {mode:'preset',preset:'iphone-12-pro',orientation:'portrait'}. This changes CSS layout breakpoints without changing the desktop browser user agent.", + parameters: PreviewAutomationResizeInput, + success: PreviewAutomationResizeResult, + failure: PreviewAutomationError, + dependencies, + }) + .annotate(Tool.Title, "Resize browser viewport") + .annotate(Tool.Idempotent, true), +); + export const PreviewSnapshotTool = readonlyBrowserTool( Tool.make("preview_snapshot", { description: @@ -168,6 +183,7 @@ export const PreviewToolkit = Toolkit.make( PreviewStatusTool, PreviewOpenTool, PreviewNavigateTool, + PreviewResizeTool, PreviewSnapshotTool, PreviewClickTool, PreviewTypeTool, @@ -183,6 +199,7 @@ export const PreviewStandardToolkit = Toolkit.make( PreviewStatusTool, PreviewOpenTool, PreviewNavigateTool, + PreviewResizeTool, PreviewClickTool, PreviewTypeTool, PreviewPressTool, diff --git a/apps/server/src/preview/Manager.test.ts b/apps/server/src/preview/Manager.test.ts index acdfe54301..693111b578 100644 --- a/apps/server/src/preview/Manager.test.ts +++ b/apps/server/src/preview/Manager.test.ts @@ -151,6 +151,61 @@ it.layer(PreviewManager.layer)("PreviewManager", (it) => { }), ); + it.effect("resizes a tab and preserves its viewport across navigation reports", () => + Effect.gen(function* () { + const threadId = freshThreadId(); + const manager = yield* PreviewManager.PreviewManager; + const collector = yield* collectEvents; + const opened = yield* manager.open({ threadId, url: "http://localhost:5173" }); + + const resized = yield* manager.resize({ + threadId, + tabId: opened.tabId, + viewport: { _tag: "freeform", width: 1024, height: 768 }, + }); + expect(resized.viewport).toEqual({ _tag: "freeform", width: 1024, height: 768 }); + + const navigated = yield* manager.navigate({ + threadId, + tabId: opened.tabId, + url: "http://localhost:5173/resized", + }); + expect(navigated.viewport).toEqual(resized.viewport); + + yield* manager.reportStatus({ + threadId, + tabId: opened.tabId, + navStatus: { _tag: "Success", url: "http://localhost:5173/resized", title: "Resized" }, + canGoBack: true, + canGoForward: false, + }); + const listed = yield* manager.list({ threadId }); + expect(listed.sessions[0]?.viewport).toEqual(resized.viewport); + + const events = yield* collector.drain; + expect(events.map((event) => event.type)).toEqual([ + "opened", + "resized", + "navigated", + "navigated", + ]); + }), + ); + + it.effect("rejects resize for an unknown tab", () => + Effect.gen(function* () { + const manager = yield* PreviewManager.PreviewManager; + const error = yield* Effect.flip( + manager.resize({ + threadId: freshThreadId(), + tabId: "tab_missing", + viewport: { _tag: "fill" }, + }), + ); + expect(error._tag).toBe("PreviewSessionLookupError"); + }), + ); + it.effect("reportStatus emits failed for LoadFailed nav", () => Effect.gen(function* () { const threadId = freshThreadId(); diff --git a/apps/server/src/preview/Manager.ts b/apps/server/src/preview/Manager.ts index fe3557c157..193ea85b21 100644 --- a/apps/server/src/preview/Manager.ts +++ b/apps/server/src/preview/Manager.ts @@ -20,6 +20,8 @@ import { type PreviewOpenInput, type PreviewRefreshInput, type PreviewReportStatusInput, + type PreviewResizeInput, + FILL_PREVIEW_VIEWPORT, PreviewSessionLookupError, type PreviewSessionSnapshot, } from "@t3tools/contracts"; @@ -45,6 +47,9 @@ export class PreviewManager extends Context.Service< input: PreviewNavigateInput, ) => Effect.Effect; readonly reportStatus: (input: PreviewReportStatusInput) => Effect.Effect; + readonly resize: ( + input: PreviewResizeInput, + ) => Effect.Effect; readonly refresh: (input: PreviewRefreshInput) => Effect.Effect; readonly close: (input: PreviewCloseInput) => Effect.Effect; readonly list: (input: PreviewListInput) => Effect.Effect; @@ -114,6 +119,7 @@ const buildLoadingSnapshot = (input: { navStatus: { _tag: "Loading", url: input.url, title: input.title }, canGoBack: false, canGoForward: false, + viewport: FILL_PREVIEW_VIEWPORT, updatedAt: input.updatedAt, }); @@ -127,6 +133,7 @@ const buildIdleSnapshot = (input: { navStatus: { _tag: "Idle" }, canGoBack: false, canGoForward: false, + viewport: FILL_PREVIEW_VIEWPORT, updatedAt: input.updatedAt, }); @@ -237,6 +244,7 @@ export const make = Effect.gen(function* PreviewManagerMake() { navStatus: { _tag: "Success", url, title: resolvedTitle }, canGoBack: session.snapshot.canGoBack, canGoForward: session.snapshot.canGoForward, + viewport: session.snapshot.viewport ?? FILL_PREVIEW_VIEWPORT, updatedAt, }; return { @@ -269,6 +277,7 @@ export const make = Effect.gen(function* PreviewManagerMake() { navStatus: input.navStatus, canGoBack: input.canGoBack, canGoForward: input.canGoForward, + viewport: session.snapshot.viewport ?? FILL_PREVIEW_VIEWPORT, updatedAt, }; const emit: PreviewEvent = @@ -299,6 +308,34 @@ export const make = Effect.gen(function* PreviewManagerMake() { ); }); + const resize: PreviewManager["Service"]["resize"] = Effect.fn("PreviewManager.resize")( + function* (input) { + return yield* mutateExistingSession( + input.threadId, + input.tabId, + Effect.fn("PreviewManager.resizeSession")(function* (session) { + const updatedAt = yield* currentIsoTimestamp; + const snapshot: PreviewSessionSnapshot = { + ...session.snapshot, + viewport: input.viewport, + updatedAt, + }; + return { + next: { ...session, snapshot }, + emit: { + type: "resized", + threadId: session.threadId, + tabId: session.tabId, + createdAt: snapshot.updatedAt, + snapshot, + }, + result: snapshot, + }; + }), + ); + }, + ); + const refresh: PreviewManager["Service"]["refresh"] = Effect.fn("PreviewManager.refresh")( function* (input) { // Verify the session exists; the desktop bridge handles the actual reload @@ -360,6 +397,7 @@ export const make = Effect.gen(function* PreviewManagerMake() { open, navigate, reportStatus, + resize, refresh, close, list, diff --git a/apps/server/src/server.ts b/apps/server/src/server.ts index 93e19ba143..bf3a8c20d1 100644 --- a/apps/server/src/server.ts +++ b/apps/server/src/server.ts @@ -31,6 +31,7 @@ import { ProviderEventLoggersLive } from "./provider/Layers/ProviderEventLoggers import * as TerminalManager from "./terminal/Manager.ts"; import * as McpHttpServer from "./mcp/McpHttpServer.ts"; import * as McpSessionRegistry from "./mcp/McpSessionRegistry.ts"; +import * as PreviewAutomationBroker from "./mcp/PreviewAutomationBroker.ts"; import * as PreviewManager from "./preview/Manager.ts"; import * as PortScanner from "./preview/PortScanner.ts"; import * as ProcessRunner from "./processRunner.ts"; @@ -328,8 +329,8 @@ export const makeRoutesLayer = Layer.mergeAll( staticAndDevRouteLayer, websocketRpcRouteLayer, ), - McpHttpServer.layer, -).pipe(Layer.provide(browserApiCorsLayer)); + McpHttpServer.layer.pipe(Layer.provide(McpSessionRegistry.layer)), +).pipe(Layer.provide(PreviewAutomationBroker.layer), Layer.provide(browserApiCorsLayer)); export const makeServerLayer = Layer.unwrap( Effect.gen(function* () { diff --git a/apps/server/src/ws.ts b/apps/server/src/ws.ts index 31d70977e0..9fce91810d 100644 --- a/apps/server/src/ws.ts +++ b/apps/server/src/ws.ts @@ -362,14 +362,14 @@ const RPC_REQUIRED_SCOPE = new Map([ [WS_METHODS.subscribeTerminalMetadata, AuthTerminalOperateScope], [WS_METHODS.previewOpen, AuthOrchestrationOperateScope], [WS_METHODS.previewNavigate, AuthOrchestrationOperateScope], + [WS_METHODS.previewResize, AuthOrchestrationOperateScope], [WS_METHODS.previewRefresh, AuthOrchestrationOperateScope], [WS_METHODS.previewClose, AuthOrchestrationOperateScope], [WS_METHODS.previewList, AuthOrchestrationReadScope], [WS_METHODS.previewReportStatus, AuthOrchestrationOperateScope], [WS_METHODS.previewAutomationConnect, AuthOrchestrationOperateScope], [WS_METHODS.previewAutomationRespond, AuthOrchestrationOperateScope], - [WS_METHODS.previewAutomationReportOwner, AuthOrchestrationOperateScope], - [WS_METHODS.previewAutomationClearOwner, AuthOrchestrationOperateScope], + [WS_METHODS.previewAutomationFocusHost, AuthOrchestrationOperateScope], [WS_METHODS.subscribePreviewEvents, AuthOrchestrationReadScope], [WS_METHODS.subscribeDiscoveredLocalServers, AuthOrchestrationReadScope], [WS_METHODS.subscribeServerConfig, AuthOrchestrationReadScope], @@ -419,7 +419,10 @@ function toAuthAccessStreamEvent( } } -const makeWsRpcLayer = (currentSession: EnvironmentAuth.AuthenticatedSession) => +const makeWsRpcLayer = ( + currentSession: EnvironmentAuth.AuthenticatedSession, + previewAutomationBroker: PreviewAutomationBroker.PreviewAutomationBroker["Service"], +) => ServerWsRpcGroup.toLayer( Effect.gen(function* () { const currentSessionId = currentSession.sessionId; @@ -452,7 +455,6 @@ const makeWsRpcLayer = (currentSession: EnvironmentAuth.AuthenticatedSession) => const vcsProvisioning = yield* VcsProvisioningService.VcsProvisioningService; const vcsStatusBroadcaster = yield* VcsStatusBroadcaster.VcsStatusBroadcaster; const terminalManager = yield* TerminalManager.TerminalManager; - const previewAutomationBroker = yield* PreviewAutomationBroker.PreviewAutomationBroker; const previewManager = yield* PreviewManager.PreviewManager; const portDiscovery = yield* PortScanner.PortDiscovery; const providerRegistry = yield* ProviderRegistry.ProviderRegistry; @@ -1490,6 +1492,10 @@ const makeWsRpcLayer = (currentSession: EnvironmentAuth.AuthenticatedSession) => observeRpcEffect(WS_METHODS.previewNavigate, previewManager.navigate(input), { "rpc.aggregate": "preview", }), + [WS_METHODS.previewResize]: (input) => + observeRpcEffect(WS_METHODS.previewResize, previewManager.resize(input), { + "rpc.aggregate": "preview", + }), [WS_METHODS.previewRefresh]: (input) => observeRpcEffect(WS_METHODS.previewRefresh, previewManager.refresh(input), { "rpc.aggregate": "preview", @@ -1518,16 +1524,10 @@ const makeWsRpcLayer = (currentSession: EnvironmentAuth.AuthenticatedSession) => previewAutomationBroker.respond(input), { "rpc.aggregate": "preview-automation" }, ), - [WS_METHODS.previewAutomationReportOwner]: (input) => + [WS_METHODS.previewAutomationFocusHost]: (input) => observeRpcEffect( - WS_METHODS.previewAutomationReportOwner, - previewAutomationBroker.reportOwner(input), - { "rpc.aggregate": "preview-automation" }, - ), - [WS_METHODS.previewAutomationClearOwner]: (input) => - observeRpcEffect( - WS_METHODS.previewAutomationClearOwner, - previewAutomationBroker.clearOwner(input), + WS_METHODS.previewAutomationFocusHost, + previewAutomationBroker.focusHost(input), { "rpc.aggregate": "preview-automation" }, ), [WS_METHODS.subscribePreviewEvents]: (_input) => @@ -1660,8 +1660,9 @@ const makeWsRpcLayer = (currentSession: EnvironmentAuth.AuthenticatedSession) => ); export const websocketRpcRouteLayer = Layer.unwrap( - Effect.succeed( - HttpRouter.add( + Effect.gen(function* () { + const previewAutomationBroker = yield* PreviewAutomationBroker.PreviewAutomationBroker; + return HttpRouter.add( "GET", "/ws", Effect.gen(function* () { @@ -1680,9 +1681,8 @@ export const websocketRpcRouteLayer = Layer.unwrap( disableTracing: true, }).pipe( Effect.provide( - makeWsRpcLayer(session).pipe( + makeWsRpcLayer(session, previewAutomationBroker).pipe( Layer.provideMerge(RpcSerialization.layerJson), - Layer.provide(PreviewAutomationBroker.layer), Layer.provide(ProviderMaintenanceRunner.layer), Layer.provide( SourceControlDiscovery.layer.pipe( @@ -1719,6 +1719,6 @@ export const websocketRpcRouteLayer = Layer.unwrap( EnvironmentInternalError: HttpServerRespondable.toResponse, }), ), - ), - ), + ); + }), ); diff --git a/apps/web/src/AppRoot.test.tsx b/apps/web/src/AppRoot.test.tsx index 9112e31cb8..d6d7434769 100644 --- a/apps/web/src/AppRoot.test.tsx +++ b/apps/web/src/AppRoot.test.tsx @@ -3,20 +3,22 @@ import { RouterProvider } from "@tanstack/react-router"; import { describe, expect, it } from "vite-plus/test"; import { ElectronBrowserHost } from "./browser/ElectronBrowserHost"; +import { PreviewAutomationHosts } from "./components/preview/PreviewAutomationHosts"; import { AppAtomRegistryProvider } from "./rpc/atomRegistry"; import type { AppRouter } from "./router"; import { AppRoot } from "./AppRoot"; describe("AppRoot", () => { - it("shares the application atom registry with routed UI and the Electron browser host", () => { + it("shares the application atom registry with routed UI and renderer-wide desktop hosts", () => { const root = AppRoot({ router: {} as AppRouter }); expect(root.type).toBe(AppAtomRegistryProvider); const children = Children.toArray( (root as ReactElement<{ readonly children: ReactNode }>).props.children, ); - expect(children).toHaveLength(2); + expect(children).toHaveLength(3); expect(isValidElement(children[0]) && children[0].type).toBe(RouterProvider); - expect(isValidElement(children[1]) && children[1].type).toBe(ElectronBrowserHost); + expect(isValidElement(children[1]) && children[1].type).toBe(PreviewAutomationHosts); + expect(isValidElement(children[2]) && children[2].type).toBe(ElectronBrowserHost); }); }); diff --git a/apps/web/src/AppRoot.tsx b/apps/web/src/AppRoot.tsx index 1ecb9f6b7b..b1fd21f84f 100644 --- a/apps/web/src/AppRoot.tsx +++ b/apps/web/src/AppRoot.tsx @@ -1,6 +1,7 @@ import { RouterProvider } from "@tanstack/react-router"; import { ElectronBrowserHost } from "./browser/ElectronBrowserHost"; +import { PreviewAutomationHosts } from "./components/preview/PreviewAutomationHosts"; import { AppAtomRegistryProvider } from "./rpc/atomRegistry"; import type { AppRouter } from "./router"; @@ -13,6 +14,7 @@ export function AppRoot({ router }: { readonly router: AppRouter }) { return ( + ); diff --git a/apps/web/src/browser/BrowserDeviceToolbar.test.ts b/apps/web/src/browser/BrowserDeviceToolbar.test.ts new file mode 100644 index 0000000000..ee4987794c --- /dev/null +++ b/apps/web/src/browser/BrowserDeviceToolbar.test.ts @@ -0,0 +1,49 @@ +import type { PreviewViewportSetting } from "@t3tools/contracts"; +import { describe, expect, it, vi } from "vite-plus/test"; + +import { + commitViewportAndAspectRatio, + reconcileLockedAspectRatio, +} from "./browserDeviceToolbarState"; + +describe("commitViewportAndAspectRatio", () => { + it("commits the aspect ratio only after the viewport succeeds", async () => { + let resolveChange: (() => void) | undefined; + const onChange = vi.fn( + () => + new Promise((resolve) => { + resolveChange = resolve; + }), + ); + const onAspectRatioChange = vi.fn(); + const setting: PreviewViewportSetting = { _tag: "freeform", width: 900, height: 600 }; + + const commit = commitViewportAndAspectRatio(setting, 1.5, onChange, onAspectRatioChange); + expect(onAspectRatioChange).not.toHaveBeenCalled(); + + resolveChange?.(); + await commit; + expect(onAspectRatioChange).toHaveBeenCalledWith(1.5); + }); + + it("keeps the previous aspect ratio when the viewport commit fails", async () => { + const onAspectRatioChange = vi.fn(); + await expect( + commitViewportAndAspectRatio( + { _tag: "fill" }, + null, + async () => Promise.reject(new Error("resize failed")), + onAspectRatioChange, + ), + ).rejects.toThrow("resize failed"); + expect(onAspectRatioChange).not.toHaveBeenCalled(); + }); +}); + +describe("reconcileLockedAspectRatio", () => { + it("tracks external viewport ratios only while the lock remains active", () => { + expect(reconcileLockedAspectRatio(1.5, 16 / 9)).toBe(16 / 9); + expect(reconcileLockedAspectRatio(null, 16 / 9)).toBeNull(); + expect(reconcileLockedAspectRatio(1.5, null)).toBeNull(); + }); +}); diff --git a/apps/web/src/browser/BrowserDeviceToolbar.tsx b/apps/web/src/browser/BrowserDeviceToolbar.tsx new file mode 100644 index 0000000000..f20ab0b371 --- /dev/null +++ b/apps/web/src/browser/BrowserDeviceToolbar.tsx @@ -0,0 +1,340 @@ +"use client"; + +import { + PREVIEW_VIEWPORT_MAX_AREA, + PREVIEW_VIEWPORT_MAX_DIMENSION, + PREVIEW_VIEWPORT_MIN_DIMENSION, + type PreviewViewportSetting, +} from "@t3tools/contracts"; +import { PREVIEW_VIEWPORT_PRESETS, resolvePreviewViewport } from "@t3tools/shared/previewViewport"; +import { Link2, X } from "lucide-react"; +import { useState } from "react"; + +import { Button } from "~/components/ui/button"; +import { Input } from "~/components/ui/input"; +import { + Select, + SelectGroup, + SelectGroupLabel, + SelectItem, + SelectPopup, + SelectTrigger, + SelectValue, +} from "~/components/ui/select"; +import { cn } from "~/lib/utils"; + +import { BROWSER_DEVICE_TOOLBAR_HEIGHT, resizeFreeformViewport } from "./browserViewportLayout"; +import { commitViewportAndAspectRatio } from "./browserDeviceToolbarState"; + +const RESPONSIVE_VALUE = "responsive"; +const SELECT_ITEMS = [ + { value: RESPONSIVE_VALUE, label: "Responsive" }, + ...PREVIEW_VIEWPORT_PRESETS.map((preset) => ({ value: preset.id, label: preset.label })), +]; + +function ScreenRotationIcon() { + return ( + + ); +} + +interface Props { + readonly setting: Exclude; + readonly width: number; + readonly aspectRatio: number | null; + readonly onAspectRatioChange: (aspectRatio: number | null) => void; + readonly onChange: (setting: PreviewViewportSetting) => Promise; +} + +export function BrowserDeviceToolbar({ + setting, + width, + aspectRatio, + onAspectRatioChange, + onChange, +}: Props) { + const [pending, setPending] = useState(false); + const [customSize, setCustomSize] = useState<{ + readonly width: string; + readonly height: string; + } | null>(null); + const presentedSize = customSize ?? { + width: String(setting.width), + height: String(setting.height), + }; + const selectedValue = + setting._tag === "preset" && + PREVIEW_VIEWPORT_PRESETS.some((preset) => preset.id === setting.presetId) + ? setting.presetId + : RESPONSIVE_VALUE; + const customWidth = Number(presentedSize.width); + const customHeight = Number(presentedSize.height); + const customValid = + Number.isInteger(customWidth) && + Number.isInteger(customHeight) && + customWidth >= PREVIEW_VIEWPORT_MIN_DIMENSION && + customWidth <= PREVIEW_VIEWPORT_MAX_DIMENSION && + customHeight >= PREVIEW_VIEWPORT_MIN_DIMENSION && + customHeight <= PREVIEW_VIEWPORT_MAX_DIMENSION && + customWidth * customHeight <= PREVIEW_VIEWPORT_MAX_AREA; + + const apply = (next: PreviewViewportSetting, nextAspectRatio = aspectRatio) => { + setPending(true); + void commitViewportAndAspectRatio(next, nextAspectRatio, onChange, onAspectRatioChange).then( + () => { + setPending(false); + setCustomSize(null); + }, + () => setPending(false), + ); + }; + + const applyCustomSize = () => { + if (!customValid || (customWidth === setting.width && customHeight === setting.height)) { + setCustomSize(null); + return; + } + apply({ _tag: "freeform", width: customWidth, height: customHeight }); + }; + + const updateCustomDimension = (axis: "width" | "height", value: string) => { + setCustomSize((current) => { + const next = { + width: axis === "width" ? value : (current?.width ?? String(setting.width)), + height: axis === "height" ? value : (current?.height ?? String(setting.height)), + }; + const numeric = Number(value); + if ( + aspectRatio === null || + !Number.isInteger(numeric) || + numeric < PREVIEW_VIEWPORT_MIN_DIMENSION || + numeric > PREVIEW_VIEWPORT_MAX_DIMENSION + ) { + return next; + } + const resized = resizeFreeformViewport( + setting, + axis === "width" + ? { x: numeric - setting.width, y: 0 } + : { x: 0, y: numeric - setting.height }, + 1, + axis === "width" ? "east" : "south", + aspectRatio, + ); + return { width: String(resized.width), height: String(resized.height) }; + }); + }; + + const selectViewport = (value: string | null) => { + if (!value) return; + if (value === RESPONSIVE_VALUE) { + if (setting._tag === "freeform") return; + apply({ _tag: "freeform", width: setting.width, height: setting.height }); + return; + } + const preset = PREVIEW_VIEWPORT_PRESETS.find((candidate) => candidate.id === value); + if (!preset) return; + apply( + resolvePreviewViewport({ mode: "preset", preset: preset.id }), + aspectRatio === null ? null : preset.width / preset.height, + ); + }; + + const rotate = () => { + const hasCustomSize = + customValid && (customWidth !== setting.width || customHeight !== setting.height); + const source = hasCustomSize + ? ({ _tag: "freeform", width: customWidth, height: customHeight } as const) + : setting; + apply( + { ...source, width: source.height, height: source.width }, + aspectRatio === null ? null : 1 / aspectRatio, + ); + }; + + const toggleAspectRatio = () => { + onAspectRatioChange(aspectRatio === null ? customWidth / customHeight : null); + }; + + return ( +
{ + const nextTarget = event.relatedTarget; + if (nextTarget instanceof Node && event.currentTarget.contains(nextTarget)) return; + const eventTarget = event.target; + if ( + (nextTarget instanceof HTMLElement && + nextTarget.closest('[data-slot="select-positioner"]')) || + (eventTarget instanceof HTMLElement && + eventTarget.closest('[data-slot="select-positioner"]')) + ) { + return; + } + applyCustomSize(); + }} + > + {width >= 560 ? ( + + Dimensions + + ) : null} + + +
{ + event.preventDefault(); + applyCustomSize(); + }} + > + + setCustomSize( + (current) => + current ?? { + width: String(setting.width), + height: String(setting.height), + }, + ) + } + onChange={(event) => updateCustomDimension("width", event.target.value)} + aria-label="Viewport width" + aria-invalid={!customValid} + className={cn( + "h-6 rounded-md text-center tabular-nums [&_[data-slot=input]]:h-full [&_[data-slot=input]]:px-1 [&_[data-slot=input]]:text-xs [&_[data-slot=input]]:leading-none [&_[data-slot=input]::-webkit-inner-spin-button]:appearance-none [&_[data-slot=input]]:[appearance:textfield]", + width >= 360 ? "w-14" : "w-11", + )} + /> + × + + setCustomSize( + (current) => + current ?? { + width: String(setting.width), + height: String(setting.height), + }, + ) + } + onChange={(event) => updateCustomDimension("height", event.target.value)} + aria-label="Viewport height" + aria-invalid={!customValid} + className={cn( + "h-6 rounded-md text-center tabular-nums [&_[data-slot=input]]:h-full [&_[data-slot=input]]:px-1 [&_[data-slot=input]]:text-xs [&_[data-slot=input]]:leading-none [&_[data-slot=input]::-webkit-inner-spin-button]:appearance-none [&_[data-slot=input]]:[appearance:textfield]", + width >= 360 ? "w-14" : "w-11", + )} + /> +
+ + + + +
+ ); +} diff --git a/apps/web/src/browser/BrowserViewportResizeHandles.tsx b/apps/web/src/browser/BrowserViewportResizeHandles.tsx new file mode 100644 index 0000000000..08e69c359a --- /dev/null +++ b/apps/web/src/browser/BrowserViewportResizeHandles.tsx @@ -0,0 +1,169 @@ +"use client"; + +import type { + CSSProperties, + KeyboardEvent as ReactKeyboardEvent, + PointerEvent as ReactPointerEvent, +} from "react"; + +import { cn } from "~/lib/utils"; + +import { + BROWSER_VIEWPORT_RESIZE_RAIL_SIZE, + type BrowserViewportLayout, + type BrowserViewportResizeDirection, +} from "./browserViewportLayout"; + +interface Props { + readonly layout: BrowserViewportLayout; + readonly activeDirection: BrowserViewportResizeDirection | null; + readonly onPointerDown: ( + direction: BrowserViewportResizeDirection, + event: ReactPointerEvent, + ) => void; + readonly onKeyDown: ( + direction: BrowserViewportResizeDirection, + event: ReactKeyboardEvent, + ) => void; +} + +type HandleKind = "horizontal" | "vertical" | "corner"; + +const EDGE_BUTTON_CLASS = + "group absolute z-20 touch-none border-0 bg-transparent p-0 outline-none before:absolute before:-inset-1 before:content-[''] focus-visible:bg-foreground/[0.04]"; +const EDGE_GRIP_CLASS = + "pointer-events-none absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 items-center justify-center text-muted-foreground/55 transition-colors duration-150 group-hover:text-foreground/85 group-focus-visible:text-foreground group-active:text-foreground"; + +function ResizeHandle(props: { + readonly direction: BrowserViewportResizeDirection; + readonly label: string; + readonly kind: HandleKind; + readonly cursorClassName: string; + readonly style: CSSProperties; + readonly active: boolean; + readonly mirrorCorner?: boolean; + readonly onPointerDown: Props["onPointerDown"]; + readonly onKeyDown: Props["onKeyDown"]; +}) { + const { + direction, + label, + kind, + cursorClassName, + style, + active, + mirrorCorner = false, + onPointerDown, + onKeyDown, + } = props; + return ( + + ); +} + +export function BrowserViewportResizeHandles({ + layout, + activeDirection, + onPointerDown, + onKeyDown, +}: Props) { + const left = layout.viewportX; + const top = layout.viewportY; + const right = left + layout.viewportWidth; + const bottom = top + layout.viewportHeight; + const railSize = BROWSER_VIEWPORT_RESIZE_RAIL_SIZE; + + const shared = { activeDirection, onPointerDown, onKeyDown }; + return ( + <> + + + + + + + ); +} diff --git a/apps/web/src/browser/ElectronBrowserHost.tsx b/apps/web/src/browser/ElectronBrowserHost.tsx index 205dce7358..51fa73a721 100644 --- a/apps/web/src/browser/ElectronBrowserHost.tsx +++ b/apps/web/src/browser/ElectronBrowserHost.tsx @@ -1,6 +1,7 @@ "use client"; import { parseScopedThreadKey } from "@t3tools/client-runtime/environment"; +import { FILL_PREVIEW_VIEWPORT } from "@t3tools/contracts"; import { useEffect, useMemo } from "react"; import { isElectron } from "~/env"; @@ -22,7 +23,7 @@ export function ElectronBrowserHost() { ? Object.values(previewState.sessions).map((snapshot) => ({ threadRef, snapshot, - active: previewState.activeTabId === snapshot.tabId, + zoomFactor: previewState.desktopByTabId[snapshot.tabId]?.zoomFactor ?? 1, })) : []; }), @@ -73,7 +74,7 @@ export function ElectronBrowserHost() { if (!isElectron) return null; return (
- {sessions.map(({ threadRef, snapshot }) => { + {sessions.map(({ threadRef, snapshot, zoomFactor }) => { const url = snapshot.navStatus._tag === "Idle" ? null : snapshot.navStatus.url; return ( ); })} diff --git a/apps/web/src/browser/HostedBrowserWebview.tsx b/apps/web/src/browser/HostedBrowserWebview.tsx index cdd33fa150..2907a067aa 100644 --- a/apps/web/src/browser/HostedBrowserWebview.tsx +++ b/apps/web/src/browser/HostedBrowserWebview.tsx @@ -1,16 +1,22 @@ "use client"; -import type { ScopedThreadRef } from "@t3tools/contracts"; +import type { PreviewViewportSetting, ScopedThreadRef } from "@t3tools/contracts"; import { useShallow } from "zustand/react/shallow"; -import { useCallback, useEffect, useRef } from "react"; +import { useCallback, useEffect, useRef, useState } from "react"; import { previewBridge } from "~/components/preview/previewBridge"; import { usePreviewBridge } from "~/components/preview/usePreviewBridge"; +import { cn } from "~/lib/utils"; import { useActiveBrowserRecordingTabId } from "./browserRecording"; -import { useBrowserSurfaceStore } from "./browserSurfaceStore"; +import { resolveBrowserSurfacePanelRect, useBrowserSurfaceStore } from "./browserSurfaceStore"; +import { browserViewportSettingKey } from "./browserViewportLayout"; +import { reconcileLockedAspectRatio } from "./browserDeviceToolbarState"; +import { BrowserDeviceToolbar } from "./BrowserDeviceToolbar"; +import { BrowserViewportResizeHandles } from "./BrowserViewportResizeHandles"; import { acquireDesktopTab, type AcquiredDesktopTab } from "./desktopTabLifetime"; import { usePreviewWebviewConfig } from "./previewWebviewConfigState"; +import { useBrowserViewportResize } from "./useBrowserViewportResize"; interface ElectronWebview extends HTMLElement { src: string; @@ -18,6 +24,7 @@ interface ElectronWebview extends HTMLElement { preload?: string; webpreferences?: string; getWebContentsId: () => number; + executeJavaScript: (code: string, userGesture?: boolean) => Promise; } declare global { @@ -30,13 +37,25 @@ export function HostedBrowserWebview(props: { readonly threadRef: ScopedThreadRef; readonly tabId: string; readonly initialUrl: string | null; + readonly viewport: PreviewViewportSetting; + readonly zoomFactor: number; }) { - const { threadRef, tabId, initialUrl } = props; + const { threadRef, tabId, initialUrl, viewport, zoomFactor } = props; const config = usePreviewWebviewConfig(threadRef.environmentId); - const initialSrcRef = useRef(initialUrl ?? "about:blank"); + const [initialSrc] = useState(() => initialUrl ?? "about:blank"); const tabLeaseRef = useRef(null); + const wrapperRef = useRef(null); const webviewRef = useRef(null); - const presentation = useBrowserSurfaceStore(useShallow((state) => state.byTabId[tabId] ?? null)); + const [lockedAspectRatio, setLockedAspectRatio] = useState(null); + const presentation = useBrowserSurfaceStore( + useShallow((state) => { + const current = state.byTabId[tabId]; + return { + rect: resolveBrowserSurfacePanelRect(state.byTabId, tabId), + visible: current?.visible ?? false, + }; + }), + ); const recording = useActiveBrowserRecordingTabId() === tabId; usePreviewBridge({ threadRef, tabId }); @@ -89,10 +108,69 @@ export function HostedBrowserWebview(props: { }; }, [config, tabId]); + const active = presentation.visible && presentation.rect !== null; + const lastRect = presentation.rect; + const normalizedZoomFactor = Number.isFinite(zoomFactor) && zoomFactor > 0 ? zoomFactor : 1; + const viewportWidth = viewport._tag === "fill" ? null : viewport.width; + const viewportHeight = viewport._tag === "fill" ? null : viewport.height; + const viewportAspectRatio = + viewportWidth === null || viewportHeight === null ? null : viewportWidth / viewportHeight; + useEffect(() => { + setLockedAspectRatio((current) => reconcileLockedAspectRatio(current, viewportAspectRatio)); + }, [viewportAspectRatio]); + const hiddenSize = + viewport._tag !== "fill" + ? { + width: viewport.width * normalizedZoomFactor, + height: viewport.height * normalizedZoomFactor, + } + : { width: lastRect?.width ?? 1280, height: lastRect?.height ?? 800 }; + const containerSize = active && lastRect ? lastRect : hiddenSize; + const deviceToolbarVisible = active && viewport._tag !== "fill"; + const { + activeDrag, + commitViewportChange, + effectiveViewport, + handleResizeKeyDown, + handleResizePointerDown, + layout, + } = useBrowserViewportResize({ + tabId, + viewport, + zoomFactor, + containerSize, + deviceToolbarVisible, + aspectRatio: lockedAspectRatio, + }); + + const syncContentPresentation = useCallback(() => { + const wrapper = wrapperRef.current; + if (!wrapper) return; + useBrowserSurfaceStore.getState().presentContent(tabId, { + x: layout.viewportX, + y: layout.viewportY, + width: layout.viewportWidth, + height: layout.viewportHeight, + scale: layout.viewportScale, + scrollLeft: wrapper.scrollLeft, + scrollTop: wrapper.scrollTop, + }); + }, [layout, tabId]); + + useEffect(() => { + const frameId = window.requestAnimationFrame(syncContentPresentation); + return () => window.cancelAnimationFrame(frameId); + }, [syncContentPresentation]); + + useEffect(() => { + const wrapper = wrapperRef.current; + if (!wrapper) return; + wrapper.scrollTo({ left: 0, top: 0 }); + }, [tabId, viewport._tag, viewportHeight, viewportWidth]); + if (!config) return null; - const active = presentation?.visible === true && presentation.rect !== null; - const lastRect = presentation?.rect; - const style = + + const wrapperStyle = active && lastRect ? { left: lastRect.x, @@ -105,23 +183,86 @@ export function HostedBrowserWebview(props: { : { left: 0, top: 0, - width: lastRect?.width ?? 1280, - height: lastRect?.height ?? 800, + width: hiddenSize.width, + height: hiddenSize.height, zIndex: recording ? 0 : -1, pointerEvents: "none" as const, }; return ( - +
+
+ {deviceToolbarVisible && effectiveViewport._tag !== "fill" ? ( + + ) : null} + + {active && effectiveViewport._tag !== "fill" ? ( + <> + + {activeDrag ? ( + + ) : null} + + ) : null} +
+
); } diff --git a/apps/web/src/browser/browserDeviceToolbarState.ts b/apps/web/src/browser/browserDeviceToolbarState.ts new file mode 100644 index 0000000000..9986ee0228 --- /dev/null +++ b/apps/web/src/browser/browserDeviceToolbarState.ts @@ -0,0 +1,18 @@ +import type { PreviewViewportSetting } from "@t3tools/contracts"; + +export function reconcileLockedAspectRatio( + current: number | null, + viewportAspectRatio: number | null, +): number | null { + return current === null || viewportAspectRatio === null ? null : viewportAspectRatio; +} + +export async function commitViewportAndAspectRatio( + setting: PreviewViewportSetting, + aspectRatio: number | null, + onChange: (setting: PreviewViewportSetting) => Promise, + onAspectRatioChange: (aspectRatio: number | null) => void, +): Promise { + await onChange(setting); + onAspectRatioChange(aspectRatio); +} diff --git a/apps/web/src/browser/browserRecording.ts b/apps/web/src/browser/browserRecording.ts index 5bb3364807..f458062880 100644 --- a/apps/web/src/browser/browserRecording.ts +++ b/apps/web/src/browser/browserRecording.ts @@ -90,6 +90,10 @@ export function useActiveBrowserRecordingTabId(): string | null { let active: ActiveRecording | null = null; let unsubscribeFrames: (() => void) | null = null; +export function readActiveBrowserRecordingTabId(): string | null { + return active?.tabId ?? null; +} + const preferredMimeType = (): string => { const candidates = ["video/mp4;codecs=avc1.42E01E", "video/webm;codecs=vp9", "video/webm"]; return candidates.find((candidate) => MediaRecorder.isTypeSupported(candidate)) ?? "video/webm"; @@ -137,10 +141,11 @@ export async function startBrowserRecording(tabId: string): Promise { activeTabId: active.tabId, }); } - const rect = useBrowserSurfaceStore.getState().byTabId[tabId]?.rect; + const surface = useBrowserSurfaceStore.getState().byTabId[tabId]; + const recordingSize = surface?.content ?? surface?.rect; const canvas = document.createElement("canvas"); - canvas.width = Math.max(1, rect?.width ?? 1280); - canvas.height = Math.max(1, rect?.height ?? 800); + canvas.width = Math.max(1, recordingSize?.width ?? 1280); + canvas.height = Math.max(1, recordingSize?.height ?? 800); const context = canvas.getContext("2d", { alpha: false }); if (!context) { throw new BrowserRecordingCanvasUnavailableError({ diff --git a/apps/web/src/browser/browserRecordingScope.test.ts b/apps/web/src/browser/browserRecordingScope.test.ts new file mode 100644 index 0000000000..ae91f1a7fd --- /dev/null +++ b/apps/web/src/browser/browserRecordingScope.test.ts @@ -0,0 +1,11 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { resolveBrowserRecordingStopTarget } from "./browserRecordingScope"; + +describe("resolveBrowserRecordingStopTarget", () => { + it("stops the active recording even after the requested tab changes", () => { + expect(resolveBrowserRecordingStopTarget("tab-a")).toBe("tab-a"); + expect(resolveBrowserRecordingStopTarget("tab-b")).toBe("tab-b"); + expect(resolveBrowserRecordingStopTarget(null)).toBeNull(); + }); +}); diff --git a/apps/web/src/browser/browserRecordingScope.ts b/apps/web/src/browser/browserRecordingScope.ts new file mode 100644 index 0000000000..807b5d0c9a --- /dev/null +++ b/apps/web/src/browser/browserRecordingScope.ts @@ -0,0 +1,3 @@ +export function resolveBrowserRecordingStopTarget(activeTabId: string | null): string | null { + return activeTabId; +} diff --git a/apps/web/src/browser/browserSurfaceStore.test.ts b/apps/web/src/browser/browserSurfaceStore.test.ts new file mode 100644 index 0000000000..1445303b8f --- /dev/null +++ b/apps/web/src/browser/browserSurfaceStore.test.ts @@ -0,0 +1,38 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { resolveBrowserSurfacePanelRect, useBrowserSurfaceStore } from "./browserSurfaceStore"; + +describe("browserSurfaceStore", () => { + it("tracks content dimensions for a browser that has never been visible", () => { + const tabId = "hidden-browser-surface-content-test"; + useBrowserSurfaceStore.getState().presentContent(tabId, { + x: 0, + y: 0, + width: 393, + height: 852, + scale: 1, + scrollLeft: 0, + scrollTop: 0, + }); + + expect(useBrowserSurfaceStore.getState().byTabId[tabId]).toMatchObject({ + rect: null, + visible: false, + content: { width: 393, height: 852 }, + }); + }); + + it("uses the live panel rect for a hidden background tab", () => { + const staleRect = { x: 0, y: 0, width: 500, height: 700 }; + const liveRect = { x: 10, y: 20, width: 900, height: 640 }; + expect( + resolveBrowserSurfacePanelRect( + { + hidden: { rect: staleRect, visible: false, content: null, updatedAt: 1 }, + active: { rect: liveRect, visible: true, content: null, updatedAt: 2 }, + }, + "hidden", + ), + ).toEqual(liveRect); + }); +}); diff --git a/apps/web/src/browser/browserSurfaceStore.ts b/apps/web/src/browser/browserSurfaceStore.ts index 64fd8e2df2..79095f0bdb 100644 --- a/apps/web/src/browser/browserSurfaceStore.ts +++ b/apps/web/src/browser/browserSurfaceStore.ts @@ -10,15 +10,47 @@ export interface BrowserSurfaceRect { export interface BrowserSurfacePresentation { readonly rect: BrowserSurfaceRect | null; readonly visible: boolean; + readonly content: BrowserSurfaceContentPresentation | null; readonly updatedAt: number; } +export interface BrowserSurfaceContentPresentation { + readonly x: number; + readonly y: number; + readonly width: number; + readonly height: number; + readonly scale: number; + readonly scrollLeft: number; + readonly scrollTop: number; +} + interface BrowserSurfaceStoreState { readonly byTabId: Record; readonly present: (tabId: string, rect: BrowserSurfaceRect, visible: boolean) => void; + readonly presentContent: (tabId: string, content: BrowserSurfaceContentPresentation) => void; readonly hide: (tabId: string) => void; } +export function resolveBrowserSurfacePanelRect( + byTabId: Readonly>, + tabId: string, +): BrowserSurfaceRect | null { + const current = byTabId[tabId]; + if (current?.visible && current.rect) return current.rect; + + let latestVisible: BrowserSurfacePresentation | undefined; + for (const presentation of Object.values(byTabId)) { + if ( + presentation.visible && + presentation.rect && + (!latestVisible || presentation.updatedAt > latestVisible.updatedAt) + ) { + latestVisible = presentation; + } + } + return latestVisible?.rect ?? current?.rect ?? null; +} + const rectEquals = (left: BrowserSurfaceRect | null, right: BrowserSurfaceRect): boolean => left !== null && left.x === right.x && @@ -35,7 +67,43 @@ export const useBrowserSurfaceStore = create()((set) = return { byTabId: { ...state.byTabId, - [tabId]: { rect, visible, updatedAt: Date.now() }, + [tabId]: { rect, visible, content: current?.content ?? null, updatedAt: Date.now() }, + }, + }; + }), + presentContent: (tabId, content) => + set((state) => { + const current = state.byTabId[tabId]; + if (!current) { + return { + byTabId: { + ...state.byTabId, + [tabId]: { + rect: null, + visible: false, + content, + updatedAt: Date.now(), + }, + }, + }; + } + const previous = current.content; + if ( + previous && + previous.x === content.x && + previous.y === content.y && + previous.width === content.width && + previous.height === content.height && + previous.scale === content.scale && + previous.scrollLeft === content.scrollLeft && + previous.scrollTop === content.scrollTop + ) { + return state; + } + return { + byTabId: { + ...state.byTabId, + [tabId]: { ...current, content, updatedAt: Date.now() }, }, }; }), diff --git a/apps/web/src/browser/browserViewportActions.test.ts b/apps/web/src/browser/browserViewportActions.test.ts new file mode 100644 index 0000000000..fd8f7809f3 --- /dev/null +++ b/apps/web/src/browser/browserViewportActions.test.ts @@ -0,0 +1,112 @@ +import type { PreviewViewportSetting } from "@t3tools/contracts"; +import { describe, expect, it, vi } from "vite-plus/test"; + +import { + BROWSER_VIEWPORT_COMMIT_TIMEOUT_MS, + commitBrowserViewportChange, + subscribeBrowserViewportChange, +} from "./browserViewportActions"; + +describe("browserViewportActions", () => { + it("routes drag commits to the visible tab handler and cleans up exactly that handler", async () => { + const first = vi.fn(async () => undefined); + const second = vi.fn(async () => undefined); + const unsubscribeFirst = subscribeBrowserViewportChange("tab-1", first); + const unsubscribeSecond = subscribeBrowserViewportChange("tab-1", second); + + unsubscribeFirst(); + await commitBrowserViewportChange("tab-1", { + _tag: "freeform", + width: 900, + height: 700, + }); + expect(first).not.toHaveBeenCalled(); + expect(second).toHaveBeenCalledWith({ _tag: "freeform", width: 900, height: 700 }); + + unsubscribeSecond(); + await expect( + commitBrowserViewportChange("tab-1", { + _tag: "freeform", + width: 800, + height: 600, + }), + ).rejects.toThrow("No visible browser viewport handler"); + }); + + it("commits viewport changes in order for each tab", async () => { + let releaseFirst: (() => void) | undefined; + let markFirstStarted: (() => void) | undefined; + const firstPending = new Promise((resolve) => { + releaseFirst = resolve; + }); + const firstStarted = new Promise((resolve) => { + markFirstStarted = resolve; + }); + const calls: Array = []; + const unsubscribe = subscribeBrowserViewportChange("tab-serial", async (setting) => { + if (setting._tag === "fill") return; + calls.push(setting.width); + if (setting.width === 800) { + markFirstStarted?.(); + await firstPending; + } + }); + + const first = commitBrowserViewportChange("tab-serial", { + _tag: "freeform", + width: 800, + height: 600, + }); + const second = commitBrowserViewportChange("tab-serial", { + _tag: "freeform", + width: 900, + height: 700, + }); + await firstStarted; + expect(calls).toEqual([800]); + + releaseFirst?.(); + await Promise.all([first, second]); + expect(calls).toEqual([800, 900]); + unsubscribe(); + }); + + it("does not let a timed-out handler overtake a newer viewport commit", async () => { + vi.useFakeTimers(); + try { + let releaseFirst: (() => void) | undefined; + const delayed = new Promise((resolve) => { + releaseFirst = resolve; + }); + const handler = vi.fn(async (_setting: PreviewViewportSetting): Promise => undefined); + handler.mockImplementationOnce(() => delayed).mockResolvedValueOnce(undefined); + const unsubscribe = subscribeBrowserViewportChange("tab-timeout", handler); + const first = commitBrowserViewportChange("tab-timeout", { + _tag: "freeform", + width: 800, + height: 600, + }); + const firstResult = expect(first).rejects.toThrow( + "Timed out committing the browser viewport for tab tab-timeout", + ); + const second = commitBrowserViewportChange("tab-timeout", { + _tag: "freeform", + width: 900, + height: 700, + }); + + await vi.advanceTimersByTimeAsync(BROWSER_VIEWPORT_COMMIT_TIMEOUT_MS); + await firstResult; + expect(handler).toHaveBeenCalledTimes(1); + + releaseFirst?.(); + await second; + + expect(handler).toHaveBeenCalledTimes(2); + expect(handler.mock.calls[1]?.[0]).toMatchObject({ width: 900, height: 700 }); + unsubscribe(); + } finally { + vi.useRealTimers(); + } + }); +}); diff --git a/apps/web/src/browser/browserViewportActions.ts b/apps/web/src/browser/browserViewportActions.ts new file mode 100644 index 0000000000..eea176ebbf --- /dev/null +++ b/apps/web/src/browser/browserViewportActions.ts @@ -0,0 +1,66 @@ +import type { PreviewViewportSetting } from "@t3tools/contracts"; + +type BrowserViewportHandler = (setting: PreviewViewportSetting) => Promise; + +export const BROWSER_VIEWPORT_COMMIT_TIMEOUT_MS = 15_000; + +export class BrowserViewportCommitTimeoutError extends Error { + override readonly name = "BrowserViewportCommitTimeoutError"; + + constructor(readonly tabId: string) { + super(`Timed out committing the browser viewport for tab ${tabId}`); + } +} + +const handlers = new Map(); +const commitTails = new Map>(); + +const runHandlerWithTimeout = (tabId: string, operation: Promise): Promise => { + let timeoutId: ReturnType | undefined; + const timeout = new Promise((_resolve, reject) => { + timeoutId = setTimeout( + () => reject(new BrowserViewportCommitTimeoutError(tabId)), + BROWSER_VIEWPORT_COMMIT_TIMEOUT_MS, + ); + }); + return Promise.race([operation, timeout]).finally(() => { + if (timeoutId !== undefined) clearTimeout(timeoutId); + }); +}; + +export function subscribeBrowserViewportChange( + tabId: string, + handler: BrowserViewportHandler, +): () => void { + handlers.set(tabId, handler); + return () => { + if (handlers.get(tabId) === handler) handlers.delete(tabId); + }; +} + +export function commitBrowserViewportChange( + tabId: string, + setting: PreviewViewportSetting, +): Promise { + const previous = commitTails.get(tabId) ?? Promise.resolve(); + const started = previous + .catch(() => undefined) + .then(() => { + const handler = handlers.get(tabId); + const operation = handler + ? Promise.resolve().then(() => handler(setting)) + : Promise.reject(new Error(`No visible browser viewport handler for tab ${tabId}`)); + return { operation }; + }); + // The queue follows the real handler lifetime, not the caller-facing timeout. + // A slow commit therefore cannot time out, release the queue, and overwrite a + // newer viewport after that newer request has already completed. + const execution = started.then(({ operation }) => operation); + const result = started.then(({ operation }) => runHandlerWithTimeout(tabId, operation)); + commitTails.set(tabId, execution); + const clear = () => { + if (commitTails.get(tabId) === execution) commitTails.delete(tabId); + }; + void execution.then(clear, clear); + return result; +} diff --git a/apps/web/src/browser/browserViewportLayout.test.ts b/apps/web/src/browser/browserViewportLayout.test.ts new file mode 100644 index 0000000000..edd432a4e9 --- /dev/null +++ b/apps/web/src/browser/browserViewportLayout.test.ts @@ -0,0 +1,165 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { + resizeBrowserViewportFromRail, + resizeFreeformViewport, + resolveBrowserDeviceViewportLayout, + resolveBrowserViewportLayout, + resolveResponsiveBrowserViewportSize, +} from "./browserViewportLayout"; + +describe("resolveBrowserViewportLayout", () => { + it("fills the available surface in fill mode", () => { + expect(resolveBrowserViewportLayout({ width: 700, height: 500 }, { _tag: "fill" })).toEqual({ + canvasWidth: 700, + canvasHeight: 500, + viewportX: 0, + viewportY: 0, + viewportWidth: 700, + viewportHeight: 500, + viewportScale: 1, + fillsPanel: true, + }); + }); + + it("centers a smaller fixed viewport", () => { + expect( + resolveBrowserViewportLayout( + { width: 700, height: 1000 }, + { _tag: "freeform", width: 393, height: 852 }, + ), + ).toMatchObject({ + canvasWidth: 700, + canvasHeight: 1000, + viewportX: 154, + viewportY: 74, + viewportWidth: 393, + viewportHeight: 852, + }); + }); + + it("scales a larger fixed viewport down to fit without creating overflow", () => { + const layout = resolveBrowserViewportLayout( + { width: 600, height: 700 }, + { _tag: "freeform", width: 1440, height: 900 }, + ); + expect(layout).toMatchObject({ + canvasWidth: 600, + canvasHeight: 700, + viewportX: 0, + viewportY: 163, + viewportWidth: 600, + viewportHeight: 375, + }); + expect(layout.viewportScale).toBeCloseTo(5 / 12); + }); + + it("keeps fixed dimensions in page CSS pixels when browser zoom changes", () => { + expect( + resolveBrowserViewportLayout( + { width: 800, height: 700 }, + { _tag: "freeform", width: 400, height: 300 }, + 1.5, + ), + ).toMatchObject({ + viewportX: 100, + viewportY: 125, + viewportWidth: 600, + viewportHeight: 450, + }); + expect(resizeFreeformViewport({ width: 400, height: 300 }, { x: 150, y: 75 }, 1.5)).toEqual({ + width: 500, + height: 350, + }); + }); + + it("bounds freeform drag sizes and total render area", () => { + expect(resizeFreeformViewport({ width: 1024, height: 768 }, { x: -2000, y: -2000 })).toEqual({ + width: 240, + height: 240, + }); + const large = resizeFreeformViewport({ width: 1920, height: 1080 }, { x: 2000, y: 2000 }); + expect(large.width * large.height).toBeLessThanOrEqual(3840 * 2160); + }); + + it("resizes only the axes controlled by each edge", () => { + expect( + resizeFreeformViewport({ width: 800, height: 600 }, { x: -100, y: 500 }, 1, "west"), + ).toEqual({ width: 900, height: 600 }); + expect( + resizeFreeformViewport({ width: 800, height: 600 }, { x: 500, y: 100 }, 1, "north"), + ).toEqual({ width: 800, height: 500 }); + expect( + resizeFreeformViewport({ width: 800, height: 600 }, { x: -100, y: -50 }, 1, "northwest"), + ).toEqual({ width: 900, height: 650 }); + }); + + it("preserves a locked aspect ratio from either axis", () => { + expect( + resizeFreeformViewport({ width: 800, height: 600 }, { x: 200, y: 0 }, 1, "east", 4 / 3), + ).toEqual({ width: 1000, height: 750 }); + expect( + resizeFreeformViewport({ width: 800, height: 600 }, { x: 0, y: 150 }, 1, "south", 4 / 3), + ).toEqual({ width: 1000, height: 750 }); + }); + + it("reserves persistent device-toolbar rails around the guest viewport", () => { + expect( + resolveBrowserDeviceViewportLayout( + { width: 1200, height: 900 }, + { _tag: "freeform", width: 1180, height: 858 }, + ), + ).toEqual({ + canvasWidth: 1200, + canvasHeight: 900, + viewportX: 10, + viewportY: 32, + viewportWidth: 1180, + viewportHeight: 858, + viewportScale: 1, + fillsPanel: false, + }); + }); + + it("captures the available framed area when responsive mode is enabled", () => { + expect(resolveResponsiveBrowserViewportSize({ width: 1200, height: 900 })).toEqual({ + width: 1180, + height: 858, + }); + expect(resolveResponsiveBrowserViewportSize({ width: 1200, height: 900 }, 2)).toEqual({ + width: 590, + height: 429, + }); + }); + + it("keeps the grabbed rail under the pointer across centered layout boundaries", () => { + const available = { width: 1120, height: 818 }; + expect( + resizeBrowserViewportFromRail( + { width: 1120, height: 818 }, + { x: -100, y: -50 }, + available, + 1, + "southeast", + ), + ).toEqual({ width: 920, height: 718 }); + expect( + resizeBrowserViewportFromRail( + { width: 800, height: 600 }, + { x: 300, y: 0 }, + { width: 1200, height: 800 }, + 1, + "east", + ), + ).toEqual({ width: 1300, height: 600 }); + expect( + resizeBrowserViewportFromRail( + { width: 560, height: 409 }, + { x: -100, y: 0 }, + available, + 2, + "east", + ), + ).toEqual({ width: 460, height: 409 }); + }); +}); diff --git a/apps/web/src/browser/browserViewportLayout.ts b/apps/web/src/browser/browserViewportLayout.ts new file mode 100644 index 0000000000..ed5529fe13 --- /dev/null +++ b/apps/web/src/browser/browserViewportLayout.ts @@ -0,0 +1,286 @@ +import { + PREVIEW_VIEWPORT_MAX_AREA, + PREVIEW_VIEWPORT_MAX_DIMENSION, + PREVIEW_VIEWPORT_MIN_DIMENSION, + type PreviewViewportSetting, + type PreviewViewportSize, +} from "@t3tools/contracts"; + +export interface BrowserViewportLayout { + readonly canvasWidth: number; + readonly canvasHeight: number; + readonly viewportX: number; + readonly viewportY: number; + /** Visible footprint inside the preview panel after fit-to-panel scaling. */ + readonly viewportWidth: number; + readonly viewportHeight: number; + /** Presentation-only scale; the guest keeps its requested CSS viewport. */ + readonly viewportScale: number; + readonly fillsPanel: boolean; +} + +export const BROWSER_DEVICE_TOOLBAR_HEIGHT = 32; +export const BROWSER_VIEWPORT_RESIZE_RAIL_SIZE = 10; + +export type BrowserViewportResizeDirection = + | "north" + | "northeast" + | "east" + | "southeast" + | "south" + | "southwest" + | "west" + | "northwest"; + +export const browserViewportSettingKey = (setting: PreviewViewportSetting): string => + setting._tag === "fill" + ? "fill" + : `${setting._tag}:${setting.width}:${setting.height}:${setting._tag === "preset" ? setting.presetId : ""}`; + +const normalizeZoomFactor = (zoomFactor: number): number => + Number.isFinite(zoomFactor) && zoomFactor > 0 ? zoomFactor : 1; + +export function resolveBrowserDeviceViewportArea(container: { + readonly width: number; + readonly height: number; +}): PreviewViewportSize { + return { + width: Math.max(1, container.width - BROWSER_VIEWPORT_RESIZE_RAIL_SIZE * 2), + height: Math.max( + 1, + container.height - BROWSER_DEVICE_TOOLBAR_HEIGHT - BROWSER_VIEWPORT_RESIZE_RAIL_SIZE, + ), + }; +} + +export function resolveBrowserViewportLayout( + container: { readonly width: number; readonly height: number }, + setting: PreviewViewportSetting, + zoomFactor = 1, +): BrowserViewportLayout { + const containerWidth = Math.max(1, Math.round(container.width)); + const containerHeight = Math.max(1, Math.round(container.height)); + if (setting._tag === "fill") { + return { + canvasWidth: containerWidth, + canvasHeight: containerHeight, + viewportX: 0, + viewportY: 0, + viewportWidth: containerWidth, + viewportHeight: containerHeight, + viewportScale: 1, + fillsPanel: true, + }; + } + const normalizedZoomFactor = normalizeZoomFactor(zoomFactor); + const renderedWidth = setting.width * normalizedZoomFactor; + const renderedHeight = setting.height * normalizedZoomFactor; + const viewportScale = Math.min( + 1, + containerWidth / renderedWidth, + containerHeight / renderedHeight, + ); + const viewportWidth = renderedWidth * viewportScale; + const viewportHeight = renderedHeight * viewportScale; + return { + canvasWidth: containerWidth, + canvasHeight: containerHeight, + viewportX: Math.max(0, Math.round((containerWidth - viewportWidth) / 2)), + viewportY: Math.max(0, Math.round((containerHeight - viewportHeight) / 2)), + viewportWidth, + viewportHeight, + viewportScale, + fillsPanel: false, + }; +} + +export function resolveBrowserDeviceViewportLayout( + container: { readonly width: number; readonly height: number }, + setting: Exclude, + zoomFactor = 1, +): BrowserViewportLayout { + const layout = resolveBrowserViewportLayout( + resolveBrowserDeviceViewportArea(container), + setting, + zoomFactor, + ); + return { + ...layout, + canvasWidth: Math.max(1, Math.round(container.width)), + canvasHeight: Math.max(1, Math.round(container.height)), + viewportX: layout.viewportX + BROWSER_VIEWPORT_RESIZE_RAIL_SIZE, + viewportY: layout.viewportY + BROWSER_DEVICE_TOOLBAR_HEIGHT, + }; +} + +const clampViewportDimension = (value: number): number => + Math.min(PREVIEW_VIEWPORT_MAX_DIMENSION, Math.max(PREVIEW_VIEWPORT_MIN_DIMENSION, value)); + +const validAspectRatio = (aspectRatio: number | undefined): aspectRatio is number => + aspectRatio !== undefined && Number.isFinite(aspectRatio) && aspectRatio > 0; + +function resizeAtAspectRatio( + desired: number, + aspectRatio: number, + primaryAxis: "width" | "height", +): PreviewViewportSize { + if (primaryAxis === "width") { + const minimum = Math.ceil( + Math.max(PREVIEW_VIEWPORT_MIN_DIMENSION, PREVIEW_VIEWPORT_MIN_DIMENSION * aspectRatio), + ); + const maximum = Math.floor( + Math.min( + PREVIEW_VIEWPORT_MAX_DIMENSION, + PREVIEW_VIEWPORT_MAX_DIMENSION * aspectRatio, + Math.sqrt(PREVIEW_VIEWPORT_MAX_AREA * aspectRatio), + ), + ); + let width = Math.min(maximum, Math.max(minimum, Math.round(desired))); + let height = Math.round(width / aspectRatio); + while (width * height > PREVIEW_VIEWPORT_MAX_AREA && width > minimum) { + width -= 1; + height = Math.round(width / aspectRatio); + } + return { width, height }; + } + + const minimum = Math.ceil( + Math.max(PREVIEW_VIEWPORT_MIN_DIMENSION, PREVIEW_VIEWPORT_MIN_DIMENSION / aspectRatio), + ); + const maximum = Math.floor( + Math.min( + PREVIEW_VIEWPORT_MAX_DIMENSION, + PREVIEW_VIEWPORT_MAX_DIMENSION / aspectRatio, + Math.sqrt(PREVIEW_VIEWPORT_MAX_AREA / aspectRatio), + ), + ); + let height = Math.min(maximum, Math.max(minimum, Math.round(desired))); + let width = Math.round(height * aspectRatio); + while (width * height > PREVIEW_VIEWPORT_MAX_AREA && height > minimum) { + height -= 1; + width = Math.round(height * aspectRatio); + } + return { width, height }; +} + +export function resizeFreeformViewport( + start: PreviewViewportSize, + delta: { readonly x: number; readonly y: number }, + zoomFactor = 1, + direction: BrowserViewportResizeDirection = "southeast", + aspectRatio?: number, +): PreviewViewportSize { + const normalizedZoomFactor = normalizeZoomFactor(zoomFactor); + const horizontalDelta = direction.includes("east") + ? delta.x + : direction.includes("west") + ? -delta.x + : 0; + const verticalDelta = direction.includes("south") + ? delta.y + : direction.includes("north") + ? -delta.y + : 0; + const desiredWidth = start.width + horizontalDelta / normalizedZoomFactor; + const desiredHeight = start.height + verticalDelta / normalizedZoomFactor; + if (validAspectRatio(aspectRatio)) { + const controlsWidth = horizontalDelta !== 0 || direction === "east" || direction === "west"; + const controlsHeight = verticalDelta !== 0 || direction === "north" || direction === "south"; + const primaryAxis = + controlsWidth && !controlsHeight + ? "width" + : controlsHeight && !controlsWidth + ? "height" + : Math.abs(desiredWidth - start.width) / start.width >= + Math.abs(desiredHeight - start.height) / start.height + ? "width" + : "height"; + return resizeAtAspectRatio( + primaryAxis === "width" ? desiredWidth : desiredHeight, + aspectRatio, + primaryAxis, + ); + } + let width = clampViewportDimension(Math.round(desiredWidth)); + let height = clampViewportDimension(Math.round(desiredHeight)); + if (width * height <= PREVIEW_VIEWPORT_MAX_AREA) return { width, height }; + if (Math.abs(horizontalDelta) >= Math.abs(verticalDelta)) { + width = Math.max( + PREVIEW_VIEWPORT_MIN_DIMENSION, + Math.floor(PREVIEW_VIEWPORT_MAX_AREA / height), + ); + } else { + height = Math.max( + PREVIEW_VIEWPORT_MIN_DIMENSION, + Math.floor(PREVIEW_VIEWPORT_MAX_AREA / width), + ); + } + return { width, height }; +} + +const resizeFromEndRail = (start: number, pointerDelta: number, available: number): number => { + const startEdge = start < available ? (available + start) / 2 : start; + const targetEdge = startEdge + pointerDelta; + return targetEdge <= available ? targetEdge * 2 - available : targetEdge; +}; + +const resizeFromStartRail = (start: number, pointerDelta: number, available: number): number => { + if (start > available) { + const distanceToFit = start - available; + return pointerDelta <= distanceToFit + ? start - pointerDelta + : available - (pointerDelta - distanceToFit) * 2; + } + const targetEdge = (available - start) / 2 + pointerDelta; + return targetEdge >= 0 ? available - targetEdge * 2 : available - targetEdge; +}; + +export function resizeBrowserViewportFromRail( + start: PreviewViewportSize, + pointerDelta: { readonly x: number; readonly y: number }, + available: PreviewViewportSize, + zoomFactor = 1, + direction: BrowserViewportResizeDirection = "southeast", + aspectRatio?: number, +): PreviewViewportSize { + const normalizedZoomFactor = normalizeZoomFactor(zoomFactor); + const startWidth = start.width * normalizedZoomFactor; + const startHeight = start.height * normalizedZoomFactor; + const desiredWidth = direction.includes("east") + ? resizeFromEndRail(startWidth, pointerDelta.x, available.width) + : direction.includes("west") + ? resizeFromStartRail(startWidth, pointerDelta.x, available.width) + : startWidth; + const desiredHeight = direction.includes("south") + ? resizeFromEndRail(startHeight, pointerDelta.y, available.height) + : direction.includes("north") + ? resizeFromStartRail(startHeight, pointerDelta.y, available.height) + : startHeight; + const widthDelta = desiredWidth - startWidth; + const heightDelta = desiredHeight - startHeight; + return resizeFreeformViewport( + start, + { + x: direction.includes("west") ? -widthDelta : widthDelta, + y: direction.includes("north") ? -heightDelta : heightDelta, + }, + normalizedZoomFactor, + direction, + aspectRatio, + ); +} + +export function resolveResponsiveBrowserViewportSize( + container: { readonly width: number; readonly height: number }, + zoomFactor = 1, +): PreviewViewportSize { + const area = resolveBrowserDeviceViewportArea(container); + const normalizedZoomFactor = normalizeZoomFactor(zoomFactor); + return resizeFreeformViewport( + { + width: area.width / normalizedZoomFactor, + height: area.height / normalizedZoomFactor, + }, + { x: 0, y: 0 }, + ); +} diff --git a/apps/web/src/browser/useBrowserViewportResize.ts b/apps/web/src/browser/useBrowserViewportResize.ts new file mode 100644 index 0000000000..4f05f6dd27 --- /dev/null +++ b/apps/web/src/browser/useBrowserViewportResize.ts @@ -0,0 +1,260 @@ +"use client"; + +import type { PreviewViewportSetting, PreviewViewportSize } from "@t3tools/contracts"; +import { + useCallback, + useEffect, + useRef, + useState, + type KeyboardEvent as ReactKeyboardEvent, + type PointerEvent as ReactPointerEvent, +} from "react"; + +import { commitBrowserViewportChange } from "./browserViewportActions"; +import { + browserViewportSettingKey, + resizeBrowserViewportFromRail, + resizeFreeformViewport, + resolveBrowserDeviceViewportArea, + resolveBrowserDeviceViewportLayout, + resolveBrowserViewportLayout, + type BrowserViewportResizeDirection, +} from "./browserViewportLayout"; + +interface ViewportDrag extends PreviewViewportSize { + readonly sourceKey: string; + readonly direction: BrowserViewportResizeDirection; +} + +const KEYBOARD_RESIZE_COMMIT_DELAY_MS = 150; + +export function useBrowserViewportResize(options: { + readonly tabId: string; + readonly viewport: PreviewViewportSetting; + readonly zoomFactor: number; + readonly containerSize: PreviewViewportSize; + readonly deviceToolbarVisible: boolean; + readonly aspectRatio: number | null; +}) { + const { tabId, viewport, zoomFactor, containerSize, deviceToolbarVisible, aspectRatio } = options; + const dragCleanupRef = useRef<(() => void) | null>(null); + const dragVersionRef = useRef(0); + const keyboardCommitTimerRef = useRef | null>(null); + const keyboardViewportRef = useRef(null); + const [dragViewport, setDragViewport] = useState(null); + const sourceViewportKey = browserViewportSettingKey(viewport); + const sourceViewportKeyRef = useRef(sourceViewportKey); + sourceViewportKeyRef.current = sourceViewportKey; + const activeDrag = dragViewport?.sourceKey === sourceViewportKey ? dragViewport : null; + const effectiveViewport = activeDrag + ? ({ + _tag: "freeform", + width: activeDrag.width, + height: activeDrag.height, + } as const satisfies PreviewViewportSetting) + : viewport; + const normalizedZoomFactor = Number.isFinite(zoomFactor) && zoomFactor > 0 ? zoomFactor : 1; + const viewportContainerSize = deviceToolbarVisible + ? resolveBrowserDeviceViewportArea(containerSize) + : containerSize; + const layout = + deviceToolbarVisible && effectiveViewport._tag !== "fill" + ? resolveBrowserDeviceViewportLayout(containerSize, effectiveViewport, zoomFactor) + : resolveBrowserViewportLayout(containerSize, effectiveViewport, zoomFactor); + + useEffect( + () => () => { + dragVersionRef.current += 1; + dragCleanupRef.current?.(); + if (keyboardCommitTimerRef.current !== null) { + clearTimeout(keyboardCommitTimerRef.current); + } + keyboardCommitTimerRef.current = null; + keyboardViewportRef.current = null; + }, + [], + ); + + useEffect(() => { + const pending = keyboardViewportRef.current; + if (!pending || pending.sourceKey === sourceViewportKey) return; + if (keyboardCommitTimerRef.current !== null) { + clearTimeout(keyboardCommitTimerRef.current); + keyboardCommitTimerRef.current = null; + } + keyboardViewportRef.current = null; + }, [sourceViewportKey]); + + const commitViewportChange = useCallback( + (next: PreviewViewportSetting) => { + dragVersionRef.current += 1; + dragCleanupRef.current?.(); + if (keyboardCommitTimerRef.current !== null) { + clearTimeout(keyboardCommitTimerRef.current); + keyboardCommitTimerRef.current = null; + } + keyboardViewportRef.current = null; + setDragViewport(null); + return commitBrowserViewportChange(tabId, next); + }, + [tabId], + ); + + const clearDrag = () => setDragViewport(null); + const commitDrag = (next: PreviewViewportSetting) => { + const version = ++dragVersionRef.current; + const clearIfCurrent = () => { + if (dragVersionRef.current === version) clearDrag(); + }; + void commitBrowserViewportChange(tabId, next).then(clearIfCurrent, clearIfCurrent); + }; + + const handleResizeKeyDown = ( + direction: BrowserViewportResizeDirection, + event: ReactKeyboardEvent, + ) => { + if (effectiveViewport._tag === "fill") return; + const controlsWidth = direction.includes("east") || direction.includes("west"); + const controlsHeight = direction.includes("north") || direction.includes("south"); + const step = (event.shiftKey ? 50 : 10) * normalizedZoomFactor; + const delta = + event.key === "ArrowLeft" && controlsWidth + ? { x: -step, y: 0 } + : event.key === "ArrowRight" && controlsWidth + ? { x: step, y: 0 } + : event.key === "ArrowUp" && controlsHeight + ? { x: 0, y: -step } + : event.key === "ArrowDown" && controlsHeight + ? { x: 0, y: step } + : null; + if (!delta) return; + event.preventDefault(); + event.stopPropagation(); + const pending = keyboardViewportRef.current; + const base = pending?.sourceKey === sourceViewportKey ? pending : effectiveViewport; + const next = resizeFreeformViewport( + base, + delta, + zoomFactor, + direction, + aspectRatio ?? undefined, + ); + if (next.width === base.width && next.height === base.height) return; + const keyboardViewport = { sourceKey: sourceViewportKey, ...next, direction }; + keyboardViewportRef.current = keyboardViewport; + setDragViewport(keyboardViewport); + if (keyboardCommitTimerRef.current !== null) { + clearTimeout(keyboardCommitTimerRef.current); + } + keyboardCommitTimerRef.current = setTimeout(() => { + keyboardCommitTimerRef.current = null; + const latest = keyboardViewportRef.current; + if (!latest || latest.sourceKey !== sourceViewportKeyRef.current) return; + keyboardViewportRef.current = null; + commitDrag({ _tag: "freeform", width: latest.width, height: latest.height }); + }, KEYBOARD_RESIZE_COMMIT_DELAY_MS); + }; + + const handleResizePointerDown = ( + direction: BrowserViewportResizeDirection, + event: ReactPointerEvent, + ) => { + if (effectiveViewport._tag === "fill") return; + event.preventDefault(); + event.stopPropagation(); + if (keyboardCommitTimerRef.current !== null) { + clearTimeout(keyboardCommitTimerRef.current); + keyboardCommitTimerRef.current = null; + } + keyboardViewportRef.current = null; + dragCleanupRef.current?.(); + dragVersionRef.current += 1; + const pointerId = event.pointerId; + const target = event.currentTarget; + const startX = event.clientX; + const startY = event.clientY; + const startWidth = effectiveViewport.width; + const startHeight = effectiveViewport.height; + const dragZoomFactor = normalizedZoomFactor * layout.viewportScale; + let latest = { width: startWidth, height: startHeight }; + setDragViewport({ + sourceKey: sourceViewportKey, + width: startWidth, + height: startHeight, + direction, + }); + try { + target.setPointerCapture(pointerId); + } catch { + // Window listeners below keep the drag functional when capture is unavailable. + } + + const sourceChanged = () => sourceViewportKeyRef.current !== sourceViewportKey; + const move = (moveEvent: PointerEvent) => { + if (moveEvent.pointerId !== pointerId) return; + if (sourceChanged()) { + cleanup(); + dragVersionRef.current += 1; + clearDrag(); + return; + } + moveEvent.preventDefault(); + const { width, height } = resizeBrowserViewportFromRail( + { width: startWidth, height: startHeight }, + { + x: moveEvent.clientX - startX, + y: moveEvent.clientY - startY, + }, + viewportContainerSize, + dragZoomFactor, + direction, + aspectRatio ?? undefined, + ); + latest = { width, height }; + setDragViewport({ sourceKey: sourceViewportKey, width, height, direction }); + }; + function cleanup() { + window.removeEventListener("pointermove", move); + window.removeEventListener("pointerup", finish); + window.removeEventListener("pointercancel", cancel); + dragCleanupRef.current = null; + try { + target.releasePointerCapture(pointerId); + } catch { + // The browser may already have released capture on pointerup. + } + } + function finish(upEvent: PointerEvent) { + if (upEvent.pointerId !== pointerId) return; + cleanup(); + if (sourceChanged() || (latest.width === startWidth && latest.height === startHeight)) { + clearDrag(); + return; + } + commitDrag({ + _tag: "freeform", + width: latest.width, + height: latest.height, + }); + } + function cancel(cancelEvent: PointerEvent) { + if (cancelEvent.pointerId !== pointerId) return; + cleanup(); + dragVersionRef.current += 1; + clearDrag(); + } + dragCleanupRef.current = cleanup; + window.addEventListener("pointermove", move, { passive: false }); + window.addEventListener("pointerup", finish); + window.addEventListener("pointercancel", cancel); + }; + + return { + activeDrag, + commitViewportChange, + effectiveViewport, + handleResizeKeyDown, + handleResizePointerDown, + layout, + }; +} diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index a011a41738..4733b813fe 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -137,7 +137,6 @@ import { addBrowserSurface } from "./preview/addBrowserSurface"; import { closePreviewSession } from "./preview/closePreviewSession"; import { subscribePreviewAction } from "./preview/previewActionBus"; import { getConfiguredPreviewUrls } from "./preview/previewEmptyStateLogic"; -import { PreviewAutomationOwner } from "./preview/PreviewAutomationOwner"; import { RightPanelTabs } from "./RightPanelTabs"; import { DiffWorkerPoolProvider } from "./DiffWorkerPoolProvider"; import { resolveShortcutCommand, shortcutLabelForCommand } from "../keybindings"; @@ -4917,9 +4916,6 @@ function ChatViewContent(props: ChatViewProps) { ref={workspaceLayoutRef} className="relative flex min-h-0 min-w-0 flex-1 overflow-hidden bg-background" > - {isElectron && activeThreadRef ? ( - - ) : null} {rightPanelOpen && !shouldUsePlanSidebarSheet ? panelLayoutControls : null}
diff --git a/apps/web/src/components/preview/AgentBrowserCursor.tsx b/apps/web/src/components/preview/AgentBrowserCursor.tsx index dcaab1e3aa..ca6c2ff723 100644 --- a/apps/web/src/components/preview/AgentBrowserCursor.tsx +++ b/apps/web/src/components/preview/AgentBrowserCursor.tsx @@ -5,6 +5,7 @@ import { MousePointer2 } from "lucide-react"; import { useEffect, useState } from "react"; import { useBrowserPointerStore } from "~/browser/browserPointerStore"; +import { useBrowserSurfaceStore } from "~/browser/browserSurfaceStore"; import { agentBrowserCursorOpacity, type BrowserController } from "./agentBrowserCursorLogic"; @@ -17,6 +18,7 @@ export function AgentBrowserCursor(props: { }) { const { tabId, zoomFactor, controller } = props; const event = useBrowserPointerStore((state) => state.byTabId[tabId] ?? null); + const content = useBrowserSurfaceStore((state) => state.byTabId[tabId]?.content ?? null); if (!event) return null; @@ -24,6 +26,7 @@ export function AgentBrowserCursor(props: { @@ -32,10 +35,17 @@ export function AgentBrowserCursor(props: { function AgentBrowserCursorEvent(props: { readonly event: DesktopPreviewPointerEvent; + readonly content: { + readonly x: number; + readonly y: number; + readonly scale: number; + readonly scrollLeft: number; + readonly scrollTop: number; + } | null; readonly zoomFactor: number; readonly controller: BrowserController; }) { - const { event, zoomFactor, controller } = props; + const { event, content, zoomFactor, controller } = props; const [active, setActive] = useState(true); useEffect(() => { @@ -48,7 +58,7 @@ function AgentBrowserCursorEvent(props: { className="pointer-events-none absolute left-0 top-0 z-40 transition-[transform,opacity] duration-150 ease-out motion-reduce:transition-none" style={{ opacity: agentBrowserCursorOpacity(active, controller), - transform: `translate3d(${event.x * zoomFactor}px, ${event.y * zoomFactor}px, 0)`, + transform: `translate3d(${event.x * zoomFactor * (content?.scale ?? 1) + (content?.x ?? 0) - (content?.scrollLeft ?? 0)}px, ${event.y * zoomFactor * (content?.scale ?? 1) + (content?.y ?? 0) - (content?.scrollTop ?? 0)}px, 0)`, }} aria-hidden="true" data-agent-browser-cursor diff --git a/apps/web/src/components/preview/PreviewAutomationHosts.tsx b/apps/web/src/components/preview/PreviewAutomationHosts.tsx new file mode 100644 index 0000000000..2cd8494691 --- /dev/null +++ b/apps/web/src/components/preview/PreviewAutomationHosts.tsx @@ -0,0 +1,569 @@ +"use client"; + +import { RegistryContext, useAtomSet, useAtomValue } from "@effect/atom-react"; +import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime"; +import { + FILL_PREVIEW_VIEWPORT, + PREVIEW_AUTOMATION_OPERATIONS, + type EnvironmentId, + type PreviewAutomationNavigateInput, + type PreviewAutomationOpenInput, + type PreviewAutomationResizeInput, + type PreviewAutomationResizeResult, + type PreviewAutomationHost as PreviewAutomationHostState, + type PreviewAutomationRequest, + type PreviewAutomationStatus, + type PreviewRenderedViewportSize, + type PreviewViewportSetting, + type ScopedThreadRef, +} from "@t3tools/contracts"; +import { resolvePreviewViewport } from "@t3tools/shared/previewViewport"; +import { useCallback, useContext, useEffect, useMemo, useState } from "react"; +import { Atom } from "effect/unstable/reactivity"; + +import { + applyPreviewServerSnapshot, + readThreadPreviewState, + reconcilePreviewServerSessions, + updatePreviewServerSnapshot, +} from "~/previewStateStore"; +import { useRightPanelStore } from "~/rightPanelStore"; +import { resolveBrowserNavigationTarget } from "~/browser/browserTargetResolver"; +import { + readActiveBrowserRecordingTabId, + startBrowserRecording, + stopBrowserRecording, +} from "~/browser/browserRecording"; +import { resolveBrowserRecordingStopTarget } from "~/browser/browserRecordingScope"; +import { useBrowserSurfaceStore } from "~/browser/browserSurfaceStore"; +import { isElectron } from "~/env"; +import { useEnvironments } from "~/state/environments"; +import { previewEnvironment } from "~/state/preview"; +import { useAtomQueryRunner } from "~/state/use-atom-query-runner"; +import { useAtomCommand } from "~/state/use-atom-command"; + +import { previewBridge } from "./previewBridge"; +import { + PreviewAutomationNavigationTimeoutError, + PreviewAutomationOperationError, + PreviewAutomationOverlayTimeoutError, + PreviewAutomationRecordingNotActiveError, + PreviewAutomationTargetUnavailableError, + PreviewAutomationViewportTimeoutError, +} from "./previewAutomationErrors"; +import { createPreviewAutomationRequestConsumerAtom } from "./previewAutomationRequestConsumer"; +import { createPreviewAutomationClientId } from "./previewAutomationClientId"; +import { + needsPreviewAutomationSessionSync, + resolvePreviewAutomationTarget, +} from "./previewAutomationTarget"; +import { isPreviewViewportReady } from "./previewViewportReadiness"; + +const waitForDesktopOverlay = async ( + threadRef: ScopedThreadRef, + requestId: string, + tabId: string, + timeoutMs: number, +): Promise => { + const deadline = Date.now() + timeoutMs; + while (Date.now() <= deadline) { + const state = readThreadPreviewState(threadRef); + if (state.desktopByTabId[tabId] && previewBridge) { + const status = await previewBridge.automation.status(tabId); + if (status.available) return; + } + await new Promise((resolve) => window.setTimeout(resolve, 50)); + } + throw new PreviewAutomationOverlayTimeoutError({ + requestId, + environmentId: threadRef.environmentId, + threadId: threadRef.threadId, + timeoutMs, + }); +}; + +const waitForNavigationReadiness = async ( + threadRef: ScopedThreadRef, + requestId: string, + tabId: string, + readiness: PreviewAutomationNavigateInput["readiness"], + timeoutMs: number, +): Promise => { + const targetReadiness = readiness ?? "load"; + if (!previewBridge || targetReadiness === "none") return; + const deadline = Date.now() + timeoutMs; + while (Date.now() <= deadline) { + if (targetReadiness === "domContentLoaded") { + const readyState = await previewBridge.automation.evaluate(tabId, { + expression: "document.readyState", + }); + if (readyState === "interactive" || readyState === "complete") return; + } else { + const status = await previewBridge.automation.status(tabId); + if (!status.loading) return; + } + await new Promise((resolve) => window.setTimeout(resolve, 50)); + } + throw new PreviewAutomationNavigationTimeoutError({ + requestId, + environmentId: threadRef.environmentId, + threadId: threadRef.threadId, + tabId, + readiness: targetReadiness, + timeoutMs, + }); +}; + +interface ExecutablePreviewWebview extends Element { + readonly executeJavaScript: (code: string, userGesture?: boolean) => Promise; +} + +const findPreviewWebview = (tabId: string): ExecutablePreviewWebview | null => + Array.from(document.querySelectorAll("webview[data-preview-tab]")).find( + (candidate) => candidate.getAttribute("data-preview-tab") === tabId, + ) ?? null; + +const readWebviewViewport = async ( + webview: ExecutablePreviewWebview, +): Promise => { + const value = await webview.executeJavaScript( + "({ width: window.innerWidth, height: window.innerHeight })", + ); + if (typeof value !== "object" || value === null) return null; + const { width, height } = value as { readonly width?: unknown; readonly height?: unknown }; + return typeof width === "number" && + Number.isInteger(width) && + width > 0 && + typeof height === "number" && + Number.isInteger(height) && + height > 0 + ? { width, height } + : null; +}; + +const readRenderedViewport = async (tabId: string): Promise => { + const webview = findPreviewWebview(tabId); + if (!webview) return null; + return await readWebviewViewport(webview); +}; + +const readDeclaredViewport = ( + webview: ExecutablePreviewWebview | null, +): PreviewRenderedViewportSize | null => { + const width = Number(webview?.getAttribute("data-preview-css-width")); + const height = Number(webview?.getAttribute("data-preview-css-height")); + return Number.isInteger(width) && width > 0 && Number.isInteger(height) && height > 0 + ? { width, height } + : null; +}; + +const waitForRenderedViewport = async ( + tabId: string, + setting: PreviewViewportSetting, + timeoutMs: number, + context: { + readonly requestId: PreviewAutomationRequest["requestId"]; + readonly environmentId: EnvironmentId; + readonly threadId: PreviewAutomationRequest["threadId"]; + }, +): Promise => { + const deadline = Date.now() + timeoutMs; + while (Date.now() <= deadline) { + try { + const webview = findPreviewWebview(tabId); + const appliedSettingKey = webview?.getAttribute("data-preview-viewport-key") ?? null; + const declaredViewport = readDeclaredViewport(webview); + const renderedViewport = webview ? await readWebviewViewport(webview) : null; + if ( + renderedViewport && + isPreviewViewportReady({ + setting, + appliedSettingKey, + declaredViewport, + renderedViewport, + }) + ) { + return renderedViewport; + } + } catch { + // Registration and navigation can transiently replace the guest while + // React applies the server snapshot. Retry until the operation deadline. + } + await new Promise((resolve) => window.setTimeout(resolve, 50)); + } + throw new PreviewAutomationViewportTimeoutError({ + ...context, + tabId, + timeoutMs, + }); +}; + +const currentStatus = async ( + threadRef: ScopedThreadRef, + requestedTabId: string | null, +): Promise => { + const state = readThreadPreviewState(threadRef); + const { snapshot, tabId } = resolvePreviewAutomationTarget(state, requestedTabId); + const visible = tabId + ? (useBrowserSurfaceStore.getState().byTabId[tabId]?.visible ?? false) + : false; + const viewportSetting = snapshot ? (snapshot.viewport ?? FILL_PREVIEW_VIEWPORT) : undefined; + const viewport = tabId ? await readRenderedViewport(tabId).catch(() => null) : null; + const viewportStatus = { + ...(viewportSetting === undefined ? {} : { viewportSetting }), + ...(viewport === null ? {} : { viewport }), + }; + if (tabId && previewBridge && state.desktopByTabId[tabId]) { + const status = await previewBridge.automation.status(tabId); + return { ...status, visible, ...viewportStatus }; + } + const navStatus = snapshot?.navStatus; + return { + available: Boolean(previewBridge?.automation), + visible, + tabId, + url: navStatus && navStatus._tag !== "Idle" ? navStatus.url : null, + title: navStatus && navStatus._tag !== "Idle" ? navStatus.title : null, + loading: navStatus?._tag === "Loading", + ...viewportStatus, + }; +}; + +export function PreviewAutomationHosts() { + const { environments } = useEnvironments(); + if (!isElectron || !previewBridge?.automation) return null; + return ( + <> + {/* + * Host lifetime follows the desktop runtime's environment connections, + * not the routed thread. This keeps background threads automatable and + * lets the subscription runtime own reconnects for every saved target. + */} + {environments.map((environment) => ( + + ))} + + ); +} + +function PreviewAutomationHost(props: { readonly environmentId: EnvironmentId }) { + const { environmentId } = props; + const registry = useContext(RegistryContext); + const [automationClientId] = useState(createPreviewAutomationClientId); + const initialAutomationHost = useMemo( + () => ({ + clientId: automationClientId, + environmentId, + supportedOperations: [...PREVIEW_AUTOMATION_OPERATIONS], + }), + [automationClientId, environmentId], + ); + const automationRequestsAtom = previewEnvironment.automationRequests({ + environmentId, + input: initialAutomationHost, + }); + const listPreviews = useAtomQueryRunner(previewEnvironment.list, { + reportFailure: false, + }); + const open = useAtomCommand(previewEnvironment.open, { + reportFailure: false, + }); + const resize = useAtomCommand(previewEnvironment.resize, { + reportFailure: false, + }); + const respondToAutomation = useAtomCommand( + previewEnvironment.respondToAutomation, + "preview automation response", + ); + const focusAutomationHost = useAtomCommand( + previewEnvironment.focusAutomationHost, + "preview automation host focus", + ); + const [automationConnectionAtom] = useState(() => Atom.make(null)); + const automationConnectionId = useAtomValue(automationConnectionAtom); + + const handleRequest = useCallback( + async (request: PreviewAutomationRequest): Promise => { + const threadRef: ScopedThreadRef = { + environmentId, + threadId: request.threadId, + }; + let tabId = request.tabId ?? null; + try { + let state = readThreadPreviewState(threadRef); + const needsSessionSync = needsPreviewAutomationSessionSync(state, request.tabId); + if (needsSessionSync) { + const listTarget = { + environmentId, + input: { threadId: request.threadId }, + } as const; + registry.refresh(previewEnvironment.list(listTarget)); + const result = await listPreviews(listTarget); + if (result._tag === "Failure") { + throw squashAtomCommandFailure(result); + } + reconcilePreviewServerSessions(threadRef, result.value.sessions); + state = readThreadPreviewState(threadRef); + } + tabId = request.tabId ?? state.snapshot?.tabId ?? null; + const unavailableTarget = { + requestId: request.requestId, + operation: request.operation, + environmentId, + threadId: request.threadId, + tabId, + bridgeAvailable: Boolean(previewBridge), + }; + const requireReadyTab = async () => { + const bridge = previewBridge; + const readyTabId = tabId; + if (!bridge || !readyTabId) { + throw new PreviewAutomationTargetUnavailableError(unavailableTarget); + } + await waitForDesktopOverlay(threadRef, request.requestId, readyTabId, request.timeoutMs); + return { bridge, tabId: readyTabId }; + }; + switch (request.operation) { + case "status": + return await currentStatus(threadRef, tabId); + case "open": { + const input = request.input as PreviewAutomationOpenInput; + let activeTabId = + (input.reuseExistingTab ?? true) ? (state.snapshot?.tabId ?? null) : null; + const reusedExistingTab = activeTabId !== null; + tabId = activeTabId; + if (!activeTabId) { + const result = await open({ + environmentId, + input: { + threadId: request.threadId, + ...(input.url ? { url: input.url } : {}), + }, + }); + if (result._tag === "Failure") { + throw squashAtomCommandFailure(result); + } + const snapshot = result.value; + applyPreviewServerSnapshot(threadRef, snapshot); + activeTabId = snapshot.tabId; + tabId = activeTabId; + } + if (input.show ?? true) { + useRightPanelStore.getState().openBrowser(threadRef, activeTabId); + } + await waitForDesktopOverlay( + threadRef, + request.requestId, + activeTabId, + request.timeoutMs, + ); + if (reusedExistingTab && input.url && previewBridge) { + const resolution = resolveBrowserNavigationTarget(environmentId, { + kind: "url", + url: input.url, + }); + await previewBridge.navigate(activeTabId, resolution.resolvedUrl); + await waitForNavigationReadiness( + threadRef, + request.requestId, + activeTabId, + "load", + request.timeoutMs, + ); + } + return await currentStatus(threadRef, activeTabId); + } + case "navigate": { + const ready = await requireReadyTab(); + const input = request.input as PreviewAutomationNavigateInput; + const resolution = resolveBrowserNavigationTarget( + environmentId, + input.target ?? { + kind: "url", + url: input.url!, + }, + ); + await ready.bridge.navigate(ready.tabId, resolution.resolvedUrl); + await waitForNavigationReadiness( + threadRef, + request.requestId, + ready.tabId, + input.readiness ?? "load", + input.timeoutMs ?? request.timeoutMs, + ); + return await currentStatus(threadRef, ready.tabId); + } + case "resize": { + const ready = await requireReadyTab(); + const input = request.input as PreviewAutomationResizeInput; + const setting = resolvePreviewViewport(input); + const result = await resize({ + environmentId, + input: { + threadId: request.threadId, + tabId: ready.tabId, + viewport: setting, + }, + }); + if (result._tag === "Failure") { + throw squashAtomCommandFailure(result); + } + updatePreviewServerSnapshot(threadRef, result.value); + const viewport = await waitForRenderedViewport( + ready.tabId, + setting, + input.timeoutMs ?? request.timeoutMs, + { + requestId: request.requestId, + environmentId, + threadId: request.threadId, + }, + ); + return { + tabId: ready.tabId, + setting, + viewport, + } satisfies PreviewAutomationResizeResult; + } + case "snapshot": { + const ready = await requireReadyTab(); + return await ready.bridge.automation.snapshot(ready.tabId); + } + case "click": { + const ready = await requireReadyTab(); + return await ready.bridge.automation.click( + ready.tabId, + request.input as Parameters[1], + ); + } + case "type": { + const ready = await requireReadyTab(); + return await ready.bridge.automation.type( + ready.tabId, + request.input as Parameters[1], + ); + } + case "press": { + const ready = await requireReadyTab(); + return await ready.bridge.automation.press( + ready.tabId, + request.input as Parameters[1], + ); + } + case "scroll": { + const ready = await requireReadyTab(); + return await ready.bridge.automation.scroll( + ready.tabId, + request.input as Parameters[1], + ); + } + case "evaluate": { + const ready = await requireReadyTab(); + return await ready.bridge.automation.evaluate( + ready.tabId, + request.input as Parameters[1], + ); + } + case "waitFor": { + const ready = await requireReadyTab(); + return await ready.bridge.automation.waitFor( + ready.tabId, + request.input as Parameters[1], + ); + } + case "recordingStart": { + const ready = await requireReadyTab(); + const startedAt = await startBrowserRecording(ready.tabId); + return { + tabId: ready.tabId, + recording: true, + startedAt, + }; + } + case "recordingStop": { + const recordingTabId = readActiveBrowserRecordingTabId(); + const stopTabId = resolveBrowserRecordingStopTarget(recordingTabId); + const artifact = stopTabId ? await stopBrowserRecording(stopTabId) : null; + if (!artifact) { + throw new PreviewAutomationRecordingNotActiveError({ + requestId: request.requestId, + environmentId, + threadId: request.threadId, + tabId, + }); + } + return artifact; + } + } + } catch (cause) { + throw PreviewAutomationOperationError.fromCause({ + requestId: request.requestId, + operation: request.operation, + environmentId, + threadId: request.threadId, + tabId, + cause, + }); + } + }, + [environmentId, listPreviews, open, registry, resize], + ); + const [requestHandlerAtom] = useState(() => Atom.make({ handle: handleRequest })); + const setRequestHandler = useAtomSet(requestHandlerAtom); + useEffect(() => { + setRequestHandler({ handle: handleRequest }); + }, [handleRequest, setRequestHandler]); + + const automationRequestConsumerAtom = useMemo( + () => + createPreviewAutomationRequestConsumerAtom({ + requestsAtom: automationRequestsAtom, + clientId: automationClientId, + connectionAtom: automationConnectionAtom, + environmentId, + requestHandlerAtom, + respond: (response) => + respondToAutomation({ + environmentId, + input: response, + }), + label: `preview:automation-host:${environmentId}:${automationClientId}`, + }), + [ + automationClientId, + automationConnectionAtom, + automationRequestsAtom, + requestHandlerAtom, + respondToAutomation, + environmentId, + ], + ); + useAtomValue(automationRequestConsumerAtom); + + useEffect(() => { + const report = () => { + if (!automationConnectionId) return; + void focusAutomationHost({ + environmentId, + input: { + clientId: automationClientId, + environmentId, + connectionId: automationConnectionId, + focused: document.hasFocus(), + }, + }); + }; + report(); + window.addEventListener("focus", report); + window.addEventListener("blur", report); + return () => { + window.removeEventListener("focus", report); + window.removeEventListener("blur", report); + }; + }, [automationClientId, automationConnectionId, environmentId, focusAutomationHost]); + + return null; +} diff --git a/apps/web/src/components/preview/PreviewAutomationOwner.test.ts b/apps/web/src/components/preview/PreviewAutomationOwner.test.ts deleted file mode 100644 index fe11ea75aa..0000000000 --- a/apps/web/src/components/preview/PreviewAutomationOwner.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { describe, expect, it } from "vite-plus/test"; - -import { observeAutomationOwnerConnectedGeneration } from "./PreviewAutomationOwner"; - -describe("observeAutomationOwnerConnectedGeneration", () => { - it("reports ownership when the initial transport generation connects", () => { - const initial = observeAutomationOwnerConnectedGeneration(null, 1); - expect(initial).toEqual({ - nextGeneration: 1, - shouldReport: true, - }); - - const disconnected = observeAutomationOwnerConnectedGeneration(initial.nextGeneration, null); - expect(disconnected).toEqual({ - nextGeneration: 1, - shouldReport: false, - }); - - expect(observeAutomationOwnerConnectedGeneration(disconnected.nextGeneration, 2)).toEqual({ - nextGeneration: 2, - shouldReport: true, - }); - }); - - it("does not re-report for repeated connected state from the same generation", () => { - expect(observeAutomationOwnerConnectedGeneration(3, 3)).toEqual({ - nextGeneration: 3, - shouldReport: false, - }); - }); -}); diff --git a/apps/web/src/components/preview/PreviewAutomationOwner.tsx b/apps/web/src/components/preview/PreviewAutomationOwner.tsx deleted file mode 100644 index 2be1436362..0000000000 --- a/apps/web/src/components/preview/PreviewAutomationOwner.tsx +++ /dev/null @@ -1,426 +0,0 @@ -"use client"; - -import { useAtomValue } from "@effect/atom-react"; -import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime"; -import { - type PreviewAutomationNavigateInput, - type PreviewAutomationOpenInput, - type PreviewAutomationOwner as PreviewAutomationOwnerState, - type PreviewAutomationRequest, - type PreviewAutomationStatus, - type ScopedThreadRef, -} from "@t3tools/contracts"; -import { useCallback, useEffect, useEffectEvent, useId, useMemo, useRef, useState } from "react"; - -import { - applyPreviewServerSnapshot, - readThreadPreviewState, - subscribeThreadPreviewState, -} from "~/previewStateStore"; -import { useRightPanelStore } from "~/rightPanelStore"; -import { resolveBrowserNavigationTarget } from "~/browser/browserTargetResolver"; -import { startBrowserRecording, stopBrowserRecording } from "~/browser/browserRecording"; -import { previewEnvironment } from "~/state/preview"; -import { useEnvironmentConnectionState } from "~/state/environments"; -import { useAtomCommand } from "~/state/use-atom-command"; - -import { previewBridge } from "./previewBridge"; -import { - PreviewAutomationNavigationTimeoutError, - PreviewAutomationOperationError, - PreviewAutomationOverlayTimeoutError, - PreviewAutomationRecordingNotActiveError, - PreviewAutomationStaleOwnerError, - PreviewAutomationTargetUnavailableError, -} from "./previewAutomationErrors"; -import { - createLatestPreviewAutomationRequestHandler, - createPreviewAutomationRequestConsumerAtom, -} from "./previewAutomationRequestConsumer"; - -export function observeAutomationOwnerConnectedGeneration( - previousGeneration: number | null, - connectedGeneration: number | null, -): { - readonly nextGeneration: number | null; - readonly shouldReport: boolean; -} { - if (connectedGeneration === null) { - return { - nextGeneration: previousGeneration, - shouldReport: false, - }; - } - return { - nextGeneration: connectedGeneration, - shouldReport: previousGeneration !== connectedGeneration, - }; -} - -const waitForDesktopOverlay = async ( - threadRef: ScopedThreadRef, - requestId: string, - timeoutMs: number, -): Promise => { - const deadline = Date.now() + timeoutMs; - while (Date.now() <= deadline) { - const state = readThreadPreviewState(threadRef); - const tabId = state.snapshot?.tabId; - if (tabId && state.desktopOverlay && previewBridge) { - const status = await previewBridge.automation.status(tabId); - if (status.available) return; - } - await new Promise((resolve) => window.setTimeout(resolve, 50)); - } - throw new PreviewAutomationOverlayTimeoutError({ - requestId, - environmentId: threadRef.environmentId, - threadId: threadRef.threadId, - timeoutMs, - }); -}; - -const waitForNavigationReadiness = async ( - threadRef: ScopedThreadRef, - requestId: string, - tabId: string, - readiness: PreviewAutomationNavigateInput["readiness"], - timeoutMs: number, -): Promise => { - const targetReadiness = readiness ?? "load"; - if (!previewBridge || targetReadiness === "none") return; - const deadline = Date.now() + timeoutMs; - while (Date.now() <= deadline) { - if (targetReadiness === "domContentLoaded") { - const readyState = await previewBridge.automation.evaluate(tabId, { - expression: "document.readyState", - }); - if (readyState === "interactive" || readyState === "complete") return; - } else { - const status = await previewBridge.automation.status(tabId); - if (!status.loading) return; - } - await new Promise((resolve) => window.setTimeout(resolve, 50)); - } - throw new PreviewAutomationNavigationTimeoutError({ - requestId, - environmentId: threadRef.environmentId, - threadId: threadRef.threadId, - tabId, - readiness: targetReadiness, - timeoutMs, - }); -}; - -const currentStatus = async ( - threadRef: ScopedThreadRef, - visible: boolean, -): Promise => { - const state = readThreadPreviewState(threadRef); - const tabId = state.snapshot?.tabId ?? null; - if (tabId && previewBridge && state.desktopOverlay) { - const status = await previewBridge.automation.status(tabId); - return { ...status, visible }; - } - const navStatus = state.snapshot?.navStatus; - return { - available: Boolean(previewBridge?.automation), - visible, - tabId, - url: navStatus && navStatus._tag !== "Idle" ? navStatus.url : null, - title: navStatus && navStatus._tag !== "Idle" ? navStatus.title : null, - loading: navStatus?._tag === "Loading", - }; -}; - -export function PreviewAutomationOwner(props: { - readonly threadRef: ScopedThreadRef; - readonly visible: boolean; -}) { - const { threadRef, visible } = props; - const automationClientId = useId(); - const initialAutomationOwner = useMemo( - () => ({ - clientId: automationClientId, - environmentId: threadRef.environmentId, - threadId: threadRef.threadId, - tabId: null, - visible: false, - supportsAutomation: Boolean(previewBridge?.automation), - focusedAt: new Date().toISOString(), - }), - [automationClientId, threadRef.environmentId, threadRef.threadId], - ); - const automationRequestsAtom = previewEnvironment.automationRequests({ - environmentId: threadRef.environmentId, - input: initialAutomationOwner, - }); - const connectionState = useEnvironmentConnectionState(threadRef.environmentId).data; - const connectedGeneration = - connectionState?.phase === "connected" ? connectionState.generation : null; - const open = useAtomCommand(previewEnvironment.open, { - reportFailure: false, - }); - const respondToAutomation = useAtomCommand( - previewEnvironment.respondToAutomation, - "preview automation response", - ); - const reportAutomationOwner = useAtomCommand( - previewEnvironment.reportAutomationOwner, - "preview automation owner report", - ); - const clearAutomationOwner = useAtomCommand( - previewEnvironment.clearAutomationOwner, - "preview automation owner clear", - ); - const connectedGenerationRef = useRef(null); - const reportCurrentAutomationOwner = useEffectEvent(() => { - const state = readThreadPreviewState(threadRef); - return reportAutomationOwner({ - environmentId: threadRef.environmentId, - input: { - clientId: automationClientId, - environmentId: threadRef.environmentId, - threadId: threadRef.threadId, - tabId: state.snapshot?.tabId ?? null, - visible, - supportsAutomation: Boolean(previewBridge?.automation), - focusedAt: new Date().toISOString(), - }, - }); - }); - useEffect(() => { - void reportCurrentAutomationOwner(); - }, [threadRef, visible]); - - const handleRequest = useCallback( - async (request: PreviewAutomationRequest): Promise => { - let tabId = request.tabId ?? null; - try { - if (request.threadId !== threadRef.threadId) { - throw new PreviewAutomationStaleOwnerError({ - requestId: request.requestId, - environmentId: threadRef.environmentId, - expectedThreadId: threadRef.threadId, - requestedThreadId: request.threadId, - }); - } - const state = readThreadPreviewState(threadRef); - tabId = request.tabId ?? state.snapshot?.tabId ?? null; - const unavailableTarget = { - requestId: request.requestId, - operation: request.operation, - environmentId: threadRef.environmentId, - threadId: threadRef.threadId, - tabId, - bridgeAvailable: Boolean(previewBridge), - }; - switch (request.operation) { - case "status": - return await currentStatus(threadRef, visible); - case "open": { - const input = request.input as PreviewAutomationOpenInput; - let activeTabId = - (input.reuseExistingTab ?? true) ? (state.snapshot?.tabId ?? null) : null; - tabId = activeTabId; - if (!activeTabId) { - const result = await open({ - environmentId: threadRef.environmentId, - input: { - threadId: threadRef.threadId, - ...(input.url ? { url: input.url } : {}), - }, - }); - if (result._tag === "Failure") { - throw squashAtomCommandFailure(result); - } - const snapshot = result.value; - applyPreviewServerSnapshot(threadRef, snapshot); - activeTabId = snapshot.tabId; - tabId = activeTabId; - } else if (input.url && previewBridge) { - await previewBridge.navigate(activeTabId, input.url); - } - if (input.show ?? true) { - useRightPanelStore.getState().openBrowser(threadRef, activeTabId); - } - await waitForDesktopOverlay(threadRef, request.requestId, request.timeoutMs); - return await currentStatus(threadRef, input.show ?? true); - } - case "navigate": { - if (!previewBridge || !tabId) { - throw new PreviewAutomationTargetUnavailableError(unavailableTarget); - } - const input = request.input as PreviewAutomationNavigateInput; - const resolution = resolveBrowserNavigationTarget( - threadRef.environmentId, - input.target ?? { kind: "url", url: input.url! }, - ); - await previewBridge.navigate(tabId, resolution.resolvedUrl); - await waitForNavigationReadiness( - threadRef, - request.requestId, - tabId, - input.readiness ?? "load", - input.timeoutMs ?? request.timeoutMs, - ); - return await currentStatus(threadRef, visible); - } - case "snapshot": - if (!previewBridge || !tabId) { - throw new PreviewAutomationTargetUnavailableError(unavailableTarget); - } - return await previewBridge.automation.snapshot(tabId); - case "click": - if (!previewBridge || !tabId) { - throw new PreviewAutomationTargetUnavailableError(unavailableTarget); - } - return await previewBridge.automation.click( - tabId, - request.input as Parameters[1], - ); - case "type": - if (!previewBridge || !tabId) { - throw new PreviewAutomationTargetUnavailableError(unavailableTarget); - } - return await previewBridge.automation.type( - tabId, - request.input as Parameters[1], - ); - case "press": - if (!previewBridge || !tabId) { - throw new PreviewAutomationTargetUnavailableError(unavailableTarget); - } - return await previewBridge.automation.press( - tabId, - request.input as Parameters[1], - ); - case "scroll": - if (!previewBridge || !tabId) { - throw new PreviewAutomationTargetUnavailableError(unavailableTarget); - } - return await previewBridge.automation.scroll( - tabId, - request.input as Parameters[1], - ); - case "evaluate": - if (!previewBridge || !tabId) { - throw new PreviewAutomationTargetUnavailableError(unavailableTarget); - } - return await previewBridge.automation.evaluate( - tabId, - request.input as Parameters[1], - ); - case "waitFor": - if (!previewBridge || !tabId) { - throw new PreviewAutomationTargetUnavailableError(unavailableTarget); - } - return await previewBridge.automation.waitFor( - tabId, - request.input as Parameters[1], - ); - case "recordingStart": { - if (!tabId) { - throw new PreviewAutomationTargetUnavailableError(unavailableTarget); - } - const startedAt = await startBrowserRecording(tabId); - return { - tabId, - recording: true, - startedAt, - }; - } - case "recordingStop": { - if (!tabId) { - throw new PreviewAutomationTargetUnavailableError(unavailableTarget); - } - const artifact = await stopBrowserRecording(tabId); - if (!artifact) { - throw new PreviewAutomationRecordingNotActiveError({ - requestId: request.requestId, - environmentId: threadRef.environmentId, - threadId: threadRef.threadId, - tabId, - }); - } - return artifact; - } - } - } catch (cause) { - throw PreviewAutomationOperationError.fromCause({ - requestId: request.requestId, - operation: request.operation, - environmentId: threadRef.environmentId, - threadId: threadRef.threadId, - tabId, - cause, - }); - } - }, - [open, threadRef, visible], - ); - const [requestHandler] = useState(() => - createLatestPreviewAutomationRequestHandler(handleRequest), - ); - useEffect(() => { - requestHandler.set(handleRequest); - }, [handleRequest, requestHandler]); - - const automationRequestConsumerAtom = useMemo( - () => - createPreviewAutomationRequestConsumerAtom({ - requestsAtom: automationRequestsAtom, - environmentId: threadRef.environmentId, - handleRequest: requestHandler.handle, - respond: (response) => - respondToAutomation({ - environmentId: threadRef.environmentId, - input: response, - }), - label: `preview:automation-request-consumer:${automationClientId}`, - }), - [ - automationClientId, - automationRequestsAtom, - requestHandler, - respondToAutomation, - threadRef.environmentId, - ], - ); - useAtomValue(automationRequestConsumerAtom); - - useEffect(() => { - const observation = observeAutomationOwnerConnectedGeneration( - connectedGenerationRef.current, - connectedGeneration, - ); - connectedGenerationRef.current = observation.nextGeneration; - if (!observation.shouldReport) return; - - void reportCurrentAutomationOwner(); - }, [connectedGeneration]); - - useEffect(() => { - const report = () => void reportCurrentAutomationOwner(); - window.addEventListener("focus", report); - const unsubscribe = subscribeThreadPreviewState(threadRef, (state, previous) => { - if (state.snapshot?.tabId !== previous.snapshot?.tabId) { - report(); - } - }); - return () => { - window.removeEventListener("focus", report); - unsubscribe(); - void clearAutomationOwner({ - environmentId: threadRef.environmentId, - input: { - clientId: automationClientId, - environmentId: threadRef.environmentId, - threadId: threadRef.threadId, - }, - }); - }; - }, [automationClientId, clearAutomationOwner, threadRef]); - - return null; -} diff --git a/apps/web/src/components/preview/PreviewMoreMenu.tsx b/apps/web/src/components/preview/PreviewMoreMenu.tsx index f11ff4d2d3..13ddcf57e9 100644 --- a/apps/web/src/components/preview/PreviewMoreMenu.tsx +++ b/apps/web/src/components/preview/PreviewMoreMenu.tsx @@ -19,6 +19,10 @@ interface Props { hasWebContents: boolean; /** Current zoom factor as a number (1.0 = 100%). */ zoomFactor: number; + /** Fixed viewport modes expose the device toolbar and resize rails. */ + deviceToolbarVisible: boolean; + /** Switches between fill-panel mode and a fixed responsive viewport. */ + onToggleDeviceToolbar: () => void; } /** @@ -26,7 +30,13 @@ interface Props { * controls, and storage-clearing actions. Only mounted by `PreviewView` * when the desktop bridge is present, so we can call it unconditionally. */ -export function PreviewMoreMenu({ tabId, hasWebContents, zoomFactor }: Props) { +export function PreviewMoreMenu({ + tabId, + hasWebContents, + zoomFactor, + deviceToolbarVisible, + onToggleDeviceToolbar, +}: Props) { if (!previewBridge) return null; const bridge = previewBridge; const tabDisabled = !tabId || !hasWebContents; @@ -59,6 +69,10 @@ export function PreviewMoreMenu({ tabId, hasWebContents, zoomFactor }: Props) { Open DevTools + + {deviceToolbarVisible ? "Hide device toolbar" : "Show device toolbar"} + + {/* Zoom row: label + inline control cluster. `closeOnClick=false` keeps the menu open while the user clicks the +/− buttons. diff --git a/apps/web/src/components/preview/PreviewView.tsx b/apps/web/src/components/preview/PreviewView.tsx index 861a8df616..bb1c4d409e 100644 --- a/apps/web/src/components/preview/PreviewView.tsx +++ b/apps/web/src/components/preview/PreviewView.tsx @@ -1,13 +1,22 @@ "use client"; import { scopedThreadKey } from "@t3tools/client-runtime/environment"; -import { type ScopedThreadRef } from "@t3tools/contracts"; +import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime"; +import { + FILL_PREVIEW_VIEWPORT, + type PreviewViewportSetting, + type ScopedThreadRef, +} from "@t3tools/contracts"; import { useCallback, useEffect, useRef, useState } from "react"; import { useComposerDraftStore } from "~/composerDraftStore"; import { previewAnnotationScreenshotFile } from "~/lib/previewAnnotation"; import { ensureLocalApi } from "~/localApi"; -import { rememberPreviewUrl, useThreadPreviewState } from "~/previewStateStore"; +import { + rememberPreviewUrl, + updatePreviewServerSnapshot, + useThreadPreviewState, +} from "~/previewStateStore"; import { resolveDiscoveredServerUrl } from "~/browser/browserTargetResolver"; import { useEnvironment, useEnvironmentHttpBaseUrl } from "~/state/environments"; import { previewEnvironment } from "~/state/preview"; @@ -20,10 +29,16 @@ import { PreviewChromeRow } from "./PreviewChromeRow"; import { formatPreviewUrl } from "./previewUrlPresentation"; import { PreviewEmptyState } from "./PreviewEmptyState"; import { PreviewMoreMenu } from "./PreviewMoreMenu"; +import { + commitBrowserViewportChange, + subscribeBrowserViewportChange, +} from "~/browser/browserViewportActions"; +import { resolveResponsiveBrowserViewportSize } from "~/browser/browserViewportLayout"; import { PreviewUnreachable } from "./PreviewUnreachable"; import { revealInFileExplorerLabel } from "./fileExplorerLabel"; import { shouldShowPreviewEmptyState } from "./previewEmptyStateLogic"; import { BrowserSurfaceSlot } from "~/browser/BrowserSurfaceSlot"; +import { useBrowserSurfaceStore } from "~/browser/browserSurfaceStore"; import { useLoadingProgress } from "./useLoadingProgress"; import { usePreviewSession } from "./usePreviewSession"; import { ZoomIndicator } from "./ZoomIndicator"; @@ -60,6 +75,7 @@ export function PreviewView({ threadRef, tabId: requestedTabId, configuredUrls, const environment = useEnvironment(threadRef.environmentId); const environmentHttpBaseUrl = useEnvironmentHttpBaseUrl(threadRef.environmentId); const open = useAtomCommand(previewEnvironment.open); + const resize = useAtomCommand(previewEnvironment.resize, "preview viewport resize"); usePreviewSession(threadRef); @@ -91,6 +107,10 @@ export function PreviewView({ threadRef, tabId: requestedTabId, configuredUrls, environmentHttpBaseUrl, }) ?? undefined) : undefined; + const viewport = snapshot?.viewport ?? FILL_PREVIEW_VIEWPORT; + const panelRect = useBrowserSurfaceStore((state) => + tabId ? (state.byTabId[tabId]?.rect ?? null) : null, + ); const handleSubmitUrl = useCallback( async (next: string) => { @@ -131,6 +151,51 @@ export function PreviewView({ threadRef, tabId: requestedTabId, configuredUrls, if (previewBridge && tabId) void previewBridge.resetZoom(tabId); }, [tabId]); + const handleViewportChange = useCallback( + async (nextViewport: PreviewViewportSetting) => { + if (!tabId) return; + const result = await resize({ + environmentId: threadRef.environmentId, + input: { + threadId: threadRef.threadId, + tabId, + viewport: nextViewport, + }, + }); + if (result._tag === "Failure") { + const error = squashAtomCommandFailure(result); + toastManager.add({ + type: "error", + title: "Unable to resize browser viewport", + description: error instanceof Error ? error.message : "An error occurred.", + }); + throw error; + } + updatePreviewServerSnapshot(threadRef, result.value); + }, + [resize, tabId, threadRef], + ); + + const handleToggleDeviceToolbar = () => { + if (!tabId) return; + if (viewport._tag !== "fill") { + void commitBrowserViewportChange(tabId, FILL_PREVIEW_VIEWPORT).catch(() => undefined); + return; + } + + const responsiveSize = panelRect + ? resolveResponsiveBrowserViewportSize(panelRect, desktopOverlay?.zoomFactor) + : { width: 1024, height: 768 }; + void commitBrowserViewportChange(tabId, { _tag: "freeform", ...responsiveSize }).catch( + () => undefined, + ); + }; + + useEffect(() => { + if (!tabId) return; + return subscribeBrowserViewportChange(tabId, handleViewportChange); + }, [handleViewportChange, tabId]); + const handleBack = useCallback(() => { if (previewBridge && tabId) void previewBridge.goBack(tabId); }, [tabId]); @@ -527,6 +592,8 @@ export function PreviewView({ threadRef, tabId: requestedTabId, configuredUrls, tabId={tabId} hasWebContents={desktopOverlay !== null} zoomFactor={desktopOverlay?.zoomFactor ?? 1} + deviceToolbarVisible={viewport._tag !== "fill"} + onToggleDeviceToolbar={handleToggleDeviceToolbar} /> ) : null } diff --git a/apps/web/src/components/preview/previewAutomationClientId.test.ts b/apps/web/src/components/preview/previewAutomationClientId.test.ts new file mode 100644 index 0000000000..f51732d91a --- /dev/null +++ b/apps/web/src/components/preview/previewAutomationClientId.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { createPreviewAutomationClientId } from "./previewAutomationClientId"; + +describe("createPreviewAutomationClientId", () => { + it("creates bounded cryptographically random identities for independent host lifetimes", () => { + const clientIds = Array.from({ length: 32 }, createPreviewAutomationClientId); + + expect(new Set(clientIds).size).toBe(clientIds.length); + expect(clientIds.every((clientId) => clientId.startsWith("preview-"))).toBe(true); + expect(clientIds.every((clientId) => clientId.length <= 128)).toBe(true); + }); +}); diff --git a/apps/web/src/components/preview/previewAutomationClientId.ts b/apps/web/src/components/preview/previewAutomationClientId.ts new file mode 100644 index 0000000000..2d243de303 --- /dev/null +++ b/apps/web/src/components/preview/previewAutomationClientId.ts @@ -0,0 +1,4 @@ +export function createPreviewAutomationClientId(): string { + const bytes = globalThis.crypto.getRandomValues(new Uint8Array(16)); + return `preview-${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`; +} diff --git a/apps/web/src/components/preview/previewAutomationErrors.ts b/apps/web/src/components/preview/previewAutomationErrors.ts index c4ca445458..dcf35de53f 100644 --- a/apps/web/src/components/preview/previewAutomationErrors.ts +++ b/apps/web/src/components/preview/previewAutomationErrors.ts @@ -1,6 +1,6 @@ import { EnvironmentId, - type PreviewAutomationOwner, + type PreviewAutomationHost, PreviewAutomationOperation, type PreviewAutomationRequest, type PreviewAutomationResponse, @@ -13,7 +13,7 @@ import * as Schema from "effect/Schema"; export interface PreviewAutomationOperationContext { readonly requestId: PreviewAutomationRequest["requestId"]; readonly operation: PreviewAutomationRequest["operation"]; - readonly environmentId: PreviewAutomationOwner["environmentId"]; + readonly environmentId: PreviewAutomationHost["environmentId"]; readonly threadId: PreviewAutomationRequest["threadId"]; readonly tabId: Exclude | null; } @@ -56,21 +56,22 @@ export class PreviewAutomationNavigationTimeoutError extends Schema.TaggedErrorC } } -export class PreviewAutomationStaleOwnerError extends Schema.TaggedErrorClass()( - "PreviewAutomationStaleOwnerError", +export class PreviewAutomationViewportTimeoutError extends Schema.TaggedErrorClass()( + "PreviewAutomationViewportTimeoutError", { requestId: TrimmedNonEmptyString, environmentId: EnvironmentId, - expectedThreadId: ThreadId, - requestedThreadId: ThreadId, + threadId: ThreadId, + tabId: PreviewTabId, + timeoutMs: Schema.Int, }, ) { get responseTag() { - return "PreviewAutomationUnavailableError" as const; + return "PreviewAutomationTimeoutError" as const; } override get message(): string { - return `Preview automation request ${this.requestId} targeted thread ${this.requestedThreadId}, but the owner for environment ${this.environmentId} is attached to thread ${this.expectedThreadId}.`; + return `Preview viewport for request ${this.requestId} on environment ${this.environmentId} thread ${this.threadId} tab ${this.tabId} was not rendered within ${this.timeoutMs}ms.`; } } @@ -100,7 +101,7 @@ export class PreviewAutomationRecordingNotActiveError extends Schema.TaggedError requestId: TrimmedNonEmptyString, environmentId: EnvironmentId, threadId: ThreadId, - tabId: PreviewTabId, + tabId: Schema.NullOr(PreviewTabId), }, ) { get responseTag() { @@ -108,10 +109,65 @@ export class PreviewAutomationRecordingNotActiveError extends Schema.TaggedError } override get message(): string { - return `Preview automation request ${this.requestId} found no active recording for tab ${this.tabId} on environment ${this.environmentId} thread ${this.threadId}.`; + return `Preview automation request ${this.requestId} found no active recording for tab ${this.tabId ?? "unassigned"} on environment ${this.environmentId} thread ${this.threadId}.`; } } +export class PreviewAutomationTargetNotEditableHostError extends Schema.TaggedErrorClass()( + "PreviewAutomationTargetNotEditableHostError", + { + requestId: TrimmedNonEmptyString, + operation: PreviewAutomationOperation, + environmentId: EnvironmentId, + threadId: ThreadId, + tabId: Schema.NullOr(PreviewTabId), + selectorKind: Schema.optional(Schema.Literals(["focused-element", "locator", "selector"])), + selectorLength: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))), + }, +) { + get responseTag() { + return "PreviewAutomationTargetNotEditableError" as const; + } + + override get message(): string { + return `Preview automation ${this.operation} request ${this.requestId} requires an editable target in tab ${this.tabId ?? "unassigned"}.`; + } +} + +const targetNotEditableDiagnostics = ( + cause: unknown, +): { + readonly selectorKind?: "focused-element" | "locator" | "selector"; + readonly selectorLength?: number; +} | null => { + if ( + typeof cause !== "object" || + cause === null || + !("_tag" in cause) || + cause._tag !== "PreviewAutomationTargetNotEditableError" + ) { + return null; + } + const selectorKind = + "selectorKind" in cause && + (cause.selectorKind === "focused-element" || + cause.selectorKind === "locator" || + cause.selectorKind === "selector") + ? cause.selectorKind + : undefined; + const selectorLength = + "selectorLength" in cause && + typeof cause.selectorLength === "number" && + Number.isInteger(cause.selectorLength) && + cause.selectorLength >= 0 + ? cause.selectorLength + : undefined; + return { + ...(selectorKind === undefined ? {} : { selectorKind }), + ...(selectorLength === undefined ? {} : { selectorLength }), + }; +}; + export class PreviewAutomationOperationError extends Schema.TaggedErrorClass()( "PreviewAutomationOperationError", { @@ -125,9 +181,18 @@ export class PreviewAutomationOperationError extends Schema.TaggedErrorClass
 {
   const detail = Object.fromEntries(
     Object.entries(error).filter(
diff --git a/apps/web/src/components/preview/previewAutomationRequestConsumer.test.ts b/apps/web/src/components/preview/previewAutomationRequestConsumer.test.ts
index 905a014d5a..af3a95c32c 100644
--- a/apps/web/src/components/preview/previewAutomationRequestConsumer.test.ts
+++ b/apps/web/src/components/preview/previewAutomationRequestConsumer.test.ts
@@ -2,13 +2,18 @@ import {
   EnvironmentId,
   type PreviewAutomationRequest,
   type PreviewAutomationResponse,
+  type PreviewAutomationStreamEvent,
   PreviewTabId,
   ThreadId,
 } from "@t3tools/contracts";
 import { AsyncResult, Atom, AtomRegistry } from "effect/unstable/reactivity";
 import { describe, expect, it, vi } from "vite-plus/test";
 
-import { PreviewAutomationTargetUnavailableError } from "./previewAutomationErrors";
+import {
+  PreviewAutomationRecordingNotActiveError,
+  PreviewAutomationTargetUnavailableError,
+  PreviewAutomationViewportTimeoutError,
+} from "./previewAutomationErrors";
 import {
   createPreviewAutomationRequestConsumerAtom,
   serializePreviewAutomationError,
@@ -17,6 +22,8 @@ import {
 const environmentId = EnvironmentId.make("environment-1");
 const threadId = ThreadId.make("thread-1");
 const tabId = PreviewTabId.make("tab-1");
+const clientId = "client-1";
+const connectionId = "connection-1";
 
 const request = (
   requestId: string,
@@ -30,10 +37,88 @@ const request = (
   ...overrides,
 });
 
+const requestEvent = (
+  requestId: string,
+  overrides: Partial = {},
+  eventConnectionId = connectionId,
+): PreviewAutomationStreamEvent => ({
+  type: "request",
+  connectionId: eventConnectionId,
+  request: request(requestId, overrides),
+});
+
+const consumerState = (handleRequest: (request: PreviewAutomationRequest) => Promise) => ({
+  connectionAtom: Atom.make(null),
+  requestHandlerAtom: Atom.make({ handle: handleRequest }),
+});
+
 describe("previewAutomationRequestConsumer", () => {
+  it("acknowledges a replacement stream before consuming requests from it", async () => {
+    const requestsAtom = Atom.make(
+      AsyncResult.success({
+        type: "connected",
+        connectionId,
+      }),
+    );
+    const handleRequest = vi.fn(async () => undefined);
+    const respond = vi.fn(async () => undefined);
+    const state = consumerState(handleRequest);
+    const consumerAtom = createPreviewAutomationRequestConsumerAtom({
+      requestsAtom,
+      clientId,
+      connectionAtom: state.connectionAtom,
+      environmentId,
+      requestHandlerAtom: state.requestHandlerAtom,
+      respond,
+      label: "test:preview-automation-connected",
+    });
+    const registry = AtomRegistry.make();
+
+    registry.mount(consumerAtom);
+    registry.set(requestsAtom, AsyncResult.success(requestEvent("request-after-connect")));
+
+    await vi.waitFor(() => expect(registry.get(state.connectionAtom)).toBe(connectionId));
+    await vi.waitFor(() => expect(respond).toHaveBeenCalledTimes(1));
+    expect(handleRequest).toHaveBeenCalledTimes(1);
+    registry.dispose();
+  });
+
+  it("drops late requests from an older stream generation", async () => {
+    const requestsAtom = Atom.make(
+      AsyncResult.success({
+        type: "connected",
+        connectionId: "connection-2",
+      }),
+    );
+    const handleRequest = vi.fn(async () => undefined);
+    const respond = vi.fn(async () => undefined);
+    const state = consumerState(handleRequest);
+    const consumerAtom = createPreviewAutomationRequestConsumerAtom({
+      requestsAtom,
+      clientId,
+      connectionAtom: state.connectionAtom,
+      environmentId,
+      requestHandlerAtom: state.requestHandlerAtom,
+      respond,
+      label: "test:preview-automation-stale-generation",
+    });
+    const registry = AtomRegistry.make();
+
+    registry.mount(consumerAtom);
+    registry.set(
+      requestsAtom,
+      AsyncResult.success(requestEvent("request-stale", {}, "connection-1")),
+    );
+
+    await vi.waitFor(() => expect(registry.get(state.connectionAtom)).toBe("connection-2"));
+    expect(handleRequest).not.toHaveBeenCalled();
+    expect(respond).not.toHaveBeenCalled();
+    registry.dispose();
+  });
+
   it("consumes every request emitted before React can render", async () => {
-    const requestsAtom = Atom.make>(
-      AsyncResult.initial(false),
+    const requestsAtom = Atom.make>(
+      AsyncResult.initial(false),
     );
     const handleRequest = vi.fn(async (value: PreviewAutomationRequest) => ({
       requestId: value.requestId,
@@ -42,18 +127,21 @@ describe("previewAutomationRequestConsumer", () => {
     const respond = vi.fn(async (response: PreviewAutomationResponse) => {
       responses.push(response);
     });
+    const state = consumerState(handleRequest);
     const consumerAtom = createPreviewAutomationRequestConsumerAtom({
       requestsAtom,
+      clientId,
+      connectionAtom: state.connectionAtom,
       environmentId,
-      handleRequest,
+      requestHandlerAtom: state.requestHandlerAtom,
       respond,
       label: "test:preview-automation-consumer",
     });
     const registry = AtomRegistry.make();
     registry.mount(consumerAtom);
 
-    registry.set(requestsAtom, AsyncResult.success(request("request-1")));
-    registry.set(requestsAtom, AsyncResult.success(request("request-2")));
+    registry.set(requestsAtom, AsyncResult.success(requestEvent("request-1")));
+    registry.set(requestsAtom, AsyncResult.success(requestEvent("request-2")));
 
     await vi.waitFor(() => expect(respond).toHaveBeenCalledTimes(2));
     expect(handleRequest.mock.calls.map(([value]) => value.requestId)).toEqual([
@@ -64,15 +152,50 @@ describe("previewAutomationRequestConsumer", () => {
     registry.dispose();
   });
 
-  it("consumes a request that arrived immediately before the consumer mounted", async () => {
-    const requestsAtom = Atom.make(
-      AsyncResult.success(request("request-ready")),
+  it("uses the latest request handler without rebuilding the stream consumer", async () => {
+    const requestsAtom = Atom.make>(
+      AsyncResult.initial(false),
     );
+    const firstHandler = vi.fn(async () => "first");
+    const secondHandler = vi.fn(async () => "second");
     const respond = vi.fn(async (_response: PreviewAutomationResponse) => undefined);
+    const state = consumerState(firstHandler);
     const consumerAtom = createPreviewAutomationRequestConsumerAtom({
       requestsAtom,
+      clientId,
+      connectionAtom: state.connectionAtom,
       environmentId,
-      handleRequest: async () => undefined,
+      requestHandlerAtom: state.requestHandlerAtom,
+      respond,
+      label: "test:preview-automation-latest-handler",
+    });
+    const registry = AtomRegistry.make();
+    registry.mount(consumerAtom);
+
+    registry.set(requestsAtom, AsyncResult.success(requestEvent("request-first")));
+    await vi.waitFor(() => expect(respond).toHaveBeenCalledTimes(1));
+    registry.set(state.requestHandlerAtom, { handle: secondHandler });
+    registry.set(requestsAtom, AsyncResult.success(requestEvent("request-second")));
+
+    await vi.waitFor(() => expect(respond).toHaveBeenCalledTimes(2));
+    expect(firstHandler).toHaveBeenCalledTimes(1);
+    expect(secondHandler).toHaveBeenCalledTimes(1);
+    expect(respond.mock.calls.map(([response]) => response.result)).toEqual(["first", "second"]);
+    registry.dispose();
+  });
+
+  it("consumes a request that arrived immediately before the consumer mounted", async () => {
+    const requestsAtom = Atom.make(
+      AsyncResult.success(requestEvent("request-ready")),
+    );
+    const respond = vi.fn(async (_response: PreviewAutomationResponse) => undefined);
+    const state = consumerState(async () => undefined);
+    const consumerAtom = createPreviewAutomationRequestConsumerAtom({
+      requestsAtom,
+      clientId,
+      connectionAtom: state.connectionAtom,
+      environmentId,
+      requestHandlerAtom: state.requestHandlerAtom,
       respond,
       label: "test:preview-automation-initial-request",
     });
@@ -81,7 +204,12 @@ describe("previewAutomationRequestConsumer", () => {
     registry.mount(consumerAtom);
 
     await vi.waitFor(() => expect(respond).toHaveBeenCalledTimes(1));
-    expect(respond).toHaveBeenCalledWith({ requestId: "request-ready", ok: true });
+    expect(respond).toHaveBeenCalledWith({
+      clientId,
+      connectionId,
+      requestId: "request-ready",
+      ok: true,
+    });
     registry.dispose();
   });
 
@@ -118,6 +246,84 @@ describe("previewAutomationRequestConsumer", () => {
     });
   });
 
+  it("reports a missing recording even when no preview tab remains", () => {
+    const error = new PreviewAutomationRecordingNotActiveError({
+      requestId: "request-recording-stop",
+      environmentId,
+      threadId,
+      tabId: null,
+    });
+
+    expect(
+      serializePreviewAutomationError(error, {
+        requestId: "request-recording-stop",
+        operation: "recordingStop",
+        environmentId,
+        threadId,
+        tabId: null,
+      }),
+    ).toMatchObject({
+      _tag: "PreviewAutomationExecutionError",
+      detail: { tabId: null },
+    });
+  });
+
+  it("preserves viewport render timeouts as timeout responses", () => {
+    const error = new PreviewAutomationViewportTimeoutError({
+      requestId: "request-resize",
+      environmentId,
+      threadId,
+      tabId,
+      timeoutMs: 2_500,
+    });
+
+    expect(
+      serializePreviewAutomationError(error, {
+        requestId: "request-resize",
+        operation: "resize",
+        environmentId,
+        threadId,
+        tabId,
+      }),
+    ).toMatchObject({
+      _tag: "PreviewAutomationTimeoutError",
+      detail: { tabId: "tab-1", timeoutMs: 2_500 },
+    });
+  });
+
+  it("maps desktop non-editable targets to the public typed response", () => {
+    expect(
+      serializePreviewAutomationError(
+        {
+          _tag: "PreviewAutomationTargetNotEditableError",
+          tabId: "tab-1",
+          selectorKind: "selector",
+          selectorLength: 6,
+        },
+        {
+          requestId: "request-type",
+          operation: "type",
+          environmentId,
+          threadId,
+          tabId,
+        },
+      ),
+    ).toEqual({
+      _tag: "PreviewAutomationTargetNotEditableError",
+      message:
+        "Preview automation type request request-type requires an editable target in tab tab-1.",
+      detail: {
+        requestId: "request-type",
+        operation: "type",
+        environmentId: "environment-1",
+        threadId: "thread-1",
+        tabId: "tab-1",
+        selectorKind: "selector",
+        selectorLength: 6,
+      },
+    });
+  });
+
   it("correlates unexpected failures without exposing cause details", () => {
     const cause = new Error("private bridge token: preview-secret");
     const context = {
@@ -145,16 +351,19 @@ describe("previewAutomationRequestConsumer", () => {
   });
 
   it("sanitizes unexpected handler failures at the response boundary", async () => {
-    const requestsAtom = Atom.make>(
-      AsyncResult.initial(false),
+    const requestsAtom = Atom.make>(
+      AsyncResult.initial(false),
     );
     const responses: PreviewAutomationResponse[] = [];
+    const state = consumerState(async () => {
+      throw new Error("desktop IPC secret: do-not-return");
+    });
     const consumerAtom = createPreviewAutomationRequestConsumerAtom({
       requestsAtom,
+      clientId,
+      connectionAtom: state.connectionAtom,
       environmentId,
-      handleRequest: async () => {
-        throw new Error("desktop IPC secret: do-not-return");
-      },
+      requestHandlerAtom: state.requestHandlerAtom,
       respond: async (response) => {
         responses.push(response);
       },
@@ -166,7 +375,7 @@ describe("previewAutomationRequestConsumer", () => {
     registry.set(
       requestsAtom,
       AsyncResult.success(
-        request("request-failed", {
+        requestEvent("request-failed", {
           operation: "click",
           tabId,
         }),
@@ -175,6 +384,8 @@ describe("previewAutomationRequestConsumer", () => {
 
     await vi.waitFor(() => expect(responses).toHaveLength(1));
     expect(responses[0]).toEqual({
+      clientId,
+      connectionId,
       requestId: "request-failed",
       ok: false,
       error: {
diff --git a/apps/web/src/components/preview/previewAutomationRequestConsumer.ts b/apps/web/src/components/preview/previewAutomationRequestConsumer.ts
index 37983b0255..89a9387e4a 100644
--- a/apps/web/src/components/preview/previewAutomationRequestConsumer.ts
+++ b/apps/web/src/components/preview/previewAutomationRequestConsumer.ts
@@ -1,87 +1,121 @@
 import type {
-  PreviewAutomationOwner,
+  PreviewAutomationHost,
   PreviewAutomationRequest,
   PreviewAutomationResponse,
+  PreviewAutomationStreamEvent,
 } from "@t3tools/contracts";
 import { AsyncResult, Atom } from "effect/unstable/reactivity";
 
 import {
   PreviewAutomationOperationError,
   type PreviewAutomationOperationContext,
-  serializePreviewAutomationOwnerError,
+  serializePreviewAutomationHostError,
 } from "./previewAutomationErrors";
 
-type AutomationRequestResult = AsyncResult.AsyncResult;
-type AutomationRequestHandler = (request: PreviewAutomationRequest) => Promise;
-
-export function createLatestPreviewAutomationRequestHandler(initial: AutomationRequestHandler): {
-  readonly set: (handler: AutomationRequestHandler) => void;
-  readonly handle: AutomationRequestHandler;
-} {
-  let current = initial;
-  return {
-    set: (handler) => {
-      current = handler;
-    },
-    handle: (request) => current(request),
-  };
-}
+type AutomationStreamResult = AsyncResult.AsyncResult;
 
 export function serializePreviewAutomationError(
   error: unknown,
   context: PreviewAutomationOperationContext,
 ): NonNullable {
-  return serializePreviewAutomationOwnerError(
+  return serializePreviewAutomationHostError(
     PreviewAutomationOperationError.fromCause({ ...context, cause: error }),
   );
 }
 
 export function createPreviewAutomationRequestConsumerAtom(options: {
-  readonly requestsAtom: Atom.Atom>;
-  readonly environmentId: PreviewAutomationOwner["environmentId"];
-  readonly handleRequest: (request: PreviewAutomationRequest) => Promise;
+  readonly requestsAtom: Atom.Atom>;
+  readonly clientId: PreviewAutomationHost["clientId"];
+  readonly connectionAtom: Atom.Writable;
+  readonly environmentId: PreviewAutomationHost["environmentId"];
+  readonly requestHandlerAtom: Atom.Atom<{
+    readonly handle: (request: PreviewAutomationRequest) => Promise;
+  }>;
   readonly respond: (response: PreviewAutomationResponse) => Promise;
   readonly label: string;
 }): Atom.Atom {
   return Atom.make((get) => {
+    get.mount(options.connectionAtom);
+    get.mount(options.requestHandlerAtom);
     let disposed = false;
+    let activeConnectionId: PreviewAutomationStreamEvent["connectionId"] | null = null;
+    let connectionExplicitlyAnnounced = false;
+    let reportedConnectionId: PreviewAutomationStreamEvent["connectionId"] | null = null;
     let requestsVersion = 0;
 
-    const consume = (result: AutomationRequestResult) => {
+    const consume = (result: AutomationStreamResult) => {
       if (!AsyncResult.isSuccess(result)) return;
-      const request = result.value;
-      void options.handleRequest(request).then(
-        (value) =>
-          options.respond({
-            requestId: request.requestId,
-            ok: true,
-            ...(value === undefined ? {} : { result: value }),
-          }),
-        (error) =>
-          options.respond({
-            requestId: request.requestId,
-            ok: false,
-            error: serializePreviewAutomationError(error, {
+      const event = result.value;
+      if (event.type === "connected") {
+        activeConnectionId = event.connectionId;
+        connectionExplicitlyAnnounced = true;
+      } else if (activeConnectionId === null) {
+        activeConnectionId = event.connectionId;
+      } else if (activeConnectionId !== event.connectionId) {
+        if (connectionExplicitlyAnnounced) return;
+        activeConnectionId = event.connectionId;
+      }
+      if (reportedConnectionId !== event.connectionId) {
+        reportedConnectionId = event.connectionId;
+        get.set(options.connectionAtom, event.connectionId);
+      }
+      if (event.type === "connected") {
+        return;
+      }
+      const request = event.request;
+      void get
+        .once(options.requestHandlerAtom)
+        .handle(request)
+        .then(
+          (value) =>
+            options.respond({
+              clientId: options.clientId,
+              connectionId: event.connectionId,
               requestId: request.requestId,
-              operation: request.operation,
-              environmentId: options.environmentId,
-              threadId: request.threadId,
-              tabId: request.tabId ?? null,
+              ok: true,
+              ...(value === undefined ? {} : { result: value }),
             }),
-          }),
-      );
+          (error) =>
+            options.respond({
+              clientId: options.clientId,
+              connectionId: event.connectionId,
+              requestId: request.requestId,
+              ok: false,
+              error: serializePreviewAutomationError(error, {
+                requestId: request.requestId,
+                operation: request.operation,
+                environmentId: options.environmentId,
+                threadId: request.threadId,
+                tabId: request.tabId ?? null,
+              }),
+            }),
+        );
     };
 
     get.addFinalizer(() => {
       disposed = true;
     });
     const initialRequest = get.once(options.requestsAtom);
+    if (AsyncResult.isSuccess(initialRequest)) {
+      activeConnectionId = initialRequest.value.connectionId;
+      connectionExplicitlyAnnounced = initialRequest.value.type === "connected";
+      if (initialRequest.value.type === "connected") {
+        reportedConnectionId = initialRequest.value.connectionId;
+        get.set(options.connectionAtom, initialRequest.value.connectionId);
+      }
+    }
     get.subscribe(options.requestsAtom, (result) => {
       requestsVersion += 1;
       consume(result);
     });
     queueMicrotask(() => {
-      if (!disposed && requestsVersion === 0) consume(initialRequest);
+      const initialConnectionWasSkipped =
+        AsyncResult.isSuccess(initialRequest) &&
+        initialRequest.value.connectionId === activeConnectionId &&
+        initialRequest.value.connectionId !== reportedConnectionId;
+      if (!disposed && (requestsVersion === 0 || initialConnectionWasSkipped)) {
+        consume(initialRequest);
+      }
     });
   }).pipe(Atom.setIdleTTL(0), Atom.withLabel(options.label));
 }
diff --git a/apps/web/src/components/preview/previewAutomationTarget.test.ts b/apps/web/src/components/preview/previewAutomationTarget.test.ts
new file mode 100644
index 0000000000..379e351905
--- /dev/null
+++ b/apps/web/src/components/preview/previewAutomationTarget.test.ts
@@ -0,0 +1,45 @@
+import type { PreviewSessionSnapshot } from "@t3tools/contracts";
+import { describe, expect, it } from "vite-plus/test";
+
+import {
+  needsPreviewAutomationSessionSync,
+  resolvePreviewAutomationTarget,
+} from "./previewAutomationTarget";
+
+const snapshot = (tabId: string): PreviewSessionSnapshot => ({
+  threadId: "thread-1",
+  tabId,
+  navStatus: { _tag: "Idle" },
+  canGoBack: false,
+  canGoForward: false,
+  updatedAt: "2026-01-01T00:00:00.000Z",
+});
+
+describe("preview automation target selection", () => {
+  it("refreshes authoritative sessions whenever the caller relies on the active tab", () => {
+    const active = snapshot("tab-active");
+    expect(
+      needsPreviewAutomationSessionSync(
+        { snapshot: active, sessions: { [active.tabId]: active } },
+        undefined,
+      ),
+    ).toBe(true);
+  });
+
+  it("refreshes an explicit tab only when it is absent locally", () => {
+    const active = snapshot("tab-active");
+    const state = { snapshot: active, sessions: { [active.tabId]: active } };
+    expect(needsPreviewAutomationSessionSync(state, active.tabId)).toBe(false);
+    expect(needsPreviewAutomationSessionSync(state, "tab-missing")).toBe(true);
+  });
+
+  it("does not report the active tab under an unknown requested tab id", () => {
+    const active = snapshot("tab-active");
+    expect(
+      resolvePreviewAutomationTarget(
+        { snapshot: active, sessions: { [active.tabId]: active } },
+        "tab-missing",
+      ),
+    ).toEqual({ tabId: null, snapshot: null });
+  });
+});
diff --git a/apps/web/src/components/preview/previewAutomationTarget.ts b/apps/web/src/components/preview/previewAutomationTarget.ts
new file mode 100644
index 0000000000..1dc9f17f78
--- /dev/null
+++ b/apps/web/src/components/preview/previewAutomationTarget.ts
@@ -0,0 +1,25 @@
+import type { PreviewSessionSnapshot } from "@t3tools/contracts";
+
+interface PreviewAutomationSessionIndex {
+  readonly snapshot: PreviewSessionSnapshot | null;
+  readonly sessions: Readonly>;
+}
+
+export function needsPreviewAutomationSessionSync(
+  state: PreviewAutomationSessionIndex,
+  requestedTabId: string | undefined,
+): boolean {
+  return (
+    Object.keys(state.sessions).length === 0 ||
+    requestedTabId === undefined ||
+    state.sessions[requestedTabId] === undefined
+  );
+}
+
+export function resolvePreviewAutomationTarget(
+  state: PreviewAutomationSessionIndex,
+  requestedTabId: string | null,
+): { readonly tabId: string | null; readonly snapshot: PreviewSessionSnapshot | null } {
+  const snapshot = requestedTabId ? (state.sessions[requestedTabId] ?? null) : state.snapshot;
+  return { tabId: snapshot?.tabId ?? null, snapshot };
+}
diff --git a/apps/web/src/components/preview/previewViewportReadiness.test.ts b/apps/web/src/components/preview/previewViewportReadiness.test.ts
new file mode 100644
index 0000000000..c47ffc3ff0
--- /dev/null
+++ b/apps/web/src/components/preview/previewViewportReadiness.test.ts
@@ -0,0 +1,72 @@
+import { describe, expect, it } from "vite-plus/test";
+
+import { browserViewportSettingKey } from "~/browser/browserViewportLayout";
+
+import { isPreviewViewportReady } from "./previewViewportReadiness";
+
+describe("isPreviewViewportReady", () => {
+  const landscape = {
+    _tag: "preset",
+    width: 844,
+    height: 390,
+    presetId: "iphone-12-pro",
+  } as const;
+
+  it("rejects a stale same-mode preset while React applies the requested orientation", () => {
+    expect(
+      isPreviewViewportReady({
+        setting: landscape,
+        appliedSettingKey: "preset:390:844:iphone-12-pro",
+        declaredViewport: { width: 390, height: 844 },
+        renderedViewport: { width: 390, height: 844 },
+      }),
+    ).toBe(false);
+  });
+
+  it("requires both the declaration and guest viewport to match a fixed request", () => {
+    const appliedSettingKey = browserViewportSettingKey(landscape);
+    expect(
+      isPreviewViewportReady({
+        setting: landscape,
+        appliedSettingKey,
+        declaredViewport: { width: 390, height: 844 },
+        renderedViewport: { width: 844, height: 390 },
+      }),
+    ).toBe(false);
+    expect(
+      isPreviewViewportReady({
+        setting: landscape,
+        appliedSettingKey,
+        declaredViewport: { width: 844, height: 390 },
+        renderedViewport: { width: 844, height: 390 },
+      }),
+    ).toBe(true);
+  });
+
+  it("allows one pixel of Electron rounding tolerance in every mode", () => {
+    expect(
+      isPreviewViewportReady({
+        setting: { _tag: "fill" },
+        appliedSettingKey: "fill",
+        declaredViewport: { width: 500, height: 700 },
+        renderedViewport: { width: 501, height: 699 },
+      }),
+    ).toBe(true);
+    expect(
+      isPreviewViewportReady({
+        setting: landscape,
+        appliedSettingKey: browserViewportSettingKey(landscape),
+        declaredViewport: { width: 844, height: 390 },
+        renderedViewport: { width: 845, height: 389 },
+      }),
+    ).toBe(true);
+    expect(
+      isPreviewViewportReady({
+        setting: landscape,
+        appliedSettingKey: browserViewportSettingKey(landscape),
+        declaredViewport: { width: 844, height: 390 },
+        renderedViewport: { width: 846, height: 390 },
+      }),
+    ).toBe(false);
+  });
+});
diff --git a/apps/web/src/components/preview/previewViewportReadiness.ts b/apps/web/src/components/preview/previewViewportReadiness.ts
new file mode 100644
index 0000000000..5ff963fbce
--- /dev/null
+++ b/apps/web/src/components/preview/previewViewportReadiness.ts
@@ -0,0 +1,37 @@
+import type { PreviewRenderedViewportSize, PreviewViewportSetting } from "@t3tools/contracts";
+
+import { browserViewportSettingKey } from "~/browser/browserViewportLayout";
+
+export function isPreviewViewportReady(input: {
+  readonly setting: PreviewViewportSetting;
+  readonly appliedSettingKey: string | null;
+  readonly declaredViewport: PreviewRenderedViewportSize | null;
+  readonly renderedViewport: PreviewRenderedViewportSize | null;
+}): boolean {
+  const { setting, appliedSettingKey, declaredViewport, renderedViewport } = input;
+  if (
+    appliedSettingKey !== browserViewportSettingKey(setting) ||
+    declaredViewport === null ||
+    renderedViewport === null
+  ) {
+    return false;
+  }
+
+  const expectedViewport =
+    setting._tag === "fill" ? declaredViewport : { width: setting.width, height: setting.height };
+  if (
+    setting._tag !== "fill" &&
+    (declaredViewport.width !== expectedViewport.width ||
+      declaredViewport.height !== expectedViewport.height)
+  ) {
+    return false;
+  }
+
+  // Electron rounds CSS pixels through the guest's fractional zoom/device scale,
+  // so a successfully applied fixed viewport can measure one pixel either way.
+  const tolerance = 1;
+  return (
+    Math.abs(renderedViewport.width - expectedViewport.width) <= tolerance &&
+    Math.abs(renderedViewport.height - expectedViewport.height) <= tolerance
+  );
+}
diff --git a/apps/web/src/components/preview/usePreviewSession.ts b/apps/web/src/components/preview/usePreviewSession.ts
index 2a82f62757..9bc2cc84c3 100644
--- a/apps/web/src/components/preview/usePreviewSession.ts
+++ b/apps/web/src/components/preview/usePreviewSession.ts
@@ -11,6 +11,7 @@ import {
   applyPreviewServerEvent,
   applyPreviewServerSnapshot,
   readThreadPreviewState,
+  reconcilePreviewServerSessions,
 } from "~/previewStateStore";
 import { previewEnvironment } from "~/state/preview";
 
@@ -50,9 +51,7 @@ const previewSessionSyncAtom = Atom.family((threadKey: string) => {
       if (result.value.sessions.length > 0) {
         recoveringUrl = null;
         recoveryId += 1;
-        for (const snapshot of result.value.sessions) {
-          applyPreviewServerSnapshot(threadRef, snapshot);
-        }
+        reconcilePreviewServerSessions(threadRef, result.value.sessions);
         return;
       }
 
diff --git a/apps/web/src/previewStateStore.test.ts b/apps/web/src/previewStateStore.test.ts
index d2bf2e7c26..c908e23f9b 100644
--- a/apps/web/src/previewStateStore.test.ts
+++ b/apps/web/src/previewStateStore.test.ts
@@ -11,10 +11,12 @@ import {
   cancelPreviewSessionClose,
   previewStateAtom,
   readThreadPreviewState,
+  reconcilePreviewServerSessions,
   rememberPreviewUrl,
   removePreviewThread,
   resetPreviewStateForTests,
   setActivePreviewTab,
+  updatePreviewServerSnapshot,
 } from "./previewStateStore";
 
 const environmentId = "env-1" as EnvironmentId;
@@ -108,6 +110,34 @@ describe("previewStateStore (single-tab)", () => {
     }
   });
 
+  it("resized event updates tab viewport without changing the active tab", () => {
+    const active = makeSnapshot({ tabId: "tab_a" });
+    const background = makeSnapshot({ tabId: "tab_b" });
+    applyPreviewServerSnapshot(ref, background);
+    applyPreviewServerSnapshot(ref, active);
+
+    applyPreviewServerEvent(ref, {
+      type: "resized",
+      threadId: "thread-1",
+      tabId: background.tabId,
+      createdAt: "2026-01-01T00:00:01.000Z",
+      snapshot: {
+        ...background,
+        viewport: { _tag: "preset", presetId: "pixel-8", width: 412, height: 915 },
+        updatedAt: "2026-01-01T00:00:01.000Z",
+      },
+    });
+
+    const state = readThreadPreviewState(ref);
+    expect(state.activeTabId).toBe(active.tabId);
+    expect(state.sessions[background.tabId]?.viewport).toEqual({
+      _tag: "preset",
+      presetId: "pixel-8",
+      width: 412,
+      height: 915,
+    });
+  });
+
   it("failed event flips the snapshot to LoadFailed when tabId matches", () => {
     const snapshot = makeSnapshot();
     applyPreviewServerEvent(ref, {
@@ -292,6 +322,64 @@ describe("previewStateStore (single-tab)", () => {
     expect(state.desktopOverlay?.canGoBack).toBe(true);
   });
 
+  it("updates a background snapshot without changing the active tab", () => {
+    const background = makeSnapshot({ tabId: "tab_a" });
+    const active = makeSnapshot({
+      tabId: "tab_b",
+      updatedAt: "2026-01-01T00:00:01.000Z",
+    });
+    applyPreviewServerSnapshot(ref, background);
+    applyPreviewServerSnapshot(ref, active);
+
+    const resized = {
+      ...background,
+      viewport: { _tag: "freeform" as const, width: 900, height: 700 },
+      updatedAt: "2026-01-01T00:00:02.000Z",
+    };
+    updatePreviewServerSnapshot(ref, resized);
+
+    const state = readThreadPreviewState(ref);
+    expect(state.activeTabId).toBe(active.tabId);
+    expect(state.snapshot?.tabId).toBe(active.tabId);
+    expect(state.sessions[background.tabId]).toEqual(resized);
+  });
+
+  it("reconciles an authoritative session list without focusing a background tab", () => {
+    const active = makeSnapshot({ tabId: "tab_a" });
+    const stale = makeSnapshot({
+      tabId: "tab_stale",
+      updatedAt: "2026-01-01T00:00:01.000Z",
+    });
+    applyPreviewServerSnapshot(ref, stale);
+    applyPreviewServerSnapshot(ref, active);
+    applyPreviewDesktopState(ref, stale.tabId, {
+      canGoBack: false,
+      canGoForward: false,
+      loading: false,
+      zoomFactor: 1,
+      controller: "none",
+    });
+
+    reconcilePreviewServerSessions(ref, [active]);
+
+    const state = readThreadPreviewState(ref);
+    expect(Object.keys(state.sessions)).toEqual([active.tabId]);
+    expect(state.activeTabId).toBe(active.tabId);
+    expect(state.snapshot).toEqual(active);
+    expect(state.desktopByTabId[stale.tabId]).toBeUndefined();
+  });
+
+  it("clears stale sessions when an authoritative list is empty", () => {
+    applyPreviewServerSnapshot(ref, makeSnapshot());
+
+    reconcilePreviewServerSessions(ref, []);
+
+    const state = readThreadPreviewState(ref);
+    expect(state.sessions).toEqual({});
+    expect(state.activeTabId).toBeNull();
+    expect(state.snapshot).toBeNull();
+  });
+
   it("applyServerSnapshot null clears snapshot for a thread that had one", () => {
     const snapshot = makeSnapshot();
     applyPreviewServerSnapshot(ref, snapshot);
diff --git a/apps/web/src/previewStateStore.ts b/apps/web/src/previewStateStore.ts
index 7f8f857613..e44a464ed2 100644
--- a/apps/web/src/previewStateStore.ts
+++ b/apps/web/src/previewStateStore.ts
@@ -112,14 +112,26 @@ const dedupeRecentUrls = (existing: string[], url: string): string[] => {
   return next.slice(0, PREVIEW_RECENT_URL_LIMIT);
 };
 
+const rememberSnapshotUrl = (
+  recentlySeenUrls: string[],
+  snapshot: PreviewSessionSnapshot,
+): string[] =>
+  snapshot.navStatus._tag === "Idle"
+    ? recentlySeenUrls
+    : dedupeRecentUrls(recentlySeenUrls, snapshot.navStatus.url);
+
+const latestSnapshot = (
+  sessions: Record,
+): PreviewSessionSnapshot | null =>
+  Object.values(sessions)
+    .toSorted((a, b) => a.updatedAt.localeCompare(b.updatedAt))
+    .at(-1) ?? null;
+
 const removeSession = (current: ThreadPreviewState, tabId: string): ThreadPreviewState => {
   if (!current.sessions[tabId]) return current;
   const { [tabId]: _closed, ...sessions } = current.sessions;
   const { [tabId]: _desktop, ...desktopByTabId } = current.desktopByTabId;
-  const nextSnapshot =
-    Object.values(sessions)
-      .toSorted((a, b) => a.updatedAt.localeCompare(b.updatedAt))
-      .at(-1) ?? null;
+  const nextSnapshot = latestSnapshot(sessions);
   const activeTabId =
     current.activeTabId === tabId ? (nextSnapshot?.tabId ?? null) : current.activeTabId;
   const snapshot = activeTabId ? (sessions[activeTabId] ?? nextSnapshot) : nextSnapshot;
@@ -163,7 +175,8 @@ export function applyPreviewServerEvent(ref: ScopedThreadRef, event: PreviewEven
   updateThreadPreviewState(ref, (current) => {
     switch (event.type) {
       case "opened":
-      case "navigated": {
+      case "navigated":
+      case "resized": {
         const snapshot = event.snapshot;
         if (current.suppressedTabIds.has(snapshot.tabId)) return current;
         const recentlySeenUrls =
@@ -228,10 +241,7 @@ export function applyPreviewServerSnapshot(
     if (current.suppressedTabIds.has(snapshot.tabId)) return current;
     const existing = current.sessions[snapshot.tabId];
     if (existing && existing.updatedAt > snapshot.updatedAt) return current;
-    const recentlySeenUrls =
-      snapshot.navStatus._tag !== "Idle"
-        ? dedupeRecentUrls(current.recentlySeenUrls, snapshot.navStatus.url)
-        : current.recentlySeenUrls;
+    const recentlySeenUrls = rememberSnapshotUrl(current.recentlySeenUrls, snapshot);
     return {
       ...current,
       snapshot,
@@ -243,6 +253,76 @@ export function applyPreviewServerSnapshot(
   });
 }
 
+/**
+ * Merge a server mutation without changing which tab the user is viewing.
+ *
+ * Commands such as resize can target background tabs. Their response is
+ * authoritative for that tab, but it is not a request to focus the tab.
+ */
+export function updatePreviewServerSnapshot(
+  ref: ScopedThreadRef,
+  snapshot: PreviewSessionSnapshot,
+): void {
+  updateThreadPreviewState(ref, (current) => {
+    if (current.suppressedTabIds.has(snapshot.tabId)) return current;
+    const existing = current.sessions[snapshot.tabId];
+    if (existing && existing.updatedAt > snapshot.updatedAt) return current;
+    const sessions = { ...current.sessions, [snapshot.tabId]: snapshot };
+    const activeTabId =
+      current.activeTabId && sessions[current.activeTabId] ? current.activeTabId : snapshot.tabId;
+    const activeSnapshot = sessions[activeTabId] ?? snapshot;
+    return {
+      ...current,
+      sessions,
+      activeTabId,
+      snapshot: activeSnapshot,
+      desktopOverlay: current.desktopByTabId[activeTabId] ?? null,
+      recentlySeenUrls: rememberSnapshotUrl(current.recentlySeenUrls, snapshot),
+    };
+  });
+}
+
+/**
+ * Replace the local session index from an authoritative preview.list result.
+ * Missing tabs are removed while the current active tab is preserved whenever
+ * it still exists in the server result.
+ */
+export function reconcilePreviewServerSessions(
+  ref: ScopedThreadRef,
+  snapshots: ReadonlyArray,
+): void {
+  updateThreadPreviewState(ref, (current) => {
+    const sessions: Record = {};
+    let recentlySeenUrls = current.recentlySeenUrls;
+    for (const snapshot of snapshots) {
+      if (current.suppressedTabIds.has(snapshot.tabId)) continue;
+      const existing = current.sessions[snapshot.tabId];
+      const next = existing && existing.updatedAt > snapshot.updatedAt ? existing : snapshot;
+      sessions[next.tabId] = next;
+      recentlySeenUrls = rememberSnapshotUrl(recentlySeenUrls, next);
+    }
+
+    const fallback = latestSnapshot(sessions);
+    const activeTabId =
+      current.activeTabId && sessions[current.activeTabId]
+        ? current.activeTabId
+        : (fallback?.tabId ?? null);
+    const snapshot = activeTabId ? (sessions[activeTabId] ?? null) : null;
+    const desktopByTabId = Object.fromEntries(
+      Object.entries(current.desktopByTabId).filter(([tabId]) => sessions[tabId] !== undefined),
+    );
+    return {
+      ...current,
+      sessions,
+      activeTabId,
+      snapshot,
+      desktopByTabId,
+      desktopOverlay: activeTabId ? (desktopByTabId[activeTabId] ?? null) : null,
+      recentlySeenUrls,
+    };
+  });
+}
+
 export function applyPreviewDesktopState(
   ref: ScopedThreadRef,
   tabId: string,
diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts
index 8f984c850d..e7bfa63204 100644
--- a/apps/web/vite.config.ts
+++ b/apps/web/vite.config.ts
@@ -156,6 +156,7 @@ export default defineConfig(() => {
         // connection logs — enable "Verbose" in DevTools to see them.
         protocol: "ws",
         host,
+        clientPort: port,
       },
     },
     build: {
diff --git a/packages/client-runtime/src/state/preview.test.ts b/packages/client-runtime/src/state/preview.test.ts
new file mode 100644
index 0000000000..7a83bccde9
--- /dev/null
+++ b/packages/client-runtime/src/state/preview.test.ts
@@ -0,0 +1,18 @@
+import { describe, expect, it } from "vite-plus/test";
+
+import { previewAutomationHostFocusConcurrencyKey } from "./preview.ts";
+
+describe("preview state commands", () => {
+  it("keeps focus updates from replacement host connections independent", () => {
+    const first = previewAutomationHostFocusConcurrencyKey({
+      environmentId: "environment-1",
+      input: { clientId: "client-1", connectionId: "connection-1" },
+    });
+    const replacement = previewAutomationHostFocusConcurrencyKey({
+      environmentId: "environment-1",
+      input: { clientId: "client-1", connectionId: "connection-2" },
+    });
+
+    expect(first).not.toBe(replacement);
+  });
+});
diff --git a/packages/client-runtime/src/state/preview.ts b/packages/client-runtime/src/state/preview.ts
index 800fc5efac..f9469ee96a 100644
--- a/packages/client-runtime/src/state/preview.ts
+++ b/packages/client-runtime/src/state/preview.ts
@@ -9,6 +9,14 @@ import {
   createEnvironmentRpcSubscriptionAtomFamily,
 } from "./runtime.ts";
 
+export const previewAutomationHostFocusConcurrencyKey = (value: {
+  readonly environmentId: string;
+  readonly input: {
+    readonly clientId: string;
+    readonly connectionId: string;
+  };
+}): string => JSON.stringify([value.environmentId, value.input.clientId, value.input.connectionId]);
+
 export function createPreviewEnvironmentAtoms(
   runtime: Atom.AtomRuntime,
 ) {
@@ -54,6 +62,12 @@ export function createPreviewEnvironmentAtoms(
       scheduler: lifecycleScheduler,
       concurrency: lifecycleConcurrency,
     }),
+    resize: createEnvironmentRpcCommand(runtime, {
+      label: "environment-data:preview:resize",
+      tag: WS_METHODS.previewResize,
+      scheduler: lifecycleScheduler,
+      concurrency: lifecycleConcurrency,
+    }),
     refresh: createEnvironmentRpcCommand(runtime, {
       label: "environment-data:preview:refresh",
       tag: WS_METHODS.previewRefresh,
@@ -82,25 +96,17 @@ export function createPreviewEnvironmentAtoms(
       scheduler: automationScheduler,
       concurrency: {
         mode: "singleFlight",
-        key: ({ environmentId, input }) => JSON.stringify([environmentId, input.requestId]),
+        key: ({ environmentId, input }) =>
+          JSON.stringify([environmentId, input.connectionId, input.requestId]),
       },
     }),
-    reportAutomationOwner: createEnvironmentRpcCommand(runtime, {
-      label: "environment-data:preview:automation-report-owner",
-      tag: WS_METHODS.previewAutomationReportOwner,
+    focusAutomationHost: createEnvironmentRpcCommand(runtime, {
+      label: "environment-data:preview:automation-focus-host",
+      tag: WS_METHODS.previewAutomationFocusHost,
       scheduler: automationScheduler,
       concurrency: {
-        mode: "serial",
-        key: ({ environmentId, input }) => JSON.stringify([environmentId, input.clientId]),
-      },
-    }),
-    clearAutomationOwner: createEnvironmentRpcCommand(runtime, {
-      label: "environment-data:preview:automation-clear-owner",
-      tag: WS_METHODS.previewAutomationClearOwner,
-      scheduler: automationScheduler,
-      concurrency: {
-        mode: "serial",
-        key: ({ environmentId, input }) => JSON.stringify([environmentId, input.clientId]),
+        mode: "latest",
+        key: previewAutomationHostFocusConcurrencyKey,
       },
     }),
   };
diff --git a/packages/contracts/src/ipc.ts b/packages/contracts/src/ipc.ts
index b2df24355e..8b7e727c28 100644
--- a/packages/contracts/src/ipc.ts
+++ b/packages/contracts/src/ipc.ts
@@ -69,19 +69,20 @@ import type {
   PreviewOpenInput,
   PreviewRefreshInput,
   PreviewReportStatusInput,
+  PreviewResizeInput,
   PreviewSessionSnapshot,
 } from "./preview.ts";
 import {
   PreviewAutomationClickInput,
   PreviewAutomationEvaluateInput,
-  PreviewAutomationOwner,
-  PreviewAutomationOwnerIdentity,
+  PreviewAutomationHost,
+  PreviewAutomationHostFocus,
   PreviewAutomationPressInput,
-  PreviewAutomationRequest,
   PreviewAutomationResponse,
   PreviewAutomationScrollInput,
   PreviewAutomationSnapshot,
   PreviewAutomationStatus,
+  PreviewAutomationStreamEvent,
   PreviewAutomationTypeInput,
   PreviewAutomationWaitForInput,
 } from "./previewAutomation.ts";
@@ -1154,19 +1155,19 @@ export interface EnvironmentApi {
   preview: {
     open: (input: typeof PreviewOpenInput.Encoded) => Promise;
     navigate: (input: typeof PreviewNavigateInput.Encoded) => Promise;
+    resize: (input: typeof PreviewResizeInput.Encoded) => Promise;
     refresh: (input: typeof PreviewRefreshInput.Encoded) => Promise;
     close: (input: typeof PreviewCloseInput.Encoded) => Promise;
     list: (input: typeof PreviewListInput.Encoded) => Promise;
     reportStatus: (input: typeof PreviewReportStatusInput.Encoded) => Promise;
     automation: {
       connect: (
-        input: { clientId: string },
-        callback: (request: PreviewAutomationRequest) => void,
+        input: PreviewAutomationHost,
+        callback: (event: PreviewAutomationStreamEvent) => void,
         options?: { onResubscribe?: () => void },
       ) => () => void;
       respond: (response: PreviewAutomationResponse) => Promise;
-      reportOwner: (owner: PreviewAutomationOwner) => Promise;
-      clearOwner: (input: PreviewAutomationOwnerIdentity) => Promise;
+      focusHost: (input: PreviewAutomationHostFocus) => Promise;
     };
     onEvent: (
       callback: (event: PreviewEvent) => void,
diff --git a/packages/contracts/src/preview.test.ts b/packages/contracts/src/preview.test.ts
index e4e6757b44..8004479387 100644
--- a/packages/contracts/src/preview.test.ts
+++ b/packages/contracts/src/preview.test.ts
@@ -6,12 +6,26 @@ import {
   PreviewEvent,
   PreviewNavStatus,
   PreviewSessionSnapshot,
+  PreviewViewportSetting,
 } from "./preview.ts";
+import {
+  PreviewAutomationHost,
+  PreviewAutomationError,
+  PreviewAutomationResizeInput,
+  PreviewAutomationResizeResult,
+  PreviewAutomationStatus,
+} from "./previewAutomation.ts";
 
 const decodePreviewEvent = Schema.decodeUnknownSync(PreviewEvent);
 const decodeSnapshot = Schema.decodeUnknownSync(PreviewSessionSnapshot);
 const decodeNavStatus = Schema.decodeUnknownSync(PreviewNavStatus);
 const decodeServer = Schema.decodeUnknownSync(DiscoveredLocalServer);
+const decodeViewport = Schema.decodeUnknownSync(PreviewViewportSetting);
+const decodeResizeInput = Schema.decodeUnknownSync(PreviewAutomationResizeInput);
+const decodeResizeResult = Schema.decodeUnknownSync(PreviewAutomationResizeResult);
+const decodeAutomationHost = Schema.decodeUnknownSync(PreviewAutomationHost);
+const decodeAutomationError = Schema.decodeUnknownSync(PreviewAutomationError);
+const decodeAutomationStatus = Schema.decodeUnknownSync(PreviewAutomationStatus);
 
 describe("PreviewNavStatus", () => {
   it("decodes Idle", () => {
@@ -68,6 +82,117 @@ describe("PreviewSessionSnapshot", () => {
   });
 });
 
+describe("PreviewViewportSetting", () => {
+  it("decodes fill, freeform, and preset modes", () => {
+    expect(decodeViewport({ _tag: "fill" })).toEqual({ _tag: "fill" });
+    expect(decodeViewport({ _tag: "freeform", width: 1024, height: 768 })).toEqual({
+      _tag: "freeform",
+      width: 1024,
+      height: 768,
+    });
+    expect(
+      decodeViewport({
+        _tag: "preset",
+        presetId: "iphone-15-pro",
+        width: 393,
+        height: 852,
+      }),
+    ).toMatchObject({ _tag: "preset", presetId: "iphone-15-pro" });
+  });
+
+  it("rejects unsafe dimensions and oversized render areas", () => {
+    expect(() => decodeViewport({ _tag: "freeform", width: 100, height: 800 })).toThrow();
+    expect(() => decodeViewport({ _tag: "freeform", width: 3840, height: 3840 })).toThrow();
+  });
+});
+
+describe("PreviewAutomationResizeInput", () => {
+  it("requires fields that match the selected mode", () => {
+    expect(decodeResizeInput({ mode: "fill" })).toEqual({ mode: "fill" });
+    expect(
+      decodeResizeInput({ mode: "preset", preset: "pixel-7", orientation: "landscape" }),
+    ).toMatchObject({ mode: "preset", preset: "pixel-7" });
+    expect(() => decodeResizeInput({ mode: "preset", preset: "pixel-8" })).toThrow();
+    expect(() => decodeResizeInput({ mode: "freeform", width: 1024 })).toThrow();
+    expect(() => decodeResizeInput({ mode: "fill", width: 1024, height: 768 })).toThrow();
+  });
+
+  it("allows fill-mode measurements below the minimum selectable fixed size", () => {
+    expect(
+      decodeResizeResult({
+        tabId: "preview-t",
+        setting: { _tag: "fill" },
+        viewport: { width: 180, height: 120 },
+      }).viewport,
+    ).toEqual({ width: 180, height: 120 });
+  });
+});
+
+describe("PreviewAutomationHost", () => {
+  it("accepts legacy hosts and current operation advertisements", () => {
+    expect(decodeAutomationHost({ clientId: "legacy", environmentId: "environment-1" })).toEqual({
+      clientId: "legacy",
+      environmentId: "environment-1",
+    });
+    expect(
+      decodeAutomationHost({
+        clientId: "current",
+        environmentId: "environment-1",
+        supportedOperations: ["status", "resize"],
+      }).supportedOperations,
+    ).toEqual(["status", "resize"]);
+  });
+});
+
+describe("PreviewAutomationError", () => {
+  it("preserves a typed non-editable target failure", () => {
+    const error = decodeAutomationError({
+      _tag: "PreviewAutomationTargetNotEditableError",
+      operation: "type",
+      environmentId: "environment-1",
+      threadId: "thread-1",
+      providerSessionId: "provider-session-1",
+      providerInstanceId: "codex",
+      clientId: "client-1",
+      connectionId: "connection-1",
+      requestId: "request-1",
+      tabId: "tab-1",
+      timeoutMs: 1_000,
+      remoteTag: "PreviewAutomationTargetNotEditableError",
+      remoteMessageLength: 12,
+      cause: {},
+      selectorKind: "focused-element",
+    });
+
+    expect(error._tag).toBe("PreviewAutomationTargetNotEditableError");
+    if (error._tag === "PreviewAutomationTargetNotEditableError") {
+      expect(error.selectorKind).toBe("focused-element");
+      expect(error.message).toBe("Preview automation type requires an editable focused element.");
+    }
+  });
+});
+
+describe("PreviewAutomationStatus", () => {
+  it("accepts old hosts without viewport data and exposes it from current hosts", () => {
+    const base = {
+      available: true,
+      visible: false,
+      tabId: "preview-t",
+      url: "https://example.com",
+      title: "Example",
+      loading: false,
+    };
+    expect(decodeAutomationStatus(base)).toEqual(base);
+    expect(
+      decodeAutomationStatus({
+        ...base,
+        viewportSetting: { _tag: "preset", presetId: "pixel-8", width: 412, height: 915 },
+        viewport: { width: 412, height: 915 },
+      }).viewport,
+    ).toEqual({ width: 412, height: 915 });
+  });
+});
+
 describe("PreviewEvent", () => {
   it("decodes opened", () => {
     const event = decodePreviewEvent({
@@ -104,6 +229,25 @@ describe("PreviewEvent", () => {
     }
   });
 
+  it("decodes resized with tab viewport state", () => {
+    const event = decodePreviewEvent({
+      type: "resized",
+      threadId: "t",
+      tabId: "preview-t",
+      createdAt: "2026-01-01T00:00:00.000Z",
+      snapshot: {
+        threadId: "t",
+        tabId: "preview-t",
+        navStatus: { _tag: "Idle" },
+        canGoBack: false,
+        canGoForward: false,
+        viewport: { _tag: "freeform", width: 1024, height: 768 },
+        updatedAt: "2026-01-01T00:00:00.000Z",
+      },
+    });
+    expect(event.type).toBe("resized");
+  });
+
   it("decodes closed without snapshot", () => {
     const event = decodePreviewEvent({
       type: "closed",
diff --git a/packages/contracts/src/preview.ts b/packages/contracts/src/preview.ts
index 457e66ee07..c00f878bcb 100644
--- a/packages/contracts/src/preview.ts
+++ b/packages/contracts/src/preview.ts
@@ -17,6 +17,100 @@ const Title = Schema.String.check(Schema.isMaxLength(512));
 export const PreviewTabId = TrimmedNonEmptyString.check(Schema.isMaxLength(128));
 export type PreviewTabId = typeof PreviewTabId.Type;
 
+export const PREVIEW_VIEWPORT_MIN_DIMENSION = 240;
+export const PREVIEW_VIEWPORT_MAX_DIMENSION = 3840;
+export const PREVIEW_VIEWPORT_MAX_AREA = 3840 * 2160;
+
+const PreviewViewportDimension = Schema.Int.check(
+  Schema.isBetween({
+    minimum: PREVIEW_VIEWPORT_MIN_DIMENSION,
+    maximum: PREVIEW_VIEWPORT_MAX_DIMENSION,
+  }),
+);
+
+const viewportAreaFilter = Schema.makeFilter(
+  ({ width, height }: { readonly width: number; readonly height: number }) =>
+    width * height <= PREVIEW_VIEWPORT_MAX_AREA ||
+    `Viewport area must not exceed ${PREVIEW_VIEWPORT_MAX_AREA} pixels.`,
+);
+
+export const PreviewViewportSize = Schema.Struct({
+  width: PreviewViewportDimension,
+  height: PreviewViewportDimension,
+}).check(viewportAreaFilter);
+export type PreviewViewportSize = typeof PreviewViewportSize.Type;
+
+/**
+ * The page's measured viewport can be smaller than the minimum selectable
+ * fixed size while fill mode follows a narrow panel. Keep measurement
+ * validation separate from the stricter user-selectable size constraints.
+ */
+export const PreviewRenderedViewportSize = Schema.Struct({
+  width: Schema.Int.check(Schema.isGreaterThan(0)),
+  height: Schema.Int.check(Schema.isGreaterThan(0)),
+});
+export type PreviewRenderedViewportSize = typeof PreviewRenderedViewportSize.Type;
+
+export const PREVIEW_VIEWPORT_PRESET_IDS = [
+  "iphone-se",
+  "iphone-xr",
+  "iphone-12-pro",
+  "iphone-14-pro-max",
+  "pixel-7",
+  "samsung-galaxy-s8-plus",
+  "samsung-galaxy-s20-ultra",
+  "ipad-mini",
+  "ipad-air",
+  "ipad-pro",
+  "surface-pro-7",
+  "surface-duo",
+  "galaxy-z-fold-5",
+  "asus-zenbook-fold",
+  "samsung-galaxy-a51-71",
+  "nest-hub",
+  "nest-hub-max",
+] as const;
+
+export const PreviewViewportPresetId = Schema.Literals(PREVIEW_VIEWPORT_PRESET_IDS);
+export type PreviewViewportPresetId = typeof PreviewViewportPresetId.Type;
+
+/**
+ * Preset IDs shipped before the Chrome-compatible catalog. Existing sessions
+ * can still reconnect with these values, but new resize requests only expose
+ * PREVIEW_VIEWPORT_PRESET_IDS.
+ */
+const LEGACY_PREVIEW_VIEWPORT_PRESET_IDS = [
+  "desktop-1920x1080",
+  "desktop-1440x900",
+  "laptop-1366x768",
+  "laptop-1280x800",
+  "ipad-pro-11",
+  "iphone-15-pro",
+  "pixel-8",
+  "galaxy-s24",
+] as const;
+
+const StoredPreviewViewportPresetId = Schema.Literals([
+  ...PREVIEW_VIEWPORT_PRESET_IDS,
+  ...LEGACY_PREVIEW_VIEWPORT_PRESET_IDS,
+]);
+
+export const PreviewViewportSetting = Schema.Union([
+  Schema.TaggedStruct("fill", {}),
+  Schema.TaggedStruct("freeform", {
+    ...PreviewViewportSize.fields,
+  }).check(viewportAreaFilter),
+  Schema.TaggedStruct("preset", {
+    ...PreviewViewportSize.fields,
+    presetId: StoredPreviewViewportPresetId,
+  }).check(viewportAreaFilter),
+]);
+export type PreviewViewportSetting = typeof PreviewViewportSetting.Type;
+
+export const FILL_PREVIEW_VIEWPORT = {
+  _tag: "fill",
+} as const satisfies PreviewViewportSetting;
+
 export const PreviewNavStatus = Schema.Union([
   Schema.TaggedStruct("Idle", {}),
   Schema.TaggedStruct("Loading", {
@@ -42,6 +136,8 @@ export const PreviewSessionSnapshot = Schema.Struct({
   navStatus: PreviewNavStatus,
   canGoBack: Schema.Boolean,
   canGoForward: Schema.Boolean,
+  /** Missing snapshots from older servers are treated as fill-panel mode. */
+  viewport: Schema.optional(PreviewViewportSetting),
   updatedAt: Schema.String,
 });
 export type PreviewSessionSnapshot = typeof PreviewSessionSnapshot.Type;
@@ -76,6 +172,13 @@ export const PreviewRefreshInput = Schema.Struct({
 });
 export type PreviewRefreshInput = typeof PreviewRefreshInput.Type;
 
+export const PreviewResizeInput = Schema.Struct({
+  threadId: ThreadId,
+  tabId: PreviewTabId,
+  viewport: PreviewViewportSetting,
+});
+export type PreviewResizeInput = typeof PreviewResizeInput.Type;
+
 export const PreviewCloseInput = Schema.Struct({
   threadId: ThreadId,
   tabId: Schema.optional(PreviewTabId),
@@ -110,6 +213,12 @@ const PreviewNavigatedEvent = Schema.Struct({
   snapshot: PreviewSessionSnapshot,
 });
 
+const PreviewResizedEvent = Schema.Struct({
+  ...PreviewEventBaseSchema.fields,
+  type: Schema.Literal("resized"),
+  snapshot: PreviewSessionSnapshot,
+});
+
 const PreviewFailedEvent = Schema.Struct({
   ...PreviewEventBaseSchema.fields,
   type: Schema.Literal("failed"),
@@ -127,6 +236,7 @@ const PreviewClosedEvent = Schema.Struct({
 export const PreviewEvent = Schema.Union([
   PreviewOpenedEvent,
   PreviewNavigatedEvent,
+  PreviewResizedEvent,
   PreviewFailedEvent,
   PreviewClosedEvent,
 ]);
diff --git a/packages/contracts/src/previewAutomation.ts b/packages/contracts/src/previewAutomation.ts
index 118fb89273..47dc7fc249 100644
--- a/packages/contracts/src/previewAutomation.ts
+++ b/packages/contracts/src/previewAutomation.ts
@@ -1,7 +1,14 @@
 import { Schema } from "effect";
 
 import { EnvironmentId, ThreadId, TrimmedNonEmptyString } from "./baseSchemas.ts";
-import { PreviewTabId } from "./preview.ts";
+import {
+  PREVIEW_VIEWPORT_MAX_AREA,
+  PreviewRenderedViewportSize,
+  PreviewTabId,
+  PreviewViewportPresetId,
+  PreviewViewportSetting,
+  PreviewViewportSize,
+} from "./preview.ts";
 import { ProviderInstanceId } from "./providerInstance.ts";
 
 const BoundedUrl = Schema.String.check(Schema.isTrimmed())
@@ -18,7 +25,8 @@ const OptionalTimeoutMs = Schema.optional(
     .annotate({ description: "Maximum wait in milliseconds. Defaults to 15000; maximum 60000." }),
 ).annotate({ description: "Maximum wait in milliseconds. Defaults to 15000; maximum 60000." });
 
-export const PreviewAutomationOperation = Schema.Literals([
+/** Operations understood by desktop hosts predating viewport resizing. */
+export const PREVIEW_AUTOMATION_V1_OPERATIONS = [
   "status",
   "open",
   "navigate",
@@ -31,7 +39,15 @@ export const PreviewAutomationOperation = Schema.Literals([
   "waitFor",
   "recordingStart",
   "recordingStop",
-]);
+] as const;
+
+/** Advertised by current desktop hosts for mixed-version routing. */
+export const PREVIEW_AUTOMATION_OPERATIONS = [
+  ...PREVIEW_AUTOMATION_V1_OPERATIONS,
+  "resize",
+] as const;
+
+export const PreviewAutomationOperation = Schema.Literals(PREVIEW_AUTOMATION_OPERATIONS);
 export type PreviewAutomationOperation = typeof PreviewAutomationOperation.Type;
 
 export const PreviewAutomationStatus = Schema.Struct({
@@ -41,6 +57,10 @@ export const PreviewAutomationStatus = Schema.Struct({
   url: Schema.NullOr(Schema.String),
   title: Schema.NullOr(Schema.String),
   loading: Schema.Boolean,
+  /** Optional for compatibility with desktop hosts predating viewport sizing. */
+  viewportSetting: Schema.optional(PreviewViewportSetting),
+  /** Measured guest-page viewport in CSS pixels when a webview is ready. */
+  viewport: Schema.optional(PreviewRenderedViewportSize),
 });
 export type PreviewAutomationStatus = typeof PreviewAutomationStatus.Type;
 
@@ -134,6 +154,80 @@ export const PreviewAutomationNavigateInput = Schema.Struct({
   });
 export type PreviewAutomationNavigateInput = typeof PreviewAutomationNavigateInput.Type;
 
+export const PreviewAutomationResizeInput = Schema.Struct({
+  mode: Schema.Literals(["fill", "freeform", "preset"]).annotate({
+    description:
+      "Viewport mode: fill follows the preview panel, freeform uses exact independently resizable dimensions, and preset uses a named device size.",
+  }),
+  preset: Schema.optional(
+    PreviewViewportPresetId.annotate({
+      description: "Named viewport from Chrome DevTools' standard device catalog.",
+    }),
+  ).annotate({
+    description: "Named device size. Required only when mode is preset.",
+  }),
+  width: Schema.optional(
+    PreviewViewportSize.fields.width.annotate({
+      description: "Freeform viewport width in CSS pixels. Required only in freeform mode.",
+    }),
+  ).annotate({
+    description: "Freeform viewport width in CSS pixels. Required only in freeform mode.",
+  }),
+  height: Schema.optional(
+    PreviewViewportSize.fields.height.annotate({
+      description: "Freeform viewport height in CSS pixels. Required only in freeform mode.",
+    }),
+  ).annotate({
+    description: "Freeform viewport height in CSS pixels. Required only in freeform mode.",
+  }),
+  orientation: Schema.optional(
+    Schema.Literals(["portrait", "landscape"]).annotate({
+      description:
+        "Orientation for a fixed device preset. Defaults to the preset's native orientation.",
+    }),
+  ).annotate({
+    description:
+      "Orientation for a named device preset. It is not accepted in fill or freeform mode.",
+  }),
+  timeoutMs: OptionalTimeoutMs,
+})
+  .check(
+    Schema.makeFilter((input) => {
+      const hasPreset = input.preset !== undefined;
+      const hasWidth = input.width !== undefined;
+      const hasHeight = input.height !== undefined;
+      if (hasWidth !== hasHeight) return "Custom dimensions require both width and height.";
+      if (input.mode === "fill") {
+        return !hasPreset && !hasWidth && input.orientation === undefined
+          ? true
+          : "Fill mode does not accept a preset, dimensions, or orientation.";
+      }
+      if (input.mode === "freeform") {
+        if (!hasWidth || !hasHeight || hasPreset || input.orientation !== undefined) {
+          return "Freeform mode requires width and height and does not accept a preset or orientation.";
+        }
+      } else if (!hasPreset || hasWidth || hasHeight) {
+        return "Preset mode requires a preset and does not accept custom dimensions.";
+      }
+      if (hasWidth && hasHeight && input.width! * input.height! > PREVIEW_VIEWPORT_MAX_AREA) {
+        return `Custom viewport area must not exceed ${PREVIEW_VIEWPORT_MAX_AREA} pixels.`;
+      }
+      return true;
+    }),
+  )
+  .annotate({
+    description:
+      "Sets the active browser tab to fill-panel, independently resizable freeform, or named device-preset sizing.",
+  });
+export type PreviewAutomationResizeInput = typeof PreviewAutomationResizeInput.Type;
+
+export const PreviewAutomationResizeResult = Schema.Struct({
+  tabId: PreviewTabId,
+  setting: PreviewViewportSetting,
+  viewport: PreviewRenderedViewportSize,
+});
+export type PreviewAutomationResizeResult = typeof PreviewAutomationResizeResult.Type;
+
 const Locator = TrimmedNonEmptyString.annotate({
   description:
     "Playwright selector, preferably role/text based, for example role=button[name='Send'] or text=Continue. Use snapshot first to inspect the page.",
@@ -411,21 +505,33 @@ export const PreviewAutomationRecordingArtifact = Schema.Struct({
 });
 export type PreviewAutomationRecordingArtifact = typeof PreviewAutomationRecordingArtifact.Type;
 
-export const PreviewAutomationOwnerIdentity = Schema.Struct({
-  clientId: TrimmedNonEmptyString,
-  environmentId: EnvironmentId,
-  threadId: ThreadId,
-});
-export type PreviewAutomationOwnerIdentity = typeof PreviewAutomationOwnerIdentity.Type;
+export const PreviewAutomationClientId = TrimmedNonEmptyString.check(Schema.isMaxLength(128));
+export type PreviewAutomationClientId = typeof PreviewAutomationClientId.Type;
+export const PreviewAutomationConnectionId = TrimmedNonEmptyString.check(Schema.isMaxLength(64));
+export type PreviewAutomationConnectionId = typeof PreviewAutomationConnectionId.Type;
 
-export const PreviewAutomationOwner = Schema.Struct({
-  ...PreviewAutomationOwnerIdentity.fields,
-  tabId: Schema.NullOr(PreviewTabId),
-  visible: Schema.Boolean,
-  supportsAutomation: Schema.Boolean,
-  focusedAt: Schema.String,
+export const PreviewAutomationHostIdentity = Schema.Struct({
+  clientId: PreviewAutomationClientId,
+  environmentId: EnvironmentId,
 });
-export type PreviewAutomationOwner = typeof PreviewAutomationOwner.Type;
+export type PreviewAutomationHostIdentity = typeof PreviewAutomationHostIdentity.Type;
+
+export const PreviewAutomationHost = Schema.Struct({
+  ...PreviewAutomationHostIdentity.fields,
+  /**
+   * Missing means the pre-capability-negotiation V1 operation set. This lets
+   * a newer server safely coexist with an older desktop during rollout.
+   */
+  supportedOperations: Schema.optional(Schema.Array(PreviewAutomationOperation)),
+});
+export type PreviewAutomationHost = typeof PreviewAutomationHost.Type;
+
+export const PreviewAutomationHostFocus = Schema.Struct({
+  ...PreviewAutomationHostIdentity.fields,
+  connectionId: PreviewAutomationConnectionId,
+  focused: Schema.Boolean,
+});
+export type PreviewAutomationHostFocus = typeof PreviewAutomationHostFocus.Type;
 
 export const PreviewAutomationRequest = Schema.Struct({
   requestId: TrimmedNonEmptyString,
@@ -437,7 +543,22 @@ export const PreviewAutomationRequest = Schema.Struct({
 });
 export type PreviewAutomationRequest = typeof PreviewAutomationRequest.Type;
 
+export const PreviewAutomationStreamEvent = Schema.Union([
+  Schema.Struct({
+    type: Schema.Literal("connected"),
+    connectionId: PreviewAutomationConnectionId,
+  }),
+  Schema.Struct({
+    type: Schema.Literal("request"),
+    connectionId: PreviewAutomationConnectionId,
+    request: PreviewAutomationRequest,
+  }),
+]);
+export type PreviewAutomationStreamEvent = typeof PreviewAutomationStreamEvent.Type;
+
 export const PreviewAutomationResponse = Schema.Struct({
+  clientId: PreviewAutomationClientId,
+  connectionId: PreviewAutomationConnectionId,
   requestId: TrimmedNonEmptyString,
   ok: Schema.Boolean,
   result: Schema.optional(Schema.Unknown),
@@ -477,6 +598,7 @@ const PreviewAutomationScopeErrorFields = {
 const PreviewAutomationRequestErrorFields = {
   ...PreviewAutomationScopeErrorFields,
   clientId: TrimmedNonEmptyString,
+  connectionId: PreviewAutomationConnectionId,
   requestId: TrimmedNonEmptyString,
   tabId: Schema.optional(PreviewTabId),
   timeoutMs: Schema.Int.check(Schema.isGreaterThan(0)),
@@ -500,11 +622,12 @@ const PreviewAutomationOptionalRemoteDiagnosticFields = {
   cause: Schema.optional(Schema.Defect()),
 };
 
-export class PreviewAutomationNoFocusedOwnerError extends Schema.TaggedErrorClass()(
-  "PreviewAutomationNoFocusedOwnerError",
+export class PreviewAutomationNoAvailableHostError extends Schema.TaggedErrorClass()(
+  "PreviewAutomationNoAvailableHostError",
   {
     ...PreviewAutomationScopeErrorFields,
     clientId: Schema.optional(TrimmedNonEmptyString),
+    connectionId: Schema.optional(PreviewAutomationConnectionId),
     requestId: Schema.optional(TrimmedNonEmptyString),
     tabId: Schema.optional(PreviewTabId),
     timeoutMs: Schema.optional(Schema.Int.check(Schema.isGreaterThan(0))),
@@ -512,7 +635,7 @@ export class PreviewAutomationNoFocusedOwnerError extends Schema.TaggedErrorClas
   },
 ) {
   override get message(): string {
-    const summary = `No focused preview automation owner is available for ${this.operation} in thread ${this.threadId}.`;
+    const summary = `No preview automation host is available for ${this.operation} in environment ${this.environmentId}.`;
     return summary;
   }
 }
@@ -598,6 +721,26 @@ export class PreviewAutomationInvalidSelectorError extends Schema.TaggedErrorCla
   }
 }
 
+export class PreviewAutomationTargetNotEditableError extends Schema.TaggedErrorClass()(
+  "PreviewAutomationTargetNotEditableError",
+  {
+    ...PreviewAutomationRequestErrorFields,
+    ...PreviewAutomationRemoteDiagnosticFields,
+    selectorKind: Schema.optional(Schema.Literals(["focused-element", "locator", "selector"])),
+    selectorLength: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),
+  },
+) {
+  override get message(): string {
+    if (this.selectorKind === "focused-element") {
+      return `Preview automation ${this.operation} requires an editable focused element.`;
+    }
+    if (this.selectorKind !== undefined && this.selectorLength !== undefined) {
+      return `Preview automation ${this.operation} requires an editable ${this.selectorKind} (${this.selectorLength} characters).`;
+    }
+    return `Preview automation ${this.operation} requires an editable target.`;
+  }
+}
+
 export class PreviewAutomationResultTooLargeError extends Schema.TaggedErrorClass()(
   "PreviewAutomationResultTooLargeError",
   {
@@ -615,18 +758,6 @@ export class PreviewAutomationResultTooLargeError extends Schema.TaggedErrorClas
   }
 }
 
-export class PreviewAutomationHostNotConnectedError extends Schema.TaggedErrorClass()(
-  "PreviewAutomationHostNotConnectedError",
-  {
-    ...PreviewAutomationScopeErrorFields,
-    clientId: TrimmedNonEmptyString,
-  },
-) {
-  override get message(): string {
-    return `Preview automation host ${this.clientId} is not connected for ${this.operation}.`;
-  }
-}
-
 export class PreviewAutomationClientDisconnectedError extends Schema.TaggedErrorClass()(
   "PreviewAutomationClientDisconnectedError",
   PreviewAutomationRequestErrorFields,
@@ -668,15 +799,15 @@ export class PreviewAutomationMalformedResponseError extends Schema.TaggedErrorC
 
 export const PreviewAutomationError = Schema.Union([
   PreviewAutomationUnavailableError,
-  PreviewAutomationNoFocusedOwnerError,
+  PreviewAutomationNoAvailableHostError,
   PreviewAutomationUnsupportedClientError,
   PreviewAutomationTabNotFoundError,
   PreviewAutomationTimeoutError,
   PreviewAutomationControlInterruptedError,
   PreviewAutomationExecutionError,
   PreviewAutomationInvalidSelectorError,
+  PreviewAutomationTargetNotEditableError,
   PreviewAutomationResultTooLargeError,
-  PreviewAutomationHostNotConnectedError,
   PreviewAutomationClientDisconnectedError,
   PreviewAutomationRequestQueueClosedError,
   PreviewAutomationRemoteUnavailableError,
diff --git a/packages/contracts/src/rpc.ts b/packages/contracts/src/rpc.ts
index 703f858c38..7a4e347db7 100644
--- a/packages/contracts/src/rpc.ts
+++ b/packages/contracts/src/rpc.ts
@@ -107,14 +107,15 @@ import {
   PreviewOpenInput,
   PreviewRefreshInput,
   PreviewReportStatusInput,
+  PreviewResizeInput,
   PreviewSessionSnapshot,
 } from "./preview.ts";
 import {
   PreviewAutomationError,
-  PreviewAutomationOwner,
-  PreviewAutomationOwnerIdentity,
-  PreviewAutomationRequest,
+  PreviewAutomationHost,
+  PreviewAutomationHostFocus,
   PreviewAutomationResponse,
+  PreviewAutomationStreamEvent,
 } from "./previewAutomation.ts";
 import {
   ServerConfigStreamEvent,
@@ -197,14 +198,14 @@ export const WS_METHODS = {
   // Preview methods
   previewOpen: "preview.open",
   previewNavigate: "preview.navigate",
+  previewResize: "preview.resize",
   previewRefresh: "preview.refresh",
   previewClose: "preview.close",
   previewList: "preview.list",
   previewReportStatus: "preview.reportStatus",
   previewAutomationConnect: "previewAutomation.connect",
   previewAutomationRespond: "previewAutomation.respond",
-  previewAutomationReportOwner: "previewAutomation.reportOwner",
-  previewAutomationClearOwner: "previewAutomation.clearOwner",
+  previewAutomationFocusHost: "previewAutomation.focusHost",
 
   // Server meta
   serverGetConfig: "server.getConfig",
@@ -547,6 +548,12 @@ export const WsPreviewNavigateRpc = Rpc.make(WS_METHODS.previewNavigate, {
   error: Schema.Union([PreviewError, EnvironmentAuthorizationError]),
 });
 
+export const WsPreviewResizeRpc = Rpc.make(WS_METHODS.previewResize, {
+  payload: PreviewResizeInput,
+  success: PreviewSessionSnapshot,
+  error: Schema.Union([PreviewError, EnvironmentAuthorizationError]),
+});
+
 export const WsPreviewRefreshRpc = Rpc.make(WS_METHODS.previewRefresh, {
   payload: PreviewRefreshInput,
   error: Schema.Union([PreviewError, EnvironmentAuthorizationError]),
@@ -569,8 +576,8 @@ export const WsPreviewReportStatusRpc = Rpc.make(WS_METHODS.previewReportStatus,
 });
 
 export const WsPreviewAutomationConnectRpc = Rpc.make(WS_METHODS.previewAutomationConnect, {
-  payload: PreviewAutomationOwner,
-  success: PreviewAutomationRequest,
+  payload: PreviewAutomationHost,
+  success: PreviewAutomationStreamEvent,
   error: Schema.Union([PreviewAutomationError, EnvironmentAuthorizationError]),
   stream: true,
 });
@@ -580,14 +587,9 @@ export const WsPreviewAutomationRespondRpc = Rpc.make(WS_METHODS.previewAutomati
   error: Schema.Union([PreviewAutomationError, EnvironmentAuthorizationError]),
 });
 
-export const WsPreviewAutomationReportOwnerRpc = Rpc.make(WS_METHODS.previewAutomationReportOwner, {
-  payload: PreviewAutomationOwner,
-  error: Schema.Union([PreviewAutomationError, EnvironmentAuthorizationError]),
-});
-
-export const WsPreviewAutomationClearOwnerRpc = Rpc.make(WS_METHODS.previewAutomationClearOwner, {
-  payload: PreviewAutomationOwnerIdentity,
-  error: Schema.Union([PreviewAutomationError, EnvironmentAuthorizationError]),
+export const WsPreviewAutomationFocusHostRpc = Rpc.make(WS_METHODS.previewAutomationFocusHost, {
+  payload: PreviewAutomationHostFocus,
+  error: EnvironmentAuthorizationError,
 });
 
 export const WsSubscribePreviewEventsRpc = Rpc.make(WS_METHODS.subscribePreviewEvents, {
@@ -771,14 +773,14 @@ export const WsRpcGroup = RpcGroup.make(
   WsSubscribeTerminalMetadataRpc,
   WsPreviewOpenRpc,
   WsPreviewNavigateRpc,
+  WsPreviewResizeRpc,
   WsPreviewRefreshRpc,
   WsPreviewCloseRpc,
   WsPreviewListRpc,
   WsPreviewReportStatusRpc,
   WsPreviewAutomationConnectRpc,
   WsPreviewAutomationRespondRpc,
-  WsPreviewAutomationReportOwnerRpc,
-  WsPreviewAutomationClearOwnerRpc,
+  WsPreviewAutomationFocusHostRpc,
   WsSubscribePreviewEventsRpc,
   WsSubscribeDiscoveredLocalServersRpc,
   WsSubscribeServerConfigRpc,
diff --git a/packages/shared/package.json b/packages/shared/package.json
index ec01e58bba..846676d53a 100644
--- a/packages/shared/package.json
+++ b/packages/shared/package.json
@@ -167,6 +167,10 @@
       "types": "./src/preview.ts",
       "import": "./src/preview.ts"
     },
+    "./previewViewport": {
+      "types": "./src/previewViewport.ts",
+      "import": "./src/previewViewport.ts"
+    },
     "./filePreview": {
       "types": "./src/filePreview.ts",
       "import": "./src/filePreview.ts"
diff --git a/packages/shared/src/previewViewport.test.ts b/packages/shared/src/previewViewport.test.ts
new file mode 100644
index 0000000000..3222e90d7b
--- /dev/null
+++ b/packages/shared/src/previewViewport.test.ts
@@ -0,0 +1,70 @@
+import { describe, expect, it } from "vite-plus/test";
+
+import {
+  PREVIEW_VIEWPORT_PRESETS,
+  previewViewportLabel,
+  previewViewportPresetOrientation,
+  resolvePreviewViewport,
+} from "./previewViewport.ts";
+
+describe("previewViewport", () => {
+  it("resolves fill and exact freeform viewports", () => {
+    expect(resolvePreviewViewport({ mode: "fill" })).toEqual({ _tag: "fill" });
+    expect(resolvePreviewViewport({ mode: "freeform", width: 1024, height: 768 })).toEqual({
+      _tag: "freeform",
+      width: 1024,
+      height: 768,
+    });
+  });
+
+  it("resolves device presets in either orientation", () => {
+    expect(resolvePreviewViewport({ mode: "preset", preset: "iphone-12-pro" })).toEqual({
+      _tag: "preset",
+      width: 390,
+      height: 844,
+      presetId: "iphone-12-pro",
+    });
+    expect(
+      resolvePreviewViewport({
+        mode: "preset",
+        preset: "iphone-12-pro",
+        orientation: "landscape",
+      }),
+    ).toEqual({
+      _tag: "preset",
+      width: 844,
+      height: 390,
+      presetId: "iphone-12-pro",
+    });
+  });
+
+  it("matches Chrome's standard device catalog ordering", () => {
+    expect(PREVIEW_VIEWPORT_PRESETS.map((preset) => preset.label)).toEqual([
+      "iPhone SE",
+      "iPhone XR",
+      "iPhone 12 Pro",
+      "iPhone 14 Pro Max",
+      "Pixel 7",
+      "Samsung Galaxy S8+",
+      "Samsung Galaxy S20 Ultra",
+      "iPad Mini",
+      "iPad Air",
+      "iPad Pro",
+      "Surface Pro 7",
+      "Surface Duo",
+      "Galaxy Z Fold 5",
+      "Asus Zenbook Fold",
+      "Samsung Galaxy A51/71",
+      "Nest Hub",
+      "Nest Hub Max",
+    ]);
+  });
+
+  it("formats settings for compact UI", () => {
+    expect(previewViewportLabel({ _tag: "fill" })).toBe("Fill panel");
+    expect(previewViewportLabel({ _tag: "freeform", width: 393, height: 852 })).toBe("393 × 852");
+    expect(previewViewportPresetOrientation({ _tag: "freeform", width: 852, height: 393 })).toBe(
+      "landscape",
+    );
+  });
+});
diff --git a/packages/shared/src/previewViewport.ts b/packages/shared/src/previewViewport.ts
new file mode 100644
index 0000000000..1d70bca5df
--- /dev/null
+++ b/packages/shared/src/previewViewport.ts
@@ -0,0 +1,186 @@
+import type {
+  PreviewAutomationResizeInput,
+  PreviewViewportPresetId,
+  PreviewViewportSetting,
+} from "@t3tools/contracts";
+import { PREVIEW_VIEWPORT_PRESET_IDS } from "@t3tools/contracts";
+
+export interface PreviewViewportPreset {
+  readonly id: PreviewViewportPresetId;
+  readonly label: string;
+  readonly category: "Desktop" | "Tablet" | "Phone";
+  readonly detail: string;
+  readonly width: number;
+  readonly height: number;
+}
+
+type PreviewViewportPresetDefinition = Omit;
+
+// Keep this in Chrome DevTools' default-device order. Dimensions are CSS
+// viewport sizes from Chromium's EmulatedDevices.ts standard catalog.
+const PREVIEW_VIEWPORT_PRESET_DEFINITIONS = {
+  "iphone-se": {
+    label: "iPhone SE",
+    category: "Phone",
+    detail: "375 × 667",
+    width: 375,
+    height: 667,
+  },
+  "iphone-xr": {
+    label: "iPhone XR",
+    category: "Phone",
+    detail: "414 × 896",
+    width: 414,
+    height: 896,
+  },
+  "iphone-12-pro": {
+    label: "iPhone 12 Pro",
+    category: "Phone",
+    detail: "390 × 844",
+    width: 390,
+    height: 844,
+  },
+  "iphone-14-pro-max": {
+    label: "iPhone 14 Pro Max",
+    category: "Phone",
+    detail: "430 × 932",
+    width: 430,
+    height: 932,
+  },
+  "pixel-7": {
+    label: "Pixel 7",
+    category: "Phone",
+    detail: "412 × 915",
+    width: 412,
+    height: 915,
+  },
+  "samsung-galaxy-s8-plus": {
+    label: "Samsung Galaxy S8+",
+    category: "Phone",
+    detail: "360 × 740",
+    width: 360,
+    height: 740,
+  },
+  "samsung-galaxy-s20-ultra": {
+    label: "Samsung Galaxy S20 Ultra",
+    category: "Phone",
+    detail: "412 × 915",
+    width: 412,
+    height: 915,
+  },
+  "ipad-mini": {
+    label: "iPad Mini",
+    category: "Tablet",
+    detail: "768 × 1024",
+    width: 768,
+    height: 1024,
+  },
+  "ipad-air": {
+    label: "iPad Air",
+    category: "Tablet",
+    detail: "820 × 1180",
+    width: 820,
+    height: 1180,
+  },
+  "ipad-pro": {
+    label: "iPad Pro",
+    category: "Tablet",
+    detail: "1024 × 1366",
+    width: 1024,
+    height: 1366,
+  },
+  "surface-pro-7": {
+    label: "Surface Pro 7",
+    category: "Tablet",
+    detail: "912 × 1368",
+    width: 912,
+    height: 1368,
+  },
+  "surface-duo": {
+    label: "Surface Duo",
+    category: "Phone",
+    detail: "540 × 720",
+    width: 540,
+    height: 720,
+  },
+  "galaxy-z-fold-5": {
+    label: "Galaxy Z Fold 5",
+    category: "Phone",
+    detail: "344 × 882",
+    width: 344,
+    height: 882,
+  },
+  "asus-zenbook-fold": {
+    label: "Asus Zenbook Fold",
+    category: "Tablet",
+    detail: "853 × 1280",
+    width: 853,
+    height: 1280,
+  },
+  "samsung-galaxy-a51-71": {
+    label: "Samsung Galaxy A51/71",
+    category: "Phone",
+    detail: "412 × 914",
+    width: 412,
+    height: 914,
+  },
+  "nest-hub": {
+    label: "Nest Hub",
+    category: "Tablet",
+    detail: "1024 × 600",
+    width: 1024,
+    height: 600,
+  },
+  "nest-hub-max": {
+    label: "Nest Hub Max",
+    category: "Tablet",
+    detail: "1280 × 800",
+    width: 1280,
+    height: 800,
+  },
+} as const satisfies Record;
+
+export const PREVIEW_VIEWPORT_PRESETS: ReadonlyArray =
+  PREVIEW_VIEWPORT_PRESET_IDS.map((id) => ({
+    id,
+    ...PREVIEW_VIEWPORT_PRESET_DEFINITIONS[id],
+  }));
+
+export function resolvePreviewViewport(
+  input: PreviewAutomationResizeInput,
+): PreviewViewportSetting {
+  if (input.mode === "fill") return { _tag: "fill" };
+  if (input.mode === "preset" && input.preset !== undefined) {
+    const preset = PREVIEW_VIEWPORT_PRESETS.find((candidate) => candidate.id === input.preset);
+    if (!preset) throw new Error(`Unknown preview viewport preset: ${input.preset}`);
+    const landscape = input.orientation === "landscape";
+    const portrait = input.orientation === "portrait";
+    const nativePortrait = preset.height >= preset.width;
+    const shouldSwap = (landscape && nativePortrait) || (portrait && !nativePortrait);
+    return {
+      _tag: "preset",
+      width: shouldSwap ? preset.height : preset.width,
+      height: shouldSwap ? preset.width : preset.height,
+      presetId: preset.id,
+    };
+  }
+  if (input.width === undefined || input.height === undefined) {
+    throw new Error("Custom preview viewport requires width and height");
+  }
+  return {
+    _tag: "freeform",
+    width: input.width,
+    height: input.height,
+  };
+}
+
+export function previewViewportLabel(viewport: PreviewViewportSetting): string {
+  return viewport._tag === "fill" ? "Fill panel" : `${viewport.width} × ${viewport.height}`;
+}
+
+export function previewViewportPresetOrientation(
+  viewport: PreviewViewportSetting,
+): "portrait" | "landscape" | null {
+  if (viewport._tag === "fill" || viewport.width === viewport.height) return null;
+  return viewport.width > viewport.height ? "landscape" : "portrait";
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e58a3473fd..a1cd5189ff 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -31,8 +31,8 @@ catalogs:
       specifier: ~6.0.3
       version: 6.0.3
     vite-plus:
-      specifier: 0.1.24
-      version: 0.1.24
+      specifier: 0.2.1
+      version: 0.2.1
 
 overrides:
   '@clerk/backend': 3.8.3-snapshot.v20260622234151
@@ -55,14 +55,12 @@ overrides:
   '@effect/sql-pg': 4.0.0-beta.78
   '@effect/sql-sqlite-bun': 4.0.0-beta.78
   '@effect/vitest': 4.0.0-beta.78
-  '@effect/vitest>@vitest/runner': '-'
   '@effect/vitest>vitest': '-'
   '@expo/metro-config': 56.0.13
   '@pierre/diffs>@shikijs/transformers': ^4.2.0
   '@types/node': 24.12.4
   effect: 4.0.0-beta.78
-  vite: npm:@voidzero-dev/vite-plus-core@0.1.24
-  vitest: npm:@voidzero-dev/vite-plus-test@0.1.24
+  vite: npm:@voidzero-dev/vite-plus-core@0.2.1
   yaml: ^2.9.0
 
 packageExtensionsChecksum: sha256-FV3+2NW/9MFbunJaPsMxvO0LAzyfccoPtPiKoIXAwUU=
@@ -108,7 +106,7 @@ importers:
         version: 7.0.0-dev.20260604.1
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   apps/desktop:
     dependencies:
@@ -172,13 +170,13 @@ importers:
         version: 4.3.0
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   apps/marketing:
     dependencies:
       astro:
-        specifier: ^6.0.4
-        version: 6.4.2(@types/node@24.12.4)(aws4fetch@1.0.20)(idb-keyval@6.2.1)(ioredis@5.11.0)(jiti@2.7.0)(rollup@4.61.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)
+        specifier: ^7.0.3
+        version: 7.0.3(@astrojs/markdown-remark@7.2.0)(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)(@types/node@24.12.4)(aws4fetch@1.0.20)(idb-keyval@6.2.1)(ioredis@5.11.0)(jiti@2.7.0)(rollup@4.61.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)
     devDependencies:
       '@astrojs/check':
         specifier: ^0.9.7
@@ -447,7 +445,7 @@ importers:
         version: 1.15.13
       '@pierre/diffs':
         specifier: 'catalog:'
-        version: 1.3.0-beta.5(patch_hash=7cb6da88544119adda056b2f46f43956f99326227732da0b345081e285a6c53a)(@shikijs/themes@4.2.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
+        version: 1.3.0-beta.5(patch_hash=7cb6da88544119adda056b2f46f43956f99326227732da0b345081e285a6c53a)(@shikijs/themes@4.3.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
       effect:
         specifier: 4.0.0-beta.78
         version: 4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5)
@@ -484,7 +482,7 @@ importers:
         version: link:../../packages/effect-codex-app-server
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   apps/web:
     dependencies:
@@ -529,7 +527,7 @@ importers:
         version: 0.41.0(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(yjs@13.6.31)
       '@pierre/diffs':
         specifier: 'catalog:'
-        version: 1.3.0-beta.5(patch_hash=7cb6da88544119adda056b2f46f43956f99326227732da0b345081e285a6c53a)(@shikijs/themes@4.2.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
+        version: 1.3.0-beta.5(patch_hash=7cb6da88544119adda056b2f46f43956f99326227732da0b345081e285a6c53a)(@shikijs/themes@4.3.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
       '@pierre/trees':
         specifier: 1.0.0-beta.4
         version: 1.0.0-beta.4(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
@@ -605,13 +603,13 @@ importers:
         version: 4.0.0-beta.78(patch_hash=42b87cc47e70d74e62496e7a8261b3fd298ecad4464d209348ab04b96f853a5f)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))
       '@rolldown/plugin-babel':
         specifier: ^0.2.0
-        version: 0.2.3(@babel/core@7.29.7)(@babel/plugin-transform-runtime@7.29.7(@babel/core@7.29.7))(@babel/runtime@7.29.7)(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(rolldown@1.0.3)
+        version: 0.2.3(@babel/core@7.29.7)(@babel/plugin-transform-runtime@7.29.7(@babel/core@7.29.7))(@babel/runtime@7.29.7)(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(rolldown@1.1.3)
       '@tailwindcss/vite':
         specifier: ^4.0.0
-        version: 4.3.0(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))
+        version: 4.3.0(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))
       '@tanstack/router-plugin':
         specifier: ^1.161.0
-        version: 1.168.13(@tanstack/react-router@1.170.10(react-dom@19.2.6(react@19.2.6))(react@19.2.6))(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))
+        version: 1.168.13(@tanstack/react-router@1.170.10(react-dom@19.2.6(react@19.2.6))(react@19.2.6))(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))
       '@types/babel__core':
         specifier: ^7.20.5
         version: 7.20.5
@@ -626,7 +624,7 @@ importers:
         version: 0.3.0
       '@vitejs/plugin-react':
         specifier: ^6.0.0
-        version: 6.0.2(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7)(@babel/plugin-transform-runtime@7.29.7(@babel/core@7.29.7))(@babel/runtime@7.29.7)(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(rolldown@1.0.3))(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(babel-plugin-react-compiler@1.0.0)
+        version: 6.0.2(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7)(@babel/plugin-transform-runtime@7.29.7(@babel/core@7.29.7))(@babel/runtime@7.29.7)(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(rolldown@1.1.3))(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(babel-plugin-react-compiler@1.0.0)
       babel-plugin-react-compiler:
         specifier: 1.0.0
         version: 1.0.0
@@ -637,11 +635,11 @@ importers:
         specifier: ^4.0.0
         version: 4.3.0
       vite:
-        specifier: npm:@voidzero-dev/vite-plus-core@0.1.24
-        version: '@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+        specifier: npm:@voidzero-dev/vite-plus-core@0.2.1
+        version: '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   infra/relay:
     dependencies:
@@ -662,7 +660,7 @@ importers:
         version: link:../../packages/shared
       alchemy:
         specifier: https://pkg.ing/alchemy/078ff00
-        version: https://pkg.ing/alchemy/078ff00(c6ed9425e2527ee8a94fe8655db2a250)
+        version: https://pkg.ing/alchemy/078ff00(9ca451f9fa94c3cde9e1ba8985172661)
       drizzle-orm:
         specifier: 1.0.0-rc.3
         version: 1.0.0-rc.3(@cloudflare/workers-types@4.20260604.1)(@effect/sql-pg@4.0.0-beta.78(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5)))(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(bun-types@1.3.14)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))(mysql2@3.22.4(@types/node@24.12.4))(pg@8.21.0)(zod@4.4.3)
@@ -686,11 +684,11 @@ importers:
         specifier: 1.0.0-rc.3
         version: 1.0.0-rc.3
       vite:
-        specifier: npm:@voidzero-dev/vite-plus-core@0.1.24
-        version: '@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+        specifier: npm:@voidzero-dev/vite-plus-core@0.2.1
+        version: '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   oxlint-plugin-t3code:
     dependencies:
@@ -709,7 +707,7 @@ importers:
         version: 4.0.0-beta.78(patch_hash=42b87cc47e70d74e62496e7a8261b3fd298ecad4464d209348ab04b96f853a5f)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   packages/client-runtime:
     dependencies:
@@ -728,7 +726,7 @@ importers:
         version: 4.0.0-beta.78(patch_hash=42b87cc47e70d74e62496e7a8261b3fd298ecad4464d209348ab04b96f853a5f)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   packages/contracts:
     dependencies:
@@ -741,7 +739,7 @@ importers:
         version: 4.0.0-beta.78(patch_hash=42b87cc47e70d74e62496e7a8261b3fd298ecad4464d209348ab04b96f853a5f)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   packages/effect-acp:
     dependencies:
@@ -763,7 +761,7 @@ importers:
         version: 24.12.4
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   packages/effect-codex-app-server:
     dependencies:
@@ -785,7 +783,7 @@ importers:
         version: 24.12.4
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   packages/shared:
     dependencies:
@@ -819,7 +817,7 @@ importers:
         version: 24.12.4
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   packages/ssh:
     dependencies:
@@ -844,7 +842,7 @@ importers:
         version: 24.12.4
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   packages/tailscale:
     dependencies:
@@ -866,7 +864,7 @@ importers:
         version: 24.12.4
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   scripts:
     dependencies:
@@ -891,7 +889,7 @@ importers:
         version: 4.0.0-beta.78(patch_hash=42b87cc47e70d74e62496e7a8261b3fd298ecad4464d209348ab04b96f853a5f)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))
       vite-plus:
         specifier: 'catalog:'
-        version: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+        version: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
 packages:
 
@@ -971,12 +969,69 @@ packages:
     peerDependencies:
       typescript: ^5.0.0 || ^6.0.0
 
+  '@astrojs/compiler-binding-darwin-arm64@0.2.3':
+    resolution: {integrity: sha512-sJIHeL1ONXEBLob8ZaXfmX6iCftUno08G/cMXj2FJnL0xNbHuELcEq1mjxHVFHNgUYu4P7xJNm2mpc0zUEPoKw==}
+    engines: {node: ^20.19.0 || >=22.12.0}
+    cpu: [arm64]
+    os: [darwin]
+
+  '@astrojs/compiler-binding-darwin-x64@0.2.3':
+    resolution: {integrity: sha512-P0NYu6aaIeLCqFfszxxBHL0a5WRaYigNVbDoO654Gi5Q2au5duDb5xZBv5EqUg4qnQVC173FXNvGZu1M7nk+/w==}
+    engines: {node: ^20.19.0 || >=22.12.0}
+    cpu: [x64]
+    os: [darwin]
+
+  '@astrojs/compiler-binding-linux-arm64-gnu@0.2.3':
+    resolution: {integrity: sha512-PqVN5AqhuDqfx3ejaerwrC8codpV9jnyKV+IOel027qsJ1anFUJLdjUlY8VVys0xgd8lmqveX11OkcaQj/otTg==}
+    engines: {node: ^20.19.0 || >=22.12.0}
+    cpu: [arm64]
+    os: [linux]
+
+  '@astrojs/compiler-binding-linux-arm64-musl@0.2.3':
+    resolution: {integrity: sha512-O3e2CbN4yTsRguWYNnRd0p5YQ0H3fb7KpcR0W4R319q/gq5B1pJ7eqNbiO3b8g2AuiEcRTiUz5jeGT9j69cxOQ==}
+    engines: {node: ^20.19.0 || >=22.12.0}
+    cpu: [arm64]
+    os: [linux]
+
+  '@astrojs/compiler-binding-linux-x64-gnu@0.2.3':
+    resolution: {integrity: sha512-hbLBjXVp+96psMe7/7uqyrquGiULXANrq6REVxxPK/I5VzebZ7LHmSfykmByUbLyR1u+K6CTBKgvdQsK2L+2Xw==}
+    engines: {node: ^20.19.0 || >=22.12.0}
+    cpu: [x64]
+    os: [linux]
+
+  '@astrojs/compiler-binding-linux-x64-musl@0.2.3':
+    resolution: {integrity: sha512-vIiEvOwrJfHZMaTmqUCrFTIwMYL0+PD3Rvy7kFDQgERyx3zhaw8CPa01MCCqa+/sj344BGrXKZ6ti37SgNLMhw==}
+    engines: {node: ^20.19.0 || >=22.12.0}
+    cpu: [x64]
+    os: [linux]
+
+  '@astrojs/compiler-binding-wasm32-wasi@0.2.3':
+    resolution: {integrity: sha512-p9S2X8z/mUR2SMzAVJRFMCt8YaalKR+pjl2DgpdjzCQc6ww4bo8kiy54tgKqxZeNF5c+/2tCDTQIxVSm9V1FsA==}
+    engines: {node: '>=14.0.0'}
+    cpu: [wasm32]
+
+  '@astrojs/compiler-binding-win32-arm64-msvc@0.2.3':
+    resolution: {integrity: sha512-vcCG6JttIb5vbSmcxO2O398hpVj7lQ349iS7cjgYP6ZuLVEnw+9qPAr2MM2kJkU5wEGZqJ2gyi/M7UJoPwH1iQ==}
+    engines: {node: ^20.19.0 || >=22.12.0}
+    cpu: [arm64]
+    os: [win32]
+
+  '@astrojs/compiler-binding-win32-x64-msvc@0.2.3':
+    resolution: {integrity: sha512-hKssjNvC36e00Inb1GW1JsVyCFSCGnIjKem4S8q0VIW6cpWAUpvYB4qQU2HIDGD6SDX0ork4F5sWkNWkp2hrGQ==}
+    engines: {node: ^20.19.0 || >=22.12.0}
+    cpu: [x64]
+    os: [win32]
+
+  '@astrojs/compiler-binding@0.2.3':
+    resolution: {integrity: sha512-Xz3iBNse+hXXD25IXxsuXEt2ai8klAWE15CRm/EQBc9+aE3jXaF07DZx+iakk3HC6NHvWlEPzLPyxsLgPzOJsw==}
+    engines: {node: ^20.19.0 || >=22.12.0}
+
+  '@astrojs/compiler-rs@0.2.3':
+    resolution: {integrity: sha512-JRAtRcPxS4JeAZEIQFQ6GecBs/Wyp4m6/E8vBNxSgVfo1AtRVLUqRCl5oCGOZ0X/BSBB3Vef/7IlzyiGKi2ORA==}
+
   '@astrojs/compiler@2.13.1':
     resolution: {integrity: sha512-f3FN83d2G/v32ipNClRKgYv30onQlMZX1vCeZMjPsMMPl1mDpmbl0+N5BYo4S/ofzqJyS5hvwacEo0CCVDn/Qg==}
 
-  '@astrojs/compiler@4.0.0':
-    resolution: {integrity: sha512-eouss7G8ygdZqHuke033VMcVw5HTZUu+PXd/h06DGDUg/jt5btPYPqh66ENWw/mU78rBrf/oeC4oqoBwMtDMNA==}
-
   '@astrojs/internal-helpers@0.10.0':
     resolution: {integrity: sha512-Ry2R3VPeIN4uPCSA4xQc+e+vsJXkalKpEbDc07hV+a/o5Bs2N/s/uDcPJH/05L19DKh9tAy7e6JM3YZ6Cxfezw==}
 
@@ -995,6 +1050,9 @@ packages:
   '@astrojs/markdown-remark@7.2.0':
     resolution: {integrity: sha512-+YxmVQu1Bd+MFfSzjq1rOJvD9+nIOJzz5YIIhdIH01RrxRkKbyKoEgyIqP3yv51MhzMDgd79QaPv+kCVPT8vHw==}
 
+  '@astrojs/markdown-satteri@0.3.2':
+    resolution: {integrity: sha512-feXuUPy41gVfeM7EHT1ciUim8ozGr+YHXab9uUBc1Hk8y60DQosO8ldL+AoPXnCAoGj1OChwHfvXmmJ6XVnY9A==}
+
   '@astrojs/prism@4.0.2':
     resolution: {integrity: sha512-KTivpmnz6lDsC6o9H4+DNm2SrE/GHzw8cNAvEJwAvUT+eoaEnn/4NtbDNfRRaxaJHdp15gf+tfHAWiXR4wB3BA==}
     engines: {node: '>=22.12.0'}
@@ -1517,6 +1575,54 @@ packages:
       '@types/react':
         optional: true
 
+  '@blazediff/core@1.9.1':
+    resolution: {integrity: sha512-ehg3jIkYKulZh+8om/O25vkvSsXXwC+skXmyA87FFx6A/45eqOkZsBltMw/TVteb0mloiGT8oGRTcjRAz66zaA==}
+
+  '@bruits/satteri-darwin-arm64@0.9.3':
+    resolution: {integrity: sha512-dRUZZrdwh1asfTOyM1nDNmzolhnHtlIFpqYrl1Tdd3YVcaebKmrfJgGL7NAoGPjbEwYmZxaugrxA0uzw83c0dw==}
+    cpu: [arm64]
+    os: [darwin]
+
+  '@bruits/satteri-darwin-x64@0.9.3':
+    resolution: {integrity: sha512-wgNCTRp2hPSpNMGFv5A4+6+VXgRJIlBZ7XKb3iwjV8YjRWNIjzE5zV2fUeYynyZYVRkuJ9aYFqQmWhc1e5H+UQ==}
+    cpu: [x64]
+    os: [darwin]
+
+  '@bruits/satteri-linux-arm64-gnu@0.9.3':
+    resolution: {integrity: sha512-A/pWy8Jb/PhDYc2/JFuYh06gFJcsfBUBDl81YydGYBrL/Z4nItDfhNDNOibyeSN/lKKDRlycIHEIajjErk00sQ==}
+    cpu: [arm64]
+    os: [linux]
+
+  '@bruits/satteri-linux-arm64-musl@0.9.3':
+    resolution: {integrity: sha512-L6YxmyOSickzo4pE5WmZfNTJnjX0MtgKOsuwQfNZECTx9Ir5vl2B37EIwnxe2AybuPPHl+FqVQtthNDUdH4Vgg==}
+    cpu: [arm64]
+    os: [linux]
+
+  '@bruits/satteri-linux-x64-gnu@0.9.3':
+    resolution: {integrity: sha512-RgH6GPihg9Lzs2yHUsMjqiLxfLyOdmBty8sg9pBY9B4CBnvdOzvg8vklqN+C4qrEEdA9TwpbDpHr1AshLKyRpw==}
+    cpu: [x64]
+    os: [linux]
+
+  '@bruits/satteri-linux-x64-musl@0.9.3':
+    resolution: {integrity: sha512-BeWhVORjNTIomePznUKiMbHZTqC0j7sMXZFsISmbX+po5d33KLkqBqKh6K332CHJ8KUmCWx16FfPjwsoysttQg==}
+    cpu: [x64]
+    os: [linux]
+
+  '@bruits/satteri-wasm32-wasi@0.9.3':
+    resolution: {integrity: sha512-dFNcOHKWV2cztCPnYTn7kZ9D7kNOt8N239z5ysFkNHLxJrfK7zaKIXQbfXYN32C+JoVFqAcTIOeWH2+VnsCOHg==}
+    engines: {node: '>=14.0.0'}
+    cpu: [wasm32]
+
+  '@bruits/satteri-win32-arm64-msvc@0.9.3':
+    resolution: {integrity: sha512-VnwjBHiAra/PNNEza8eSZdQiG4A3PtTJJwUDtOPAc6iTs0BWZwZX8+OPUZE7//yQCBhgvEMcI8vpwsAwCb6qGQ==}
+    cpu: [arm64]
+    os: [win32]
+
+  '@bruits/satteri-win32-x64-msvc@0.9.3':
+    resolution: {integrity: sha512-Dsoe4reWe69MyILmMwU6iISIceTW7YIFqbyym7haf9DhUvqkYfMAyp7GMM21JzV0SpG9A2BwzFVP7iq9mmxrpA==}
+    cpu: [x64]
+    os: [win32]
+
   '@bufbuild/protobuf@1.10.0':
     resolution: {integrity: sha512-QDdVFLoN93Zjg36NoQPZfsVH9tZew7wKDKyV5qRdj8ntT4wQCOradQjRaTdwMhWUYsgKsvCINKKm87FdEk96Ag==}
 
@@ -1526,22 +1632,22 @@ packages:
       react: '*'
       react-native: '*'
 
-  '@capsizecss/unpack@4.0.0':
-    resolution: {integrity: sha512-VERIM64vtTP1C4mxQ5thVT9fK0apjPFobqybMtA1UdUujWka24ERHbRHFGmpbbhp73MhV+KSsHQH9C6uOTdEQA==}
+  '@capsizecss/unpack@4.0.1':
+    resolution: {integrity: sha512-CuNiSqg7+e1cO/GjffyMOm5Tt2jUF9CWHHnvQ/UkqvtkGfHdgwEC0wpmq7fkN3gxwpRnrAN0WzO3vREKmNolMQ==}
     engines: {node: '>=18'}
 
   '@clack/core@0.5.0':
     resolution: {integrity: sha512-p3y0FIOwaYRUPRcMO7+dlmLh8PSRcrjuTndsiA0WAFbWES0mLZlrjVoBRZ9DzkPFJZG6KGkJmoEAY0ZcVWTkow==}
 
-  '@clack/core@1.4.0':
-    resolution: {integrity: sha512-7Wctjq6f7c1CPz8sPpkwUnz8yRgVANkpNupb81q432FjcJg4l+Sw7XANdNSdWfAKq0IHI0JTcUeK5dxs/HrGPw==}
+  '@clack/core@1.4.2':
+    resolution: {integrity: sha512-0Ty/1Gfm+Kb07sXcuESjyKfwEhSy4Ns1AgeEisHb/bDY5fWme0tTeTkU14T1Gmcs17YIjB/teiDe4uaCghbYqQ==}
     engines: {node: '>= 20.12.0'}
 
   '@clack/prompts@0.11.0':
     resolution: {integrity: sha512-pMN5FcrEw9hUkZA4f+zLlzivQSeQf5dRGJjSUbvVYDLvpKCdQx5OaknvKzgbtXOizhP+SJJJjqEbOe55uKKfAw==}
 
-  '@clack/prompts@1.5.0':
-    resolution: {integrity: sha512-wKh+wTjmrUoUdkZg8KpJO5X+p9PWV+KE9mePseq9UYWkukgTKsGS47RRL2HstwVcvDQH+PenrPJWII8+MfiiyA==}
+  '@clack/prompts@1.6.0':
+    resolution: {integrity: sha512-EYlRokl8szrP9Z25qT5aepMdBjzBvHF9ZEhzIiUBc9guz/T31EqRgvD0QSgZcpE93xiwrr+OkB4nz0BZyF6fSA==}
     engines: {node: '>= 20.12.0'}
 
   '@clerk/backend@3.8.3-snapshot.v20260622234151':
@@ -1997,12 +2103,21 @@ packages:
   '@emnapi/core@1.10.0':
     resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==}
 
+  '@emnapi/core@1.11.1':
+    resolution: {integrity: sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ==}
+
   '@emnapi/runtime@1.10.0':
     resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==}
 
+  '@emnapi/runtime@1.11.1':
+    resolution: {integrity: sha512-vgj7R3y3Wgx24IQaGPA/R6YFXLHVMOZ0uVEyIQPaWs+rd1AzfEMXlAC22FYwO1XkKR6NPsq7mUandH8oIRdZFw==}
+
   '@emnapi/wasi-threads@1.2.1':
     resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==}
 
+  '@emnapi/wasi-threads@1.2.2':
+    resolution: {integrity: sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==}
+
   '@epic-web/invariant@1.0.0':
     resolution: {integrity: sha512-lrTPqgvfFQtR/eY/qkIzp98OGdNJu0m5ji3q/nJI8v3SXkRKEnWiOxMmbvcSoAIzv/cGiuvRy57k4suKQSAdwA==}
 
@@ -2012,8 +2127,8 @@ packages:
     cpu: [ppc64]
     os: [aix]
 
-  '@esbuild/aix-ppc64@0.27.7':
-    resolution: {integrity: sha512-EKX3Qwmhz1eMdEJokhALr0YiD0lhQNwDqkPYyPhiSwKrh7/4KRjQc04sZ8db+5DVVnZ1LmbNDI1uAMPEUBnQPg==}
+  '@esbuild/aix-ppc64@0.28.1':
+    resolution: {integrity: sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==}
     engines: {node: '>=18'}
     cpu: [ppc64]
     os: [aix]
@@ -2024,8 +2139,8 @@ packages:
     cpu: [arm64]
     os: [android]
 
-  '@esbuild/android-arm64@0.27.7':
-    resolution: {integrity: sha512-62dPZHpIXzvChfvfLJow3q5dDtiNMkwiRzPylSCfriLvZeq0a1bWChrGx/BbUbPwOrsWKMn8idSllklzBy+dgQ==}
+  '@esbuild/android-arm64@0.28.1':
+    resolution: {integrity: sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==}
     engines: {node: '>=18'}
     cpu: [arm64]
     os: [android]
@@ -2036,8 +2151,8 @@ packages:
     cpu: [arm]
     os: [android]
 
-  '@esbuild/android-arm@0.27.7':
-    resolution: {integrity: sha512-jbPXvB4Yj2yBV7HUfE2KHe4GJX51QplCN1pGbYjvsyCZbQmies29EoJbkEc+vYuU5o45AfQn37vZlyXy4YJ8RQ==}
+  '@esbuild/android-arm@0.28.1':
+    resolution: {integrity: sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==}
     engines: {node: '>=18'}
     cpu: [arm]
     os: [android]
@@ -2048,8 +2163,8 @@ packages:
     cpu: [x64]
     os: [android]
 
-  '@esbuild/android-x64@0.27.7':
-    resolution: {integrity: sha512-x5VpMODneVDb70PYV2VQOmIUUiBtY3D3mPBG8NxVk5CogneYhkR7MmM3yR/uMdITLrC1ml/NV1rj4bMJuy9MCg==}
+  '@esbuild/android-x64@0.28.1':
+    resolution: {integrity: sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==}
     engines: {node: '>=18'}
     cpu: [x64]
     os: [android]
@@ -2060,8 +2175,8 @@ packages:
     cpu: [arm64]
     os: [darwin]
 
-  '@esbuild/darwin-arm64@0.27.7':
-    resolution: {integrity: sha512-5lckdqeuBPlKUwvoCXIgI2D9/ABmPq3Rdp7IfL70393YgaASt7tbju3Ac+ePVi3KDH6N2RqePfHnXkaDtY9fkw==}
+  '@esbuild/darwin-arm64@0.28.1':
+    resolution: {integrity: sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==}
     engines: {node: '>=18'}
     cpu: [arm64]
     os: [darwin]
@@ -2072,8 +2187,8 @@ packages:
     cpu: [x64]
     os: [darwin]
 
-  '@esbuild/darwin-x64@0.27.7':
-    resolution: {integrity: sha512-rYnXrKcXuT7Z+WL5K980jVFdvVKhCHhUwid+dDYQpH+qu+TefcomiMAJpIiC2EM3Rjtq0sO3StMV/+3w3MyyqQ==}
+  '@esbuild/darwin-x64@0.28.1':
+    resolution: {integrity: sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==}
     engines: {node: '>=18'}
     cpu: [x64]
     os: [darwin]
@@ -2084,8 +2199,8 @@ packages:
     cpu: [arm64]
     os: [freebsd]
 
-  '@esbuild/freebsd-arm64@0.27.7':
-    resolution: {integrity: sha512-B48PqeCsEgOtzME2GbNM2roU29AMTuOIN91dsMO30t+Ydis3z/3Ngoj5hhnsOSSwNzS+6JppqWsuhTp6E82l2w==}
+  '@esbuild/freebsd-arm64@0.28.1':
+    resolution: {integrity: sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==}
     engines: {node: '>=18'}
     cpu: [arm64]
     os: [freebsd]
@@ -2096,8 +2211,8 @@ packages:
     cpu: [x64]
     os: [freebsd]
 
-  '@esbuild/freebsd-x64@0.27.7':
-    resolution: {integrity: sha512-jOBDK5XEjA4m5IJK3bpAQF9/Lelu/Z9ZcdhTRLf4cajlB+8VEhFFRjWgfy3M1O4rO2GQ/b2dLwCUGpiF/eATNQ==}
+  '@esbuild/freebsd-x64@0.28.1':
+    resolution: {integrity: sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==}
     engines: {node: '>=18'}
     cpu: [x64]
     os: [freebsd]
@@ -2108,8 +2223,8 @@ packages:
     cpu: [arm64]
     os: [linux]
 
-  '@esbuild/linux-arm64@0.27.7':
-    resolution: {integrity: sha512-RZPHBoxXuNnPQO9rvjh5jdkRmVizktkT7TCDkDmQ0W2SwHInKCAV95GRuvdSvA7w4VMwfCjUiPwDi0ZO6Nfe9A==}
+  '@esbuild/linux-arm64@0.28.1':
+    resolution: {integrity: sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==}
     engines: {node: '>=18'}
     cpu: [arm64]
     os: [linux]
@@ -2120,8 +2235,8 @@ packages:
     cpu: [arm]
     os: [linux]
 
-  '@esbuild/linux-arm@0.27.7':
-    resolution: {integrity: sha512-RkT/YXYBTSULo3+af8Ib0ykH8u2MBh57o7q/DAs3lTJlyVQkgQvlrPTnjIzzRPQyavxtPtfg0EopvDyIt0j1rA==}
+  '@esbuild/linux-arm@0.28.1':
+    resolution: {integrity: sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==}
     engines: {node: '>=18'}
     cpu: [arm]
     os: [linux]
@@ -2132,8 +2247,8 @@ packages:
     cpu: [ia32]
     os: [linux]
 
-  '@esbuild/linux-ia32@0.27.7':
-    resolution: {integrity: sha512-GA48aKNkyQDbd3KtkplYWT102C5sn/EZTY4XROkxONgruHPU72l+gW+FfF8tf2cFjeHaRbWpOYa/uRBz/Xq1Pg==}
+  '@esbuild/linux-ia32@0.28.1':
+    resolution: {integrity: sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==}
     engines: {node: '>=18'}
     cpu: [ia32]
     os: [linux]
@@ -2144,8 +2259,8 @@ packages:
     cpu: [loong64]
     os: [linux]
 
-  '@esbuild/linux-loong64@0.27.7':
-    resolution: {integrity: sha512-a4POruNM2oWsD4WKvBSEKGIiWQF8fZOAsycHOt6JBpZ+JN2n2JH9WAv56SOyu9X5IqAjqSIPTaJkqN8F7XOQ5Q==}
+  '@esbuild/linux-loong64@0.28.1':
+    resolution: {integrity: sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==}
     engines: {node: '>=18'}
     cpu: [loong64]
     os: [linux]
@@ -2156,8 +2271,8 @@ packages:
     cpu: [mips64el]
     os: [linux]
 
-  '@esbuild/linux-mips64el@0.27.7':
-    resolution: {integrity: sha512-KabT5I6StirGfIz0FMgl1I+R1H73Gp0ofL9A3nG3i/cYFJzKHhouBV5VWK1CSgKvVaG4q1RNpCTR2LuTVB3fIw==}
+  '@esbuild/linux-mips64el@0.28.1':
+    resolution: {integrity: sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==}
     engines: {node: '>=18'}
     cpu: [mips64el]
     os: [linux]
@@ -2168,8 +2283,8 @@ packages:
     cpu: [ppc64]
     os: [linux]
 
-  '@esbuild/linux-ppc64@0.27.7':
-    resolution: {integrity: sha512-gRsL4x6wsGHGRqhtI+ifpN/vpOFTQtnbsupUF5R5YTAg+y/lKelYR1hXbnBdzDjGbMYjVJLJTd2OFmMewAgwlQ==}
+  '@esbuild/linux-ppc64@0.28.1':
+    resolution: {integrity: sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==}
     engines: {node: '>=18'}
     cpu: [ppc64]
     os: [linux]
@@ -2180,8 +2295,8 @@ packages:
     cpu: [riscv64]
     os: [linux]
 
-  '@esbuild/linux-riscv64@0.27.7':
-    resolution: {integrity: sha512-hL25LbxO1QOngGzu2U5xeXtxXcW+/GvMN3ejANqXkxZ/opySAZMrc+9LY/WyjAan41unrR3YrmtTsUpwT66InQ==}
+  '@esbuild/linux-riscv64@0.28.1':
+    resolution: {integrity: sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==}
     engines: {node: '>=18'}
     cpu: [riscv64]
     os: [linux]
@@ -2192,8 +2307,8 @@ packages:
     cpu: [s390x]
     os: [linux]
 
-  '@esbuild/linux-s390x@0.27.7':
-    resolution: {integrity: sha512-2k8go8Ycu1Kb46vEelhu1vqEP+UeRVj2zY1pSuPdgvbd5ykAw82Lrro28vXUrRmzEsUV0NzCf54yARIK8r0fdw==}
+  '@esbuild/linux-s390x@0.28.1':
+    resolution: {integrity: sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==}
     engines: {node: '>=18'}
     cpu: [s390x]
     os: [linux]
@@ -2204,8 +2319,8 @@ packages:
     cpu: [x64]
     os: [linux]
 
-  '@esbuild/linux-x64@0.27.7':
-    resolution: {integrity: sha512-hzznmADPt+OmsYzw1EE33ccA+HPdIqiCRq7cQeL1Jlq2gb1+OyWBkMCrYGBJ+sxVzve2ZJEVeePbLM2iEIZSxA==}
+  '@esbuild/linux-x64@0.28.1':
+    resolution: {integrity: sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==}
     engines: {node: '>=18'}
     cpu: [x64]
     os: [linux]
@@ -2216,8 +2331,8 @@ packages:
     cpu: [arm64]
     os: [netbsd]
 
-  '@esbuild/netbsd-arm64@0.27.7':
-    resolution: {integrity: sha512-b6pqtrQdigZBwZxAn1UpazEisvwaIDvdbMbmrly7cDTMFnw/+3lVxxCTGOrkPVnsYIosJJXAsILG9XcQS+Yu6w==}
+  '@esbuild/netbsd-arm64@0.28.1':
+    resolution: {integrity: sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==}
     engines: {node: '>=18'}
     cpu: [arm64]
     os: [netbsd]
@@ -2228,8 +2343,8 @@ packages:
     cpu: [x64]
     os: [netbsd]
 
-  '@esbuild/netbsd-x64@0.27.7':
-    resolution: {integrity: sha512-OfatkLojr6U+WN5EDYuoQhtM+1xco+/6FSzJJnuWiUw5eVcicbyK3dq5EeV/QHT1uy6GoDhGbFpprUiHUYggrw==}
+  '@esbuild/netbsd-x64@0.28.1':
+    resolution: {integrity: sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==}
     engines: {node: '>=18'}
     cpu: [x64]
     os: [netbsd]
@@ -2240,8 +2355,8 @@ packages:
     cpu: [arm64]
     os: [openbsd]
 
-  '@esbuild/openbsd-arm64@0.27.7':
-    resolution: {integrity: sha512-AFuojMQTxAz75Fo8idVcqoQWEHIXFRbOc1TrVcFSgCZtQfSdc1RXgB3tjOn/krRHENUB4j00bfGjyl2mJrU37A==}
+  '@esbuild/openbsd-arm64@0.28.1':
+    resolution: {integrity: sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==}
     engines: {node: '>=18'}
     cpu: [arm64]
     os: [openbsd]
@@ -2252,8 +2367,8 @@ packages:
     cpu: [x64]
     os: [openbsd]
 
-  '@esbuild/openbsd-x64@0.27.7':
-    resolution: {integrity: sha512-+A1NJmfM8WNDv5CLVQYJ5PshuRm/4cI6WMZRg1by1GwPIQPCTs1GLEUHwiiQGT5zDdyLiRM/l1G0Pv54gvtKIg==}
+  '@esbuild/openbsd-x64@0.28.1':
+    resolution: {integrity: sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==}
     engines: {node: '>=18'}
     cpu: [x64]
     os: [openbsd]
@@ -2264,8 +2379,8 @@ packages:
     cpu: [arm64]
     os: [openharmony]
 
-  '@esbuild/openharmony-arm64@0.27.7':
-    resolution: {integrity: sha512-+KrvYb/C8zA9CU/g0sR6w2RBw7IGc5J2BPnc3dYc5VJxHCSF1yNMxTV5LQ7GuKteQXZtspjFbiuW5/dOj7H4Yw==}
+  '@esbuild/openharmony-arm64@0.28.1':
+    resolution: {integrity: sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==}
     engines: {node: '>=18'}
     cpu: [arm64]
     os: [openharmony]
@@ -2276,8 +2391,8 @@ packages:
     cpu: [x64]
     os: [sunos]
 
-  '@esbuild/sunos-x64@0.27.7':
-    resolution: {integrity: sha512-ikktIhFBzQNt/QDyOL580ti9+5mL/YZeUPKU2ivGtGjdTYoqz6jObj6nOMfhASpS4GU4Q/Clh1QtxWAvcYKamA==}
+  '@esbuild/sunos-x64@0.28.1':
+    resolution: {integrity: sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==}
     engines: {node: '>=18'}
     cpu: [x64]
     os: [sunos]
@@ -2288,8 +2403,8 @@ packages:
     cpu: [arm64]
     os: [win32]
 
-  '@esbuild/win32-arm64@0.27.7':
-    resolution: {integrity: sha512-7yRhbHvPqSpRUV7Q20VuDwbjW5kIMwTHpptuUzV+AA46kiPze5Z7qgt6CLCK3pWFrHeNfDd1VKgyP4O+ng17CA==}
+  '@esbuild/win32-arm64@0.28.1':
+    resolution: {integrity: sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==}
     engines: {node: '>=18'}
     cpu: [arm64]
     os: [win32]
@@ -2300,8 +2415,8 @@ packages:
     cpu: [ia32]
     os: [win32]
 
-  '@esbuild/win32-ia32@0.27.7':
-    resolution: {integrity: sha512-SmwKXe6VHIyZYbBLJrhOoCJRB/Z1tckzmgTLfFYOfpMAx63BJEaL9ExI8x7v0oAO3Zh6D/Oi1gVxEYr5oUCFhw==}
+  '@esbuild/win32-ia32@0.28.1':
+    resolution: {integrity: sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==}
     engines: {node: '>=18'}
     cpu: [ia32]
     os: [win32]
@@ -2312,8 +2427,8 @@ packages:
     cpu: [x64]
     os: [win32]
 
-  '@esbuild/win32-x64@0.27.7':
-    resolution: {integrity: sha512-56hiAJPhwQ1R4i+21FVF7V8kSD5zZTdHcVuRFMW0hn753vVfQN8xlx4uOPT4xoGH0Z/oVATuR82AiqSTDIpaHg==}
+  '@esbuild/win32-x64@0.28.1':
+    resolution: {integrity: sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==}
     engines: {node: '>=18'}
     cpu: [x64]
     os: [win32]
@@ -3008,14 +3123,8 @@ packages:
     resolution: {integrity: sha512-VVPPgHyQ6ShqnrmDWuxjmUIsO9gWyOZFmuOfLd9LfBGQJwZfy0gvv9pbHSJuoFNIYC7ZDX9aoFwowjcdSC4E8w==}
     engines: {node: '>=18'}
 
-  '@napi-rs/wasm-runtime@1.1.4':
-    resolution: {integrity: sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==}
-    peerDependencies:
-      '@emnapi/core': ^1.7.1
-      '@emnapi/runtime': ^1.7.1
-
-  '@napi-rs/wasm-runtime@1.1.5':
-    resolution: {integrity: sha512-AWPoBRJ9tsnVhor4sjO7rkni+7p+2IAEFj6cx06UgP10jkQHqay/36uRV/bFkgrh18D9vb4cr8Q0Pthskgzy+Q==}
+  '@napi-rs/wasm-runtime@1.1.6':
+    resolution: {integrity: sha512-ZLv/JdUfkvOy9eCnnBaGfiO+XimbjebAeO+MRQqD/B+FR1tnRN0tpKSJHRbE8sFfS6aqsXZ67TQjfwfsxULVbg==}
     peerDependencies:
       '@emnapi/core': ^1.7.1
       '@emnapi/runtime': ^1.7.1
@@ -3113,8 +3222,8 @@ packages:
   '@oslojs/encoding@1.1.0':
     resolution: {integrity: sha512-70wQhgYmndg4GCPxPPxPGevRKqTIJ2Nh4OkiMWmDAVYsTQ+Ta7Sq+rPevXyXGdzr30/qZBnyOalCszoMxlyldQ==}
 
-  '@oxc-project/runtime@0.133.0':
-    resolution: {integrity: sha512-PkvjA1Lq5++V5S1E6Patr92ZVcieE6EalDr1VJTqv4BnjZdOUC4W3p8k1wMXSd5/2aFP4b/A6N5sg2Bkzcr9vQ==}
+  '@oxc-project/runtime@0.136.0':
+    resolution: {integrity: sha512-u0EutjK5y6NHJkl5jNJCs8zbup1z6A/UEWgajrYzqcEU3UX05HjqybhMQOLhSM0eKGISyM6WfSMMuklYSmH2wA==}
     engines: {node: ^20.19.0 || >=22.12.0}
 
   '@oxc-project/types@0.127.0':
@@ -3123,119 +3232,122 @@ packages:
   '@oxc-project/types@0.130.0':
     resolution: {integrity: sha512-ibD2usx9JRu7f5pu2tMKMI4cpA4NgXJQoYRP4pQ7Pxmn1l6k/53qWtQWZayhYy3X4QZkt90Ot+mJEaeXouio6Q==}
 
-  '@oxc-project/types@0.133.0':
-    resolution: {integrity: sha512-KzkdCd6Uxqnf6l3HOw1xfatAlUURA0g14cvBYFyJ5SaNOQbOUvBr9PKArcPcrNIeRsBdgcUzOGrhKveVpvOIGA==}
+  '@oxc-project/types@0.136.0':
+    resolution: {integrity: sha512-39Al/B3v9esnHCX7S8l9Se2+s2tb9b2jcMd+bZ2L659VG73kNyGPpPrL5Zi/p0ty7p4pTTU2/Dd+g27hv94XCg==}
 
-  '@oxfmt/binding-android-arm-eabi@0.52.0':
-    resolution: {integrity: sha512-17EMSJnQ9g+upVHrAUYDMfH5lvRKQ9Nvg8WtEoH72oDr1VpWz+7/o3tD97U1EToen2YAQ/68JmtDYkQUi20dfQ==}
+  '@oxc-project/types@0.137.0':
+    resolution: {integrity: sha512-WT+Gb24i8hmvo85AIv2oEYouEXkRlKAlT9WaCa3TfLgNCN+GhrJOGZuIlMouAh38Qe4QOx26eUOVsq70qXrywA==}
+
+  '@oxfmt/binding-android-arm-eabi@0.55.0':
+    resolution: {integrity: sha512-+rFDOqQe5LOWgxrAJaZgLRudr6GQm0wGI6gtu7vVkrdLGjNMUSGbAlaCr8j7F2H2Er97vYQCU8WDb30onqMM1g==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm]
     os: [android]
 
-  '@oxfmt/binding-android-arm64@0.52.0':
-    resolution: {integrity: sha512-A2G1IdwGEW2lLJkIxcvuirRH1CzSl/e0NX11zTlW1gvxJThfwbI/BEoaKrTNpm7M2FchvIf6guvIQU7d5iz+OQ==}
+  '@oxfmt/binding-android-arm64@0.55.0':
+    resolution: {integrity: sha512-ctulLq8s3x8Zmvw6+iccB09TIKERAklRSmbJ10gk8mlAn05qZxoyo52dj3Hi9IJcmDSwF54fQaTVh2CbL6PInw==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [android]
 
-  '@oxfmt/binding-darwin-arm64@0.52.0':
-    resolution: {integrity: sha512-f9+bLvOYxy7NttCLFTvQ7afmqDOWY4wIP9xdvfj5trQ1qj6f2UFAGwZESlfsMjvJNTyRpXfIlOanCI9FOvoeQA==}
+  '@oxfmt/binding-darwin-arm64@0.55.0':
+    resolution: {integrity: sha512-xDQczLH9pw/RBk1h/GH0qcGMm8hQtmtVHBNLSH3lk1gEIR09hZ4L+mJQl4VqiVAvPK9VG9PYrWWuSQLt7xTbiA==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [darwin]
 
-  '@oxfmt/binding-darwin-x64@0.52.0':
-    resolution: {integrity: sha512-YSTB9sJ5nnQd/Q0ddHkgof0ZCHPAnWZT1IW2SJ8omz7CP7KluJhO1fNHrpqdxCtpztJwSs4hY1uAee35wKxxaw==}
+  '@oxfmt/binding-darwin-x64@0.55.0':
+    resolution: {integrity: sha512-JaNoFCkF2CJdGgpPSMbuO9HVyXyoNGIhMHPvp6NYAjeVKw9XEYc0HcUWJLPQa3Q69WV5wMa9m5jPMJPtbLtcRg==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [darwin]
 
-  '@oxfmt/binding-freebsd-x64@0.52.0':
-    resolution: {integrity: sha512-NIrRNTTPCs4UbmVs0bxLSCDlLCtIRMJIXklNKaXa5Oj2/K1UIMBvgE8+uPVo01Io3N9HF0+GAX+aAHjUgZS7vA==}
+  '@oxfmt/binding-freebsd-x64@0.55.0':
+    resolution: {integrity: sha512-DNbszhpg6S2MIzax5azdHFTTBIVkR5xr8yyRZuA4yoDAwOkzIp3tmldgKZM2+VlT+hJIG0xUksA+elISzMEAfA==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [freebsd]
 
-  '@oxfmt/binding-linux-arm-gnueabihf@0.52.0':
-    resolution: {integrity: sha512-JXUCde8mn3GpgQouz2PXUokgy/uT1QrRJBL2s983VWcSQp62wTFYiNXgTKdeo1Jgbr0IgUnKKvzIk/YBlj/nVQ==}
+  '@oxfmt/binding-linux-arm-gnueabihf@0.55.0':
+    resolution: {integrity: sha512-2snoaoRfFFyGnbOcKUK36rREBYxe/Xgz3uHbiA5zbCB/s6R4DQj4mHqYAaWWhgizCUSDxV8cE9zAZ0XleNpKGw==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm]
     os: [linux]
 
-  '@oxfmt/binding-linux-arm-musleabihf@0.52.0':
-    resolution: {integrity: sha512-psbUXaRZ+V8DaXz10Qf7LSHtdtdKAmC8fxXgeU608jjzrmWK4quamZMOpl6sf+dikoFHA85uE93Q0BqxrCdQrQ==}
+  '@oxfmt/binding-linux-arm-musleabihf@0.55.0':
+    resolution: {integrity: sha512-q1aktHF/WRpSK81BX1dE/9vWrS2jGw1Nax2kb4DBLGAewubCLcoNyp4Zl/NSMgbv3vUS46Z33wIQkBVYOP3PYg==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm]
     os: [linux]
 
-  '@oxfmt/binding-linux-arm64-gnu@0.52.0':
-    resolution: {integrity: sha512-Jw7MgWUU9lcLCcy82updISP3EthTlfvAwR6gWNxPzqly7+fLvOi2gHQE9xXQjpqaVLm/8P+gOzlv9ODuoVlaaw==}
+  '@oxfmt/binding-linux-arm64-gnu@0.55.0':
+    resolution: {integrity: sha512-VD0y36aENezl/3tsclA/4G53Cc7iV+7Uoh7gz4yvcOTaEYBtJpQsE6PKDGTtUtOvGS4kv51ybfXY/nWZejO5IA==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [linux]
 
-  '@oxfmt/binding-linux-arm64-musl@0.52.0':
-    resolution: {integrity: sha512-wZg6bLjDvh2KibyI3QFUYo8GTXneIFsd0JvehtvJiUmQ8WRPERgxd/VM4ctWb86U5FT1FkqgS8/wZKVB+AZScg==}
+  '@oxfmt/binding-linux-arm64-musl@0.55.0':
+    resolution: {integrity: sha512-r8xlKJFcsRmn0H5jZrdORae6RX9jDBrZVvOoxF+bCQtampQJClv80aZEHsv+NsLsp2KCE5ql79O7DpPVzYWpXA==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [linux]
 
-  '@oxfmt/binding-linux-ppc64-gnu@0.52.0':
-    resolution: {integrity: sha512-IngE8uxhNvxcMrLjZNDo9xNLY7rEK33AKnaMd2B46he1e/mz2CfcW6If/U1wUjdRZddm1QzQaciqZkuMkdh1FA==}
+  '@oxfmt/binding-linux-ppc64-gnu@0.55.0':
+    resolution: {integrity: sha512-GRKv/HXHcwIVld/WU61rF0g0R16hl5EJ+ScKdpjevT57lnLnagj/U2YUbXf2mT+2Pg1uCzWC+mvGicPV3CDdLQ==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [ppc64]
     os: [linux]
 
-  '@oxfmt/binding-linux-riscv64-gnu@0.52.0':
-    resolution: {integrity: sha512-H3+DdFMv/efN3Efmhsv18jDrpiWWqKG7wsfAlQBqAt6z/E2Bx+TwEj2Nowe51CPOWB8/mFBC2dAMSgVFLvvowA==}
+  '@oxfmt/binding-linux-riscv64-gnu@0.55.0':
+    resolution: {integrity: sha512-rdv57enTiPtpSYRMKfAiEbQb0Puw5t9N7isVinDoo5qeLDScro2gznmZqSgSWbVZRzLisTeCTW8Qwgw0bOHv3A==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [riscv64]
     os: [linux]
 
-  '@oxfmt/binding-linux-riscv64-musl@0.52.0':
-    resolution: {integrity: sha512-zji+1kb7lJKohSDjzC1IsS+K/cKRs1hdVf0ZH0VbdbiakmtLvN9twBoXo/k8VdjFax7kfo+DyPxS7vv52br1aw==}
+  '@oxfmt/binding-linux-riscv64-musl@0.55.0':
+    resolution: {integrity: sha512-7v1nNrlD43VY6+sYQ6efYyb3lE6QY182304PD/768ZxTjOmFd/3dQa3u/nGBUAXYdGSWOQc5N3PnS0QzUXyEIA==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [riscv64]
     os: [linux]
 
-  '@oxfmt/binding-linux-s390x-gnu@0.52.0':
-    resolution: {integrity: sha512-hcLBYedpCy7ToUvvBidWk7+11Yhg1oAZ4+6hKPic/mQI6NaqXJSXMps5nFlwUuX2ewhtLZZDPg63TI042qGKBg==}
+  '@oxfmt/binding-linux-s390x-gnu@0.55.0':
+    resolution: {integrity: sha512-f4lJLUSPOgScjFl9LiflKCTocyNRwE25JmTMbN4XQdDjoZzEHjqf3wA3VESF1/csg7i8m7+EQLbrZyYDqe10UQ==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [s390x]
     os: [linux]
 
-  '@oxfmt/binding-linux-x64-gnu@0.52.0':
-    resolution: {integrity: sha512-IDO2loXK2OtTOhSPchU9MW25mWL2QCDGdJbjN8MXKZVS80qXe5gMTwQWu/gMJ3juoBHbkuUZNB2N1LHzNT7DoA==}
+  '@oxfmt/binding-linux-x64-gnu@0.55.0':
+    resolution: {integrity: sha512-MihqiPziJNoWy4MqNSV+jVA1g+07iQDjZiR0vaCaDoPgFEiJpCMsxamktzLV07cEeQsSJ04vQaU4CzCQwIvtDA==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [linux]
 
-  '@oxfmt/binding-linux-x64-musl@0.52.0':
-    resolution: {integrity: sha512-mAV2Hjn0SatJ+KoAzKUC3eJhdJ8wv+3m1KyuS0dTsbF0c5weq+QrCt/DRZZM+uj/XiKzCDEUKYsBF30e2qkcyw==}
+  '@oxfmt/binding-linux-x64-musl@0.55.0':
+    resolution: {integrity: sha512-Yqghym7KYAVjP9MmSrNZiDeerMuoejNjo0r3ox5H3GDKk8eAfl8VyJm9i+pWCLDCTnAbcTUMMN2ZKjUYXH1v3g==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [linux]
 
-  '@oxfmt/binding-openharmony-arm64@0.52.0':
-    resolution: {integrity: sha512-vd4npaUIwChxp7XzkqmepBWTT9YMcSe/NBApVGPC30/lLyOVaV3dvma1SKo03t8O73BPRAG7EyJzGlN5cJM5hQ==}
+  '@oxfmt/binding-openharmony-arm64@0.55.0':
+    resolution: {integrity: sha512-s5SDvVVSbyQl1V5UU3Yl12M+XLUQ3rl5SglNqgAA2K4PXUtQhyNSS00wivONPEnNo5W01rCou8WkDNyvI/RGHg==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [openharmony]
 
-  '@oxfmt/binding-win32-arm64-msvc@0.52.0':
-    resolution: {integrity: sha512-k2sz6gWQdMfh5HPpIS+Bw/0UEV/kaK2xuqJRrWL233sEHx9WLlsmvlPFM4HUNThkYbSN0U0vPW7LVKZWDS8hPQ==}
+  '@oxfmt/binding-win32-arm64-msvc@0.55.0':
+    resolution: {integrity: sha512-7p9FB5R32tw2KyyNX3wpQrR2WHwEHvMEiBlGXxeTCaRMCVNx3UtFMAUbaQ/pRNWIrEUZmYhJ6tcUH52uPTRYjQ==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [win32]
 
-  '@oxfmt/binding-win32-ia32-msvc@0.52.0':
-    resolution: {integrity: sha512-rhke69GTcArodLHpjMTfNnvjTEBryDeZcUCKK/VjXDMtfTULl6QRh0ymX5/hbCUv2WjYm9h/QbW++q2vE15gWQ==}
+  '@oxfmt/binding-win32-ia32-msvc@0.55.0':
+    resolution: {integrity: sha512-ZYqj3fDnOT1IaVGMP5kpmkQl4F3tQIm2ZyAxvqkJYmI0xgWWak4ss4XYwv3VDfM+TWXeC9K4uQ/wW5jm/5XABA==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [ia32]
     os: [win32]
 
-  '@oxfmt/binding-win32-x64-msvc@0.52.0':
-    resolution: {integrity: sha512-q5xL7oeXkZdEtNZWBdvehJcmt+GRu9l2bK40yJs1jJXlqq+r0Hygb1rTjq+FM2o/2xyt4cufH6KRplHp3Jjsvw==}
+  '@oxfmt/binding-win32-x64-msvc@0.55.0':
+    resolution: {integrity: sha512-eEYT5tivGnGbPHuOHuQpi6CGLObhh0re/5jcNQHihD2GRYkTM85dyi5a19zjP8Q00t1uqAx+/QGLUGdHeqzWyg==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [win32]
@@ -3270,124 +3382,120 @@ packages:
     cpu: [x64]
     os: [win32]
 
-  '@oxlint/binding-android-arm-eabi@1.67.0':
-    resolution: {integrity: sha512-VrSi571rDv1N8HaEDM+DEX8nmT0y9jJo8tzzW13vsOWTx59xQczCIJx68n2zWOXRT5YKZsOZXp4qkHN/10x4mw==}
+  '@oxlint/binding-android-arm-eabi@1.70.0':
+    resolution: {integrity: sha512-zFh0P4cswmRvw6nkyb89dr18rRanuaCPAsEXsFDoQY8WdaquI8Pt4NWFjaMJg6L23cy5NeN8J9cBnREbWzZhaw==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm]
     os: [android]
 
-  '@oxlint/binding-android-arm64@1.67.0':
-    resolution: {integrity: sha512-l6+NdYxMoRohix5r5bbigW16LPicceCwGcQ6LKKuE1kUdjgFfQolJjrJsQYPFetIs78Gxj/G/f5TEGoTCwj9nQ==}
+  '@oxlint/binding-android-arm64@1.70.0':
+    resolution: {integrity: sha512-qI8o4HZjeGiBrWv+pJv4lH0Yi2Gl/JSp/EumBUApezJprIKa5PS4nU0lQsQngtky8k+SplQIOjv6hwu0SSxeyg==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [android]
 
-  '@oxlint/binding-darwin-arm64@1.67.0':
-    resolution: {integrity: sha512-jOzXxS1AxFxhImLIRbtGIMrEwaXcgMw3gR57WB1cRk8ai+vpr6726kxXqVvlNsrXtJ/FrmOm8RxlC0m8SW24Qg==}
+  '@oxlint/binding-darwin-arm64@1.70.0':
+    resolution: {integrity: sha512-8KjgVVHI5F9nVwHCRwwA78Ty7zNKP4Wd9OeN5PSv3iu/F/u1RVXoOCgLhWqust6HmwQG6xc8c+RCyaWENy24+w==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [darwin]
 
-  '@oxlint/binding-darwin-x64@1.67.0':
-    resolution: {integrity: sha512-3DFAVY94OqjIZHXIPz37yGRSWwOFTAqChQ64/M69GYLawzP0KiwdhDNfqdKKYT0bTR/DNxmMnQsj3ns+8+X/Lg==}
+  '@oxlint/binding-darwin-x64@1.70.0':
+    resolution: {integrity: sha512-WVydssv5PSUBXFJTdNBWlmGkbNmvPGaFt/2SUT/EZRB6bq6bEOHmMlbnupZD5jmlEvi9+mZJHi8TCw15lyfSfQ==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [darwin]
 
-  '@oxlint/binding-freebsd-x64@1.67.0':
-    resolution: {integrity: sha512-e4dDKZuLu8TR9DEBssWSDahlPgZBwojTTHZUvnjBRJfJJbpxYCjfjKfi0Z1+CSLMiJBwI2yCDtRM1XJQaARjmg==}
+  '@oxlint/binding-freebsd-x64@1.70.0':
+    resolution: {integrity: sha512-hJucmUf8OlinHNb1R7fI4Fw6WsAstOz7i8nmkWQfiHoZXtbufNm+MxiDTIMk1ggh2Ro4vLzgQ+bKvRY54MZoRA==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [freebsd]
 
-  '@oxlint/binding-linux-arm-gnueabihf@1.67.0':
-    resolution: {integrity: sha512-BKytFdcQzbITV3xlnzDUDTEDtbUMCCiC4EaNTDZ4FyT8gdNvBC4gfiLucXp/sQl0XU3p7syTlorUWVVVBZab2g==}
+  '@oxlint/binding-linux-arm-gnueabihf@1.70.0':
+    resolution: {integrity: sha512-1BnS7wbCYDSXwWzJJ+mc3NURoha6m6m6RT5c6vgAY3oz7C3OVXP+S0awo2mRq97arrJkVvO3qRQfyAHL+76xtQ==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm]
     os: [linux]
 
-  '@oxlint/binding-linux-arm-musleabihf@1.67.0':
-    resolution: {integrity: sha512-XYAv0esBDX7BpTzRDjVX2Vdj+zndd8ll2dFQiaeQ6zTZr7A8GRDTN7fH3FP3jU+O0vCDx85oH/EtG7BzPgAXuw==}
+  '@oxlint/binding-linux-arm-musleabihf@1.70.0':
+    resolution: {integrity: sha512-yKy/UdbR55+M2yEcuiV5DCNC/gdQAjr/GioUy50QwBzSrKm8ueWADqyRLS9Xk+qjNeCYGg6A8FvUBds56ttfqg==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm]
     os: [linux]
 
-  '@oxlint/binding-linux-arm64-gnu@1.67.0':
-    resolution: {integrity: sha512-zizRMjA0i6u/2B0evgda04iycu+MoNuf1pBy6Eh+1CjC5wMEG7qN5zdDKTCvFc0KSYSDM9QTG3gjZHirgtQuKg==}
+  '@oxlint/binding-linux-arm64-gnu@1.70.0':
+    resolution: {integrity: sha512-0A5XJ4alvmqFUFP/4oYSyaO+qLto/HrKEWTSaegiVl+HOufFngK2BjYw9x4RbwBt/du5QG6l5q1zeWiJYYG5yg==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [linux]
 
-  '@oxlint/binding-linux-arm64-musl@1.67.0':
-    resolution: {integrity: sha512-zB/Tf6sUjmmvvbva9Gj3JTJ8rJ9t4I8/U0o6vSRtd0DRIsIuyegBwJAzhSUFQHdMijIRJkW0exs/yBhpw2S20w==}
+  '@oxlint/binding-linux-arm64-musl@1.70.0':
+    resolution: {integrity: sha512-JiylyurlB0CLSedNtx1gzv3FvfWPF1h/2Y3BJszPLNt5XQFlBsH5ke0Jle3iJb3uqu5m2e7A/DwzpuCAHdiU+A==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [linux]
 
-  '@oxlint/binding-linux-ppc64-gnu@1.67.0':
-    resolution: {integrity: sha512-kgU40Gt74CK0TCsF51KZymkIwN9U0BajKsMijB52zPqOeZU9NAHkA/NSQkZDHEaCakx42DxhXkODiAqf2b4Gug==}
+  '@oxlint/binding-linux-ppc64-gnu@1.70.0':
+    resolution: {integrity: sha512-J8VPG7I3/HmgaU4u8pNU2kFx2+0U+vPLS1dXFxXOaR/2TQ0f8AC7DRz0SRGRI1bfphnX2hVYTTtLuhL4nYKL+Q==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [ppc64]
     os: [linux]
 
-  '@oxlint/binding-linux-riscv64-gnu@1.67.0':
-    resolution: {integrity: sha512-tOYhkk/iaG9aD3FvGpBFd1Lrw0x0RaVoJBxjUkfNzS50rC5NS5BteNCwgr8A2zCdADrIIoze6D7u6U5Ic++/iQ==}
+  '@oxlint/binding-linux-riscv64-gnu@1.70.0':
+    resolution: {integrity: sha512-N2+4lV2KLN+oXTIIIwmWDhwkrnvqf5oX7Hw0zPjk+RuIVgiBQSOlJWF7uQoFx2siEYX0ZQ5cfSbEAHm+J3t7Wg==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [riscv64]
     os: [linux]
 
-  '@oxlint/binding-linux-riscv64-musl@1.67.0':
-    resolution: {integrity: sha512-sEtywrPb+0b+tHYl1SDCrw903fiC4eyKoNqzP3v+f2JT3Xcv4NEYG+P8rj+eEnX7IWhqV/xj8/JmcmVj21CXaA==}
+  '@oxlint/binding-linux-riscv64-musl@1.70.0':
+    resolution: {integrity: sha512-1e2L7cFCvx9QDzq6NPP+0tABKb5z6nWHyddWTNKprEsjO9xNrAtPowuCGpjNXxkTdsMiZ4jc8YQ5SstZd4XK6g==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [riscv64]
     os: [linux]
 
-  '@oxlint/binding-linux-s390x-gnu@1.67.0':
-    resolution: {integrity: sha512-BvR8Moa0zCLxroOx4vZaZN9nUfwAUpSTwjZdxZyKy4bv3PrzrXrxKR/ZQ0L9wNSvlPhnMJeZfa3q5w6ZCTuN6Q==}
+  '@oxlint/binding-linux-s390x-gnu@1.70.0':
+    resolution: {integrity: sha512-Kwu/l/8GcYibCWA9m9N5pRXMIKVSsL/YbgpLzYkqDhWTiqdRfnNJ/+nqIKRKQiFbHWsdlHEhzMwruJK+qcEruA==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [s390x]
     os: [linux]
 
-  '@oxlint/binding-linux-x64-gnu@1.67.0':
-    resolution: {integrity: sha512-mm2cxM6fksOpq6l0uFws8BUGKAR4dNa/cZCn37Npq7PFbhD5HDJqWfnoIvTaeRKMy5XdS2tO0MA0qbHDrnXAAA==}
+  '@oxlint/binding-linux-x64-gnu@1.70.0':
+    resolution: {integrity: sha512-tap04CsHYOl0nSAQJfPNIuBxqEPB2HnhQqwaOXLg1jnp2XfRo8Fa814dA4QC4zpvTWXCjAAaCY1W5LOORkEQuQ==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [linux]
 
-  '@oxlint/binding-linux-x64-musl@1.67.0':
-    resolution: {integrity: sha512-WmbMuLapKyDlobMkXAaAL0Y+Uczh4LETfIfQsUpbId4Ip8Ai82/jqeYTOoUCkuuhBFapgqP253+d83tLKOksJg==}
+  '@oxlint/binding-linux-x64-musl@1.70.0':
+    resolution: {integrity: sha512-hzJa/WgvtJpbBD9rgfy0qe+MjbxOXNUT0bfR1S6EQQzfTtBFA9xg5q8KSwRrQ2QfSS+TaP4j+4mVPQrfNc6UNg==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [linux]
 
-  '@oxlint/binding-openharmony-arm64@1.67.0':
-    resolution: {integrity: sha512-9g/PqxYJelzzTAOR5Y+RiRqdeydhEuXv2KxNeFcAKQ7UsvnWSY1OP4MsuPMbTO2Pf70tz7mFhl1j13H3fyh+8g==}
+  '@oxlint/binding-openharmony-arm64@1.70.0':
+    resolution: {integrity: sha512-xbsaNSNzVSnaJACCUYr1HQMyY/Q/Q1LkePmHG3UvZPvGCYGNxrsZp9OmtA6ick8xH47ltRRbRrPCM1YXYcyC+A==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [openharmony]
 
-  '@oxlint/binding-win32-arm64-msvc@1.67.0':
-    resolution: {integrity: sha512-2VhwE6Gatb0vJGnN0TBuQMbKCOiZlSQ/zJvVWYLK4a9d4iDiJOen/yVQkGpmsJ90MuH66fzi0kEKI0jRQMDxGA==}
+  '@oxlint/binding-win32-arm64-msvc@1.70.0':
+    resolution: {integrity: sha512-icAEsUI7JbW1TMRdEXV83mVAInhRVQYuuAlPpxdGwJ95chNdnCzjloRW8GglT0WvzOEZSio6fnYSk2DJ2Hv7LQ==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [win32]
 
-  '@oxlint/binding-win32-ia32-msvc@1.67.0':
-    resolution: {integrity: sha512-EQ3VExXfeM1InbE5+JjufhZZTWy+kHUwgt3yZR7gQ47Je/mE0WspQPan0OJznh493L5anM210YNJtH1PXjTSFg==}
+  '@oxlint/binding-win32-ia32-msvc@1.70.0':
+    resolution: {integrity: sha512-FHMSWbVsPVs/f+Jcl04ws4JJ2wUnauyTzlpxWRG/lSO/8GpX08Fo2gQZqdA6CrRFI+zvkxl+N/KwJGWfUwYVZA==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [ia32]
     os: [win32]
 
-  '@oxlint/binding-win32-x64-msvc@1.67.0':
-    resolution: {integrity: sha512-bw24y+/1MHS4QDkons3YyHkPT9uCMoLHHgQhb+mb8NOjTYwub1CZ+K9Ngr8aO5DMrDrkqHwTzlTwFP2vS8Y/ZQ==}
+  '@oxlint/binding-win32-x64-msvc@1.70.0':
+    resolution: {integrity: sha512-ptOlKwCz7n4AKs5VweMqG6DAg677FmKOK+vBkkL9DMNgFATIQ+upqUYBTOEwRQyRAx1ncGlPlXleV2hIcm3z4g==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [win32]
 
-  '@oxlint/plugins@1.61.0':
-    resolution: {integrity: sha512-nkOyZEF1vH527CkdQtOp1HMrVFEM4ResURvI2JFeGoup+h+43J/k/FgdOR9b9Isxg+Yae7qVDa7y3nssE8b3TQ==}
-    engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
-
   '@oxlint/plugins@1.68.0':
     resolution: {integrity: sha512-titLmukUt/h8ho7Svlf0xSBjoy2ccZKrXjpXpZCj+v6V4CJccC2KyP45BLSCMx8YIpifMyiDyUptM4+5sruKbQ==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@@ -3766,8 +3874,8 @@ packages:
     cpu: [arm64]
     os: [android]
 
-  '@rolldown/binding-android-arm64@1.0.3':
-    resolution: {integrity: sha512-454rs7jHngixp/NMxd5srYD57OnzSlZ/eFTETjORQHLwJG1lRtmNOJcBerZlfu4GjKqeq8aCCIQrMdHyhI51Hw==}
+  '@rolldown/binding-android-arm64@1.1.3':
+    resolution: {integrity: sha512-DT6Z3PhvioeHMvxo+xHc3KtqggrI7CCTXCmC2h/5zUlp5jVitv7XEy+9q5/7v8IolhlioawpMo8Kg0EEBy7J0g==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [android]
@@ -3784,8 +3892,8 @@ packages:
     cpu: [arm64]
     os: [darwin]
 
-  '@rolldown/binding-darwin-arm64@1.0.3':
-    resolution: {integrity: sha512-PcAhP+ynjURNyy8SKGl5DQP94aGuB/7JrXJb/t7P+hanXvQVMWzUvRRhBAcg/lNRadBhoUPqSoP4xw5tR/KBEA==}
+  '@rolldown/binding-darwin-arm64@1.1.3':
+    resolution: {integrity: sha512-0NwgwsjM7LrsuVnXMK3koTpagBNOhloc/BNjKqZjv4V5zI5r13qx69uVhRx+o5Z0yy4Hzq+lpy7TAgUG/ocvrw==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [darwin]
@@ -3802,8 +3910,8 @@ packages:
     cpu: [x64]
     os: [darwin]
 
-  '@rolldown/binding-darwin-x64@1.0.3':
-    resolution: {integrity: sha512-9YpfeUvSE2RS7wysJ81uOZkXJz7f7Q55H2Gvp3VEw/EsahqDtrphrZ0EwDLK5vvKOzaCrBsjF8JmnMLcUt78Gg==}
+  '@rolldown/binding-darwin-x64@1.1.3':
+    resolution: {integrity: sha512-YtiBp4disu6V560loT6PjMdiRaWmVvDNrUunAalbiFx2ggeJwxdAsgZMcoGP17uyAsTwAj5V1niksxlHnVQ1Sw==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [darwin]
@@ -3820,8 +3928,8 @@ packages:
     cpu: [x64]
     os: [freebsd]
 
-  '@rolldown/binding-freebsd-x64@1.0.3':
-    resolution: {integrity: sha512-yB1IlAsSNHncV6SCTL27/MVGR5htvQsoGxIv5KMGXALp+Ll1wYsn+x98M9MW7qa+NdSbvrrY7ANI4wLJ0n1e6g==}
+  '@rolldown/binding-freebsd-x64@1.1.3':
+    resolution: {integrity: sha512-yD3EkEdXk2LypPxnf/kSZHirarsI8gcPzc62SukhR9VJTyvV+F9Q/GxWNuCojc7sXyuVC4DxRGhdDK4X8VSsbw==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [freebsd]
@@ -3838,8 +3946,8 @@ packages:
     cpu: [arm]
     os: [linux]
 
-  '@rolldown/binding-linux-arm-gnueabihf@1.0.3':
-    resolution: {integrity: sha512-Yi30IVAAfLUCy2MseFjbB1jAMDl1VMCAas5StnYp8da9+CKvMd2H2cbEjWcw5NPaPqzvYkVIaF1nNUG+b7u/sw==}
+  '@rolldown/binding-linux-arm-gnueabihf@1.1.3':
+    resolution: {integrity: sha512-c+8vieQbsD7HNAHKIA34w0GJ9FedFFuJGD+7E6vz7Q3uqAIugL5p45fhlsj4UaAsHpcmlqugBWMhA0/j7o0sIg==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm]
     os: [linux]
@@ -3856,8 +3964,8 @@ packages:
     cpu: [arm64]
     os: [linux]
 
-  '@rolldown/binding-linux-arm64-gnu@1.0.3':
-    resolution: {integrity: sha512-jsO7R8To+AdlYgUmN5sHSCZbfhtMBkO0WUx8iORQnPcMMdgr7qM2DQmMwgabs3GhNztdmoKkMKQFHD6DTMCIQw==}
+  '@rolldown/binding-linux-arm64-gnu@1.1.3':
+    resolution: {integrity: sha512-50jD0uUwLvur7Zz9LHz17kaAdTPjn5wN93hEgjvmYFRZwiR7ZJYovTd5ipyWJDAnXKvZ+wgc+/Ika6dwSF5OcA==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [linux]
@@ -3874,8 +3982,8 @@ packages:
     cpu: [arm64]
     os: [linux]
 
-  '@rolldown/binding-linux-arm64-musl@1.0.3':
-    resolution: {integrity: sha512-VWkUHwWriDciit80wleYwKILoR/KMvxh/IdwS/paX+ZgpuRpCrKLUdadJbc0NpBEiyhpYawsJ73j9aCvOH+f7Q==}
+  '@rolldown/binding-linux-arm64-musl@1.1.3':
+    resolution: {integrity: sha512-BO9+oPL8K9poZJBfYPsXNtYjPE5uM3qeehT3aFcW4LITOl+iSqhp0abzjR2nWBUNjIZeKXjAEWBZ64WjNoHd6w==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [linux]
@@ -3892,8 +4000,8 @@ packages:
     cpu: [ppc64]
     os: [linux]
 
-  '@rolldown/binding-linux-ppc64-gnu@1.0.3':
-    resolution: {integrity: sha512-5f1laC0SlIR0yDbFCd8acUhvJIag6N3zC5P7oUPN6wX0aOma+uKJ0wBDH5aq7I1PVI2ttTlhJwzwRIBnLiSGEg==}
+  '@rolldown/binding-linux-ppc64-gnu@1.1.3':
+    resolution: {integrity: sha512-f3VpLB1vQ0Eo6ecr/6cekLnvYMFF4YBFoVGkfkvPLq1bAkbAwHYQPZKoAmG6OJyTcxxoC+AvezGx/S1obNC0Mw==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [ppc64]
     os: [linux]
@@ -3910,8 +4018,8 @@ packages:
     cpu: [s390x]
     os: [linux]
 
-  '@rolldown/binding-linux-s390x-gnu@1.0.3':
-    resolution: {integrity: sha512-Iq4ko0r4XsgbrF/LunNgHtAGLRRVE2kXonAXQ/MV0mC6jQpMOhW1SvtZja2EhC/kd05++bP78dsqBeIQyYJ6Yg==}
+  '@rolldown/binding-linux-s390x-gnu@1.1.3':
+    resolution: {integrity: sha512-AmurZ26Pqx/RI9N1gzEOCklkKXl927yjfXWUUS0O7Puh8ARM/Ob8qfrD3qnWksScdw6cSrW5PSHE9DyLu7+PtA==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [s390x]
     os: [linux]
@@ -3928,8 +4036,8 @@ packages:
     cpu: [x64]
     os: [linux]
 
-  '@rolldown/binding-linux-x64-gnu@1.0.3':
-    resolution: {integrity: sha512-B8m6tD5+/N5FeNQFbKlLA/2yVq9ycQP1SeedyEYYKWBNR3ZQbkvIUcNnDNM03lO1l5F2roiiFJGgvoLLyZXtSg==}
+  '@rolldown/binding-linux-x64-gnu@1.1.3':
+    resolution: {integrity: sha512-JJpqs8bRGITDOdbkNKnlojzBabbOHrqjSvDr0IVsZObE1lBcPjxItUEY9eWIDbxaJ3cGrXPWGfGkIxFijg/URg==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [linux]
@@ -3946,8 +4054,8 @@ packages:
     cpu: [x64]
     os: [linux]
 
-  '@rolldown/binding-linux-x64-musl@1.0.3':
-    resolution: {integrity: sha512-pSdpdUJHkuCxun9LE7jvgUB9qsRgaiyNNCX7m/AvHTcq67AiT/Yhoxvw5zPfhrM8k/BfP8ce/hMOpthKDpEUow==}
+  '@rolldown/binding-linux-x64-musl@1.1.3':
+    resolution: {integrity: sha512-rSJcdjPxzA/by/6/rYs+v+bXU7UjvnbUWz8MJb6kh6+knqB1dCrtHg0uu7C/4haqJvqdkYHQ5IGn+tCH9GLW/g==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [linux]
@@ -3964,8 +4072,8 @@ packages:
     cpu: [arm64]
     os: [openharmony]
 
-  '@rolldown/binding-openharmony-arm64@1.0.3':
-    resolution: {integrity: sha512-OXXS3RKJgX2uLwM+gYyuH5omcH8fL1LJs96pZGgtetVCahON57+d4SJHzTgZiOjxgGkSnpXpOsWuPDGAKAigEg==}
+  '@rolldown/binding-openharmony-arm64@1.1.3':
+    resolution: {integrity: sha512-hQ3/PYkDJICgevvyNcVrihVeqq7k1Pp3VZ9lY+dauAYUJKO+auqApvANhvR1An9BhmqYKvW2Mu1F9u4DXSMLxQ==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [openharmony]
@@ -3980,8 +4088,8 @@ packages:
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [wasm32]
 
-  '@rolldown/binding-wasm32-wasi@1.0.3':
-    resolution: {integrity: sha512-JTtb8BWFynicNSoPrehsCzBtOKjZ6jhMiPFEmOiuXg1Fl8dn2KHQob+GuPSGR0dryQa1PQJbzjF3dqO/whhjLg==}
+  '@rolldown/binding-wasm32-wasi@1.1.3':
+    resolution: {integrity: sha512-Elcv/BtML9lXrV6JuKITc/grN2kYV9gjsQpW8Jfw4ioK0TOkjBjye0nnyqQNy9STNaI20lXNaQBRrD5gSgR0Yg==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [wasm32]
 
@@ -3997,8 +4105,8 @@ packages:
     cpu: [arm64]
     os: [win32]
 
-  '@rolldown/binding-win32-arm64-msvc@1.0.3':
-    resolution: {integrity: sha512-gEdFFEN70A/jxb2svrWsN3aDL7OUtmvlOy+6fa2jxG8K0wQ1ZbdeLGnidov6Yu5/733dI5ySfzFlQ/cb0bSz1g==}
+  '@rolldown/binding-win32-arm64-msvc@1.1.3':
+    resolution: {integrity: sha512-2DrEfhluH9yhiaFApmsjsjwrSYbNcY1oFTzYSP1a535jDbV98zCFanA/96TBUd0iDFcxGmw9QRExwGCXz3U+/g==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [arm64]
     os: [win32]
@@ -4015,8 +4123,8 @@ packages:
     cpu: [x64]
     os: [win32]
 
-  '@rolldown/binding-win32-x64-msvc@1.0.3':
-    resolution: {integrity: sha512-eXB7CHuaQdqmJcc3koCNtNPmT/bj2gc999kUFgBxG8Ac0NdgXc4rkCHhqrgrhN3zddvvvrgzj1e90SuSfmyIXA==}
+  '@rolldown/binding-win32-x64-msvc@1.1.3':
+    resolution: {integrity: sha512-OL4OMk7UPXOeVGGd3qo5zJyPIljf4AFgk5QAkPPS+OoLuOOozhuaQGC18MxVTnw/06q93gShAJzlwnSCY9YtqA==}
     engines: {node: ^20.19.0 || >=22.12.0}
     cpu: [x64]
     os: [win32]
@@ -4178,66 +4286,46 @@ packages:
     cpu: [x64]
     os: [win32]
 
-  '@shikijs/core@4.1.0':
-    resolution: {integrity: sha512-jLJtSJeuFffqX6/inRE1zqU5aFv2hrszvYgq3OjbAgFRZiWv7abKMDdQzYxuSDfmUPQozZvI/kuy6VMTvnvqTQ==}
-    engines: {node: '>=20'}
-
   '@shikijs/core@4.2.0':
     resolution: {integrity: sha512-Hc87Ab1Ld/vEbZRCbwx344I5v+4RU8CVToUTRkqXL1+TjbuOp9U5Xa0M23V4GEWHxVn+yO5otb+HkQVm3ptWQQ==}
     engines: {node: '>=20'}
 
-  '@shikijs/engine-javascript@4.1.0':
-    resolution: {integrity: sha512-YquhawCUgaBfhsS72e2Y/dI59gCBNPHu3fEO/tvLaXrTssxZrY5ddjtNLTwndrMgPo8b3IscE+xoICDzpTmlFQ==}
-    engines: {node: '>=20'}
-
   '@shikijs/engine-javascript@4.2.0':
     resolution: {integrity: sha512-fjETeq1k5ffyXqRgS6+3hpvqseLalp1kjNfRbXpUgWR8FpZ1CmQfiNHovc5lncYjt/Vg5JK/WJEmLahjwMa0og==}
     engines: {node: '>=20'}
 
-  '@shikijs/engine-oniguruma@4.1.0':
-    resolution: {integrity: sha512-axLpjVs45YBvvINa+dJF+NPW+KtFkNXsFr4SDw2BMj9GdeMnGxVB9PQb2xXlJYovslt/nz6giedAyOANkfc7hg==}
-    engines: {node: '>=20'}
-
   '@shikijs/engine-oniguruma@4.2.0':
     resolution: {integrity: sha512-hTorK1dffPkpbMUk6Z+828PgRo7d07HbnizoP0hNPFjhxMHctj0Px/qoHeGMYafc6ju+u9iMldN4JbVzNQM++g==}
     engines: {node: '>=20'}
 
-  '@shikijs/langs@4.1.0':
-    resolution: {integrity: sha512-nwOMruEkbgdZfQ/b8CgpNBVOpvG1k0N5tbmgiFeqsan401+x3ILqlzZJowSla4Agmq4hG2Uf2wh5jLTEhR8VSg==}
-    engines: {node: '>=20'}
-
   '@shikijs/langs@4.2.0':
     resolution: {integrity: sha512-bwrVRlJ0wUhZxAbVdvBbv2TTC9yLsh4C/IO5Ofz0T8MQntgDvyVnkbjw9vi50r1kx7RCIJdnJnjZAwmAsXFLZQ==}
     engines: {node: '>=20'}
 
-  '@shikijs/primitive@4.1.0':
-    resolution: {integrity: sha512-zx2/2Uwj2q9X3KSyYREEhXO23xBw5WUhP4orK2lE4r+t9JGITmEe0JH+wPmJhqHpOT2bRRs6lAL945+LDvOAGw==}
-    engines: {node: '>=20'}
-
   '@shikijs/primitive@4.2.0':
     resolution: {integrity: sha512-NOq+DtUkVBJtZMVXL5A0vI0Xk8nvDYaXetFHSJFlOqjDZIVhIPRYFdGkSoElDqNuegikcc3A76SNUa8dTqtAYA==}
     engines: {node: '>=20'}
 
-  '@shikijs/themes@4.1.0':
-    resolution: {integrity: sha512-emCcTnUM7yO2wltYbaxm+yLvcCI4+h8XBKc4KmJ7EZUXoSGjcCHifkI//R4OFit9ewpg7H2/9tjOuXrT2v/Knw==}
-    engines: {node: '>=20'}
-
   '@shikijs/themes@4.2.0':
     resolution: {integrity: sha512-RX8IHYeLv8Cu2W6ruc3RxUqWn0IYCqSrMBzi/uRGAmfyDNOnNO5BF/Px7o97n4XTpmFTo5GbRaazuOWj+2ak2w==}
     engines: {node: '>=20'}
 
+  '@shikijs/themes@4.3.0':
+    resolution: {integrity: sha512-Avgt05YiT+Y3prjIc9lmQxhJzHBcCfR6cjiFW4OyaMBbt2A6trX5rfjUzx+Vj/mE9qpArYjatnqo9XPjQNW/AQ==}
+    engines: {node: '>=20'}
+
   '@shikijs/transformers@4.2.0':
     resolution: {integrity: sha512-pKrYVNUr1oPjJvs76gkPPirDySx3GKG9O88P2Y3AQ+7AjSFws9Y+Ry/Q/6Yg6QpyigzjdQ6H5JAMNAvLXZ63dw==}
     engines: {node: '>=20'}
 
-  '@shikijs/types@4.1.0':
-    resolution: {integrity: sha512-3EQWX54fMpniOrDblzAhiwiJwpiTMW6+B9DWyUd9ska483tbayFYuw47UxwuPknI31bKnySfVQ/QW+jFL4rFdA==}
-    engines: {node: '>=20'}
-
   '@shikijs/types@4.2.0':
     resolution: {integrity: sha512-VT/MKtlpOhEPZloSH3Pb9WCZEBDoQVMa9jedp5UAwmJOar1DVc9DRODAxmYPW9M93IK4ryuqRejFfmlvlVDemw==}
     engines: {node: '>=20'}
 
+  '@shikijs/types@4.3.0':
+    resolution: {integrity: sha512-oc8b9U2SYvofKZk8e/737nIX0qwf6eV2vHFATeObAu7r+mUVpLs8Re0BmVkIjAWAYgkmG/CzLNo7rzuBzRu/wQ==}
+    engines: {node: '>=20'}
+
   '@shikijs/vscode-textmate@10.0.2':
     resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==}
 
@@ -4610,8 +4698,8 @@ packages:
     peerDependencies:
       '@testing-library/dom': '>=7.21.4'
 
-  '@tybys/wasm-util@0.10.2':
-    resolution: {integrity: sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==}
+  '@tybys/wasm-util@0.10.3':
+    resolution: {integrity: sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==}
 
   '@types/aria-query@5.0.4':
     resolution: {integrity: sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==}
@@ -4802,13 +4890,52 @@ packages:
       babel-plugin-react-compiler:
         optional: true
 
-  '@voidzero-dev/vite-plus-core@0.1.24':
-    resolution: {integrity: sha512-iXPGBABnQnrDMx89H6MOCGcTZp+QW+3rY4YMVKdE6ydchSvPk2O3MI2vgaRVfOtWJ2IjnxSnf1n2yjP67ZBRFQ==}
-    engines: {node: ^20.19.0 || >=22.12.0}
+  '@vitest/browser-preview@4.1.9':
+    resolution: {integrity: sha512-a4/OrkMDb/WUnE4OOB/4FJbK3rYVO7YykqtUgcTKG4p2a0R3XcjPVu7SLRHFBs2+NIYhv5yxp1Lz3dbdGBjIow==}
+    peerDependencies:
+      vitest: 4.1.9
+
+  '@vitest/browser@4.1.9':
+    resolution: {integrity: sha512-j1BKtWmPcqpMhmx/L9EPLgAJpCb0zKfwoWLmqBbxaogCXHjOwHFSEoHCBfnGtx93xKQwilZ26m+UOsHqHMkRNg==}
+    peerDependencies:
+      vitest: 4.1.9
+
+  '@vitest/expect@4.1.9':
+    resolution: {integrity: sha512-vl/rYsUKcBr3SnQn166+XR5ZQcgMx3DQhFWdfli/cWpLnLUmbxZvyrJZotLFUryib+LtArYMSTJ5RbQ57ZqrlA==}
+
+  '@vitest/mocker@4.1.9':
+    resolution: {integrity: sha512-EVkXzBjrPGM+cK8/ANWgBrkUCfJfb38/EfTSO8h7pWvKkyPkpWxvR7BkD2MyItMF62C97zAEoqdpUixwR/e+Rw==}
+    peerDependencies:
+      msw: ^2.4.9
+      vite: ^6.0.0 || ^7.0.0 || ^8.0.0
+    peerDependenciesMeta:
+      msw:
+        optional: true
+      vite:
+        optional: true
+
+  '@vitest/pretty-format@4.1.9':
+    resolution: {integrity: sha512-s0iufns3iIFitdgm+YR7g1whCAaGtXz459VS9/PqyKDEEFgYIhsHOQmXgIgDuYCt7DeQmiZT0Qe2OA2p4ZPu5A==}
+
+  '@vitest/runner@4.1.9':
+    resolution: {integrity: sha512-KXLMDtc7oe70+3mJfGrPUWPesswH+3sTxAMAMl8DG7I8IUQT4XW718dY5ID3vPUcmlu27CcKfY4P3h3I29SLJg==}
+
+  '@vitest/snapshot@4.1.9':
+    resolution: {integrity: sha512-Jc7RKGNBo8Z28WYIm0Niej4xdSPByRf6mU58VpHQkd6Zh05rlnA+twjbK5HyeIGHxrzsc3mJgS43uM0CZKzaIA==}
+
+  '@vitest/spy@4.1.9':
+    resolution: {integrity: sha512-fHpsS6mIi+PiEW+vcRVOMkX1oSaPKne3VOclSFICPcGOmfKgXPU5iAah+wcNcj2xPrCCmfq99IDGf+EojhhvhA==}
+
+  '@vitest/utils@4.1.9':
+    resolution: {integrity: sha512-A51o8ymO5PpqlWNnBP9ZHPXDIpuMtTLlGSjN7la4US+LJzoUMyhwjA5QXlm39JexgwHKW4Xjs8Z2d3dLCXOeuA==}
+
+  '@voidzero-dev/vite-plus-core@0.2.1':
+    resolution: {integrity: sha512-iWdtOlLezgYcDqIzxZx1yOUhY93vUB+ob+mRYBNr7/3Hf80uRyTQbqVD1WtsYaANbzeUi81SQ1ZoUraXHO+u8A==}
+    engines: {node: ^20.19.0 || ^22.18.0 || >=24.11.0}
     peerDependencies:
       '@arethetypeswrong/core': ^0.18.1
-      '@tsdown/css': 0.22.1
-      '@tsdown/exe': 0.22.1
+      '@tsdown/css': 0.22.3
+      '@tsdown/exe': 0.22.3
       '@types/node': 24.12.4
       '@vitejs/devtools': ^0.1.18
       esbuild: ^0.27.0 || ^0.28.0
@@ -4865,82 +4992,51 @@ packages:
       yaml:
         optional: true
 
-  '@voidzero-dev/vite-plus-darwin-arm64@0.1.24':
-    resolution: {integrity: sha512-Hpo9W9piSFlEsJzGkwzfDXhJGrnYByxHXF7NVQZ7g+SLOprddtlfTeM8t+gq9dxcuq0RzM8ddMAhDQP/K3fZQA==}
-    engines: {node: ^20.19.0 || >=22.12.0}
+  '@voidzero-dev/vite-plus-darwin-arm64@0.2.1':
+    resolution: {integrity: sha512-9AfN/5LKRks8gbTaHPiQHT0L4yboy2xB6x6vvCRWxQMWxPS6/ZJLf5kUIZeE7I1z33AEyLKKkDscsZZVMgMLgg==}
+    engines: {node: ^20.19.0 || ^22.18.0 || >=24.11.0}
     cpu: [arm64]
     os: [darwin]
 
-  '@voidzero-dev/vite-plus-darwin-x64@0.1.24':
-    resolution: {integrity: sha512-SwnnnZrEFBiU5iKlh/CZAVwn0RFt/Udrvt3kFLtdRxMtN5bKaqTFVA2H8Y/FPCWp1QX9bs4V9ZIAeXAk06zLkw==}
-    engines: {node: ^20.19.0 || >=22.12.0}
+  '@voidzero-dev/vite-plus-darwin-x64@0.2.1':
+    resolution: {integrity: sha512-Q1vyimRbf4M82qIQSWRyr7NJaH9ag5G7vVEfGVVJlQHNprI+Q8zj2Phcs/PGf6QcyjcL8UclLznQTHU9NgnKZw==}
+    engines: {node: ^20.19.0 || ^22.18.0 || >=24.11.0}
     cpu: [x64]
     os: [darwin]
 
-  '@voidzero-dev/vite-plus-linux-arm64-gnu@0.1.24':
-    resolution: {integrity: sha512-ImM3eqDki4DpRuHjW6dEh4St8zvbcfOMR7KQZJX42ArriCLQ/QdaYhDRRbcDi27XsOBqRxm2eqUUEymPrYIHpA==}
-    engines: {node: ^20.19.0 || >=22.12.0}
+  '@voidzero-dev/vite-plus-linux-arm64-gnu@0.2.1':
+    resolution: {integrity: sha512-WHW3DziqedRfhJ2upq6kC4y/pmdQWYt322DVB7+4Xb4oOa/CT9GtnSrWIiXVJ4PSO42v54+YsSTKPH2HC5RbtA==}
+    engines: {node: ^20.19.0 || ^22.18.0 || >=24.11.0}
     cpu: [arm64]
     os: [linux]
 
-  '@voidzero-dev/vite-plus-linux-arm64-musl@0.1.24':
-    resolution: {integrity: sha512-gj4mzbob/ls8Zs7iTuF9Gr0EFFF7tdpDiPxDPBkH8tJP5OkHABlzWUwJhU+9xxcUbTaXqpHDw68Mil7jm5dpMg==}
-    engines: {node: ^20.19.0 || >=22.12.0}
+  '@voidzero-dev/vite-plus-linux-arm64-musl@0.2.1':
+    resolution: {integrity: sha512-vUY7hYycZW0qEevpl7ImzZJFnOEKRYCaCOX4TBW0vk6MJZ+zj/xW7e0LOggzJcz2wbYAgLDqp5h+b8wV9dguDA==}
+    engines: {node: ^20.19.0 || ^22.18.0 || >=24.11.0}
     cpu: [arm64]
     os: [linux]
 
-  '@voidzero-dev/vite-plus-linux-x64-gnu@0.1.24':
-    resolution: {integrity: sha512-x7IYK7lI+WuF1n3jSzEYU6FgJxPX/R0rDmTTsOutooGGCU7uShZvfZqIoiTXK0eFnJU5ij5BfBgenenUfsaT/A==}
-    engines: {node: ^20.19.0 || >=22.12.0}
+  '@voidzero-dev/vite-plus-linux-x64-gnu@0.2.1':
+    resolution: {integrity: sha512-tFxpToEaykBGxMQHp8M/qmr1yruRRED+c9gA1h9kmplqot04OxuqzRCWu/IiIvMJ0v3JFdOP3gqkyjXLLJhxIA==}
+    engines: {node: ^20.19.0 || ^22.18.0 || >=24.11.0}
     cpu: [x64]
     os: [linux]
 
-  '@voidzero-dev/vite-plus-linux-x64-musl@0.1.24':
-    resolution: {integrity: sha512-JCy2w0eSVUlWQlggK5T47MnL+j0o4EY7hLskINVI8gi+aixQF4xnYBDobz0lbxkqz3/IfiLyXUx6TcU3thcsGQ==}
-    engines: {node: ^20.19.0 || >=22.12.0}
+  '@voidzero-dev/vite-plus-linux-x64-musl@0.2.1':
+    resolution: {integrity: sha512-2scSS7wEbLO2758fqr1/bAULg7nLCFa5V8LO2b5w3g1CrTYdMTDt2WX1ghPesIi+70pYGydRbXo6iaaN43zfMg==}
+    engines: {node: ^20.19.0 || ^22.18.0 || >=24.11.0}
     cpu: [x64]
     os: [linux]
 
-  '@voidzero-dev/vite-plus-test@0.1.24':
-    resolution: {integrity: sha512-9NiG6UadG0iOaPL1AMsO5sDKkx6MADHw4/mMOmHWZUhhUwqzfVtnnptMK37vD71e6KyR7yAscx19FrtOWWtjvA==}
-    engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0}
-    peerDependencies:
-      '@edge-runtime/vm': '*'
-      '@opentelemetry/api': ^1.9.0
-      '@types/node': 24.12.4
-      '@vitest/coverage-istanbul': 4.1.8
-      '@vitest/coverage-v8': 4.1.8
-      '@vitest/ui': 4.1.8
-      happy-dom: '*'
-      jsdom: '*'
-      vite: ^6.0.0 || ^7.0.0 || ^8.0.0
-    peerDependenciesMeta:
-      '@edge-runtime/vm':
-        optional: true
-      '@opentelemetry/api':
-        optional: true
-      '@types/node':
-        optional: true
-      '@vitest/coverage-istanbul':
-        optional: true
-      '@vitest/coverage-v8':
-        optional: true
-      '@vitest/ui':
-        optional: true
-      happy-dom:
-        optional: true
-      jsdom:
-        optional: true
-
-  '@voidzero-dev/vite-plus-win32-arm64-msvc@0.1.24':
-    resolution: {integrity: sha512-G+/lhLKVjyn3FmgXX8jeWgq7RcE5O1kdR7QyFayQOdlMX/ZRkvUwQD7bFaqhKzgJM6Oj3a1FH3HQPYk5QOYuCQ==}
-    engines: {node: ^20.19.0 || >=22.12.0}
+  '@voidzero-dev/vite-plus-win32-arm64-msvc@0.2.1':
+    resolution: {integrity: sha512-3+5FJYhi9SqBszjngI2LBmvoiqEwxJWyQ5UsOUtNz6/d+yDrDw+tOgHLl4OKIh5aVNZeIGXzxvP6h24kcEqIyg==}
+    engines: {node: ^20.19.0 || ^22.18.0 || >=24.11.0}
     cpu: [arm64]
     os: [win32]
 
-  '@voidzero-dev/vite-plus-win32-x64-msvc@0.1.24':
-    resolution: {integrity: sha512-b0e5XohEV1w/RdzAtv8/Hm6tvHPXouPtBNsljjW/lDJZq3NCLND5s6lqe8H4IenrgmKSoqakHWtlqJqM36cFbw==}
-    engines: {node: ^20.19.0 || >=22.12.0}
+  '@voidzero-dev/vite-plus-win32-x64-msvc@0.2.1':
+    resolution: {integrity: sha512-5sOEwEoU5PW7ObmJ5VCakU09Oh14rYCoLQJkFqvOph6PK30lN5iqWGk0KigEyfcd7Zv+fZg9EmcERDol/3Xl9w==}
+    engines: {node: ^20.19.0 || ^22.18.0 || >=24.11.0}
     cpu: [x64]
     os: [win32]
 
@@ -5152,6 +5248,10 @@ packages:
   alien-signals@2.0.6:
     resolution: {integrity: sha512-P3TxJSe31bUHBiblg59oU1PpaWPtmxF9GhJ/cB7OkgJ0qN/ifFSKUI25/v8ZhsT+lIG6ac8DpTOplXxORX6F3Q==}
 
+  am-i-vibing@0.4.0:
+    resolution: {integrity: sha512-MxT4XZL7pzLHpuvhDKdMaQHMGGkJDLluKBLsbstn+8wv9sWcFT6h+0ve9qkml95amVTZtZV83gQe2hY+ojgHLg==}
+    hasBin: true
+
   anser@1.4.10:
     resolution: {integrity: sha512-hCv9AqTQ8ycjpSd3upOJd7vFwW1JaoYQ7tpham03GJ1ca8/65rqn0RpaWpItOAd6ylW9wAw6luXYPJIyPFVOww==}
 
@@ -5247,10 +5347,15 @@ packages:
     resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==}
     engines: {node: '>=8'}
 
-  astro@6.4.2:
-    resolution: {integrity: sha512-8H89CH2dKL5SCU99OCqdU9BGjmPkSJqaPurywj5XMo7eMFGUFD3vsNhdEKnEh4mK4LgGje3/QDTTSIIGst0G0Q==}
+  astro@7.0.3:
+    resolution: {integrity: sha512-CK+G+Tl2DMV1EXCwVG45vyurxf2IfRTklMxDhRKn+tst9Yl8rWXpudL62Fa6zin5Bt968FBvuyASj1aJShROZg==}
     engines: {node: '>=22.12.0', npm: '>=9.6.5', pnpm: '>=7.1.0'}
     hasBin: true
+    peerDependencies:
+      '@astrojs/markdown-remark': 7.2.0
+    peerDependenciesMeta:
+      '@astrojs/markdown-remark':
+        optional: true
 
   async-exit-hook@2.0.1:
     resolution: {integrity: sha512-NW2cX8m1Q7KPA7a5M2ULQeZ2wR5qI5PAbw5L0UOMxdioVk9PMZ0h1TmyZEkPYrCvYjDlFICusOu1dlEKAAeXBw==}
@@ -5369,8 +5474,8 @@ packages:
     peerDependencies:
       react: '>=17.0.1'
 
-  body-parser@2.2.2:
-    resolution: {integrity: sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==}
+  body-parser@2.3.0:
+    resolution: {integrity: sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==}
     engines: {node: '>=18'}
 
   boolbase@1.0.0:
@@ -5478,6 +5583,10 @@ packages:
   ccount@2.0.1:
     resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==}
 
+  chai@6.2.2:
+    resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==}
+    engines: {node: '>=18'}
+
   chalk@2.4.2:
     resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==}
     engines: {node: '>=4'}
@@ -6167,9 +6276,6 @@ packages:
     resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==}
     engines: {node: '>= 0.4'}
 
-  es-module-lexer@1.7.0:
-    resolution: {integrity: sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==}
-
   es-module-lexer@2.1.0:
     resolution: {integrity: sha512-n27zTYMjYu1aj4MjCWzSP7G9r75utsaoc8m61weK+W8JMBGGQybd43GstCXZ3WNmSFtGT9wi59qQTW6mhTR5LQ==}
 
@@ -6192,8 +6298,8 @@ packages:
     engines: {node: '>=18'}
     hasBin: true
 
-  esbuild@0.27.7:
-    resolution: {integrity: sha512-IxpibTjyVnmrIQo5aqNpCgoACA/dTKLTlhMHihVHhdkxKyPO1uBBthumT0rdHmcsk9uMonIWS0m4FljWzILh3w==}
+  esbuild@0.28.1:
+    resolution: {integrity: sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==}
     engines: {node: '>=18'}
     hasBin: true
 
@@ -6226,6 +6332,9 @@ packages:
   estree-walker@2.0.2:
     resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
 
+  estree-walker@3.0.3:
+    resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}
+
   etag@1.8.1:
     resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==}
     engines: {node: '>= 0.6'}
@@ -6245,6 +6354,10 @@ packages:
     resolution: {integrity: sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==}
     engines: {node: '>=18.0.0'}
 
+  expect-type@1.4.0:
+    resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==}
+    engines: {node: '>=12.0.0'}
+
   expo-application@56.0.3:
     resolution: {integrity: sha512-DdGGPlMuM6cSTeKhbvh6OeLr2O/+EI5BHKYrD+Do8sJPYgLwzGrgESELfyjJCpEhFzT+TgKIdmLmWXhNUQnHiw==}
     peerDependencies:
@@ -6880,8 +6993,8 @@ packages:
   hoist-non-react-statics@3.3.2:
     resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==}
 
-  hono@4.12.25:
-    resolution: {integrity: sha512-2NFaIyNVgJmBs/ecmtGzlmluTFs5cHEWGTdu0t1HBwYzoGXOL5nUQBRMXsXWla5i4KkG//QMzVP88m1+I3fdAQ==}
+  hono@4.12.27:
+    resolution: {integrity: sha512-1yrb/+w6HWQJrUCLkJ2IF5jNIPvvFkblV5RNOYl6bV+OA6p9GLcMpHFFGTosSvHvcAUibuUukRqhlYI4z32C7Q==}
     engines: {node: '>=16.9.0'}
 
   hosted-git-info@4.1.0:
@@ -8067,8 +8180,9 @@ packages:
   obuf@1.1.2:
     resolution: {integrity: sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==}
 
-  obug@2.1.1:
-    resolution: {integrity: sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==}
+  obug@2.1.3:
+    resolution: {integrity: sha512-9miFgM2OFba7hB+pRgvtV84pYTBaoTHohvmIgiRt6dRIzbwEOIaNaP+dIlGs2fNFoB0SeISs0Jz5WFVRid6Xyg==}
+    engines: {node: '>=12.20.0'}
 
   ofetch@1.5.1:
     resolution: {integrity: sha512-2W4oUZlVaqAPAil6FUg/difl6YhqhUR7x2eZY4bQCko22UXg3hptq9KLQdqFClV+Wu85UX7hNtdGTngi/1BxcA==}
@@ -8128,8 +8242,8 @@ packages:
   outvariant@1.4.3:
     resolution: {integrity: sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==}
 
-  oxfmt@0.52.0:
-    resolution: {integrity: sha512-nJlYM35F64zTDMecCNhoHNkf+D/eHv7xcjj9XDSj+bFAVtN93m7v8DQMdHd6nDG6Akf/kEYYHmDUBs2Dz27Sug==}
+  oxfmt@0.55.0:
+    resolution: {integrity: sha512-jSj2wCTakwgPMxkfiVZX0jf+nX+Nz6xlyAZjqNE0qXTFdCBPYlP6JAN+ODjmealw7DXBjOzYbdsqwBMAZnPZ6A==}
     engines: {node: ^20.19.0 || >=22.12.0}
     hasBin: true
     peerDependencies:
@@ -8145,8 +8259,8 @@ packages:
     resolution: {integrity: sha512-3mBv3CoPbh8dFbzfDGIWa2ytZjn2v+3EX4aKRXjIhsoGFzG8GCjfRirz3rwZf1wYbZzsNLTSgpw8VjQuWdp/jA==}
     hasBin: true
 
-  oxlint@1.67.0:
-    resolution: {integrity: sha512-blwwaHPdoH8piQ5/z0KHeoHFR7FZgl12WluKJfu4qFLPkZl6mK04PkLE45Fw1NxfBRSlh40Gu7MkxHUw++ociQ==}
+  oxlint@1.70.0:
+    resolution: {integrity: sha512-D6JgHtzkhRwvEC+A0Nw5AEc5bk8x5i1pHzvZIEf/a0C4hOzmAACNGtkDGPyFaxxX3ZVGxCPeig3P3rMM8XU3/g==}
     engines: {node: ^20.19.0 || >=22.12.0}
     hasBin: true
     peerDependencies:
@@ -8326,10 +8440,6 @@ packages:
     resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==}
     engines: {node: '>=12'}
 
-  pixelmatch@7.2.0:
-    resolution: {integrity: sha512-xhcb4yHu9sM/G7foGzoLtXYcC0zHEaOXXjRKhGup0fw78Nf2Tkiapv4EQyMzrbcmQPsllAI7DbFY2UT7PlI9Pg==}
-    hasBin: true
-
   pkce-challenge@5.0.1:
     resolution: {integrity: sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==}
     engines: {node: '>=16.20.0'}
@@ -8440,6 +8550,10 @@ packages:
     resolution: {integrity: sha512-iG+GYldRf2BQ0UDUAd6JQ/RwzaQy6mXmsk/IzlYyal4A4SNFw54MeH4/tLkF4I5WoWG9SQwuqWzS99jaFQHBuQ==}
     engines: {node: ^20.17.0 || >=22.9.0}
 
+  process-ancestry@0.1.0:
+    resolution: {integrity: sha512-tGqJW/UnclpYASFcM6Xh8D8l/BMtaQ9+CSG0vlJSJTcdMM4lDRv4c6H0Pdcsfted+bVczdYSfk2fdukg2gQkZg==}
+    engines: {node: '>=18.0.0'}
+
   process-nextick-args@2.0.1:
     resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==}
 
@@ -8481,8 +8595,8 @@ packages:
   pure-rand@8.4.0:
     resolution: {integrity: sha512-IoM8YF/jY0hiugFo/wOWqfmarlE6J0wc6fDK1PhftMk7MGhVZl88sZimmqBBFomLOCSmcCCpsfj7wXASCpvK9A==}
 
-  qs@6.15.2:
-    resolution: {integrity: sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==}
+  qs@6.15.3:
+    resolution: {integrity: sha512-O9gl3zCl5h5blw1KGUzQKhA5oUXSl8rwUIM5o0S3nCXMliSvy5Dzx7/DJcI+SwgICv+IneSZwhBh1oSyEHA71A==}
     engines: {node: '>=0.6'}
 
   query-string@7.1.3:
@@ -8916,8 +9030,8 @@ packages:
     engines: {node: ^20.19.0 || >=22.12.0}
     hasBin: true
 
-  rolldown@1.0.3:
-    resolution: {integrity: sha512-i00lAJ2ks1BYr7rjNjKC7BcqAS7nVfiT3QX1SI5aY+AFHblCmaUf9OE9dbdzDvW6dJxbi2ZCZiy9v3CcwOiX3g==}
+  rolldown@1.1.3:
+    resolution: {integrity: sha512-1F1eEtUBtFvcGm1HQ9TiUIUHPQG7mSAODrhIzjxoUEFuo8OcbrGLiVLkevNgj84TE4lnHvnumwFjhJO5Eu135g==}
     engines: {node: ^20.19.0 || >=22.12.0}
     hasBin: true
 
@@ -8945,6 +9059,9 @@ packages:
   sanitize-filename@1.6.4:
     resolution: {integrity: sha512-9ZyI08PsvdQl2r/bBIGubpVdR3RR9sY6RDiWFPreA21C/EFlQhmgo20UZlNjZMMZNubusLhAQozkA0Od5J21Eg==}
 
+  satteri@0.9.3:
+    resolution: {integrity: sha512-2XfBh89LCnBMFkNOeVKkBLelAZcIA17VLHsgJum1tJ2fXiPZDN/TDXv4ku46rFOQXYd41LJ0kiZh5gPqExcCsg==}
+
   sax@1.6.0:
     resolution: {integrity: sha512-6R3J5M4AcbtLUdZmRv2SygeVaM7IhrLXu9BmnOGmmACak8fiUtOsYNWUS4uK7upbmHIBbLBeFeI//477BKLBzA==}
     engines: {node: '>=11.0.0'}
@@ -8968,8 +9085,8 @@ packages:
     engines: {node: '>=10'}
     hasBin: true
 
-  semver@7.8.1:
-    resolution: {integrity: sha512-rkVq3IXh+4FDGch+KwzX3aV9W3kO54GyEgpvBzSyctDA6Xtd7RJQV1xmXbeQp5v7+VzLOfVqiutSE6GICgPFvg==}
+  semver@7.8.5:
+    resolution: {integrity: sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==}
     engines: {node: '>=10'}
     hasBin: true
 
@@ -9039,10 +9156,6 @@ packages:
     resolution: {integrity: sha512-VsC6n6vz1ihYYyZZwX7YZSF5l5x36ca17OC+a69h94YqB7X6XLwf+5MOgynYir2SLFUbl8gIYvBo8K8RoNQ6bQ==}
     engines: {node: '>= 0.4'}
 
-  shiki@4.1.0:
-    resolution: {integrity: sha512-l/ABZPUR5v70jI10EzqfMS/I96vjSGv2y0ihUV+WYFzv0EfvW4s54m0Lg8wCrrL+2IkwBzFTuxkZjPf8b2NX9Q==}
-    engines: {node: '>=20'}
-
   shiki@4.2.0:
     resolution: {integrity: sha512-hjNax6o/ylDy9lefQEaSDtzaT3iVNtZ3WmpQnbuQNoG4xvnSKf2kSKbihZVO4JRG1TTMejs7CmNRYlWgAL66pQ==}
     engines: {node: '>=20'}
@@ -9063,6 +9176,9 @@ packages:
     resolution: {integrity: sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==}
     engines: {node: '>= 0.4'}
 
+  siginfo@2.0.0:
+    resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}
+
   signal-exit@3.0.7:
     resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
 
@@ -9103,8 +9219,8 @@ packages:
     resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==}
     engines: {node: '>= 6.0.0', npm: '>= 3.0.0'}
 
-  smol-toml@1.6.1:
-    resolution: {integrity: sha512-dWUG8F5sIIARXih1DTaQAX4SsiTXhInKf1buxdY9DIg4ZYPZK5nGM1VRIYmEbDbsHt7USo99xSLFu5Q1IqTmsg==}
+  smol-toml@1.7.0:
+    resolution: {integrity: sha512-aqVvWoyO21L23mb+drl4RmMXbf6N7FdHjAhTRA9ZBL7apWBgfWC16KjrASI+1p9GAroljyMHj6fK67i0UiTNvQ==}
     engines: {node: '>= 18'}
 
   source-map-js@1.2.1:
@@ -9144,6 +9260,9 @@ packages:
     resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==}
     engines: {node: '>=10'}
 
+  stackback@0.0.2:
+    resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
+
   stackframe@1.3.4:
     resolution: {integrity: sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==}
 
@@ -9325,8 +9444,8 @@ packages:
   tinybench@2.9.0:
     resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==}
 
-  tinyclip@0.1.13:
-    resolution: {integrity: sha512-8OqlXQ35euK9+e7L68u8UwcODxkHoIkjbGsgXuARKNyQ5G6xt8nw1YPeMbxMLgCPFkToU+UEK5j05t2t8edKpQ==}
+  tinyclip@0.1.15:
+    resolution: {integrity: sha512-uo33abH+Ays0xYaDysoBt494Hb3hsEczMpcC0MwFl773pazORx4fmvKhclhR1wonUbB6vvpRsvVMwnhfqeMc+A==}
     engines: {node: ^16.14.0 || >= 17.3.0}
 
   tinyexec@1.2.4:
@@ -9341,6 +9460,10 @@ packages:
     resolution: {integrity: sha512-Pugqs6M0m7Lv1I7FtxN4aoyToKg1C4tu+/381vH35y8oENM/Ai7f7C4StcoK4/+BSw9ebcS8jRiVrORFKCALLw==}
     engines: {node: ^20.0.0 || >=22.0.0}
 
+  tinyrainbow@3.1.0:
+    resolution: {integrity: sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==}
+    engines: {node: '>=14.0.0'}
+
   tldts-core@7.4.2:
     resolution: {integrity: sha512-nwEyF4vl4RSJjwSjBUmOSxc3BFPoIFdlRthJ6e+5v9P3bHNsoD06UjuqMUspqp7vsEZ1beaHi1km+optiE17yA==}
 
@@ -9701,10 +9824,18 @@ packages:
   vfile@6.0.3:
     resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==}
 
-  vite-plus@0.1.24:
-    resolution: {integrity: sha512-b3fr6WtCiEhetjuzW/4KcEMOAMuZxoxZATWaXKmPzOLf1upG+pzKJOFZTb94D6wiPBlwcjxoaUtF7C3uAN+VjQ==}
-    engines: {node: ^20.19.0 || >=22.12.0}
+  vite-plus@0.2.1:
+    resolution: {integrity: sha512-q5q/Y38UkWFsNg1JO+RyRdPUqoewaSqIlMyK2p83GKNUvf4D38Ntb3PToRTDZbTRh7mWt+B+d0DQBv4nCDpMcQ==}
+    engines: {node: ^20.19.0 || ^22.18.0 || >=24.11.0}
     hasBin: true
+    peerDependencies:
+      '@vitest/browser-playwright': 4.1.9
+      '@vitest/browser-webdriverio': 4.1.9
+    peerDependenciesMeta:
+      '@vitest/browser-playwright':
+        optional: true
+      '@vitest/browser-webdriverio':
+        optional: true
 
   vitefu@1.1.3:
     resolution: {integrity: sha512-ub4okH7Z5KLjb6hDyjqrGXqWtWvoYdU3IGm/NorpgHncKoLTCfRIbvlhBm7r0YstIaQRYlp4yEbFqDcKSzXSSg==}
@@ -9714,6 +9845,47 @@ packages:
       vite:
         optional: true
 
+  vitest@4.1.9:
+    resolution: {integrity: sha512-nE3/LEyc0z87uHYLZebqCUOaJr2hdtuPp7BQ4BosVFnfltxgAvMG08NyrSGlPpOUWvR27c5flSmYFTNr78L9GQ==}
+    engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0}
+    hasBin: true
+    peerDependencies:
+      '@edge-runtime/vm': '*'
+      '@opentelemetry/api': ^1.9.0
+      '@types/node': 24.12.4
+      '@vitest/browser-playwright': 4.1.9
+      '@vitest/browser-preview': 4.1.9
+      '@vitest/browser-webdriverio': 4.1.9
+      '@vitest/coverage-istanbul': 4.1.9
+      '@vitest/coverage-v8': 4.1.9
+      '@vitest/ui': 4.1.9
+      happy-dom: '*'
+      jsdom: '*'
+      vite: ^6.0.0 || ^7.0.0 || ^8.0.0
+    peerDependenciesMeta:
+      '@edge-runtime/vm':
+        optional: true
+      '@opentelemetry/api':
+        optional: true
+      '@types/node':
+        optional: true
+      '@vitest/browser-playwright':
+        optional: true
+      '@vitest/browser-preview':
+        optional: true
+      '@vitest/browser-webdriverio':
+        optional: true
+      '@vitest/coverage-istanbul':
+        optional: true
+      '@vitest/coverage-v8':
+        optional: true
+      '@vitest/ui':
+        optional: true
+      happy-dom:
+        optional: true
+      jsdom:
+        optional: true
+
   vlq@1.0.1:
     resolution: {integrity: sha512-gQpnTgkubC6hQgdIcRdYGDSDc+SaujOdyesZQMv6JlfQee/9Mp0Qhnys6WxDWvQnL5WZdT7o2Ul187aSt0Rq+w==}
 
@@ -9857,6 +10029,11 @@ packages:
     engines: {node: ^20.17.0 || >=22.9.0}
     hasBin: true
 
+  why-is-node-running@2.3.0:
+    resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==}
+    engines: {node: '>=8'}
+    hasBin: true
+
   widest-line@6.0.0:
     resolution: {integrity: sha512-U89AsyEeAsyoF0zVJBkG9zBgekjgjK7yk9sje3F4IQpXBJ10TF6ByLlIfjMhcmHMJgHZI4KHt4rdNfktzxIAMA==}
     engines: {node: '>=20'}
@@ -10107,9 +10284,61 @@ snapshots:
       - prettier
       - prettier-plugin-astro
 
-  '@astrojs/compiler@2.13.1': {}
+  '@astrojs/compiler-binding-darwin-arm64@0.2.3':
+    optional: true
 
-  '@astrojs/compiler@4.0.0': {}
+  '@astrojs/compiler-binding-darwin-x64@0.2.3':
+    optional: true
+
+  '@astrojs/compiler-binding-linux-arm64-gnu@0.2.3':
+    optional: true
+
+  '@astrojs/compiler-binding-linux-arm64-musl@0.2.3':
+    optional: true
+
+  '@astrojs/compiler-binding-linux-x64-gnu@0.2.3':
+    optional: true
+
+  '@astrojs/compiler-binding-linux-x64-musl@0.2.3':
+    optional: true
+
+  '@astrojs/compiler-binding-wasm32-wasi@0.2.3(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)':
+    dependencies:
+      '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)
+    transitivePeerDependencies:
+      - '@emnapi/core'
+      - '@emnapi/runtime'
+    optional: true
+
+  '@astrojs/compiler-binding-win32-arm64-msvc@0.2.3':
+    optional: true
+
+  '@astrojs/compiler-binding-win32-x64-msvc@0.2.3':
+    optional: true
+
+  '@astrojs/compiler-binding@0.2.3(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)':
+    optionalDependencies:
+      '@astrojs/compiler-binding-darwin-arm64': 0.2.3
+      '@astrojs/compiler-binding-darwin-x64': 0.2.3
+      '@astrojs/compiler-binding-linux-arm64-gnu': 0.2.3
+      '@astrojs/compiler-binding-linux-arm64-musl': 0.2.3
+      '@astrojs/compiler-binding-linux-x64-gnu': 0.2.3
+      '@astrojs/compiler-binding-linux-x64-musl': 0.2.3
+      '@astrojs/compiler-binding-wasm32-wasi': 0.2.3(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)
+      '@astrojs/compiler-binding-win32-arm64-msvc': 0.2.3
+      '@astrojs/compiler-binding-win32-x64-msvc': 0.2.3
+    transitivePeerDependencies:
+      - '@emnapi/core'
+      - '@emnapi/runtime'
+
+  '@astrojs/compiler-rs@0.2.3(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)':
+    dependencies:
+      '@astrojs/compiler-binding': 0.2.3(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)
+    transitivePeerDependencies:
+      - '@emnapi/core'
+      - '@emnapi/runtime'
+
+  '@astrojs/compiler@2.13.1': {}
 
   '@astrojs/internal-helpers@0.10.0':
     dependencies:
@@ -10119,7 +10348,7 @@ snapshots:
       picomatch: 4.0.4
       retext-smartypants: 6.2.0
       shiki: 4.2.0
-      smol-toml: 1.6.1
+      smol-toml: 1.7.0
       unified: 11.0.5
 
   '@astrojs/language-server@2.16.10(prettier@3.8.3)(typescript@6.0.3)':
@@ -10168,6 +10397,14 @@ snapshots:
       vfile: 6.0.3
     transitivePeerDependencies:
       - supports-color
+    optional: true
+
+  '@astrojs/markdown-satteri@0.3.2':
+    dependencies:
+      '@astrojs/internal-helpers': 0.10.0
+      '@astrojs/prism': 4.0.2
+      github-slugger: 2.0.0
+      satteri: 0.9.3
 
   '@astrojs/prism@4.0.2':
     dependencies:
@@ -10917,6 +11154,39 @@ snapshots:
     optionalDependencies:
       '@types/react': 19.2.16
 
+  '@blazediff/core@1.9.1': {}
+
+  '@bruits/satteri-darwin-arm64@0.9.3':
+    optional: true
+
+  '@bruits/satteri-darwin-x64@0.9.3':
+    optional: true
+
+  '@bruits/satteri-linux-arm64-gnu@0.9.3':
+    optional: true
+
+  '@bruits/satteri-linux-arm64-musl@0.9.3':
+    optional: true
+
+  '@bruits/satteri-linux-x64-gnu@0.9.3':
+    optional: true
+
+  '@bruits/satteri-linux-x64-musl@0.9.3':
+    optional: true
+
+  '@bruits/satteri-wasm32-wasi@0.9.3':
+    dependencies:
+      '@emnapi/core': 1.11.1
+      '@emnapi/runtime': 1.11.1
+      '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)
+    optional: true
+
+  '@bruits/satteri-win32-arm64-msvc@0.9.3':
+    optional: true
+
+  '@bruits/satteri-win32-x64-msvc@0.9.3':
+    optional: true
+
   '@bufbuild/protobuf@1.10.0': {}
 
   '@callstack/liquid-glass@0.7.1(react-native@0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6))(react@19.2.3)':
@@ -10924,7 +11194,7 @@ snapshots:
       react: 19.2.3
       react-native: 0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6)
 
-  '@capsizecss/unpack@4.0.0':
+  '@capsizecss/unpack@4.0.1':
     dependencies:
       fontkitten: 1.0.3
 
@@ -10933,7 +11203,7 @@ snapshots:
       picocolors: 1.1.1
       sisteransi: 1.0.5
 
-  '@clack/core@1.4.0':
+  '@clack/core@1.4.2':
     dependencies:
       fast-wrap-ansi: 0.2.2
       sisteransi: 1.0.5
@@ -10944,9 +11214,9 @@ snapshots:
       picocolors: 1.1.1
       sisteransi: 1.0.5
 
-  '@clack/prompts@1.5.0':
+  '@clack/prompts@1.6.0':
     dependencies:
-      '@clack/core': 1.4.0
+      '@clack/core': 1.4.2
       fast-string-width: 3.0.2
       fast-wrap-ansi: 0.2.2
       sisteransi: 1.0.5
@@ -11193,13 +11463,13 @@ snapshots:
       '@effect/platform-bun': 4.0.0-beta.78(bufferutil@4.1.0)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))(utf-8-validate@6.0.6)
       '@effect/platform-node': 4.0.0-beta.78(bufferutil@4.1.0)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))(ioredis@5.11.0)(utf-8-validate@6.0.6)
 
-  '@distilled.cloud/cloudflare-vite-plugin@0.10.5(1a78211785aa6331880fcdb516c7c682)':
+  '@distilled.cloud/cloudflare-vite-plugin@0.10.5(b718c520067d628926c627c09697d025)':
     dependencies:
       '@distilled.cloud/cloudflare': 0.23.1(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))
       '@distilled.cloud/cloudflare-rolldown-plugin': 0.10.5(rolldown@1.0.1)(workerd@1.20260526.1)
       '@distilled.cloud/cloudflare-runtime': 0.10.5(@distilled.cloud/cloudflare@0.23.1(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5)))(@effect/platform-bun@4.0.0-beta.78(bufferutil@4.1.0)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))(utf-8-validate@6.0.6))(@effect/platform-node@4.0.0-beta.78(bufferutil@4.1.0)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))(ioredis@5.11.0)(utf-8-validate@6.0.6))(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))
       effect: 4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5)
-      vite: '@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+      vite: '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
     optionalDependencies:
       '@effect/platform-bun': 4.0.0-beta.78(bufferutil@4.1.0)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))(utf-8-validate@6.0.6)
       '@effect/platform-node': 4.0.0-beta.78(bufferutil@4.1.0)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))(ioredis@5.11.0)(utf-8-validate@6.0.6)
@@ -11481,172 +11751,188 @@ snapshots:
       tslib: 2.8.1
     optional: true
 
+  '@emnapi/core@1.11.1':
+    dependencies:
+      '@emnapi/wasi-threads': 1.2.2
+      tslib: 2.8.1
+    optional: true
+
   '@emnapi/runtime@1.10.0':
     dependencies:
       tslib: 2.8.1
     optional: true
 
+  '@emnapi/runtime@1.11.1':
+    dependencies:
+      tslib: 2.8.1
+    optional: true
+
   '@emnapi/wasi-threads@1.2.1':
     dependencies:
       tslib: 2.8.1
     optional: true
 
+  '@emnapi/wasi-threads@1.2.2':
+    dependencies:
+      tslib: 2.8.1
+    optional: true
+
   '@epic-web/invariant@1.0.0': {}
 
   '@esbuild/aix-ppc64@0.25.12':
     optional: true
 
-  '@esbuild/aix-ppc64@0.27.7':
+  '@esbuild/aix-ppc64@0.28.1':
     optional: true
 
   '@esbuild/android-arm64@0.25.12':
     optional: true
 
-  '@esbuild/android-arm64@0.27.7':
+  '@esbuild/android-arm64@0.28.1':
     optional: true
 
   '@esbuild/android-arm@0.25.12':
     optional: true
 
-  '@esbuild/android-arm@0.27.7':
+  '@esbuild/android-arm@0.28.1':
     optional: true
 
   '@esbuild/android-x64@0.25.12':
     optional: true
 
-  '@esbuild/android-x64@0.27.7':
+  '@esbuild/android-x64@0.28.1':
     optional: true
 
   '@esbuild/darwin-arm64@0.25.12':
     optional: true
 
-  '@esbuild/darwin-arm64@0.27.7':
+  '@esbuild/darwin-arm64@0.28.1':
     optional: true
 
   '@esbuild/darwin-x64@0.25.12':
     optional: true
 
-  '@esbuild/darwin-x64@0.27.7':
+  '@esbuild/darwin-x64@0.28.1':
     optional: true
 
   '@esbuild/freebsd-arm64@0.25.12':
     optional: true
 
-  '@esbuild/freebsd-arm64@0.27.7':
+  '@esbuild/freebsd-arm64@0.28.1':
     optional: true
 
   '@esbuild/freebsd-x64@0.25.12':
     optional: true
 
-  '@esbuild/freebsd-x64@0.27.7':
+  '@esbuild/freebsd-x64@0.28.1':
     optional: true
 
   '@esbuild/linux-arm64@0.25.12':
     optional: true
 
-  '@esbuild/linux-arm64@0.27.7':
+  '@esbuild/linux-arm64@0.28.1':
     optional: true
 
   '@esbuild/linux-arm@0.25.12':
     optional: true
 
-  '@esbuild/linux-arm@0.27.7':
+  '@esbuild/linux-arm@0.28.1':
     optional: true
 
   '@esbuild/linux-ia32@0.25.12':
     optional: true
 
-  '@esbuild/linux-ia32@0.27.7':
+  '@esbuild/linux-ia32@0.28.1':
     optional: true
 
   '@esbuild/linux-loong64@0.25.12':
     optional: true
 
-  '@esbuild/linux-loong64@0.27.7':
+  '@esbuild/linux-loong64@0.28.1':
     optional: true
 
   '@esbuild/linux-mips64el@0.25.12':
     optional: true
 
-  '@esbuild/linux-mips64el@0.27.7':
+  '@esbuild/linux-mips64el@0.28.1':
     optional: true
 
   '@esbuild/linux-ppc64@0.25.12':
     optional: true
 
-  '@esbuild/linux-ppc64@0.27.7':
+  '@esbuild/linux-ppc64@0.28.1':
     optional: true
 
   '@esbuild/linux-riscv64@0.25.12':
     optional: true
 
-  '@esbuild/linux-riscv64@0.27.7':
+  '@esbuild/linux-riscv64@0.28.1':
     optional: true
 
   '@esbuild/linux-s390x@0.25.12':
     optional: true
 
-  '@esbuild/linux-s390x@0.27.7':
+  '@esbuild/linux-s390x@0.28.1':
     optional: true
 
   '@esbuild/linux-x64@0.25.12':
     optional: true
 
-  '@esbuild/linux-x64@0.27.7':
+  '@esbuild/linux-x64@0.28.1':
     optional: true
 
   '@esbuild/netbsd-arm64@0.25.12':
     optional: true
 
-  '@esbuild/netbsd-arm64@0.27.7':
+  '@esbuild/netbsd-arm64@0.28.1':
     optional: true
 
   '@esbuild/netbsd-x64@0.25.12':
     optional: true
 
-  '@esbuild/netbsd-x64@0.27.7':
+  '@esbuild/netbsd-x64@0.28.1':
     optional: true
 
   '@esbuild/openbsd-arm64@0.25.12':
     optional: true
 
-  '@esbuild/openbsd-arm64@0.27.7':
+  '@esbuild/openbsd-arm64@0.28.1':
     optional: true
 
   '@esbuild/openbsd-x64@0.25.12':
     optional: true
 
-  '@esbuild/openbsd-x64@0.27.7':
+  '@esbuild/openbsd-x64@0.28.1':
     optional: true
 
   '@esbuild/openharmony-arm64@0.25.12':
     optional: true
 
-  '@esbuild/openharmony-arm64@0.27.7':
+  '@esbuild/openharmony-arm64@0.28.1':
     optional: true
 
   '@esbuild/sunos-x64@0.25.12':
     optional: true
 
-  '@esbuild/sunos-x64@0.27.7':
+  '@esbuild/sunos-x64@0.28.1':
     optional: true
 
   '@esbuild/win32-arm64@0.25.12':
     optional: true
 
-  '@esbuild/win32-arm64@0.27.7':
+  '@esbuild/win32-arm64@0.28.1':
     optional: true
 
   '@esbuild/win32-ia32@0.25.12':
     optional: true
 
-  '@esbuild/win32-ia32@0.27.7':
+  '@esbuild/win32-ia32@0.28.1':
     optional: true
 
   '@esbuild/win32-x64@0.25.12':
     optional: true
 
-  '@esbuild/win32-x64@0.27.7':
+  '@esbuild/win32-x64@0.28.1':
     optional: true
 
   '@expo-google-fonts/dm-sans@0.4.2': {}
@@ -11703,7 +11989,7 @@ snapshots:
       progress: 2.0.3
       prompts: 2.4.2
       resolve-from: 5.0.0
-      semver: 7.8.1
+      semver: 7.8.5
       send: 0.19.2
       slugify: 1.6.9
       stacktrace-parser: 0.1.11
@@ -11744,7 +12030,7 @@ snapshots:
       debug: 4.4.3
       getenv: 2.0.0
       glob: 13.0.6
-      semver: 7.8.1
+      semver: 7.8.5
       slugify: 1.6.9
       xcode: 3.0.1
       xml2js: 0.6.0
@@ -11764,7 +12050,7 @@ snapshots:
       getenv: 2.0.0
       glob: 13.0.6
       resolve-workspace-root: 2.0.1
-      semver: 7.8.1
+      semver: 7.8.5
       slugify: 1.6.9
     transitivePeerDependencies:
       - supports-color
@@ -11812,7 +12098,7 @@ snapshots:
       ignore: 5.3.2
       minimatch: 10.2.5
       resolve-from: 5.0.0
-      semver: 7.8.1
+      semver: 7.8.5
     transitivePeerDependencies:
       - supports-color
 
@@ -11824,7 +12110,7 @@ snapshots:
       getenv: 2.0.0
       jimp-compact: 0.16.1
       parse-png: 2.1.0
-      semver: 7.8.1
+      semver: 7.8.5
     transitivePeerDependencies:
       - supports-color
       - typescript
@@ -11967,7 +12253,7 @@ snapshots:
       debug: 4.4.3
       expo-modules-autolinking: 56.0.14(typescript@6.0.3)
       resolve-from: 5.0.0
-      semver: 7.8.1
+      semver: 7.8.5
     transitivePeerDependencies:
       - supports-color
       - typescript
@@ -12101,9 +12387,9 @@ snapshots:
 
   '@formkit/auto-animate@0.9.0': {}
 
-  '@hono/node-server@1.19.14(hono@4.12.25)':
+  '@hono/node-server@1.19.14(hono@4.12.27)':
     dependencies:
-      hono: 4.12.25
+      hono: 4.12.27
 
   '@iarna/toml@2.2.5': {}
 
@@ -12192,7 +12478,7 @@ snapshots:
 
   '@img/sharp-wasm32@0.34.5':
     dependencies:
-      '@emnapi/runtime': 1.10.0
+      '@emnapi/runtime': 1.11.1
     optional: true
 
   '@img/sharp-win32-arm64@0.34.5':
@@ -12528,7 +12814,7 @@ snapshots:
 
   '@modelcontextprotocol/sdk@1.29.0(zod@4.4.3)':
     dependencies:
-      '@hono/node-server': 1.19.14(hono@4.12.25)
+      '@hono/node-server': 1.19.14(hono@4.12.27)
       ajv: 8.20.0
       ajv-formats: 3.0.1(ajv@8.20.0)
       content-type: 1.0.5
@@ -12538,7 +12824,7 @@ snapshots:
       eventsource-parser: 3.1.0
       express: 5.2.1
       express-rate-limit: 8.5.2(express@5.2.1)
-      hono: 4.12.25
+      hono: 4.12.27
       jose: 6.2.3
       json-schema-typed: 8.0.2
       pkce-challenge: 5.0.1
@@ -12575,18 +12861,18 @@ snapshots:
       outvariant: 1.4.3
       strict-event-emitter: 0.5.1
 
-  '@napi-rs/wasm-runtime@1.1.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)':
+  '@napi-rs/wasm-runtime@1.1.6(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)':
     dependencies:
       '@emnapi/core': 1.10.0
       '@emnapi/runtime': 1.10.0
-      '@tybys/wasm-util': 0.10.2
+      '@tybys/wasm-util': 0.10.3
     optional: true
 
-  '@napi-rs/wasm-runtime@1.1.5(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)':
+  '@napi-rs/wasm-runtime@1.1.6(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)':
     dependencies:
-      '@emnapi/core': 1.10.0
-      '@emnapi/runtime': 1.10.0
-      '@tybys/wasm-util': 0.10.2
+      '@emnapi/core': 1.11.1
+      '@emnapi/runtime': 1.11.1
+      '@tybys/wasm-util': 0.10.3
     optional: true
 
   '@neon-rs/load@0.0.4': {}
@@ -12689,70 +12975,72 @@ snapshots:
 
   '@oslojs/encoding@1.1.0': {}
 
-  '@oxc-project/runtime@0.133.0': {}
+  '@oxc-project/runtime@0.136.0': {}
 
   '@oxc-project/types@0.127.0':
     optional: true
 
   '@oxc-project/types@0.130.0': {}
 
-  '@oxc-project/types@0.133.0': {}
+  '@oxc-project/types@0.136.0': {}
 
-  '@oxfmt/binding-android-arm-eabi@0.52.0':
+  '@oxc-project/types@0.137.0': {}
+
+  '@oxfmt/binding-android-arm-eabi@0.55.0':
     optional: true
 
-  '@oxfmt/binding-android-arm64@0.52.0':
+  '@oxfmt/binding-android-arm64@0.55.0':
     optional: true
 
-  '@oxfmt/binding-darwin-arm64@0.52.0':
+  '@oxfmt/binding-darwin-arm64@0.55.0':
     optional: true
 
-  '@oxfmt/binding-darwin-x64@0.52.0':
+  '@oxfmt/binding-darwin-x64@0.55.0':
     optional: true
 
-  '@oxfmt/binding-freebsd-x64@0.52.0':
+  '@oxfmt/binding-freebsd-x64@0.55.0':
     optional: true
 
-  '@oxfmt/binding-linux-arm-gnueabihf@0.52.0':
+  '@oxfmt/binding-linux-arm-gnueabihf@0.55.0':
     optional: true
 
-  '@oxfmt/binding-linux-arm-musleabihf@0.52.0':
+  '@oxfmt/binding-linux-arm-musleabihf@0.55.0':
     optional: true
 
-  '@oxfmt/binding-linux-arm64-gnu@0.52.0':
+  '@oxfmt/binding-linux-arm64-gnu@0.55.0':
     optional: true
 
-  '@oxfmt/binding-linux-arm64-musl@0.52.0':
+  '@oxfmt/binding-linux-arm64-musl@0.55.0':
     optional: true
 
-  '@oxfmt/binding-linux-ppc64-gnu@0.52.0':
+  '@oxfmt/binding-linux-ppc64-gnu@0.55.0':
     optional: true
 
-  '@oxfmt/binding-linux-riscv64-gnu@0.52.0':
+  '@oxfmt/binding-linux-riscv64-gnu@0.55.0':
     optional: true
 
-  '@oxfmt/binding-linux-riscv64-musl@0.52.0':
+  '@oxfmt/binding-linux-riscv64-musl@0.55.0':
     optional: true
 
-  '@oxfmt/binding-linux-s390x-gnu@0.52.0':
+  '@oxfmt/binding-linux-s390x-gnu@0.55.0':
     optional: true
 
-  '@oxfmt/binding-linux-x64-gnu@0.52.0':
+  '@oxfmt/binding-linux-x64-gnu@0.55.0':
     optional: true
 
-  '@oxfmt/binding-linux-x64-musl@0.52.0':
+  '@oxfmt/binding-linux-x64-musl@0.55.0':
     optional: true
 
-  '@oxfmt/binding-openharmony-arm64@0.52.0':
+  '@oxfmt/binding-openharmony-arm64@0.55.0':
     optional: true
 
-  '@oxfmt/binding-win32-arm64-msvc@0.52.0':
+  '@oxfmt/binding-win32-arm64-msvc@0.55.0':
     optional: true
 
-  '@oxfmt/binding-win32-ia32-msvc@0.52.0':
+  '@oxfmt/binding-win32-ia32-msvc@0.55.0':
     optional: true
 
-  '@oxfmt/binding-win32-x64-msvc@0.52.0':
+  '@oxfmt/binding-win32-x64-msvc@0.55.0':
     optional: true
 
   '@oxlint-tsgolint/darwin-arm64@0.23.0':
@@ -12773,65 +13061,63 @@ snapshots:
   '@oxlint-tsgolint/win32-x64@0.23.0':
     optional: true
 
-  '@oxlint/binding-android-arm-eabi@1.67.0':
+  '@oxlint/binding-android-arm-eabi@1.70.0':
     optional: true
 
-  '@oxlint/binding-android-arm64@1.67.0':
+  '@oxlint/binding-android-arm64@1.70.0':
     optional: true
 
-  '@oxlint/binding-darwin-arm64@1.67.0':
+  '@oxlint/binding-darwin-arm64@1.70.0':
     optional: true
 
-  '@oxlint/binding-darwin-x64@1.67.0':
+  '@oxlint/binding-darwin-x64@1.70.0':
     optional: true
 
-  '@oxlint/binding-freebsd-x64@1.67.0':
+  '@oxlint/binding-freebsd-x64@1.70.0':
     optional: true
 
-  '@oxlint/binding-linux-arm-gnueabihf@1.67.0':
+  '@oxlint/binding-linux-arm-gnueabihf@1.70.0':
     optional: true
 
-  '@oxlint/binding-linux-arm-musleabihf@1.67.0':
+  '@oxlint/binding-linux-arm-musleabihf@1.70.0':
     optional: true
 
-  '@oxlint/binding-linux-arm64-gnu@1.67.0':
+  '@oxlint/binding-linux-arm64-gnu@1.70.0':
     optional: true
 
-  '@oxlint/binding-linux-arm64-musl@1.67.0':
+  '@oxlint/binding-linux-arm64-musl@1.70.0':
     optional: true
 
-  '@oxlint/binding-linux-ppc64-gnu@1.67.0':
+  '@oxlint/binding-linux-ppc64-gnu@1.70.0':
     optional: true
 
-  '@oxlint/binding-linux-riscv64-gnu@1.67.0':
+  '@oxlint/binding-linux-riscv64-gnu@1.70.0':
     optional: true
 
-  '@oxlint/binding-linux-riscv64-musl@1.67.0':
+  '@oxlint/binding-linux-riscv64-musl@1.70.0':
     optional: true
 
-  '@oxlint/binding-linux-s390x-gnu@1.67.0':
+  '@oxlint/binding-linux-s390x-gnu@1.70.0':
     optional: true
 
-  '@oxlint/binding-linux-x64-gnu@1.67.0':
+  '@oxlint/binding-linux-x64-gnu@1.70.0':
     optional: true
 
-  '@oxlint/binding-linux-x64-musl@1.67.0':
+  '@oxlint/binding-linux-x64-musl@1.70.0':
     optional: true
 
-  '@oxlint/binding-openharmony-arm64@1.67.0':
+  '@oxlint/binding-openharmony-arm64@1.70.0':
     optional: true
 
-  '@oxlint/binding-win32-arm64-msvc@1.67.0':
+  '@oxlint/binding-win32-arm64-msvc@1.70.0':
     optional: true
 
-  '@oxlint/binding-win32-ia32-msvc@1.67.0':
+  '@oxlint/binding-win32-ia32-msvc@1.70.0':
     optional: true
 
-  '@oxlint/binding-win32-x64-msvc@1.67.0':
+  '@oxlint/binding-win32-x64-msvc@1.70.0':
     optional: true
 
-  '@oxlint/plugins@1.61.0': {}
-
   '@oxlint/plugins@1.68.0': {}
 
   '@pierre/diffs@1.3.0-beta.5(patch_hash=7cb6da88544119adda056b2f46f43956f99326227732da0b345081e285a6c53a)(@shikijs/themes@4.2.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)':
@@ -12848,10 +13134,10 @@ snapshots:
     transitivePeerDependencies:
       - '@shikijs/themes'
 
-  '@pierre/diffs@1.3.0-beta.5(patch_hash=7cb6da88544119adda056b2f46f43956f99326227732da0b345081e285a6c53a)(@shikijs/themes@4.2.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)':
+  '@pierre/diffs@1.3.0-beta.5(patch_hash=7cb6da88544119adda056b2f46f43956f99326227732da0b345081e285a6c53a)(@shikijs/themes@4.3.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)':
     dependencies:
       '@pierre/theme': 1.0.3
-      '@pierre/theming': 0.0.1(@pierre/theme@1.0.3)(@shikijs/themes@4.2.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(shiki@4.2.0)
+      '@pierre/theming': 0.0.1(@pierre/theme@1.0.3)(@shikijs/themes@4.3.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(shiki@4.2.0)
       '@shikijs/transformers': 4.2.0
       diff: 8.0.3
       hast-util-to-html: 9.0.5
@@ -12872,10 +13158,10 @@ snapshots:
       react-dom: 19.2.3(react@19.2.3)
       shiki: 4.2.0
 
-  '@pierre/theming@0.0.1(@pierre/theme@1.0.3)(@shikijs/themes@4.2.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(shiki@4.2.0)':
+  '@pierre/theming@0.0.1(@pierre/theme@1.0.3)(@shikijs/themes@4.3.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(shiki@4.2.0)':
     optionalDependencies:
       '@pierre/theme': 1.0.3
-      '@shikijs/themes': 4.2.0
+      '@shikijs/themes': 4.3.0
       react: 19.2.6
       react-dom: 19.2.6(react@19.2.6)
       shiki: 4.2.0
@@ -13186,7 +13472,7 @@ snapshots:
       metro: 0.84.4(bufferutil@4.1.0)(utf-8-validate@6.0.6)
       metro-config: 0.84.4(bufferutil@4.1.0)(utf-8-validate@6.0.6)
       metro-core: 0.84.4
-      semver: 7.8.1
+      semver: 7.8.5
     optionalDependencies:
       '@react-native/metro-config': 0.85.3(@babel/core@7.29.7)
     transitivePeerDependencies:
@@ -13263,7 +13549,7 @@ snapshots:
   '@rolldown/binding-android-arm64@1.0.1':
     optional: true
 
-  '@rolldown/binding-android-arm64@1.0.3':
+  '@rolldown/binding-android-arm64@1.1.3':
     optional: true
 
   '@rolldown/binding-darwin-arm64@1.0.0-rc.17':
@@ -13272,7 +13558,7 @@ snapshots:
   '@rolldown/binding-darwin-arm64@1.0.1':
     optional: true
 
-  '@rolldown/binding-darwin-arm64@1.0.3':
+  '@rolldown/binding-darwin-arm64@1.1.3':
     optional: true
 
   '@rolldown/binding-darwin-x64@1.0.0-rc.17':
@@ -13281,7 +13567,7 @@ snapshots:
   '@rolldown/binding-darwin-x64@1.0.1':
     optional: true
 
-  '@rolldown/binding-darwin-x64@1.0.3':
+  '@rolldown/binding-darwin-x64@1.1.3':
     optional: true
 
   '@rolldown/binding-freebsd-x64@1.0.0-rc.17':
@@ -13290,7 +13576,7 @@ snapshots:
   '@rolldown/binding-freebsd-x64@1.0.1':
     optional: true
 
-  '@rolldown/binding-freebsd-x64@1.0.3':
+  '@rolldown/binding-freebsd-x64@1.1.3':
     optional: true
 
   '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.17':
@@ -13299,7 +13585,7 @@ snapshots:
   '@rolldown/binding-linux-arm-gnueabihf@1.0.1':
     optional: true
 
-  '@rolldown/binding-linux-arm-gnueabihf@1.0.3':
+  '@rolldown/binding-linux-arm-gnueabihf@1.1.3':
     optional: true
 
   '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.17':
@@ -13308,7 +13594,7 @@ snapshots:
   '@rolldown/binding-linux-arm64-gnu@1.0.1':
     optional: true
 
-  '@rolldown/binding-linux-arm64-gnu@1.0.3':
+  '@rolldown/binding-linux-arm64-gnu@1.1.3':
     optional: true
 
   '@rolldown/binding-linux-arm64-musl@1.0.0-rc.17':
@@ -13317,7 +13603,7 @@ snapshots:
   '@rolldown/binding-linux-arm64-musl@1.0.1':
     optional: true
 
-  '@rolldown/binding-linux-arm64-musl@1.0.3':
+  '@rolldown/binding-linux-arm64-musl@1.1.3':
     optional: true
 
   '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.17':
@@ -13326,7 +13612,7 @@ snapshots:
   '@rolldown/binding-linux-ppc64-gnu@1.0.1':
     optional: true
 
-  '@rolldown/binding-linux-ppc64-gnu@1.0.3':
+  '@rolldown/binding-linux-ppc64-gnu@1.1.3':
     optional: true
 
   '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.17':
@@ -13335,7 +13621,7 @@ snapshots:
   '@rolldown/binding-linux-s390x-gnu@1.0.1':
     optional: true
 
-  '@rolldown/binding-linux-s390x-gnu@1.0.3':
+  '@rolldown/binding-linux-s390x-gnu@1.1.3':
     optional: true
 
   '@rolldown/binding-linux-x64-gnu@1.0.0-rc.17':
@@ -13344,7 +13630,7 @@ snapshots:
   '@rolldown/binding-linux-x64-gnu@1.0.1':
     optional: true
 
-  '@rolldown/binding-linux-x64-gnu@1.0.3':
+  '@rolldown/binding-linux-x64-gnu@1.1.3':
     optional: true
 
   '@rolldown/binding-linux-x64-musl@1.0.0-rc.17':
@@ -13353,7 +13639,7 @@ snapshots:
   '@rolldown/binding-linux-x64-musl@1.0.1':
     optional: true
 
-  '@rolldown/binding-linux-x64-musl@1.0.3':
+  '@rolldown/binding-linux-x64-musl@1.1.3':
     optional: true
 
   '@rolldown/binding-openharmony-arm64@1.0.0-rc.17':
@@ -13362,28 +13648,28 @@ snapshots:
   '@rolldown/binding-openharmony-arm64@1.0.1':
     optional: true
 
-  '@rolldown/binding-openharmony-arm64@1.0.3':
+  '@rolldown/binding-openharmony-arm64@1.1.3':
     optional: true
 
   '@rolldown/binding-wasm32-wasi@1.0.0-rc.17':
     dependencies:
       '@emnapi/core': 1.10.0
       '@emnapi/runtime': 1.10.0
-      '@napi-rs/wasm-runtime': 1.1.5(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)
+      '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)
     optional: true
 
   '@rolldown/binding-wasm32-wasi@1.0.1':
     dependencies:
       '@emnapi/core': 1.10.0
       '@emnapi/runtime': 1.10.0
-      '@napi-rs/wasm-runtime': 1.1.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)
+      '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)
     optional: true
 
-  '@rolldown/binding-wasm32-wasi@1.0.3':
+  '@rolldown/binding-wasm32-wasi@1.1.3':
     dependencies:
-      '@emnapi/core': 1.10.0
-      '@emnapi/runtime': 1.10.0
-      '@napi-rs/wasm-runtime': 1.1.5(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)
+      '@emnapi/core': 1.11.1
+      '@emnapi/runtime': 1.11.1
+      '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)
     optional: true
 
   '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.17':
@@ -13392,7 +13678,7 @@ snapshots:
   '@rolldown/binding-win32-arm64-msvc@1.0.1':
     optional: true
 
-  '@rolldown/binding-win32-arm64-msvc@1.0.3':
+  '@rolldown/binding-win32-arm64-msvc@1.1.3':
     optional: true
 
   '@rolldown/binding-win32-x64-msvc@1.0.0-rc.17':
@@ -13401,18 +13687,18 @@ snapshots:
   '@rolldown/binding-win32-x64-msvc@1.0.1':
     optional: true
 
-  '@rolldown/binding-win32-x64-msvc@1.0.3':
+  '@rolldown/binding-win32-x64-msvc@1.1.3':
     optional: true
 
-  '@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7)(@babel/plugin-transform-runtime@7.29.7(@babel/core@7.29.7))(@babel/runtime@7.29.7)(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(rolldown@1.0.3)':
+  '@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7)(@babel/plugin-transform-runtime@7.29.7(@babel/core@7.29.7))(@babel/runtime@7.29.7)(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(rolldown@1.1.3)':
     dependencies:
       '@babel/core': 7.29.7
       picomatch: 4.0.4
-      rolldown: 1.0.3
+      rolldown: 1.1.3
     optionalDependencies:
       '@babel/plugin-transform-runtime': 7.29.7(@babel/core@7.29.7)
       '@babel/runtime': 7.29.7
-      vite: '@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+      vite: '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
 
   '@rolldown/pluginutils@1.0.0-rc.17':
     optional: true
@@ -13502,14 +13788,6 @@ snapshots:
   '@rollup/rollup-win32-x64-msvc@4.61.0':
     optional: true
 
-  '@shikijs/core@4.1.0':
-    dependencies:
-      '@shikijs/primitive': 4.1.0
-      '@shikijs/types': 4.1.0
-      '@shikijs/vscode-textmate': 10.0.2
-      '@types/hast': 3.0.4
-      hast-util-to-html: 9.0.5
-
   '@shikijs/core@4.2.0':
     dependencies:
       '@shikijs/primitive': 4.2.0
@@ -13518,67 +13796,47 @@ snapshots:
       '@types/hast': 3.0.4
       hast-util-to-html: 9.0.5
 
-  '@shikijs/engine-javascript@4.1.0':
-    dependencies:
-      '@shikijs/types': 4.1.0
-      '@shikijs/vscode-textmate': 10.0.2
-      oniguruma-to-es: 4.3.6
-
   '@shikijs/engine-javascript@4.2.0':
     dependencies:
       '@shikijs/types': 4.2.0
       '@shikijs/vscode-textmate': 10.0.2
       oniguruma-to-es: 4.3.6
 
-  '@shikijs/engine-oniguruma@4.1.0':
-    dependencies:
-      '@shikijs/types': 4.1.0
-      '@shikijs/vscode-textmate': 10.0.2
-
   '@shikijs/engine-oniguruma@4.2.0':
     dependencies:
       '@shikijs/types': 4.2.0
       '@shikijs/vscode-textmate': 10.0.2
 
-  '@shikijs/langs@4.1.0':
-    dependencies:
-      '@shikijs/types': 4.1.0
-
   '@shikijs/langs@4.2.0':
     dependencies:
       '@shikijs/types': 4.2.0
 
-  '@shikijs/primitive@4.1.0':
-    dependencies:
-      '@shikijs/types': 4.1.0
-      '@shikijs/vscode-textmate': 10.0.2
-      '@types/hast': 3.0.4
-
   '@shikijs/primitive@4.2.0':
     dependencies:
       '@shikijs/types': 4.2.0
       '@shikijs/vscode-textmate': 10.0.2
       '@types/hast': 3.0.4
 
-  '@shikijs/themes@4.1.0':
-    dependencies:
-      '@shikijs/types': 4.1.0
-
   '@shikijs/themes@4.2.0':
     dependencies:
       '@shikijs/types': 4.2.0
 
+  '@shikijs/themes@4.3.0':
+    dependencies:
+      '@shikijs/types': 4.3.0
+    optional: true
+
   '@shikijs/transformers@4.2.0':
     dependencies:
       '@shikijs/core': 4.2.0
       '@shikijs/types': 4.2.0
 
-  '@shikijs/types@4.1.0':
+  '@shikijs/types@4.2.0':
     dependencies:
       '@shikijs/vscode-textmate': 10.0.2
       '@types/hast': 3.0.4
 
-  '@shikijs/types@4.2.0':
+  '@shikijs/types@4.3.0':
     dependencies:
       '@shikijs/vscode-textmate': 10.0.2
       '@types/hast': 3.0.4
@@ -13808,12 +14066,12 @@ snapshots:
       '@tailwindcss/oxide-win32-arm64-msvc': 4.3.0
       '@tailwindcss/oxide-win32-x64-msvc': 4.3.0
 
-  '@tailwindcss/vite@4.3.0(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))':
+  '@tailwindcss/vite@4.3.0(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))':
     dependencies:
       '@tailwindcss/node': 4.3.0
       '@tailwindcss/oxide': 4.3.0
       tailwindcss: 4.3.0
-      vite: '@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+      vite: '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
 
   '@tanstack/devtools-event-client@0.4.3': {}
 
@@ -13876,7 +14134,7 @@ snapshots:
     transitivePeerDependencies:
       - supports-color
 
-  '@tanstack/router-plugin@1.168.13(@tanstack/react-router@1.170.10(react-dom@19.2.6(react@19.2.6))(react@19.2.6))(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))':
+  '@tanstack/router-plugin@1.168.13(@tanstack/react-router@1.170.10(react-dom@19.2.6(react@19.2.6))(react@19.2.6))(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))':
     dependencies:
       '@babel/core': 7.29.7
       '@babel/plugin-syntax-jsx': 7.29.7(@babel/core@7.29.7)
@@ -13893,7 +14151,7 @@ snapshots:
       zod: 4.4.3
     optionalDependencies:
       '@tanstack/react-router': 1.170.10(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
-      vite: '@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+      vite: '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
     transitivePeerDependencies:
       - supports-color
 
@@ -13941,7 +14199,7 @@ snapshots:
     dependencies:
       '@testing-library/dom': 10.4.1
 
-  '@tybys/wasm-util@0.10.2':
+  '@tybys/wasm-util@0.10.3':
     dependencies:
       tslib: 2.8.1
     optional: true
@@ -14133,23 +14391,94 @@ snapshots:
     optionalDependencies:
       ajv: 6.15.0
 
-  '@vitejs/plugin-react@6.0.2(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7)(@babel/plugin-transform-runtime@7.29.7(@babel/core@7.29.7))(@babel/runtime@7.29.7)(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(rolldown@1.0.3))(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(babel-plugin-react-compiler@1.0.0)':
+  '@vitejs/plugin-react@6.0.2(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7)(@babel/plugin-transform-runtime@7.29.7(@babel/core@7.29.7))(@babel/runtime@7.29.7)(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(rolldown@1.1.3))(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(babel-plugin-react-compiler@1.0.0)':
     dependencies:
       '@rolldown/pluginutils': 1.0.1
-      vite: '@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+      vite: '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
     optionalDependencies:
-      '@rolldown/plugin-babel': 0.2.3(@babel/core@7.29.7)(@babel/plugin-transform-runtime@7.29.7(@babel/core@7.29.7))(@babel/runtime@7.29.7)(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(rolldown@1.0.3)
+      '@rolldown/plugin-babel': 0.2.3(@babel/core@7.29.7)(@babel/plugin-transform-runtime@7.29.7(@babel/core@7.29.7))(@babel/runtime@7.29.7)(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(rolldown@1.1.3)
       babel-plugin-react-compiler: 1.0.0
 
-  '@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)':
+  '@vitest/browser-preview@4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(bufferutil@4.1.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(utf-8-validate@6.0.6)(vitest@4.1.9(@types/node@24.12.4)(@vitest/browser-preview@4.1.9)(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3)))':
     dependencies:
-      '@oxc-project/runtime': 0.133.0
-      '@oxc-project/types': 0.133.0
+      '@testing-library/dom': 10.4.1
+      '@testing-library/user-event': 14.6.1(@testing-library/dom@10.4.1)
+      '@vitest/browser': 4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(bufferutil@4.1.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(utf-8-validate@6.0.6)(vitest@4.1.9(@types/node@24.12.4)(@vitest/browser-preview@4.1.9)(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3)))
+      vitest: 4.1.9(@types/node@24.12.4)(@vitest/browser-preview@4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(bufferutil@4.1.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(utf-8-validate@6.0.6)(vitest@4.1.9))(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))
+    transitivePeerDependencies:
+      - bufferutil
+      - msw
+      - utf-8-validate
+      - vite
+
+  '@vitest/browser@4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(bufferutil@4.1.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(utf-8-validate@6.0.6)(vitest@4.1.9(@types/node@24.12.4)(@vitest/browser-preview@4.1.9)(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3)))':
+    dependencies:
+      '@blazediff/core': 1.9.1
+      '@vitest/mocker': 4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))
+      '@vitest/utils': 4.1.9
+      magic-string: 0.30.21
+      pngjs: 7.0.0
+      sirv: 3.0.2
+      tinyrainbow: 3.1.0
+      vitest: 4.1.9(@types/node@24.12.4)(@vitest/browser-preview@4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(bufferutil@4.1.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(utf-8-validate@6.0.6)(vitest@4.1.9))(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))
+      ws: 8.21.0(bufferutil@4.1.0)(utf-8-validate@6.0.6)
+    transitivePeerDependencies:
+      - bufferutil
+      - msw
+      - utf-8-validate
+      - vite
+
+  '@vitest/expect@4.1.9':
+    dependencies:
+      '@standard-schema/spec': 1.1.0
+      '@types/chai': 5.2.3
+      '@vitest/spy': 4.1.9
+      '@vitest/utils': 4.1.9
+      chai: 6.2.2
+      tinyrainbow: 3.1.0
+
+  '@vitest/mocker@4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))':
+    dependencies:
+      '@vitest/spy': 4.1.9
+      estree-walker: 3.0.3
+      magic-string: 0.30.21
+    optionalDependencies:
+      msw: 2.12.11(@types/node@24.12.4)(typescript@6.0.3)
+      vite: '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+
+  '@vitest/pretty-format@4.1.9':
+    dependencies:
+      tinyrainbow: 3.1.0
+
+  '@vitest/runner@4.1.9':
+    dependencies:
+      '@vitest/utils': 4.1.9
+      pathe: 2.0.3
+
+  '@vitest/snapshot@4.1.9':
+    dependencies:
+      '@vitest/pretty-format': 4.1.9
+      '@vitest/utils': 4.1.9
+      magic-string: 0.30.21
+      pathe: 2.0.3
+
+  '@vitest/spy@4.1.9': {}
+
+  '@vitest/utils@4.1.9':
+    dependencies:
+      '@vitest/pretty-format': 4.1.9
+      convert-source-map: 2.0.0
+      tinyrainbow: 3.1.0
+
+  '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)':
+    dependencies:
+      '@oxc-project/runtime': 0.136.0
+      '@oxc-project/types': 0.136.0
       lightningcss: 1.32.0
       postcss: 8.5.15
     optionalDependencies:
       '@types/node': 24.12.4
-      esbuild: 0.27.7
+      esbuild: 0.28.1
       fsevents: 2.3.3
       jiti: 2.7.0
       terser: 5.48.0
@@ -14157,68 +14486,28 @@ snapshots:
       unrun: 0.2.39
       yaml: 2.9.0
 
-  '@voidzero-dev/vite-plus-darwin-arm64@0.1.24':
+  '@voidzero-dev/vite-plus-darwin-arm64@0.2.1':
     optional: true
 
-  '@voidzero-dev/vite-plus-darwin-x64@0.1.24':
+  '@voidzero-dev/vite-plus-darwin-x64@0.2.1':
     optional: true
 
-  '@voidzero-dev/vite-plus-linux-arm64-gnu@0.1.24':
+  '@voidzero-dev/vite-plus-linux-arm64-gnu@0.2.1':
     optional: true
 
-  '@voidzero-dev/vite-plus-linux-arm64-musl@0.1.24':
+  '@voidzero-dev/vite-plus-linux-arm64-musl@0.2.1':
     optional: true
 
-  '@voidzero-dev/vite-plus-linux-x64-gnu@0.1.24':
+  '@voidzero-dev/vite-plus-linux-x64-gnu@0.2.1':
     optional: true
 
-  '@voidzero-dev/vite-plus-linux-x64-musl@0.1.24':
+  '@voidzero-dev/vite-plus-linux-x64-musl@0.2.1':
     optional: true
 
-  '@voidzero-dev/vite-plus-test@0.1.24(@types/node@24.12.4)(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)':
-    dependencies:
-      '@standard-schema/spec': 1.1.0
-      '@types/chai': 5.2.3
-      '@voidzero-dev/vite-plus-core': 0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)
-      es-module-lexer: 1.7.0
-      obug: 2.1.1
-      pixelmatch: 7.2.0
-      pngjs: 7.0.0
-      sirv: 3.0.2
-      std-env: 4.1.0
-      tinybench: 2.9.0
-      tinyexec: 1.2.4
-      tinyglobby: 0.2.17
-      vite: '@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
-      ws: 8.21.0(bufferutil@4.1.0)(utf-8-validate@6.0.6)
-    optionalDependencies:
-      '@types/node': 24.12.4
-    transitivePeerDependencies:
-      - '@arethetypeswrong/core'
-      - '@tsdown/css'
-      - '@tsdown/exe'
-      - '@vitejs/devtools'
-      - bufferutil
-      - esbuild
-      - jiti
-      - less
-      - publint
-      - sass
-      - sass-embedded
-      - stylus
-      - sugarss
-      - terser
-      - tsx
-      - typescript
-      - unplugin-unused
-      - unrun
-      - utf-8-validate
-      - yaml
-
-  '@voidzero-dev/vite-plus-win32-arm64-msvc@0.1.24':
+  '@voidzero-dev/vite-plus-win32-arm64-msvc@0.2.1':
     optional: true
 
-  '@voidzero-dev/vite-plus-win32-x64-msvc@0.1.24':
+  '@voidzero-dev/vite-plus-win32-x64-msvc@0.2.1':
     optional: true
 
   '@volar/kit@2.4.28(typescript@6.0.3)':
@@ -14377,7 +14666,7 @@ snapshots:
       json-schema-traverse: 1.0.0
       require-from-string: 2.0.2
 
-  alchemy@https://pkg.ing/alchemy/078ff00(c6ed9425e2527ee8a94fe8655db2a250):
+  alchemy@https://pkg.ing/alchemy/078ff00(9ca451f9fa94c3cde9e1ba8985172661):
     dependencies:
       '@alchemy.run/node-utils': 0.0.4
       '@aws-sdk/credential-providers': 3.1062.0
@@ -14387,7 +14676,7 @@ snapshots:
       '@distilled.cloud/cloudflare': 0.23.1(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))
       '@distilled.cloud/cloudflare-rolldown-plugin': 0.10.5(rolldown@1.0.1)(workerd@1.20260526.1)
       '@distilled.cloud/cloudflare-runtime': 0.10.5(@distilled.cloud/cloudflare@0.23.1(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5)))(@effect/platform-bun@4.0.0-beta.78(bufferutil@4.1.0)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))(utf-8-validate@6.0.6))(@effect/platform-node@4.0.0-beta.78(bufferutil@4.1.0)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))(ioredis@5.11.0)(utf-8-validate@6.0.6))(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))
-      '@distilled.cloud/cloudflare-vite-plugin': 0.10.5(1a78211785aa6331880fcdb516c7c682)
+      '@distilled.cloud/cloudflare-vite-plugin': 0.10.5(b718c520067d628926c627c09697d025)
       '@distilled.cloud/core': 0.23.1(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))
       '@distilled.cloud/neon': 0.23.1(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))
       '@distilled.cloud/planetscale': 0.23.1(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))
@@ -14421,7 +14710,7 @@ snapshots:
       '@effect/sql-pg': 4.0.0-beta.78(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))
       drizzle-kit: 1.0.0-rc.3
       drizzle-orm: 1.0.0-rc.3(@cloudflare/workers-types@4.20260604.1)(@effect/sql-pg@4.0.0-beta.78(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5)))(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(bun-types@1.3.14)(effect@4.0.0-beta.78(patch_hash=c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5))(mysql2@3.22.4(@types/node@24.12.4))(pg@8.21.0)(zod@4.4.3)
-      vite: '@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+      vite: '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
       ws: 8.21.0(bufferutil@4.1.0)(utf-8-validate@6.0.6)
     transitivePeerDependencies:
       - '@types/node'
@@ -14434,6 +14723,10 @@ snapshots:
 
   alien-signals@2.0.6: {}
 
+  am-i-vibing@0.4.0:
+    dependencies:
+      process-ancestry: 0.1.0
+
   anser@1.4.10: {}
 
   ansi-escapes@4.3.2:
@@ -14530,7 +14823,8 @@ snapshots:
 
   aria-query@5.3.2: {}
 
-  array-iterate@2.0.1: {}
+  array-iterate@2.0.1:
+    optional: true
 
   asap@2.0.6: {}
 
@@ -14542,16 +14836,17 @@ snapshots:
   astral-regex@2.0.0:
     optional: true
 
-  astro@6.4.2(@types/node@24.12.4)(aws4fetch@1.0.20)(idb-keyval@6.2.1)(ioredis@5.11.0)(jiti@2.7.0)(rollup@4.61.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0):
+  astro@7.0.3(@astrojs/markdown-remark@7.2.0)(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)(@types/node@24.12.4)(aws4fetch@1.0.20)(idb-keyval@6.2.1)(ioredis@5.11.0)(jiti@2.7.0)(rollup@4.61.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0):
     dependencies:
-      '@astrojs/compiler': 4.0.0
+      '@astrojs/compiler-rs': 0.2.3(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)
       '@astrojs/internal-helpers': 0.10.0
-      '@astrojs/markdown-remark': 7.2.0
+      '@astrojs/markdown-satteri': 0.3.2
       '@astrojs/telemetry': 3.3.2
-      '@capsizecss/unpack': 4.0.0
-      '@clack/prompts': 1.5.0
+      '@capsizecss/unpack': 4.0.1
+      '@clack/prompts': 1.6.0
       '@oslojs/encoding': 1.1.0
       '@rollup/pluginutils': 5.4.0(rollup@4.61.0)
+      am-i-vibing: 0.4.0
       aria-query: 5.3.2
       axobject-query: 4.1.0
       ci-info: 4.4.0
@@ -14562,7 +14857,7 @@ snapshots:
       diff: 8.0.3
       dset: 3.1.4
       es-module-lexer: 2.1.0
-      esbuild: 0.27.7
+      esbuild: 0.28.1
       flattie: 1.1.1
       fontace: 0.4.1
       get-tsconfig: 5.0.0-beta.4
@@ -14575,18 +14870,18 @@ snapshots:
       magicast: 0.5.3
       mrmime: 2.0.1
       neotraverse: 0.6.18
-      obug: 2.1.1
+      obug: 2.1.3
       p-limit: 7.3.0
       p-queue: 9.3.0
       package-manager-detector: 1.6.0
       piccolore: 0.1.3
       picomatch: 4.0.4
       rehype: 13.0.2
-      semver: 7.8.1
-      shiki: 4.1.0
-      smol-toml: 1.6.1
+      semver: 7.8.5
+      shiki: 4.2.0
+      smol-toml: 1.7.0
       svgo: 4.0.1
-      tinyclip: 0.1.13
+      tinyclip: 0.1.15
       tinyexec: 1.2.4
       tinyglobby: 0.2.17
       ultrahtml: 1.6.0
@@ -14594,12 +14889,13 @@ snapshots:
       unist-util-visit: 5.1.0
       unstorage: 1.17.5(aws4fetch@1.0.20)(idb-keyval@6.2.1)(ioredis@5.11.0)
       vfile: 6.0.3
-      vite: '@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
-      vitefu: 1.1.3(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))
+      vite: '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+      vitefu: 1.1.3(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))
       xxhash-wasm: 1.1.0
       yargs-parser: 22.0.0
       zod: 4.4.3
     optionalDependencies:
+      '@astrojs/markdown-remark': 7.2.0
       sharp: 0.34.5
     transitivePeerDependencies:
       - '@arethetypeswrong/core'
@@ -14611,6 +14907,8 @@ snapshots:
       - '@azure/storage-blob'
       - '@capacitor/preferences'
       - '@deno/kv'
+      - '@emnapi/core'
+      - '@emnapi/runtime'
       - '@netlify/blobs'
       - '@planetscale/database'
       - '@tsdown/css'
@@ -14633,7 +14931,6 @@ snapshots:
       - sass-embedded
       - stylus
       - sugarss
-      - supports-color
       - terser
       - tsx
       - typescript
@@ -14790,15 +15087,15 @@ snapshots:
     dependencies:
       react: 19.2.6
 
-  body-parser@2.2.2:
+  body-parser@2.3.0:
     dependencies:
       bytes: 3.1.2
-      content-type: 1.0.5
+      content-type: 2.0.0
       debug: 4.4.3
       http-errors: 2.0.1
       iconv-lite: 0.7.2
       on-finished: 2.4.1
-      qs: 6.15.2
+      qs: 6.15.3
       raw-body: 3.0.2
       type-is: 2.1.0
     transitivePeerDependencies:
@@ -14936,6 +15233,8 @@ snapshots:
 
   ccount@2.0.1: {}
 
+  chai@6.2.2: {}
+
   chalk@2.4.2:
     dependencies:
       ansi-styles: 3.2.1
@@ -15129,7 +15428,7 @@ snapshots:
       json-schema-typed: 7.0.3
       onetime: 5.1.2
       pkg-up: 3.1.0
-      semver: 7.8.1
+      semver: 7.8.5
 
   connect@3.7.0:
     dependencies:
@@ -15540,8 +15839,6 @@ snapshots:
 
   es-errors@1.3.0: {}
 
-  es-module-lexer@1.7.0: {}
-
   es-module-lexer@2.1.0: {}
 
   es-object-atoms@1.1.2:
@@ -15589,34 +15886,34 @@ snapshots:
       '@esbuild/win32-ia32': 0.25.12
       '@esbuild/win32-x64': 0.25.12
 
-  esbuild@0.27.7:
+  esbuild@0.28.1:
     optionalDependencies:
-      '@esbuild/aix-ppc64': 0.27.7
-      '@esbuild/android-arm': 0.27.7
-      '@esbuild/android-arm64': 0.27.7
-      '@esbuild/android-x64': 0.27.7
-      '@esbuild/darwin-arm64': 0.27.7
-      '@esbuild/darwin-x64': 0.27.7
-      '@esbuild/freebsd-arm64': 0.27.7
-      '@esbuild/freebsd-x64': 0.27.7
-      '@esbuild/linux-arm': 0.27.7
-      '@esbuild/linux-arm64': 0.27.7
-      '@esbuild/linux-ia32': 0.27.7
-      '@esbuild/linux-loong64': 0.27.7
-      '@esbuild/linux-mips64el': 0.27.7
-      '@esbuild/linux-ppc64': 0.27.7
-      '@esbuild/linux-riscv64': 0.27.7
-      '@esbuild/linux-s390x': 0.27.7
-      '@esbuild/linux-x64': 0.27.7
-      '@esbuild/netbsd-arm64': 0.27.7
-      '@esbuild/netbsd-x64': 0.27.7
-      '@esbuild/openbsd-arm64': 0.27.7
-      '@esbuild/openbsd-x64': 0.27.7
-      '@esbuild/openharmony-arm64': 0.27.7
-      '@esbuild/sunos-x64': 0.27.7
-      '@esbuild/win32-arm64': 0.27.7
-      '@esbuild/win32-ia32': 0.27.7
-      '@esbuild/win32-x64': 0.27.7
+      '@esbuild/aix-ppc64': 0.28.1
+      '@esbuild/android-arm': 0.28.1
+      '@esbuild/android-arm64': 0.28.1
+      '@esbuild/android-x64': 0.28.1
+      '@esbuild/darwin-arm64': 0.28.1
+      '@esbuild/darwin-x64': 0.28.1
+      '@esbuild/freebsd-arm64': 0.28.1
+      '@esbuild/freebsd-x64': 0.28.1
+      '@esbuild/linux-arm': 0.28.1
+      '@esbuild/linux-arm64': 0.28.1
+      '@esbuild/linux-ia32': 0.28.1
+      '@esbuild/linux-loong64': 0.28.1
+      '@esbuild/linux-mips64el': 0.28.1
+      '@esbuild/linux-ppc64': 0.28.1
+      '@esbuild/linux-riscv64': 0.28.1
+      '@esbuild/linux-s390x': 0.28.1
+      '@esbuild/linux-x64': 0.28.1
+      '@esbuild/netbsd-arm64': 0.28.1
+      '@esbuild/netbsd-x64': 0.28.1
+      '@esbuild/openbsd-arm64': 0.28.1
+      '@esbuild/openbsd-x64': 0.28.1
+      '@esbuild/openharmony-arm64': 0.28.1
+      '@esbuild/sunos-x64': 0.28.1
+      '@esbuild/win32-arm64': 0.28.1
+      '@esbuild/win32-ia32': 0.28.1
+      '@esbuild/win32-x64': 0.28.1
 
   escalade@3.2.0: {}
 
@@ -15634,6 +15931,10 @@ snapshots:
 
   estree-walker@2.0.2: {}
 
+  estree-walker@3.0.3:
+    dependencies:
+      '@types/estree': 1.0.9
+
   etag@1.8.1: {}
 
   event-target-shim@5.0.1: {}
@@ -15646,6 +15947,8 @@ snapshots:
     dependencies:
       eventsource-parser: 3.1.0
 
+  expect-type@1.4.0: {}
+
   expo-application@56.0.3(expo@56.0.8):
     dependencies:
       expo: 56.0.8(@babel/core@7.29.7)(@expo/dom-webview@56.0.5)(@expo/metro-runtime@56.0.13)(bufferutil@4.1.0)(expo-router@56.2.8)(expo-widgets@56.0.16)(react-dom@19.2.3(react@19.2.3))(react-native-webview@13.16.1(react-native@0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6))(react@19.2.3))(react-native-worklets@0.8.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(react-native@0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6))(react@19.2.3))(react-native@0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6))(react@19.2.3)(typescript@6.0.3)(utf-8-validate@6.0.6)
@@ -15680,7 +15983,7 @@ snapshots:
       '@expo/schema-utils': 56.0.1
       expo: 56.0.8(@babel/core@7.29.7)(@expo/dom-webview@56.0.5)(@expo/metro-runtime@56.0.13)(bufferutil@4.1.0)(expo-router@56.2.8)(expo-widgets@56.0.16)(react-dom@19.2.3(react@19.2.3))(react-native-webview@13.16.1(react-native@0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6))(react@19.2.3))(react-native-worklets@0.8.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(react-native@0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6))(react@19.2.3))(react-native@0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6))(react@19.2.3)(typescript@6.0.3)(utf-8-validate@6.0.6)
       resolve-from: 5.0.0
-      semver: 7.8.1
+      semver: 7.8.5
 
   expo-camera@56.0.7(@types/emscripten@1.41.5)(expo@56.0.8)(react-native@0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6))(react@19.2.3):
     dependencies:
@@ -16019,7 +16322,7 @@ snapshots:
   express@5.2.1:
     dependencies:
       accepts: 2.0.0
-      body-parser: 2.2.2
+      body-parser: 2.3.0
       content-disposition: 1.1.0
       content-type: 1.0.5
       cookie: 0.7.2
@@ -16038,7 +16341,7 @@ snapshots:
       once: 1.4.0
       parseurl: 1.3.3
       proxy-addr: 2.0.7
-      qs: 6.15.2
+      qs: 6.15.3
       range-parser: 1.2.1
       router: 2.2.0
       send: 1.2.1
@@ -16328,7 +16631,7 @@ snapshots:
       es6-error: 4.1.1
       matcher: 3.0.0
       roarr: 2.15.4
-      semver: 7.8.1
+      semver: 7.8.5
       serialize-error: 7.0.1
     optional: true
 
@@ -16412,6 +16715,7 @@ snapshots:
   hast-util-is-element@3.0.0:
     dependencies:
       '@types/hast': 3.0.4
+    optional: true
 
   hast-util-parse-selector@4.0.0:
     dependencies:
@@ -16489,6 +16793,7 @@ snapshots:
       '@types/unist': 3.0.3
       hast-util-is-element: 3.0.0
       unist-util-find-after: 5.0.0
+    optional: true
 
   hast-util-whitespace@3.0.0:
     dependencies:
@@ -16522,7 +16827,7 @@ snapshots:
     dependencies:
       react-is: 16.13.1
 
-  hono@4.12.25: {}
+  hono@4.12.27: {}
 
   hosted-git-info@4.1.0:
     dependencies:
@@ -17132,6 +17437,7 @@ snapshots:
       '@types/mdast': 4.0.4
       '@types/unist': 3.0.3
       unist-util-visit: 5.1.0
+    optional: true
 
   mdast-util-find-and-replace@3.0.2:
     dependencies:
@@ -17826,7 +18132,7 @@ snapshots:
 
   node-abi@4.31.0:
     dependencies:
-      semver: 7.8.1
+      semver: 7.8.5
 
   node-addon-api@1.7.2:
     optional: true
@@ -17835,7 +18141,7 @@ snapshots:
 
   node-api-version@0.2.1:
     dependencies:
-      semver: 7.8.1
+      semver: 7.8.5
 
   node-fetch-native@1.6.7: {}
 
@@ -17856,7 +18162,7 @@ snapshots:
       graceful-fs: 4.2.11
       nopt: 9.0.0
       proc-log: 6.1.0
-      semver: 7.8.1
+      semver: 7.8.5
       tar: 7.5.16
       tinyglobby: 0.2.17
       undici: 6.26.0
@@ -17884,7 +18190,7 @@ snapshots:
     dependencies:
       hosted-git-info: 7.0.2
       proc-log: 4.2.0
-      semver: 7.8.1
+      semver: 7.8.5
       validate-npm-package-name: 5.0.1
 
   nth-check@2.1.1:
@@ -17906,7 +18212,7 @@ snapshots:
 
   obuf@1.1.2: {}
 
-  obug@2.1.1: {}
+  obug@2.1.3: {}
 
   ofetch@1.5.1:
     dependencies:
@@ -17981,30 +18287,30 @@ snapshots:
 
   outvariant@1.4.3: {}
 
-  oxfmt@0.52.0(vite-plus@0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)):
+  oxfmt@0.55.0(vite-plus@0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)):
     dependencies:
       tinypool: 2.1.0
     optionalDependencies:
-      '@oxfmt/binding-android-arm-eabi': 0.52.0
-      '@oxfmt/binding-android-arm64': 0.52.0
-      '@oxfmt/binding-darwin-arm64': 0.52.0
-      '@oxfmt/binding-darwin-x64': 0.52.0
-      '@oxfmt/binding-freebsd-x64': 0.52.0
-      '@oxfmt/binding-linux-arm-gnueabihf': 0.52.0
-      '@oxfmt/binding-linux-arm-musleabihf': 0.52.0
-      '@oxfmt/binding-linux-arm64-gnu': 0.52.0
-      '@oxfmt/binding-linux-arm64-musl': 0.52.0
-      '@oxfmt/binding-linux-ppc64-gnu': 0.52.0
-      '@oxfmt/binding-linux-riscv64-gnu': 0.52.0
-      '@oxfmt/binding-linux-riscv64-musl': 0.52.0
-      '@oxfmt/binding-linux-s390x-gnu': 0.52.0
-      '@oxfmt/binding-linux-x64-gnu': 0.52.0
-      '@oxfmt/binding-linux-x64-musl': 0.52.0
-      '@oxfmt/binding-openharmony-arm64': 0.52.0
-      '@oxfmt/binding-win32-arm64-msvc': 0.52.0
-      '@oxfmt/binding-win32-ia32-msvc': 0.52.0
-      '@oxfmt/binding-win32-x64-msvc': 0.52.0
-      vite-plus: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+      '@oxfmt/binding-android-arm-eabi': 0.55.0
+      '@oxfmt/binding-android-arm64': 0.55.0
+      '@oxfmt/binding-darwin-arm64': 0.55.0
+      '@oxfmt/binding-darwin-x64': 0.55.0
+      '@oxfmt/binding-freebsd-x64': 0.55.0
+      '@oxfmt/binding-linux-arm-gnueabihf': 0.55.0
+      '@oxfmt/binding-linux-arm-musleabihf': 0.55.0
+      '@oxfmt/binding-linux-arm64-gnu': 0.55.0
+      '@oxfmt/binding-linux-arm64-musl': 0.55.0
+      '@oxfmt/binding-linux-ppc64-gnu': 0.55.0
+      '@oxfmt/binding-linux-riscv64-gnu': 0.55.0
+      '@oxfmt/binding-linux-riscv64-musl': 0.55.0
+      '@oxfmt/binding-linux-s390x-gnu': 0.55.0
+      '@oxfmt/binding-linux-x64-gnu': 0.55.0
+      '@oxfmt/binding-linux-x64-musl': 0.55.0
+      '@oxfmt/binding-openharmony-arm64': 0.55.0
+      '@oxfmt/binding-win32-arm64-msvc': 0.55.0
+      '@oxfmt/binding-win32-ia32-msvc': 0.55.0
+      '@oxfmt/binding-win32-x64-msvc': 0.55.0
+      vite-plus: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   oxlint-tsgolint@0.23.0:
     optionalDependencies:
@@ -18015,29 +18321,29 @@ snapshots:
       '@oxlint-tsgolint/win32-arm64': 0.23.0
       '@oxlint-tsgolint/win32-x64': 0.23.0
 
-  oxlint@1.67.0(oxlint-tsgolint@0.23.0)(vite-plus@0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)):
+  oxlint@1.70.0(oxlint-tsgolint@0.23.0)(vite-plus@0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)):
     optionalDependencies:
-      '@oxlint/binding-android-arm-eabi': 1.67.0
-      '@oxlint/binding-android-arm64': 1.67.0
-      '@oxlint/binding-darwin-arm64': 1.67.0
-      '@oxlint/binding-darwin-x64': 1.67.0
-      '@oxlint/binding-freebsd-x64': 1.67.0
-      '@oxlint/binding-linux-arm-gnueabihf': 1.67.0
-      '@oxlint/binding-linux-arm-musleabihf': 1.67.0
-      '@oxlint/binding-linux-arm64-gnu': 1.67.0
-      '@oxlint/binding-linux-arm64-musl': 1.67.0
-      '@oxlint/binding-linux-ppc64-gnu': 1.67.0
-      '@oxlint/binding-linux-riscv64-gnu': 1.67.0
-      '@oxlint/binding-linux-riscv64-musl': 1.67.0
-      '@oxlint/binding-linux-s390x-gnu': 1.67.0
-      '@oxlint/binding-linux-x64-gnu': 1.67.0
-      '@oxlint/binding-linux-x64-musl': 1.67.0
-      '@oxlint/binding-openharmony-arm64': 1.67.0
-      '@oxlint/binding-win32-arm64-msvc': 1.67.0
-      '@oxlint/binding-win32-ia32-msvc': 1.67.0
-      '@oxlint/binding-win32-x64-msvc': 1.67.0
+      '@oxlint/binding-android-arm-eabi': 1.70.0
+      '@oxlint/binding-android-arm64': 1.70.0
+      '@oxlint/binding-darwin-arm64': 1.70.0
+      '@oxlint/binding-darwin-x64': 1.70.0
+      '@oxlint/binding-freebsd-x64': 1.70.0
+      '@oxlint/binding-linux-arm-gnueabihf': 1.70.0
+      '@oxlint/binding-linux-arm-musleabihf': 1.70.0
+      '@oxlint/binding-linux-arm64-gnu': 1.70.0
+      '@oxlint/binding-linux-arm64-musl': 1.70.0
+      '@oxlint/binding-linux-ppc64-gnu': 1.70.0
+      '@oxlint/binding-linux-riscv64-gnu': 1.70.0
+      '@oxlint/binding-linux-riscv64-musl': 1.70.0
+      '@oxlint/binding-linux-s390x-gnu': 1.70.0
+      '@oxlint/binding-linux-x64-gnu': 1.70.0
+      '@oxlint/binding-linux-x64-musl': 1.70.0
+      '@oxlint/binding-openharmony-arm64': 1.70.0
+      '@oxlint/binding-win32-arm64-msvc': 1.70.0
+      '@oxlint/binding-win32-ia32-msvc': 1.70.0
+      '@oxlint/binding-win32-x64-msvc': 1.70.0
       oxlint-tsgolint: 0.23.0
-      vite-plus: 0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
+      vite-plus: 0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
 
   p-cancelable@2.1.1: {}
 
@@ -18088,6 +18394,7 @@ snapshots:
       unist-util-modify-children: 4.0.0
       unist-util-visit-children: 3.0.0
       vfile: 6.0.3
+    optional: true
 
   parse-png@2.1.0:
     dependencies:
@@ -18191,10 +18498,6 @@ snapshots:
 
   picomatch@4.0.4: {}
 
-  pixelmatch@7.2.0:
-    dependencies:
-      pngjs: 7.0.0
-
   pkce-challenge@5.0.1: {}
 
   pkg-up@3.1.0:
@@ -18282,6 +18585,8 @@ snapshots:
 
   proc-log@6.1.0: {}
 
+  process-ancestry@0.1.0: {}
+
   process-nextick-args@2.0.1: {}
 
   progress@2.0.3: {}
@@ -18324,8 +18629,9 @@ snapshots:
 
   pure-rand@8.4.0: {}
 
-  qs@6.15.2:
+  qs@6.15.3:
     dependencies:
+      es-define-property: 1.0.1
       side-channel: 1.1.1
 
   query-string@7.1.3:
@@ -18469,7 +18775,7 @@ snapshots:
       react-native: 0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6)
       react-native-is-edge-to-edge: 1.3.1(react-native@0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6))(react@19.2.3)
       react-native-worklets: 0.8.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(react-native@0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6))(react@19.2.3)
-      semver: 7.8.1
+      semver: 7.8.5
 
   react-native-safe-area-context@5.7.0(react-native@0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6))(react@19.2.3):
     dependencies:
@@ -18485,7 +18791,7 @@ snapshots:
 
   react-native-shiki-engine@0.3.12(react-native@0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6))(react@19.2.3):
     dependencies:
-      '@shikijs/types': 4.2.0
+      '@shikijs/types': 4.3.0
       '@shikijs/vscode-textmate': 10.0.2
       react: 19.2.3
       react-native: 0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6)
@@ -18526,7 +18832,7 @@ snapshots:
       convert-source-map: 2.0.0
       react: 19.2.3
       react-native: 0.85.3(@babel/core@7.29.7)(@react-native/metro-config@0.85.3(@babel/core@7.29.7))(@types/react@19.2.16)(bufferutil@4.1.0)(react@19.2.3)(utf-8-validate@6.0.6)
-      semver: 7.8.1
+      semver: 7.8.5
     transitivePeerDependencies:
       - supports-color
 
@@ -18559,7 +18865,7 @@ snapshots:
       react-refresh: 0.14.2
       regenerator-runtime: 0.13.11
       scheduler: 0.27.0
-      semver: 7.8.1
+      semver: 7.8.5
       stacktrace-parser: 0.1.11
       tinyglobby: 0.2.17
       whatwg-fetch: 3.6.20
@@ -18747,6 +19053,7 @@ snapshots:
       retext-smartypants: 6.2.0
       unified: 11.0.5
       unist-util-visit: 5.1.0
+    optional: true
 
   remark-stringify@11.0.0:
     dependencies:
@@ -18807,6 +19114,7 @@ snapshots:
       '@types/nlcst': 2.0.3
       parse-latin: 7.0.0
       unified: 11.0.5
+    optional: true
 
   retext-smartypants@6.2.0:
     dependencies:
@@ -18819,6 +19127,7 @@ snapshots:
       '@types/nlcst': 2.0.3
       nlcst-to-string: 4.0.0
       unified: 11.0.5
+    optional: true
 
   retext@9.0.0:
     dependencies:
@@ -18826,6 +19135,7 @@ snapshots:
       retext-latin: 4.0.0
       retext-stringify: 4.0.0
       unified: 11.0.5
+    optional: true
 
   retry@0.12.0: {}
 
@@ -18890,26 +19200,26 @@ snapshots:
       '@rolldown/binding-win32-arm64-msvc': 1.0.1
       '@rolldown/binding-win32-x64-msvc': 1.0.1
 
-  rolldown@1.0.3:
+  rolldown@1.1.3:
     dependencies:
-      '@oxc-project/types': 0.133.0
+      '@oxc-project/types': 0.137.0
       '@rolldown/pluginutils': 1.0.1
     optionalDependencies:
-      '@rolldown/binding-android-arm64': 1.0.3
-      '@rolldown/binding-darwin-arm64': 1.0.3
-      '@rolldown/binding-darwin-x64': 1.0.3
-      '@rolldown/binding-freebsd-x64': 1.0.3
-      '@rolldown/binding-linux-arm-gnueabihf': 1.0.3
-      '@rolldown/binding-linux-arm64-gnu': 1.0.3
-      '@rolldown/binding-linux-arm64-musl': 1.0.3
-      '@rolldown/binding-linux-ppc64-gnu': 1.0.3
-      '@rolldown/binding-linux-s390x-gnu': 1.0.3
-      '@rolldown/binding-linux-x64-gnu': 1.0.3
-      '@rolldown/binding-linux-x64-musl': 1.0.3
-      '@rolldown/binding-openharmony-arm64': 1.0.3
-      '@rolldown/binding-wasm32-wasi': 1.0.3
-      '@rolldown/binding-win32-arm64-msvc': 1.0.3
-      '@rolldown/binding-win32-x64-msvc': 1.0.3
+      '@rolldown/binding-android-arm64': 1.1.3
+      '@rolldown/binding-darwin-arm64': 1.1.3
+      '@rolldown/binding-darwin-x64': 1.1.3
+      '@rolldown/binding-freebsd-x64': 1.1.3
+      '@rolldown/binding-linux-arm-gnueabihf': 1.1.3
+      '@rolldown/binding-linux-arm64-gnu': 1.1.3
+      '@rolldown/binding-linux-arm64-musl': 1.1.3
+      '@rolldown/binding-linux-ppc64-gnu': 1.1.3
+      '@rolldown/binding-linux-s390x-gnu': 1.1.3
+      '@rolldown/binding-linux-x64-gnu': 1.1.3
+      '@rolldown/binding-linux-x64-musl': 1.1.3
+      '@rolldown/binding-openharmony-arm64': 1.1.3
+      '@rolldown/binding-wasm32-wasi': 1.1.3
+      '@rolldown/binding-win32-arm64-msvc': 1.1.3
+      '@rolldown/binding-win32-x64-msvc': 1.1.3
 
   rollup@4.61.0:
     dependencies:
@@ -18967,6 +19277,23 @@ snapshots:
     dependencies:
       truncate-utf8-bytes: 1.0.2
 
+  satteri@0.9.3:
+    dependencies:
+      '@types/estree-jsx': 1.0.5
+      '@types/hast': 3.0.4
+      '@types/mdast': 4.0.4
+      '@types/unist': 3.0.3
+    optionalDependencies:
+      '@bruits/satteri-darwin-arm64': 0.9.3
+      '@bruits/satteri-darwin-x64': 0.9.3
+      '@bruits/satteri-linux-arm64-gnu': 0.9.3
+      '@bruits/satteri-linux-arm64-musl': 0.9.3
+      '@bruits/satteri-linux-x64-gnu': 0.9.3
+      '@bruits/satteri-linux-x64-musl': 0.9.3
+      '@bruits/satteri-wasm32-wasi': 0.9.3
+      '@bruits/satteri-win32-arm64-msvc': 0.9.3
+      '@bruits/satteri-win32-x64-msvc': 0.9.3
+
   sax@1.6.0: {}
 
   scheduler@0.27.0: {}
@@ -18980,7 +19307,7 @@ snapshots:
 
   semver@7.7.4: {}
 
-  semver@7.8.1: {}
+  semver@7.8.5: {}
 
   send@0.19.2:
     dependencies:
@@ -19061,7 +19388,7 @@ snapshots:
     dependencies:
       '@img/colour': 1.1.0
       detect-libc: 2.1.2
-      semver: 7.8.1
+      semver: 7.8.5
     optionalDependencies:
       '@img/sharp-darwin-arm64': 0.34.5
       '@img/sharp-darwin-x64': 0.34.5
@@ -19097,17 +19424,6 @@ snapshots:
 
   shell-quote@1.8.4: {}
 
-  shiki@4.1.0:
-    dependencies:
-      '@shikijs/core': 4.1.0
-      '@shikijs/engine-javascript': 4.1.0
-      '@shikijs/engine-oniguruma': 4.1.0
-      '@shikijs/langs': 4.1.0
-      '@shikijs/themes': 4.1.0
-      '@shikijs/types': 4.1.0
-      '@shikijs/vscode-textmate': 10.0.2
-      '@types/hast': 3.0.4
-
   shiki@4.2.0:
     dependencies:
       '@shikijs/core': 4.2.0
@@ -19147,6 +19463,8 @@ snapshots:
       side-channel-map: 1.0.1
       side-channel-weakmap: 1.0.2
 
+  siginfo@2.0.0: {}
+
   signal-exit@3.0.7: {}
 
   signal-exit@4.1.0: {}
@@ -19163,7 +19481,7 @@ snapshots:
 
   simple-update-notifier@2.0.0:
     dependencies:
-      semver: 7.8.1
+      semver: 7.8.5
 
   sirv@3.0.2:
     dependencies:
@@ -19190,7 +19508,7 @@ snapshots:
   smart-buffer@4.2.0:
     optional: true
 
-  smol-toml@1.6.1: {}
+  smol-toml@1.7.0: {}
 
   source-map-js@1.2.1: {}
 
@@ -19218,6 +19536,8 @@ snapshots:
     dependencies:
       escape-string-regexp: 2.0.0
 
+  stackback@0.0.2: {}
+
   stackframe@1.3.4: {}
 
   stacktrace-parser@0.1.11:
@@ -19394,7 +19714,7 @@ snapshots:
 
   tinybench@2.9.0: {}
 
-  tinyclip@0.1.13: {}
+  tinyclip@0.1.15: {}
 
   tinyexec@1.2.4: {}
 
@@ -19405,6 +19725,8 @@ snapshots:
 
   tinypool@2.1.0: {}
 
+  tinyrainbow@3.1.0: {}
+
   tldts-core@7.4.2: {}
 
   tldts@7.4.2:
@@ -19470,7 +19792,7 @@ snapshots:
 
   typescript-auto-import-cache@0.3.6:
     dependencies:
-      semver: 7.8.1
+      semver: 7.8.5
 
   typescript@6.0.3: {}
 
@@ -19527,6 +19849,7 @@ snapshots:
     dependencies:
       '@types/unist': 3.0.3
       unist-util-is: 6.0.1
+    optional: true
 
   unist-util-is@6.0.1:
     dependencies:
@@ -19536,6 +19859,7 @@ snapshots:
     dependencies:
       '@types/unist': 3.0.3
       array-iterate: 2.0.1
+    optional: true
 
   unist-util-position@5.0.0:
     dependencies:
@@ -19545,6 +19869,7 @@ snapshots:
     dependencies:
       '@types/unist': 3.0.3
       unist-util-visit: 5.1.0
+    optional: true
 
   unist-util-stringify-position@4.0.0:
     dependencies:
@@ -19553,6 +19878,7 @@ snapshots:
   unist-util-visit-children@3.0.0:
     dependencies:
       '@types/unist': 3.0.3
+    optional: true
 
   unist-util-visit-parents@6.0.2:
     dependencies:
@@ -19698,25 +20024,34 @@ snapshots:
       '@types/unist': 3.0.3
       vfile-message: 4.0.3
 
-  vite-plus@0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0):
+  vite-plus@0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0):
     dependencies:
-      '@oxc-project/types': 0.133.0
-      '@oxlint/plugins': 1.61.0
-      '@voidzero-dev/vite-plus-core': 0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)
-      '@voidzero-dev/vite-plus-test': 0.1.24(@types/node@24.12.4)(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
-      oxfmt: 0.52.0(vite-plus@0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0))
-      oxlint: 1.67.0(oxlint-tsgolint@0.23.0)(vite-plus@0.1.24(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0))
+      '@oxc-project/types': 0.136.0
+      '@oxlint/plugins': 1.68.0
+      '@vitest/browser': 4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(bufferutil@4.1.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(utf-8-validate@6.0.6)(vitest@4.1.9(@types/node@24.12.4)(@vitest/browser-preview@4.1.9)(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3)))
+      '@vitest/browser-preview': 4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(bufferutil@4.1.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(utf-8-validate@6.0.6)(vitest@4.1.9(@types/node@24.12.4)(@vitest/browser-preview@4.1.9)(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3)))
+      '@vitest/expect': 4.1.9
+      '@vitest/mocker': 4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))
+      '@vitest/pretty-format': 4.1.9
+      '@vitest/runner': 4.1.9
+      '@vitest/snapshot': 4.1.9
+      '@vitest/spy': 4.1.9
+      '@vitest/utils': 4.1.9
+      '@voidzero-dev/vite-plus-core': 0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)
+      oxfmt: 0.55.0(vite-plus@0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0))
+      oxlint: 1.70.0(oxlint-tsgolint@0.23.0)(vite-plus@0.2.1(@types/node@24.12.4)(bufferutil@4.1.0)(esbuild@0.28.1)(jiti@2.7.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0))
       oxlint-tsgolint: 0.23.0
-      vite: '@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+      vite: '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+      vitest: 4.1.9(@types/node@24.12.4)(@vitest/browser-preview@4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(bufferutil@4.1.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(utf-8-validate@6.0.6)(vitest@4.1.9))(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))
     optionalDependencies:
-      '@voidzero-dev/vite-plus-darwin-arm64': 0.1.24
-      '@voidzero-dev/vite-plus-darwin-x64': 0.1.24
-      '@voidzero-dev/vite-plus-linux-arm64-gnu': 0.1.24
-      '@voidzero-dev/vite-plus-linux-arm64-musl': 0.1.24
-      '@voidzero-dev/vite-plus-linux-x64-gnu': 0.1.24
-      '@voidzero-dev/vite-plus-linux-x64-musl': 0.1.24
-      '@voidzero-dev/vite-plus-win32-arm64-msvc': 0.1.24
-      '@voidzero-dev/vite-plus-win32-x64-msvc': 0.1.24
+      '@voidzero-dev/vite-plus-darwin-arm64': 0.2.1
+      '@voidzero-dev/vite-plus-darwin-x64': 0.2.1
+      '@voidzero-dev/vite-plus-linux-arm64-gnu': 0.2.1
+      '@voidzero-dev/vite-plus-linux-arm64-musl': 0.2.1
+      '@voidzero-dev/vite-plus-linux-x64-gnu': 0.2.1
+      '@voidzero-dev/vite-plus-linux-x64-musl': 0.2.1
+      '@voidzero-dev/vite-plus-win32-arm64-msvc': 0.2.1
+      '@voidzero-dev/vite-plus-win32-x64-msvc': 0.2.1
     transitivePeerDependencies:
       - '@arethetypeswrong/core'
       - '@edge-runtime/vm'
@@ -19734,6 +20069,7 @@ snapshots:
       - jiti
       - jsdom
       - less
+      - msw
       - publint
       - sass
       - sass-embedded
@@ -19748,9 +20084,37 @@ snapshots:
       - utf-8-validate
       - yaml
 
-  vitefu@1.1.3(@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)):
+  vitefu@1.1.3(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)):
     optionalDependencies:
-      vite: '@voidzero-dev/vite-plus-core@0.1.24(@types/node@24.12.4)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+      vite: '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+
+  vitest@4.1.9(@types/node@24.12.4)(@vitest/browser-preview@4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(bufferutil@4.1.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(utf-8-validate@6.0.6)(vitest@4.1.9))(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3)):
+    dependencies:
+      '@vitest/expect': 4.1.9
+      '@vitest/mocker': 4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))
+      '@vitest/pretty-format': 4.1.9
+      '@vitest/runner': 4.1.9
+      '@vitest/snapshot': 4.1.9
+      '@vitest/spy': 4.1.9
+      '@vitest/utils': 4.1.9
+      es-module-lexer: 2.1.0
+      expect-type: 1.4.0
+      magic-string: 0.30.21
+      obug: 2.1.3
+      pathe: 2.0.3
+      picomatch: 4.0.4
+      std-env: 4.1.0
+      tinybench: 2.9.0
+      tinyexec: 1.2.4
+      tinyglobby: 0.2.17
+      tinyrainbow: 3.1.0
+      vite: '@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0)'
+      why-is-node-running: 2.3.0
+    optionalDependencies:
+      '@types/node': 24.12.4
+      '@vitest/browser-preview': 4.1.9(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(bufferutil@4.1.0)(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3))(utf-8-validate@6.0.6)(vitest@4.1.9(@types/node@24.12.4)(@vitest/browser-preview@4.1.9)(@voidzero-dev/vite-plus-core@0.2.1(@types/node@24.12.4)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(yaml@2.9.0))(msw@2.12.11(@types/node@24.12.4)(typescript@6.0.3)))
+    transitivePeerDependencies:
+      - msw
 
   vlq@1.0.1: {}
 
@@ -19795,7 +20159,7 @@ snapshots:
   volar-service-typescript@0.0.70(@volar/language-service@2.4.28):
     dependencies:
       path-browserify: 1.0.1
-      semver: 7.8.1
+      semver: 7.8.5
       typescript-auto-import-cache: 0.3.6
       vscode-languageserver-textdocument: 1.0.12
       vscode-nls: 5.2.0
@@ -19891,6 +20255,11 @@ snapshots:
     dependencies:
       isexe: 4.0.0
 
+  why-is-node-running@2.3.0:
+    dependencies:
+      siginfo: 2.0.0
+      stackback: 0.0.2
+
   widest-line@6.0.0:
     dependencies:
       string-width: 8.2.1
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 8096d3a0a3..446139ed6d 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -27,13 +27,11 @@ catalog:
   "@pierre/diffs": 1.3.0-beta.5
   "@types/node": 24.12.4
   "@typescript/native-preview": 7.0.0-dev.20260604.1
-  "@vitest/runner": 4.1.8
   effect: 4.0.0-beta.78
   jose: 6.2.2
   typescript: ~6.0.3
-  vite: npm:@voidzero-dev/vite-plus-core@0.1.24
-  vite-plus: 0.1.24
-  vitest: npm:@voidzero-dev/vite-plus-test@0.1.24
+  vite: npm:@voidzero-dev/vite-plus-core@0.2.1
+  vite-plus: 0.2.1
   yaml: ^2.9.0
 
 ignoredBuiltDependencies:
@@ -70,14 +68,14 @@ overrides:
   "@effect/sql-pg": "catalog:"
   "@effect/sql-sqlite-bun": "catalog:"
   "@effect/vitest": "catalog:"
-  "@effect/vitest>@vitest/runner": "-"
+  # @effect/vitest is patched to use vite-plus/test; do not auto-install its
+  # upstream Vitest peer and create a second Vite/Vitest toolchain.
   "@effect/vitest>vitest": "-"
   "@expo/metro-config": 56.0.13
   "@pierre/diffs>@shikijs/transformers": ^4.2.0
   "@types/node": "catalog:"
   effect: "catalog:"
   vite: "catalog:"
-  vitest: "catalog:"
   yaml: "catalog:"
 
 packageExtensions:
@@ -102,7 +100,5 @@ patchedDependencies:
 peerDependencyRules:
   allowAny:
     - vite
-    - vitest
   allowedVersions:
     vite: "*"
-    vitest: "*"
diff --git a/scripts/dev-runner.test.ts b/scripts/dev-runner.test.ts
index 85d57c4181..432b50cf72 100644
--- a/scripts/dev-runner.test.ts
+++ b/scripts/dev-runner.test.ts
@@ -253,6 +253,7 @@ it.layer(NodeServices.layer)("dev-runner", (it) => {
             T3CODE_MODE: "web",
             T3CODE_NO_BROWSER: "0",
             T3CODE_HOST: "0.0.0.0",
+            VITE_DEV_SERVER_URL: "http://127.0.0.1:8526",
             VITE_WS_URL: "ws://localhost:13773",
           },
           serverOffset: 0,
diff --git a/scripts/dev-runner.ts b/scripts/dev-runner.ts
index fb82310bbd..2953a2f4de 100644
--- a/scripts/dev-runner.ts
+++ b/scripts/dev-runner.ts
@@ -158,12 +158,6 @@ const optionalIntegerConfig = (name: string): Config.Config
     Config.option,
     Config.map((value) => Option.getOrUndefined(value)),
   );
-const optionalUrlConfig = (name: string): Config.Config =>
-  Config.url(name).pipe(
-    Config.option,
-    Config.map((value) => Option.getOrUndefined(value)),
-  );
-
 const OffsetConfig = Config.all({
   portOffset: optionalIntegerConfig("T3CODE_PORT_OFFSET"),
   devInstance: optionalStringConfig("T3CODE_DEV_INSTANCE"),
@@ -621,8 +615,11 @@ const devRunnerCli = Command.make("dev-runner", {
   ),
   devUrl: Flag.string("dev-url").pipe(
     Flag.withSchema(Schema.URLFromString),
-    Flag.withDescription("Web dev URL override (forwards to VITE_DEV_SERVER_URL)."),
-    Flag.withFallbackConfig(optionalUrlConfig("VITE_DEV_SERVER_URL")),
+    Flag.withDescription(
+      "Explicit web dev URL override (forwards to VITE_DEV_SERVER_URL). Ambient VITE_DEV_SERVER_URL values are ignored so a parent dev app cannot redirect the child runner.",
+    ),
+    Flag.optional,
+    Flag.map(Option.getOrUndefined),
   ),
   dryRun: Flag.boolean("dry-run").pipe(
     Flag.withDescription("Resolve mode/ports/env and print, but do not spawn Vite+."),