Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(preview): keep browsers that answer at their own deadline #15338

ClosedPixPMusic(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/15338/headopened View on GitHub

Showing 4 changed files with 145 additions and 5 deletions (loading 1).

x
0 of 4 viewed, 4 left
9 additions and 2 deletionsapps/server/src/mcp/toolkits/preview/handlers.tsModified
View file
@@ -1,5 +1,6 @@
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
+import * as Option from "effect/Option";
import * as Schema from "effect/Schema";
import {
PROVIDER_SEND_TURN_MAX_FILE_BYTES,
@@ -78,16 +79,22 @@
(operation !== "evaluate" && typeof result === "object" && result !== null
? (result as { tabId?: PreviewTabId }).tabId
: undefined) ?? targetTabId;
+ // Best-effort page metadata for the tool icon. Bound only our wait: an
+ // abandoned request leaves the host assigned, while a broker timeout would
+ // evict a healthy host over missing metadata.
const page = yield* broker
.invoke<PreviewAutomationStatus>({
scope,
operation: "status",
input: {},
- timeoutMs: 500,
updateCurrentTab: false,
...(statusTabId === undefined ? {} : { tabId: statusTabId }),
})
- .pipe(Effect.orElseSucceed(() => null));
+ .pipe(
+ Effect.timeoutOption(500),
+ Effect.map(Option.getOrNull),
+ Effect.orElseSucceed(() => null),
+ );
return {