mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Add comprehensive documentation and download feature (#83)
* fix: markdown files now default to rendered view and render properly - Add .md and .mdx MIME type support in backend (files.ts, defaults.ts) - Add key props to FilePreview components to force proper remounting when switching files - Fix markdown file detection with case-insensitive extension check - Reset markdownPreview state when file changes to ensure correct default view - Add onContentLoaded callback to VirtualizedTextView for reactive content updates - Add fullContent state to properly handle large markdown file rendering - Add error handling for async content loading to prevent blank screens - Reduce loading timeout from 50ms to 0ms for more responsive loading Fixes issues where: - Markdown files opened in raw view instead of rendered view - Large markdown files (12k+ lines) showed blank after loading completed - State persisted incorrectly when switching between different file types * Add directory download feature with ZIP archive support * Improve voice recording UX with loading states and better transcript handling * Fix auth config for prod/dev ports and add documentation Update AUTH_TRUSTED_ORIGINS and PASSKEY_ORIGIN to use backend port 5003 (frontend uses 5173 in dev). Add comprehensive auth documentation covering secrets, trusted origins, admin reset, and passkeys. Update README and add mkdocs config. * Remove roadmap section from README
This commit is contained in:
1 parent
358abbf20e
commit
da6cad8b3a
51 files changed
+4276
-353
No files matched your search
@@ -0,0 +1,112 @@
|
||||
import { useState } from 'react'
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Download, Loader2, Archive } from 'lucide-react'
|
||||
|
||||
interface DownloadDialogProps {
|
||||
open: boolean
|
||||
onOpenChange: (open: boolean) => void
|
||||
onDownload: () => Promise<void>
|
||||
title: string
|
||||
description: string
|
||||
itemName: string
|
||||
}
|
||||
|
||||
export function DownloadDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
onDownload,
|
||||
title,
|
||||
description,
|
||||
itemName,
|
||||
}: DownloadDialogProps) {
|
||||
const [isDownloading, setIsDownloading] = useState(false)
|
||||
const [isConfirmed, setIsConfirmed] = useState(false)
|
||||
|
||||
const handleConfirm = async () => {
|
||||
setIsConfirmed(true)
|
||||
setIsDownloading(true)
|
||||
try {
|
||||
await onDownload()
|
||||
} catch (error) {
|
||||
console.error('Download failed:', error)
|
||||
} finally {
|
||||
setIsDownloading(false)
|
||||
onOpenChange(false)
|
||||
setIsConfirmed(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleCancel = () => {
|
||||
if (isDownloading) return
|
||||
onOpenChange(false)
|
||||
setIsConfirmed(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={handleCancel}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="flex items-center gap-2">
|
||||
{isDownloading ? (
|
||||
<Loader2 className="w-5 h-5 animate-spin" />
|
||||
) : (
|
||||
<Archive className="w-5 h-5" />
|
||||
)}
|
||||
{title}
|
||||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="space-y-4 py-4">
|
||||
{!isDownloading && (
|
||||
<DialogDescription>
|
||||
{description}
|
||||
</DialogDescription>
|
||||
)}
|
||||
|
||||
<div className="flex items-center gap-3 p-3 bg-muted rounded-md">
|
||||
<Archive className="w-8 h-8 text-muted-foreground" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-sm font-medium">{isConfirmed ? 'Processing...' : itemName}</p>
|
||||
{isDownloading && (
|
||||
<p className="text-xs text-muted-foreground mt-1">
|
||||
Creating ZIP archive, please wait...
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{isDownloading && (
|
||||
<div className="space-y-2">
|
||||
<div className="h-2 bg-muted rounded-full overflow-hidden">
|
||||
<div className="h-full bg-primary animate-progress w-full" />
|
||||
</div>
|
||||
<p className="text-xs text-center text-muted-foreground">
|
||||
Download starting...
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<DialogFooter >
|
||||
{!isDownloading && !isConfirmed && (
|
||||
<div className='flex gap-2 w-full'>
|
||||
<Button variant="outline" onClick={handleCancel} className="flex-1">
|
||||
Cancel
|
||||
</Button>
|
||||
<Button onClick={handleConfirm} className="gap-2 flex-1">
|
||||
<Download className="w-4 h-4" />
|
||||
Download
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@@ -13,6 +13,7 @@ interface VirtualizedTextViewProps {
|
||||
className?: string
|
||||
initialLineNumber?: number
|
||||
lineWrap?: boolean
|
||||
onContentLoaded?: (content: string) => void
|
||||
}
|
||||
|
||||
export interface VirtualizedTextViewHandle {
|
||||
@@ -141,6 +142,7 @@ export const VirtualizedTextView = forwardRef<VirtualizedTextViewHandle, Virtual
|
||||
className = '',
|
||||
initialLineNumber,
|
||||
lineWrap = false,
|
||||
onContentLoaded,
|
||||
}, ref) {
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
const scrollTopRef = useRef(0)
|
||||
@@ -192,6 +194,12 @@ export const VirtualizedTextView = forwardRef<VirtualizedTextViewHandle, Virtual
|
||||
onSaveStateChange?.(hasUnsavedChanges)
|
||||
}, [hasUnsavedChanges, onSaveStateChange])
|
||||
|
||||
useEffect(() => {
|
||||
if (isFullyLoaded && fullContent && onContentLoaded) {
|
||||
onContentLoaded(fullContent)
|
||||
}
|
||||
}, [isFullyLoaded, fullContent, onContentLoaded])
|
||||
|
||||
useEffect(() => {
|
||||
loadedBufferRef.current = { start: 0, end: 0 }
|
||||
heightCacheRef.current.clear()
|
||||
|
||||
Reference in new issue
Block a user