feat: add dev-server preview system with proxy, file serving, and HTML artifact preview

Adds a full dev-server preview system including:
- Backend proxy/upgrade handler for dev server traffic
- File-serving backend route with CSP headers
- DevServerPreviewButton and HtmlArtifactPanel components
- HTML artifact detection and preview in messages
- File preview improvements with mobile support
- Shared types and settings schema for dev server config
- Comprehensive test coverage for all new code
This commit is contained in:
Chris Scott committed 2026-06-21 14:37:53 -04:00
1 parent 71ba7371bc
commit 9afd5f04d5
57 files changed
+3464 -184

No files matched your search

@@ -0,0 +1,44 @@
import { useMutation } from '@tanstack/react-query'
import { getDevServerStatus, getDevPreviewUrl } from '@/api/devServer'
import { Button } from '@/components/ui/button'
import { showToast } from '@/lib/toast'
import { Loader2, Play } from 'lucide-react'
import type { OpenHtmlArtifactInput } from '@/lib/htmlArtifacts'
interface DevServerPreviewButtonProps {
repoId: number
onOpen: (input: OpenHtmlArtifactInput) => void
}
export function DevServerPreviewButton({ repoId, onOpen }: DevServerPreviewButtonProps) {
const { mutate, isPending } = useMutation({
mutationFn: () => getDevServerStatus(repoId),
onSuccess: (state) => {
if (state.status !== 'running') {
showToast.error(`No app detected on localhost:${state.port}`)
return
}
onOpen({
source: 'devserver',
previewUrl: getDevPreviewUrl(repoId),
title: 'App preview',
})
},
onError: () => {
showToast.error('Failed to check preview port')
},
})
return (
<Button
variant="ghost"
size="sm"
onClick={() => mutate()}
disabled={isPending}
aria-label="Open app preview"
>
{isPending ? <Loader2 className="size-4 animate-spin" /> : <Play className="size-4" />}
</Button>
)
}