fix daytona sandbox url

This commit is contained in:
marko-kraemer 2025-04-21 13:00:31 +01:00
parent ddc4887627
commit b71762bafd
3 changed files with 29 additions and 7 deletions

View File

@ -299,12 +299,29 @@ async def start_agent(
sandbox = create_sandbox(sandbox_pass)
logger.info(f"Created new sandbox with preview: {sandbox.get_preview_link(6080)}/vnc_lite.html?password={sandbox_pass}")
sandbox_id = sandbox.id
# Get preview links
vnc_link = sandbox.get_preview_link(6080)
website_link = sandbox.get_preview_link(8080)
# Extract the actual URLs and token from the preview link objects
vnc_url = vnc_link.url if hasattr(vnc_link, 'url') else str(vnc_link).split("url='")[1].split("'")[0]
website_url = website_link.url if hasattr(website_link, 'url') else str(website_link).split("url='")[1].split("'")[0]
# Extract token if available
token = None
if hasattr(vnc_link, 'token'):
token = vnc_link.token
elif "token='" in str(vnc_link):
token = str(vnc_link).split("token='")[1].split("'")[0]
await client.table('projects').update({
'sandbox': {
'id': sandbox_id,
'pass': sandbox_pass,
'vnc_preview': str(sandbox.get_preview_link(6080)),
'sandbox_url': str(sandbox.get_preview_link(8080))
'vnc_preview': vnc_url,
'sandbox_url': website_url,
'token': token
}
}).eq('project_id', project_id).execute()

View File

@ -152,10 +152,15 @@ class SandboxToolsBase(Tool):
logger.error(f"Error retrieving sandbox: {str(e)}", exc_info=True)
raise e
# Get and log preview links
vnc_url = self.sandbox.get_preview_link(6080)
website_url = self.sandbox.get_preview_link(8080)
# Get preview links
vnc_link = self.sandbox.get_preview_link(6080)
website_link = self.sandbox.get_preview_link(8080)
# Extract the actual URLs from the preview link objects
vnc_url = vnc_link.url if hasattr(vnc_link, 'url') else str(vnc_link)
website_url = website_link.url if hasattr(website_link, 'url') else str(website_link)
# Log the actual URLs
logger.info(f"Sandbox VNC URL: {vnc_url}")
logger.info(f"Sandbox Website URL: {website_url}")

View File

@ -139,12 +139,12 @@ export function FileOperationToolView({
const isCsv = fileName.endsWith('.csv');
const language = getLanguageFromFileName(fileName);
const hasHighlighting = language !== 'text';
// Construct HTML file preview URL if we have a sandbox and the file is HTML
const htmlPreviewUrl = (isHtml && project?.sandbox?.sandbox_url && processedFilePath)
? `${project.sandbox.sandbox_url}/${processedFilePath}`
: undefined;
console.log('HTML Preview URL:', htmlPreviewUrl);
// Add state for view mode toggle (code or preview)
const [viewMode, setViewMode] = useState<'code' | 'preview'>(isHtml || isMarkdown || isCsv ? 'preview' : 'code');