mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
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:
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>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user