fix(preview): recover automation after timeouts and paused rendering #12706
ClosedQuicksaver(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/12706/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/server/src/mcp/PreviewAutomationBroker.ts line 473Resolvedby Quicksaver(GitHub profile, opens in a new tab)@@ -372,12 +442,15 @@372442 yield* Queue.offer(queue, { type: "connected", connectionId });373443 const connection: ClientConnection = {374444 clientId,445+ hostId: host.hostId ?? clientId,375446 connectionId,376447 environmentId: host.environmentId,448+ label: host.label ?? `Preview host ${clientId.slice(-8)}`,449+ platform: host.platform ?? "unknown",377450 supportedOperations: new Set(host.supportedOperations ?? PREVIEW_AUTOMATION_V1_OPERATIONS),378451 focused: false,379452 focusOrder: 0,380453 queue,381454 };382455 const registration = yield* SynchronizedRef.modify(state, (current) => {383- const previousConnection = current.clients.get(clientId);456+ const previousConnection = Array.from(current.clients.values()).find(apps/web/src/browser/browserRecording.ts line 1018Resolvedby Quicksaver(GitHub profile, opens in a new tab)@@ -743,4 +899,6 @@743899 } catch (cause) {744900 cleanupErrors.push(cause);745901 } finally {746- clearActiveRecording(recording);902+ recording.releaseSurfaceActivity?.();903+ recording.releaseSurfaceActivity = null;904+ if (result._tag === "Failure" || !result.artifact || !recording.retainForUpload) {apps/web/src/components/preview/closePreviewAutomationTab.ts lines 30 to 32Resolvedby Quicksaver(GitHub profile, opens in a new tab)@@ -0,0 +12,21 @@12+ readonly closePreview: (input: {13+ readonly environmentId: EnvironmentId;14+ readonly input: PreviewCloseInput;15+ }) => Promise<AtomCommandResult<void, E>>;16+ readonly closeRuntimeTab: (runtimeTabId: string) => Promise<void>;17+ readonly runtimeTabId: string;18+ readonly snapshot: PreviewSessionSnapshot | null;19+ readonly tabId: string;20+ readonly threadRef: ScopedThreadRef;21+}22+23+/**24+ * Removes the authoritative preview session before disposing its local Electron25+ * runtime. A failed server close leaves the runtime available for a retry.26+ */27+export async function closePreviewAutomationTab<E>(28+ input: ClosePreviewAutomationTabInput<E>,29+): Promise<AtomCommandResult<void, E>> {30+ const result = await closePreviewSession(input);31+ if (result._tag === "Failure") return result;32+ await input.closeRuntimeTab(input.runtimeTabId);apps/desktop/src/preview/Manager.ts line 2916OutdatedResolvedby Quicksaver(GitHub profile, opens in a new tab)@@ -2686,4 +2903,14 @@26862903 }),26872904 );26882905 }2689- }).pipe(Effect.ignore);2906+ }).pipe(2907+ Effect.timeoutOption(2908+ Math.max(1, DEFAULT_AUTOMATION_TIMEOUT_MS - AUTOMATION_TIMEOUT_RESPONSE_GRACE_MS),2909+ ),2910+ Effect.flatMap((result) =>2911+ Option.isSome(result)2912+ ? Effect.void2913+ : Effect.logWarning("Timed out restoring the preview control session.", {2914+ tabId,2915+ webContentsId: wc.id,2916+ }).pipe(Effect.andThen(detachControlSession(wc.id))),apps/web/src/components/preview/previewViewportReadiness.ts lines 52 to 68Resolvedby Quicksaver(GitHub profile, opens in a new tab)@@ -37,0 +38,21 @@38+39+export async function waitForPreviewViewportReadiness(input: {40+ readonly setting: PreviewViewportSetting;41+ readonly timeoutMs: number;42+ readonly assertCurrent: () => void;43+ readonly readViewport: () => Promise<{44+ readonly appliedSettingKey: string | null;45+ readonly declaredViewport: PreviewRenderedViewportSize | null;46+ readonly renderedViewport: PreviewRenderedViewportSize | null;47+ } | null>;48+}): Promise<PreviewRenderedViewportSize | null> {49+ const deadline = Date.now() + input.timeoutMs;50+ while (Date.now() <= deadline) {51+ input.assertCurrent();52+ let viewportState: Awaited<ReturnType<typeof input.readViewport>> = null;53+ try {54+ viewportState = await input.readViewport();55+ } catch {56+ // Registration and navigation can transiently replace the guest while57+ // React applies the server snapshot. Retry until the operation deadline.58+ }
- .agents/skills/worktrees/SKILL.md lines 68 to 82OutdatedResolvedby Quicksaver(GitHub profile, opens in a new tab)@@ -0,0 +62,21 @@62+Require the Mac worktree `HEAD` to equal the recorded SHA. When the source was dirty, require its binary diff and untracked-file manifest to match the Windows source before requesting capacity.63+64+Include your request ID in every transfer ref and filename. At final teardown, remove your temporary worktree first. Then delete only the refs and transfer artifacts named by your request ID on both hosts.65+66+## Host-local capacities67+68+Run `scripts/worktree-runtime-slot.ts` from the main checkout on the host whose runtime will be used. Each host provides:69+70+`mobile`: two holders.71+`desktop`: one holder.72+73+The web server itself has no queue. Worktree-local `.t3` state and the actual ports printed by `dev-runner` isolate parallel servers. The `desktop` lease begins when integrated UI automation starts, regardless of the browser driver.74+75+Every acquisition and release uses the same request ID:76+77+```sh78+node scripts/worktree-runtime-slot.ts acquire mobile --worktree "<worktree>" --request-id "<request-id>"79+node scripts/worktree-runtime-slot.ts release mobile --worktree "<worktree>" --request-id "<request-id>"80+node scripts/worktree-runtime-slot.ts acquire desktop --worktree "<worktree>" --request-id "<request-id>"81+node scripts/worktree-runtime-slot.ts release desktop --worktree "<worktree>" --request-id "<request-id>"82+```apps/web/src/browser/browserRecording.ts lines 625 to 627Resolvedby Quicksaver(GitHub profile, opens in a new tab)@@ -485,7 +577,21 @@577+ promise,578+ new Promise<never>((_, reject) => {579+ timeout = setTimeout(() => reject(recordingStopDeadlineError(tabId)), remainingMs);580+ }),581+ ]);582+ } finally {583+ if (timeout !== null) clearTimeout(timeout);584+ }585+};586+485587 export async function startBrowserRecording(486588 tabId: string,487589 threadRef: ScopedThreadRef | null = null,488590 serverTabId = tabId,591+ timeoutMs?: number,489592 ): Promise<string> {490593 const bridge = previewBridge;491594 if (!bridge) throw new BrowserRecordingUnavailableError({ tabId });595+ const deadline = timeoutMs === undefined ? null : Date.now() + timeoutMs;596+ const remainingStartupBudget = (): number | undefined =>597+ deadline === null ? undefined : Math.max(0, deadline - Date.now());apps/web/src/browser/browserRecording.ts lines 935 to 939Resolvedby Quicksaver(GitHub profile, opens in a new tab)@@ -686,4 +820,8 @@686820 result = { _tag: "Success", artifact: null };687821 } else {688822 try {689- await stopMediaRecorder(recording.recorder);823+ await awaitWithinRecordingStopDeadline(824+ stopMediaRecorder(recording.recorder),825+ deadline,826+ tabId,827+ );apps/web/src/browser/browserRecordingUpload.ts lines 75 to 78OutdatedResolvedby Quicksaver(GitHub profile, opens in a new tab)@@ -72,7 +72,7 @@7272 });7373 }7474 const cause = result.status === "failed" ? result.error : undefined;75- if (Date.now() >= deadlineMs - 1_000) {75+ if (Date.now() >= deadlineMs) {7676 throw new PreviewAutomationRecordingDeadlineExpiredError({ threadId, cause });7777 }7878 throw new PreviewAutomationRecordingTransferError({apps/web/src/components/preview/previewAutomationClientId.ts lines 63 to 68Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -4,0 +48,21 @@48+ navigatorPlatform: string,49+ clientId: string,50+): {51+ readonly label: PreviewAutomationHostLabel;52+ readonly platform: PreviewAutomationHostPlatform;53+} {54+ const nativeLabel = Predicate.isString(nativeMetadata?.label) ? nativeMetadata.label.trim() : "";55+ const nativePlatform = nativeMetadata?.platform;56+ const platform =57+ nativePlatform === "macos" ||58+ nativePlatform === "windows" ||59+ nativePlatform === "linux" ||60+ nativePlatform === "unknown"61+ ? nativePlatform62+ : resolvePreviewAutomationHostPlatform(navigatorPlatform);63+ if (nativeLabel) {64+ return {65+ label: nativeLabel.slice(0, 128) as PreviewAutomationHostLabel,66+ platform,67+ };68+ }
- apps/web/src/browser/browserRecording.ts lines 548 to 574Resolvedby Quicksaver(GitHub profile, opens in a new tab)@@ -489,0 +543,21 @@543+ error: unknown,544+): error is BrowserRecordingOperationError =>545+ isBrowserRecordingOperationError(error) && error.operation === "stop-deadline";546+547+const isDesktopRecordingTimeout = (error: unknown): boolean => {548+ const seen = new Set<object>();549+ let current = error;550+ while (current && typeof current === "object" && !seen.has(current)) {551+ seen.add(current);552+ if (553+ ("_tag" in current &&554+ (current as { readonly _tag?: unknown })._tag === "PreviewAutomationTimeoutError") ||555+ ("name" in current &&556+ (current as { readonly name?: unknown }).name === "PreviewAutomationTimeoutError")557+ ) {558+ return true;559+ }560+ current = "cause" in current ? (current as { readonly cause?: unknown }).cause : undefined;561+ }562+ return false;563+};apps/web/src/browser/browserRecording.ts lines 1096 to 1103Resolvedby Quicksaver(GitHub profile, opens in a new tab)@@ -824,5 +1073,20 @@1073+ return awaitWithinRecordingStopDeadline(recording.lifecycle.stopPromise, deadline, tabId).then(1074+ (artifact) => {1075+ if (!recording.retainForUpload) clearActiveRecording(recording);1076+ return artifact;1077+ },1078+ );1079+ }8241080 if (recording.lifecycle.phase === "starting") recording.lifecycle.cancelBeforeGrant();82510818261082 const stopPromise = Promise.resolve()827- .then(() => finalizeBrowserRecording(bridge, recording))1083+ .then(() => finalizeBrowserRecording(bridge, recording, deadline))8281084 .catch((error) => {1085+ if (1086+ isBrowserRecordingStopDeadlineError(error) &&1087+ activeRecordings.get(recording.tabId) === recording &&1088+ recording.lifecycle.phase === "stopping" &&1089+ recording.lifecycle.stopPromise === stopPromise1090+ ) {1091+ recording.lifecycle = { phase: "recording" };1092+ }apps/web/src/components/preview/previewHostRendering.ts lines 31 to 35Resolvedby Quicksaver(GitHub profile, opens in a new tab)@@ -0,0 +10,21 @@10+/**11+ * Probes whether the host window is painting. There is no continuous timer:12+ * one animation frame is requested only while a status or snapshot request13+ * needs the answer, and the losing side of the race is cancelled.14+ */15+export const measurePreviewHostRendering = (16+ boundMs = PREVIEW_HOST_RENDERING_PROBE_MS,17+): Promise<PreviewAutomationHostRendering> =>18+ new Promise((resolve) => {19+ let frameId: number | null = null;20+ let timer: ReturnType<typeof globalThis.setTimeout> | null = null;21+ frameId = globalThis.requestAnimationFrame(() => {22+ frameId = null;23+ if (timer !== null) globalThis.clearTimeout(timer);24+ resolve("active");25+ });26+ timer = globalThis.setTimeout(() => {27+ timer = null;28+ if (frameId !== null) globalThis.cancelAnimationFrame(frameId);29+ resolve("paused");30+ }, boundMs);@@ -0,0 +47,21 @@47+48+Upstream commit `6c69534a58` (`fix(preview): render website favicons for browser tool activity`) owns website tool icons, their response schemas, and capturing the operation's tab before a concurrent request changes the current target. The branch preserves that presentation metadata while carrying caller timeouts for input and evaluation operations. Optional favicon status lookup consumes only the original operation's remaining deadline, capped at 500 milliseconds, and is skipped when no time remains. An unavailable or timed-out metadata lookup preserves the completed operation result. The broker and handler share the same default operation timeout so omitted caller timeouts have the same bound.49+50+Upstream commit `55c24273a0` (`fix(desktop): align preview recording cursors and show input feedback`) owns recording input decorations and the renderer compositor. The branch includes compositor initialization in the recording startup deadline and aborts pending initialization at expiry, releasing its input listener, frame callback, and canvas capture tracks before playback settles. Late initialization results cannot revive that compositor or disturb a newer recording. Desktop recording-controller notifications remain synchronous with state changes while renderer state listeners remain outside bounded finalization.51+52+Upstream commit `894d33419d` (`fix(preview): use the visible browser for new agent sessions`) owns preferring the visible target tab's host when a provider session has no assignment. The branch retains explicit stable-host selection and reconnect recovery ahead of that implicit routing policy. Upstream commit `4f27a84631` (`fix(mcp): preview snapshots fit in the agent's tool output again`) owns compact saved-image responses and bounded snapshot text; the branch preserves semantic-only output when no screenshot exists.53+54+This branch does not add a second recording/PiP capture lifecycle or another hidden-preview lifetime mechanism. In `apps/desktop/src/preview/Manager.ts`, upstream's `frameCaptureSessionsRef` owns sustained recording/PiP lifetime and background-throttling policy; upstream recording frames now come from the renderer's display-media stream, while picture-in-picture retains the native frame loop. One-shot automation snapshots never enter that registry. The branch's remaining background-specific code is limited to bounded, one-shot automation snapshots. That distinction is necessary: a fresh offscreen guest did not produce a frame or settle recording startup within eight seconds, while staging the same guest at effectively transparent opacity produced a complete screenshot and semantic snapshot in under 100 milliseconds. The sustained capture paths therefore do not replace the automation snapshot presentation lease, exact-target CDP capture, request deadline propagation, or nullable semanti55+56+Expected behavior:57+58+MCP native caller metadata separates host and current-tab selection within an inherited credential. It is a bounded namespace, never a T3 thread selector: every tab stays under the credential-owned main conversation, with creator and host attribution. New contexts open their own tabs; human selection and sibling defaults cannot retarget them. Explicit `tabId` remains the deliberate sharing mechanism. Providers that omit native caller metadata retain one shared default context per credential. This path has no Magi or projected-subagent dependency.59+The WebSocket client delivers independent RPC requests concurrently while retaining per-request ordering and ACK backpressure. A paused subscription cannot block preview requests, responses, stream completion, or reconnect registration behind its receive queue. Connection failure interrupts pending delivery; timed-out browser actions are never replayed.60+Every Electron automation operation has a bounded control-session lifetime. The desktop manager reserves response grace inside the requested timeout without making the execution budget shrink when the caller increases a short timeout, always finalizes controller and action-timeline state, and detaches a timed-out debugger session while still holding an acquired control permit when a CDP command may be pending. Finalization commits the controller reset before responding but delivers that state notification separately under manager scope, so a stalled listener cannot withhold the bounded response. Timeout errors retain the failed operation or capture stage, so caller-visible diagnostics and action-timeline entries identify the work that stalled. Session removal and debugger teardown are atomic with respect to new session acquisition and bound to the exact acquired session, so late interruption or snapshot cleanup cannot detach a healthy replacement. Operations already queued on the ret61+Click, type, press, scroll, evaluate, and wait operations carry their caller-supplied timeout through the MCP broker, clamp it to the remaining renderer host budget after readiness, and enter the desktop control-session boundary with that remaining value. Color-scheme changes and recording startup likewise receive the remaining deadline after overlay readiness; bounded and unbounded appearance mutations serialize per tab so live CDP state and persisted tab state cannot diverge, a timed-out color-scheme command does not persist a late preference, and timed-out recording startup observes cleanup only inside its reserved response grace while allowing an already-started cleanup to finish under manager scope. Timed appearance persistence re-reads current tab state after CDP settles and retries against the current guest if replacement rejects the stale guest's command. Recording stop bounds desktop capture shutdown, MediaRecorder settlement, blob conversion, and artifact persistence to the62+`stopBrowserRecordingForUpload` in `apps/web/src/browser/browserRecording.ts` retains the saved blob, artifact, and recording slot until a transfer result reaches a caller within its deadline. A failed upload can be retried without saving the file again. A retry joins an unsettled upload; if that transfer rejects because its original request deadline expired, a caller with remaining budget starts or joins one fresh transfer using its own deadline. If an upload succeeds after its caller times out, the next stop request receives that same attachment result. Native media tracks and browser-surface activity are released before upload, so retaining retry state does not keep capture running. A local Stop, including tab disposal through `desktopTabLifetime.ts`, can release retained transfer state and return the saved desktop artifact. `PreviewAutomationHosts.tsx` supplies the remaining stop budget and the shared operation deadline; `browserRecordingUpload.ts` uses that deadline without rese63+Snapshot collection captures every screenshot with `webContents.capturePage` on the desktop's serialized native-capture queue: `stayHidden: true` for a background guest, normal visible-page capture for the foreground. CDP `Page.captureScreenshot` is not used. For an unselected tab, the renderer stages the still-mounted guest at effectively transparent opacity for two compositor frames, but only for the snapshot itself, and the desktop manager never focuses the guest or calls `Page.bringToFront`; either activation call can make Electron promote the native guest over the host window and keep the T3 interface covered after staging ends. The screenshot wait is clamped to the remaining control-session deadline with settlement grace reserved, so a tight caller deadline still returns semantic data instead of being preempted by the outer session timeout. Every returned PNG, including resized output, is validated and bounded. When no PNG exists the snapshot returns `screenshot: null` together64+The desktop manager keeps the display awake while one-shot automation is live. `apps/desktop/src/preview/Manager.ts` holds at most one Electron `powerSaveBlocker` of type `prevent-display-sleep`: it starts on the first automation request (status, any control-session action, recording start or stop), which is how every automation flow begins, and every later request refreshes an activity timestamp. A tab counts as an automation tab only after an automation request targets it, so a tab a human opened and drove never holds the block; the desktop does not receive the server's `automationOrigin`, and this definition needs no extra plumbing. The block is released after `AUTOMATION_DISPLAY_WAKE_INACTIVITY_MS` (five minutes) without automation traffic, when the last automation tab closes, or on manager shutdown, whichever comes first; start and release are idempotent and logged at debug level with their reason. `preview_status` reports `displaySleepBlocked` next to `hostRendering`. This is s65+`apps/web/src/components/preview/previewHostRendering.ts` probes whether the host window is painting by racing one `requestAnimationFrame` against a 500 ms bound; there is no continuous timer, and the losing side is cancelled. `preview_status` reports the result as `hostRendering: "active" | "paused"` only when the request budget leaves at least twice the probe, so the 500 ms favicon status lookup behind every action never pays for it, and `preview_snapshot` attaches it to `screenshotUnavailable` after the presentation lease is released. The MCP snapshot response states the stage, the host's message, and the liveness result in its text, so an agent can tell that the host renderer is not painting (display off, hidden window) rather than that capture is broken.66+Desktop preview guests following the system color scheme create their CDP debugger session lazily, with initialization included in the automation operation deadline. This prevents an offscreen Chromium guest from leaving `Runtime.enable` pending while holding the synchronized session lock, which previously made every later evaluation or snapshot against that tab time out even after it became presentable. `apps/web/src/browser/desktopTabLifetime.ts` passes the upstream browser appearance default through `DesktopPreviewCreateTabInputSchema` in `packages/contracts/src/ipc.ts`; `apps/desktop/src/preview/Manager.ts` normalizes that value. Its `reconcileRegisteredGuestState` reasserts current zoom and native mute state after attachment without opening a CDP session; a guest disappearing during the best-effort mute reassert does not fail registration. Only a non-system color-scheme override starts the separately bounded `restoreControlSession` recovery path after webview registration, while67+Building on upstream's retained hidden guest, automation background snapshot presentation is reference-counted independently from the normal surface lease and composes with upstream's fitted-source content and corner-radius presentation. `PreviewAutomationHosts.tsx` passes the epoch-scoped runtime tab id into `previewAutomationPresentation.ts`; every surface lookup, staging marker, readiness check, diagnostic read, lease, and desktop capture targets that exact runtime guest, while selection and errors retain the stable server tab id. The presentation helper API has no state-derived or server-id compatibility fallback. Only a one-shot automation snapshot acquires this lease; upstream recording and picture-in-picture continue to use their shared frame-capture lifecycle, while navigation, color-scheme changes, evaluation, waits, and input operations do not acquire an automation presentation lease. Staging always restores the offscreen position and does not change the human-selected surfpackages/contracts/src/ipc.ts lines 1114 to 1119Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1082,3 +1111,9 @@10821111 tabId: DesktopPreviewTabIdSchema,10831112 mimeType: Schema.String.check(Schema.isTrimmed()).check(Schema.isNonEmpty()),10841113 data: Schema.Uint8Array,1114+ idempotencyKey: Schema.String.check(1115+ Schema.isTrimmed(),1116+ Schema.isNonEmpty(),1117+ Schema.isMaxLength(128),1118+ Schema.isPattern(/^[a-z0-9-]+$/i),1119+ ),
Quicksaver(GitHub profile, opens in a new tab) changed the title
- @@ -0,0 +42,21 @@42+Upstream commit `de1b798c6e` (`fix(preview): bound automation waits and screenshot captures`) owns transient native screenshot retries and an initial bound on host readiness. The branch retains its end-to-end remaining-budget propagation and semantic-only snapshot fallback. Its request-consumer and overlay-readiness helpers own deadline enforcement without a separate host-budget policy. Manual screenshot retries use the branch's serialized native-capture queue and stop immediately when that exact guest is retired, replaced, or blocked by an unsettled timed-out capture.43+44+Upstream commit `8bbe2bf660` (`feat(web): float device streams over chat`) owns the floating player source union for browser tabs and device streams. The branch uses the browser-specific selector and source constructor in `HostedBrowserWebview.tsx`, `PreviewAutomationHosts.tsx`, and `previewAutomationPresentation.ts`. Its visibility checks, explicit background suppression, and selection recovery therefore continue to target browser tabs without treating an unrelated device stream as that browser's presentation.45+46+Upstream commit `e816064945` (`fix(desktop): keep preview keystrokes out of the composer`) owns keyboard target resolution and native Windows guest input routing. The branch passes its control-epoch check through the bounded control-session callback to that keyboard path, alongside the operation deadline and exact-session reset. Keyboard focus timeout errors carry the branch-required operation metadata, and a timed-out operation still releases control so later input or evaluation can recover.47+48+Upstream commit `6c69534a58` (`fix(preview): render website favicons for browser tool activity`) owns website tool icons, their response schemas, and capturing the operation's tab before a concurrent request changes the current target. The branch preserves that presentation metadata while carrying caller timeouts for input and evaluation operations. Optional favicon status lookup consumes only the original operation's remaining deadline, capped at 500 milliseconds, and is skipped when no time remains. An unavailable or timed-out metadata lookup preserves the completed operation result. The broker and handler share the same default operation timeout so omitted caller timeouts have the same bound.49+50+Upstream commit `55c24273a0` (`fix(desktop): align preview recording cursors and show input feedback`) owns recording input decorations and the renderer compositor. The branch includes compositor initialization in the recording startup deadline and aborts pending initialization at expiry, releasing its input listener, frame callback, and canvas capture tracks before playback settles. Late initialization results cannot revive that compositor or disturb a newer recording. Desktop recording-controller notifications remain synchronous with state changes while renderer state listeners remain outside bounded finalization.51+52+Upstream commit `894d33419d` (`fix(preview): use the visible browser for new agent sessions`) owns preferring the visible target tab's host when a provider session has no assignment. The branch retains explicit stable-host selection and reconnect recovery ahead of that implicit routing policy. Upstream commit `4f27a84631` (`fix(mcp): preview snapshots fit in the agent's tool output again`) owns compact saved-image responses and bounded snapshot text; the branch preserves semantic-only output when no screenshot exists.53+54+Upstream's `frameCaptureSessionsRef` in `apps/desktop/src/preview/Manager.ts` continues to own sustained recording/PiP capture. Bounded automation operations temporarily disable host-window background throttling and share that registry's synchronization, so concurrent actions and recording/PiP shutdown cannot suspend each other. Native input and screenshots wait for the host to commit a frame after waking; screenshot preparation stays inside the screenshot budget so semantic snapshots and evaluation remain available when rendering cannot resume. The last operation restores throttling unless a sustained capture still needs it. This does not show or focus a window, focus a guest, or start another capture loop. The renderer's one-shot snapshot staging remains necessary to expose an inactive guest's pixels without changing human selection.55+56+Expected behavior:57+58+MCP native caller metadata separates host and current-tab selection within an inherited credential. It is a bounded namespace, never a T3 thread selector: every tab stays under the credential-owned main conversation, with creator and host attribution. New contexts open their own tabs; human selection and sibling defaults cannot retarget them. Explicit `tabId` remains the deliberate sharing mechanism. Providers that omit native caller metadata retain one shared default context per credential. This path has no Magi or projected-subagent dependency.59+The WebSocket client delivers independent RPC requests concurrently while retaining per-request ordering and ACK backpressure. A paused subscription cannot block preview requests, responses, stream completion, or reconnect registration behind its receive queue. Connection failure interrupts pending delivery; timed-out browser actions are never replayed.60+Every Electron automation operation has a bounded control-session lifetime. The desktop manager reserves response grace inside the requested timeout without making the execution budget shrink when the caller increases a short timeout, always finalizes controller and action-timeline state, and detaches a timed-out debugger session while still holding an acquired control permit when a CDP command may be pending. Finalization commits the controller reset before responding but delivers that state notification separately under manager scope, so a stalled listener cannot withhold the bounded response. Timeout errors retain the failed operation or capture stage, so caller-visible diagnostics and action-timeline entries identify the work that stalled. Session removal and debugger teardown are atomic with respect to new session acquisition and bound to the exact acquired session, so late interruption or snapshot cleanup cannot detach a healthy replacement. Operations already queued on the ret61+Click, type, press, scroll, evaluate, and wait operations carry their caller-supplied timeout through the MCP broker, clamp it to the remaining renderer host budget after readiness, and enter the desktop control-session boundary with that remaining value. Color-scheme changes and recording startup likewise receive the remaining deadline after overlay readiness; bounded and unbounded appearance mutations serialize per tab so live CDP state and persisted tab state cannot diverge, a timed-out color-scheme command does not persist a late preference, and timed-out recording startup observes cleanup only inside its reserved response grace while allowing an already-started cleanup to finish under manager scope. Timed appearance persistence re-reads current tab state after CDP settles and retries against the current guest if replacement rejects the stale guest's command. Recording stop bounds desktop capture shutdown, MediaRecorder settlement, blob conversion, and artifact persistence to the62+`stopBrowserRecordingForUpload` in `apps/web/src/browser/browserRecording.ts` retains the saved blob, artifact, and recording slot until a transfer result reaches a caller within its deadline. A failed upload can be retried without saving the file again. A retry joins an unsettled upload; if that transfer rejects because its original request deadline expired, a caller with remaining budget starts or joins one fresh transfer using its own deadline. If an upload succeeds after its caller times out, the next stop request receives that same attachment result. Native media tracks and browser-surface activity are released before upload, so retaining retry state does not keep capture running. A local Stop, including tab disposal through `desktopTabLifetime.ts`, can release retained transfer state and return the saved desktop artifact. `PreviewAutomationHosts.tsx` supplies the remaining stop budget and the shared operation deadline; `browserRecordingUpload.ts` uses that deadline without rese
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed