diff --git a/packages/server-contract/src/api/thread-tabs.ts b/packages/server-contract/src/api/thread-tabs.ts index 13cc3a47a..17f4082b8 100644 --- a/packages/server-contract/src/api/thread-tabs.ts +++ b/packages/server-contract/src/api/thread-tabs.ts @@ -31,12 +31,61 @@ const threadTabEnvironmentFileSourceSchema = z.discriminatedUnion("kind", [ .strict(), ]); +// A plugin file-opener tab (see apps/app file-opener-tabs.ts) retains the +// native preview it diverted (passed to the opener as experimental_Original). +// Present only on opener tabs; plain plugin-panel action tabs omit it. +const threadTabFileOpenerOwnerSchema = z.discriminatedUnion("kind", [ + z + .object({ + kind: z.literal("workspace-file-preview"), + environmentId: z.string().min(1).nullable(), + projectId: z.string().min(1).nullable(), + tab: z + .object({ + lineRange: threadTabLineRangeSchema.nullable(), + path: threadTabPathSchema, + source: threadTabEnvironmentFileSourceSchema, + statusLabel: z.literal("deleted").nullable(), + }) + .strict(), + threadId: z.string().min(1).nullable(), + }) + .strict(), + z + .object({ + kind: z.literal("host-file-preview"), + environmentId: z.string().min(1), + tab: z + .object({ + lineRange: threadTabLineRangeSchema.nullable(), + path: threadTabPathSchema, + }) + .strict(), + threadId: z.string().min(1), + }) + .strict(), + z + .object({ + kind: z.literal("thread-storage-file-preview"), + environmentId: z.string().min(1).nullable(), + tab: z + .object({ + lineRange: threadTabLineRangeSchema.nullable(), + path: threadTabPathSchema, + }) + .strict(), + threadId: z.string().min(1), + }) + .strict(), +]); + export const threadTabSchema = z.discriminatedUnion("kind", [ z.object({ id: threadTabIdSchema, kind: z.literal("thread-info") }).strict(), z.object({ id: threadTabIdSchema, kind: z.literal("git-diff") }).strict(), z .object({ actionId: z.string().min(1).max(THREAD_TAB_PATH_MAX_LENGTH), + fileOpenerOwner: threadTabFileOpenerOwnerSchema.optional(), id: threadTabIdSchema, kind: z.literal("plugin-panel"), paramsJson: z.string().max(THREAD_TAB_PARAMS_MAX_LENGTH).nullable(),