@devries-cameron20 / t3code Mirror · read-only / commits / 2fbe313096
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 24, 14:00 UTC

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

Theo Browne committed Aug 27, 2026 at 22:29 UTC 2fbe313096b54a3422e101ed1bcc3589f6cf371c
4 files changed +54 -5
apps/desktop/src/ipc/methods/preview.test.ts
+43
@@ -1,4 +1,5 @@
1 import { it as effectIt } from "@effect/vitest";
2 +import { PreviewAutomationStatus } from "@t3tools/contracts";
3 import * as Cause from "effect/Cause";
4 import * as Effect from "effect/Effect";
5 import * as Exit from "effect/Exit";
@@ -51,4 +52,46 @@ describe("preview IPC methods", () => {
52 },
53 ),
54 );
55 +
56 + effectIt.effect("returns automation status for long runtime tab ids", () =>
57 + Effect.gen(function* () {
58 + const tabId =
59 + `["environment-1","thread:delegated-task:${"a".repeat(120)}",` +
60 + `"server-epoch-1","preview-1"]`;
61 + const status = {
62 + available: false,
63 + visible: true,
64 + tabId,
65 + url: null,
66 + title: null,
67 + loading: false,
68 + };
69 + const manager = PreviewManager.PreviewManager.of({
70 + automationStatus: () => Effect.succeed(status),
71 + } as unknown as PreviewManager.PreviewManager["Service"]);
72 +
73 + expect(tabId.length).toBeGreaterThan(128);
74 + expect(
75 + yield* PreviewIpc.automationStatus
76 + .handler({ tabId })
77 + .pipe(Effect.provideService(PreviewManager.PreviewManager, manager)),
78 + ).toEqual(status);
79 + }),
80 + );
81 +
82 + it("keeps the public automation status tab id limit", () => {
83 + const encode = Schema.encodeUnknownSync(PreviewAutomationStatus);
84 + const tabId = "t".repeat(129);
85 +
86 + expect(() =>
87 + encode({
88 + available: false,
89 + visible: true,
90 + tabId,
91 + url: null,
92 + title: null,
93 + loading: false,
94 + }),
95 + ).toThrow();
96 + });
97 });
apps/desktop/src/ipc/methods/preview.ts
+2 -2
@@ -5,6 +5,7 @@ import {
5 DesktopPreviewAutomationEvaluateInputSchema,
6 DesktopPreviewAutomationPressInputSchema,
7 DesktopPreviewAutomationScrollInputSchema,
8 + DesktopPreviewAutomationStatusSchema,
9 DesktopPreviewAutomationTypeInputSchema,
10 DesktopPreviewAutomationWaitForInputSchema,
11 DesktopPreviewConfigInputSchema,
@@ -20,7 +21,6 @@ import {
21 DesktopPreviewWebviewConfigSchema,
22 PreviewAnnotationSubmissionResultSchema,
23 PreviewAutomationSnapshot,
23 - PreviewAutomationStatus,
24 } from "@t3tools/contracts";
25 import * as Effect from "effect/Effect";
26 import * as Schema from "effect/Schema";
@@ -282,7 +282,7 @@ export const copyArtifactToClipboard = DesktopIpc.makeIpcMethod({
282 export const automationStatus = DesktopIpc.makeIpcMethod({
283 channel: IpcChannels.PREVIEW_AUTOMATION_STATUS_CHANNEL,
284 payload: DesktopPreviewTabInputSchema,
285 - result: PreviewAutomationStatus,
285 + result: DesktopPreviewAutomationStatusSchema,
286 handler: Effect.fn("desktop.ipc.preview.automationStatus")(function* ({ tabId }) {
287 const manager = yield* PreviewManager.PreviewManager;
288 return yield* manager.automationStatus(tabId);
apps/desktop/src/preview/Manager.ts
+2 -2
@@ -7,6 +7,7 @@
7 */
8 import type {
9 DesktopPreviewAnnotationTheme,
10 + DesktopPreviewAutomationStatus,
11 DesktopPreviewColorScheme,
12 DesktopPreviewFavicon,
13 DesktopPreviewPointerEvent,
@@ -25,7 +26,6 @@ import type {
26 PreviewAutomationNetworkEntry,
27 PreviewAutomationScrollInput,
28 PreviewAutomationSnapshot,
28 - PreviewAutomationStatus,
29 PreviewAutomationTypeInput,
30 PreviewAutomationWaitForInput,
31 } from "@t3tools/contracts";
@@ -4089,7 +4089,7 @@ export class PreviewManager extends Context.Service<
4089 ) => Effect.Effect<DesktopPreviewRecordingArtifact, PreviewManagerError>;
4090 readonly automationStatus: (
4091 tabId: string,
4092 - ) => Effect.Effect<PreviewAutomationStatus, PreviewManagerError>;
4092 + ) => Effect.Effect<DesktopPreviewAutomationStatus, PreviewManagerError>;
4093 readonly automationSnapshot: (
4094 tabId: string,
4095 ) => Effect.Effect<PreviewAutomationSnapshot, PreviewManagerError>;
packages/contracts/src/ipc.ts
+7 -1
@@ -584,6 +584,12 @@ export const DesktopPreviewTabIdSchema = Schema.String.check(Schema.isTrimmed())
584 Schema.isNonEmpty(),
585 );
586
587 +export const DesktopPreviewAutomationStatusSchema = Schema.Struct({
588 + ...PreviewAutomationStatus.fields,
589 + tabId: Schema.NullOr(DesktopPreviewTabIdSchema),
590 +});
591 +export type DesktopPreviewAutomationStatus = typeof DesktopPreviewAutomationStatusSchema.Type;
592 +
593 export const DesktopPreviewNavStatusSchema = Schema.Union([
594 Schema.Struct({ kind: Schema.Literal("Idle") }),
595 Schema.Struct({
@@ -1217,7 +1223,7 @@ export interface DesktopPreviewBridge {
1223 onFrame: (listener: (frame: DesktopPreviewRecordingFrame) => void) => () => void;
1224 };
1225 automation: {
1220 - status: (tabId: string) => Promise<PreviewAutomationStatus>;
1226 + status: (tabId: string) => Promise<DesktopPreviewAutomationStatus>;
1227 snapshot: (tabId: string) => Promise<PreviewAutomationSnapshot>;
1228 click: (tabId: string, input: PreviewAutomationClickInput) => Promise<void>;
1229 type: (tabId: string, input: PreviewAutomationTypeInput) => Promise<void>;