From e19104e9c861731fb1edd16600ef516dcd38c2c7 Mon Sep 17 00:00:00 2001 From: Ariel Weinberger Date: Sun, 20 Jul 2025 18:05:44 -0500 Subject: [PATCH] auto start existing sandbox when it exists --- ai-service/src/handlers/conversation.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ai-service/src/handlers/conversation.ts b/ai-service/src/handlers/conversation.ts index 99da146af..0f77a8663 100644 --- a/ai-service/src/handlers/conversation.ts +++ b/ai-service/src/handlers/conversation.ts @@ -1,5 +1,5 @@ import { daytona } from "@/lib/daytona-client"; -import { getArtifactSandbox } from "@/lib/daytona-utils"; +import { getArtifactSandbox, startDevServer } from "@/lib/daytona-utils"; import { convertDBMessagesToImagineUIMessages, getOrCreateConversation } from "@/lib/message-history"; import { prisma } from "@/lib/prisma"; import { ImagineUIMessage } from "@/shared-types"; @@ -35,6 +35,16 @@ export const getConversation = async (c: Context) => { const sandbox = await getArtifactSandbox({ artifactId: conversationId }); if (sandbox) { + console.log("Sandbox id", sandbox.id); + + if (sandbox.state === "stopped") { + await sandbox.start(); + await startDevServer({ + sandbox, + onStepUpdate: () => {} + }); + } + const previewLinkResult = await sandbox.getPreviewLink(3000); previewUrl = previewLinkResult.url; }