fix(desktop): allow preview automation in agent-created threads (#8483)

This commit is contained in:
Theo Browne authored and GitHub committed 2026-08-27 22:29:30 -07:00
1 parent 850e4582e4
commit 2fbe313096
4 files changed
+54 -5

No files matched your search

@@ -1,4 +1,5 @@
import { it as effectIt } from "@effect/vitest";
import { PreviewAutomationStatus } from "@t3tools/contracts";
import * as Cause from "effect/Cause";
import * as Effect from "effect/Effect";
import * as Exit from "effect/Exit";
@@ -51,4 +52,46 @@ describe("preview IPC methods", () => {
},
),
);
effectIt.effect("returns automation status for long runtime tab ids", () =>
Effect.gen(function* () {
const tabId =
`["environment-1","thread:delegated-task:${"a".repeat(120)}",` +
`"server-epoch-1","preview-1"]`;
const status = {
available: false,
visible: true,
tabId,
url: null,
title: null,
loading: false,
};
const manager = PreviewManager.PreviewManager.of({
automationStatus: () => Effect.succeed(status),
} as unknown as PreviewManager.PreviewManager["Service"]);
expect(tabId.length).toBeGreaterThan(128);
expect(
yield* PreviewIpc.automationStatus
.handler({ tabId })
.pipe(Effect.provideService(PreviewManager.PreviewManager, manager)),
).toEqual(status);
}),
);
it("keeps the public automation status tab id limit", () => {
const encode = Schema.encodeUnknownSync(PreviewAutomationStatus);
const tabId = "t".repeat(129);
expect(() =>
encode({
available: false,
visible: true,
tabId,
url: null,
title: null,
loading: false,
}),
).toThrow();
});
});
+2 -2
View File
@@ -5,6 +5,7 @@ import {
DesktopPreviewAutomationEvaluateInputSchema,
DesktopPreviewAutomationPressInputSchema,
DesktopPreviewAutomationScrollInputSchema,
DesktopPreviewAutomationStatusSchema,
DesktopPreviewAutomationTypeInputSchema,
DesktopPreviewAutomationWaitForInputSchema,
DesktopPreviewConfigInputSchema,
@@ -20,7 +21,6 @@ import {
DesktopPreviewWebviewConfigSchema,
PreviewAnnotationSubmissionResultSchema,
PreviewAutomationSnapshot,
PreviewAutomationStatus,
} from "@t3tools/contracts";
import * as Effect from "effect/Effect";
import * as Schema from "effect/Schema";
@@ -282,7 +282,7 @@ export const copyArtifactToClipboard = DesktopIpc.makeIpcMethod({
export const automationStatus = DesktopIpc.makeIpcMethod({
channel: IpcChannels.PREVIEW_AUTOMATION_STATUS_CHANNEL,
payload: DesktopPreviewTabInputSchema,
result: PreviewAutomationStatus,
result: DesktopPreviewAutomationStatusSchema,
handler: Effect.fn("desktop.ipc.preview.automationStatus")(function* ({ tabId }) {
const manager = yield* PreviewManager.PreviewManager;
return yield* manager.automationStatus(tabId);
+2 -2
View File
@@ -7,6 +7,7 @@
*/
import type {
DesktopPreviewAnnotationTheme,
DesktopPreviewAutomationStatus,
DesktopPreviewColorScheme,
DesktopPreviewFavicon,
DesktopPreviewPointerEvent,
@@ -25,7 +26,6 @@ import type {
PreviewAutomationNetworkEntry,
PreviewAutomationScrollInput,
PreviewAutomationSnapshot,
PreviewAutomationStatus,
PreviewAutomationTypeInput,
PreviewAutomationWaitForInput,
} from "@t3tools/contracts";
@@ -4089,7 +4089,7 @@ export class PreviewManager extends Context.Service<
) => Effect.Effect<DesktopPreviewRecordingArtifact, PreviewManagerError>;
readonly automationStatus: (
tabId: string,
) => Effect.Effect<PreviewAutomationStatus, PreviewManagerError>;
) => Effect.Effect<DesktopPreviewAutomationStatus, PreviewManagerError>;
readonly automationSnapshot: (
tabId: string,
) => Effect.Effect<PreviewAutomationSnapshot, PreviewManagerError>;
+7 -1
View File
@@ -584,6 +584,12 @@ export const DesktopPreviewTabIdSchema = Schema.String.check(Schema.isTrimmed())
Schema.isNonEmpty(),
);
export const DesktopPreviewAutomationStatusSchema = Schema.Struct({
...PreviewAutomationStatus.fields,
tabId: Schema.NullOr(DesktopPreviewTabIdSchema),
});
export type DesktopPreviewAutomationStatus = typeof DesktopPreviewAutomationStatusSchema.Type;
export const DesktopPreviewNavStatusSchema = Schema.Union([
Schema.Struct({ kind: Schema.Literal("Idle") }),
Schema.Struct({
@@ -1217,7 +1223,7 @@ export interface DesktopPreviewBridge {
onFrame: (listener: (frame: DesktopPreviewRecordingFrame) => void) => () => void;
};
automation: {
status: (tabId: string) => Promise<PreviewAutomationStatus>;
status: (tabId: string) => Promise<DesktopPreviewAutomationStatus>;
snapshot: (tabId: string) => Promise<PreviewAutomationSnapshot>;
click: (tabId: string, input: PreviewAutomationClickInput) => Promise<void>;
type: (tabId: string, input: PreviewAutomationTypeInput) => Promise<void>;