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
@@ -42,4 +42,24 @@ export async function applyFilePatches(path: string, patches: PatchOperation[]):
|
||||
}
|
||||
|
||||
return response.json()
|
||||
}
|
||||
|
||||
export async function downloadDirectoryAsZip(path: string): Promise<void> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/files/${path}/download-zip`)
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
throw new Error(error.error || 'Failed to download directory')
|
||||
}
|
||||
|
||||
const blob = await response.blob()
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
const dirName = path.split('/').pop() || 'download'
|
||||
a.download = `${dirName}.zip`
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
window.URL.revokeObjectURL(url)
|
||||
}
|
||||
@@ -534,7 +534,7 @@ useEffect(() => {
|
||||
{!isMobile && (
|
||||
<div className="flex-1 overflow-y-auto min-h-0 h-full">
|
||||
{selectedFile && !selectedFile.isDirectory ? (
|
||||
<FilePreview file={selectedFile} />
|
||||
<FilePreview key={selectedFile.path} file={selectedFile} />
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-full text-muted-foreground">
|
||||
Select a file to preview
|
||||
@@ -633,7 +633,7 @@ useEffect(() => {
|
||||
{!isMobile && (
|
||||
<div className="flex-1 overflow-y-auto min-h-0 ">
|
||||
{selectedFile && !selectedFile.isDirectory ? (
|
||||
<FilePreview file={selectedFile} />
|
||||
<FilePreview key={selectedFile.path} file={selectedFile} />
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-64 text-muted-foreground">
|
||||
Select a file to preview
|
||||
|
||||
@@ -3,23 +3,35 @@ import { FileBrowser } from './FileBrowser'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { PathDisplay } from '@/components/ui/path-display'
|
||||
import { FullscreenSheet, FullscreenSheetHeader, FullscreenSheetContent } from '@/components/ui/fullscreen-sheet'
|
||||
import { X } from 'lucide-react'
|
||||
import { DownloadDialog } from '@/components/ui/download-dialog'
|
||||
import { X, Download } from 'lucide-react'
|
||||
import { GPU_ACCELERATED_STYLE, MODAL_TRANSITION_MS } from '@/lib/utils'
|
||||
import { useSwipeBack } from '@/hooks/useMobile'
|
||||
import { downloadDirectoryAsZip } from '@/api/files'
|
||||
import { downloadRepo } from '@/api/repos'
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu'
|
||||
|
||||
interface FileBrowserSheetProps {
|
||||
isOpen: boolean
|
||||
onClose: () => void
|
||||
basePath?: string
|
||||
repoName?: string
|
||||
repoId?: number
|
||||
initialSelectedFile?: string
|
||||
}
|
||||
|
||||
export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose, basePath = '', repoName, initialSelectedFile }: FileBrowserSheetProps) {
|
||||
export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose, basePath = '', repoName, repoId, initialSelectedFile }: FileBrowserSheetProps) {
|
||||
const normalizedBasePath = basePath || '.'
|
||||
const [isEditing, setIsEditing] = useState(false)
|
||||
const [displayPath, setDisplayPath] = useState<string>('/')
|
||||
const [shouldRender, setShouldRender] = useState(false)
|
||||
const [currentPath, setCurrentPath] = useState<string>(basePath || '.')
|
||||
const [downloadDialog, setDownloadDialog] = useState<{ type: 'directory' | 'repository' } | null>(null)
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
const { bind, swipeStyles } = useSwipeBack(onClose, {
|
||||
@@ -42,11 +54,14 @@ export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose
|
||||
const handleDirectoryLoad = useCallback((info: { workspaceRoot?: string; currentPath: string }) => {
|
||||
if (!info.currentPath || info.currentPath === '.' || info.currentPath === '') {
|
||||
setDisplayPath('/')
|
||||
setCurrentPath(basePath || '.')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
setCurrentPath(info.currentPath)
|
||||
|
||||
const pathParts = info.currentPath.split('/').filter(Boolean)
|
||||
|
||||
|
||||
if (repoName) {
|
||||
const repoIndex = pathParts.findIndex(p => p === repoName || p.startsWith(repoName + '-'))
|
||||
if (repoIndex >= 0) {
|
||||
@@ -58,7 +73,21 @@ export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose
|
||||
} else {
|
||||
setDisplayPath('/' + pathParts.join('/'))
|
||||
}
|
||||
}, [repoName])
|
||||
}, [repoName, basePath])
|
||||
|
||||
const handleDownloadDirectory = useCallback(async () => {
|
||||
if (!currentPath) return
|
||||
await downloadDirectoryAsZip(currentPath)
|
||||
}, [currentPath])
|
||||
|
||||
const handleDownloadRepo = useCallback(async () => {
|
||||
if (!repoId || !repoName) return
|
||||
await downloadRepo(repoId, repoName)
|
||||
}, [repoId, repoName])
|
||||
|
||||
const handleOpenDownloadDialog = (type: 'directory' | 'repository') => {
|
||||
setDownloadDialog({ type })
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const handleEscape = (e: KeyboardEvent) => {
|
||||
@@ -98,30 +127,55 @@ export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose
|
||||
>
|
||||
<FullscreenSheet style={{ ...GPU_ACCELERATED_STYLE, ...swipeStyles }}>
|
||||
<FullscreenSheetHeader className="px-4 py-1">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
{(displayPath === '/' || !repoName) && (
|
||||
<h1 className="text-sm font-semibold text-foreground">
|
||||
{repoName || 'Workspace Files'}
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-2 min-w-0 flex-1 overflow-hidden">
|
||||
{(displayPath === '/' || !repoName) && repoName && (
|
||||
<h1 className="text-sm font-semibold text-foreground shrink-0 truncate max-w-[150px]">
|
||||
{repoName}
|
||||
</h1>
|
||||
)}
|
||||
<PathDisplay path={displayPath} maxSegments={3} />
|
||||
<PathDisplay path={displayPath} maxSegments={2} className="truncate" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{repoId && !isEditing && (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="text-muted-foreground hover:text-foreground hover:bg-muted transition-all duration-200"
|
||||
>
|
||||
<Download className="w-5 h-5" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onClick={() => handleOpenDownloadDialog('directory')}>
|
||||
<Download className="w-4 h-4 mr-2" />
|
||||
Current Directory
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => handleOpenDownloadDialog('repository')}>
|
||||
<Download className="w-4 h-4 mr-2" />
|
||||
Entire Repository
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
)}
|
||||
{!isEditing && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={onClose}
|
||||
className="text-muted-foreground hover:text-foreground hover:bg-muted transition-all duration-200"
|
||||
>
|
||||
<X className="w-5 h-5" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{!isEditing && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={onClose}
|
||||
className="text-muted-foreground hover:text-foreground hover:bg-muted transition-all duration-200"
|
||||
>
|
||||
<X className="w-5 h-5" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</FullscreenSheetHeader>
|
||||
|
||||
<FullscreenSheetContent>
|
||||
<FileBrowser
|
||||
<FileBrowser
|
||||
basePath={normalizedBasePath}
|
||||
embedded={true}
|
||||
initialSelectedFile={initialSelectedFile}
|
||||
@@ -129,6 +183,17 @@ export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose
|
||||
/>
|
||||
</FullscreenSheetContent>
|
||||
</FullscreenSheet>
|
||||
|
||||
<DownloadDialog
|
||||
open={downloadDialog !== null}
|
||||
onOpenChange={(open) => !open && setDownloadDialog(null)}
|
||||
onDownload={downloadDialog?.type === 'directory' ? handleDownloadDirectory : handleDownloadRepo}
|
||||
title={downloadDialog?.type === 'directory' ? 'Download Current Directory' : 'Download Repository'}
|
||||
description={downloadDialog?.type === 'directory'
|
||||
? 'This will create a ZIP archive of the current directory and all its contents.'
|
||||
: 'This will create a ZIP archive of the entire repository.'}
|
||||
itemName={downloadDialog?.type === 'directory' ? currentPath.split('/').pop() || 'Directory' : repoName || 'Repository'}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
@@ -22,7 +22,7 @@ interface FilePreviewProps {
|
||||
}
|
||||
|
||||
export const FilePreview = memo(function FilePreview({ file, hideHeader = false, isMobileModal = false, onCloseModal, onFileSaved, initialLineNumber }: FilePreviewProps) {
|
||||
const isMarkdownFile = file.name.endsWith('.md') || file.name.endsWith('.mdx') || file.mimeType === 'text/markdown'
|
||||
const isMarkdownFile = file.name.toLowerCase().endsWith('.md') || file.name.toLowerCase().endsWith('.mdx') || file.mimeType === 'text/markdown'
|
||||
|
||||
const [viewMode, setViewMode] = useState<'preview' | 'edit'>('preview')
|
||||
const [editContent, setEditContent] = useState('')
|
||||
@@ -33,6 +33,7 @@ export const FilePreview = memo(function FilePreview({ file, hideHeader = false,
|
||||
const [markdownPreview, setMarkdownPreview] = useState(isMarkdownFile)
|
||||
const [isLoadingAllContent, setIsLoadingAllContent] = useState(false)
|
||||
const [fullContentLoaded, setFullContentLoaded] = useState(false)
|
||||
const [fullContent, setFullContent] = useState<string | null>(null)
|
||||
const virtualizedRef = useRef<VirtualizedTextViewHandle>(null)
|
||||
const contentRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
@@ -41,18 +42,25 @@ export const FilePreview = memo(function FilePreview({ file, hideHeader = false,
|
||||
|
||||
useEffect(() => {
|
||||
setFullContentLoaded(false)
|
||||
}, [file.path])
|
||||
setMarkdownPreview(isMarkdownFile)
|
||||
setFullContent(null)
|
||||
}, [file.path, isMarkdownFile])
|
||||
|
||||
useEffect(() => {
|
||||
if (shouldVirtualize && isMarkdownFile && markdownPreview && !isMarkdownTooLarge && !fullContentLoaded) {
|
||||
const loadContent = async () => {
|
||||
if (!virtualizedRef.current) return
|
||||
setIsLoadingAllContent(true)
|
||||
await virtualizedRef.current.loadAll()
|
||||
setFullContentLoaded(true)
|
||||
setIsLoadingAllContent(false)
|
||||
try {
|
||||
await virtualizedRef.current.loadAll()
|
||||
setFullContentLoaded(true)
|
||||
} catch {
|
||||
setFullContentLoaded(false)
|
||||
} finally {
|
||||
setIsLoadingAllContent(false)
|
||||
}
|
||||
}
|
||||
const timer = setTimeout(loadContent, 50)
|
||||
const timer = setTimeout(loadContent, 0)
|
||||
return () => clearTimeout(timer)
|
||||
}
|
||||
}, [shouldVirtualize, isMarkdownFile, markdownPreview, isMarkdownTooLarge, fullContentLoaded])
|
||||
@@ -191,7 +199,6 @@ export const FilePreview = memo(function FilePreview({ file, hideHeader = false,
|
||||
|
||||
if (shouldVirtualize && isTextFile) {
|
||||
const showMarkdownPreview = isMarkdownFile && markdownPreview && viewMode !== 'edit'
|
||||
const fullContent = virtualizedRef.current?.getFullContent()
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -203,6 +210,7 @@ export const FilePreview = memo(function FilePreview({ file, hideHeader = false,
|
||||
editable={viewMode === 'edit'}
|
||||
onSaveStateChange={handleVirtualizedSaveStateChange}
|
||||
onSave={handleVirtualizedSave}
|
||||
onContentLoaded={setFullContent}
|
||||
className="h-full"
|
||||
initialLineNumber={initialLineNumber}
|
||||
lineWrap={lineWrap}
|
||||
|
||||
@@ -76,6 +76,7 @@ export function FilePreviewDialog({ isOpen, onClose, filePath, repoBasePath, onF
|
||||
</div>
|
||||
) : file ? (
|
||||
<FilePreview
|
||||
key={file.path}
|
||||
file={file}
|
||||
hideHeader={false}
|
||||
isMobileModal={true}
|
||||
|
||||
@@ -56,6 +56,7 @@ export const MobileFilePreviewModal = memo(function MobileFilePreviewModal({
|
||||
<FullscreenSheet style={{ ...GPU_ACCELERATED_STYLE, ...swipeStyles }}>
|
||||
<div className={`h-full overflow-hidden bg-background pt-safe ${showFilePreviewHeader ? "" : "pb-8"}`}>
|
||||
<FilePreview
|
||||
key={localFile.path}
|
||||
file={localFile}
|
||||
hideHeader={!showFilePreviewHeader}
|
||||
isMobileModal={showFilePreviewHeader}
|
||||
|
||||
@@ -92,9 +92,12 @@ export const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(funct
|
||||
const [selectedAgent, setSelectedAgent] = useState<string | null>(null)
|
||||
const [localMode, setLocalMode] = useState<string | null>(null)
|
||||
const [isFocused, setIsFocused] = useState(false)
|
||||
const [isTogglingRecording, setIsTogglingRecording] = useState(false)
|
||||
const lastAddedTranscriptRef = useRef('')
|
||||
|
||||
const {
|
||||
isRecording,
|
||||
isProcessing,
|
||||
startRecording,
|
||||
stopRecording,
|
||||
abortRecording,
|
||||
@@ -104,7 +107,7 @@ export const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(funct
|
||||
transcript,
|
||||
clear: clearSTT,
|
||||
} = useSTT()
|
||||
|
||||
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||
|
||||
@@ -356,9 +359,14 @@ export const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(funct
|
||||
if (isRecording) {
|
||||
stopRecording()
|
||||
} else {
|
||||
await startRecording()
|
||||
if (textareaRef.current) {
|
||||
textareaRef.current.blur()
|
||||
setIsTogglingRecording(true)
|
||||
try {
|
||||
await startRecording()
|
||||
if (textareaRef.current) {
|
||||
textareaRef.current.blur()
|
||||
}
|
||||
} catch {
|
||||
setIsTogglingRecording(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,13 +375,30 @@ export const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(funct
|
||||
const textToUse = transcript || interimTranscript
|
||||
if (!isRecording && textToUse && textToUse !== 'Processing...' && textToUse !== 'Recording...') {
|
||||
const trimmedTranscript = textToUse.trim()
|
||||
if (trimmedTranscript && (prompt === '' || prompt === 'Processing...' || prompt === 'Recording...')) {
|
||||
setPrompt(trimmedTranscript)
|
||||
if (trimmedTranscript && trimmedTranscript !== lastAddedTranscriptRef.current) {
|
||||
if (prompt === '' || prompt === 'Processing...' || prompt === 'Recording...') {
|
||||
setPrompt(trimmedTranscript)
|
||||
} else {
|
||||
setPrompt(prev => `${prev} ${trimmedTranscript}`)
|
||||
}
|
||||
lastAddedTranscriptRef.current = trimmedTranscript
|
||||
textareaRef.current?.focus()
|
||||
}
|
||||
}
|
||||
}, [isRecording, interimTranscript, transcript, prompt])
|
||||
|
||||
useEffect(() => {
|
||||
if (isRecording && isTogglingRecording) {
|
||||
setIsTogglingRecording(false)
|
||||
}
|
||||
}, [isRecording, isTogglingRecording])
|
||||
|
||||
useEffect(() => {
|
||||
if (isTogglingRecording) {
|
||||
lastAddedTranscriptRef.current = ''
|
||||
}
|
||||
}, [isTogglingRecording])
|
||||
|
||||
const addImageAttachment = (file: File) => {
|
||||
const generateId = () => {
|
||||
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
||||
@@ -859,7 +884,7 @@ return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleVoiceToggle}
|
||||
disabled={disabled}
|
||||
disabled={disabled || isProcessing}
|
||||
className={`hidden md:flex p-2 rounded-lg transition-all duration-200 active:scale-95 hover:scale-105 shadow-md border items-center justify-center ${
|
||||
isRecording
|
||||
? 'bg-gradient-to-br from-red-600 to-red-700 hover:from-red-500 hover:to-red-600 text-destructive-foreground border-red-500/60 animate-pulse'
|
||||
@@ -867,21 +892,37 @@ return (
|
||||
}`}
|
||||
title={isRecording ? 'Stop recording' : 'Voice input'}
|
||||
>
|
||||
{isRecording ? <SquareFill className="w-5 h-5" /> : <Mic className="w-5 h-5" />}
|
||||
{isTogglingRecording && !isRecording ? (
|
||||
<div className="w-5 h-5 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent" />
|
||||
) : isProcessing && !isRecording ? (
|
||||
<div className="w-5 h-5 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent" />
|
||||
) : isRecording ? (
|
||||
<SquareFill className="w-5 h-5" />
|
||||
) : (
|
||||
<Mic className="w-5 h-5" />
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
{isMobile && !prompt.trim() && imageAttachments.length === 0 && sttEnabled && sttSupported && !hasPendingPermissionForSession ? (
|
||||
<button
|
||||
onClick={handleVoiceToggle}
|
||||
disabled={disabled}
|
||||
disabled={disabled || isProcessing}
|
||||
className={`px-4 py-2 rounded-lg transition-all duration-200 active:scale-95 flex items-center justify-center min-w-[52px] ${
|
||||
isRecording
|
||||
isRecording || isTogglingRecording || (isProcessing && !isRecording)
|
||||
? 'bg-gradient-to-br from-red-600 to-red-700 hover:from-red-500 hover:to-red-600 text-destructive-foreground border-2 border-red-500/60 shadow-lg shadow-red-500/30 animate-pulse'
|
||||
: 'bg-primary hover:bg-primary/90 text-primary-foreground border border-white/30'
|
||||
}`}
|
||||
title={isRecording ? 'Stop recording' : 'Voice input'}
|
||||
>
|
||||
{isRecording ? <SquareFill className="w-5 h-5" /> : <Mic className="w-5 h-5" />}
|
||||
{isTogglingRecording && !isRecording ? (
|
||||
<div className="w-5 h-5 animate-spin rounded-full border-2 border-white border-t-transparent" />
|
||||
) : isProcessing && !isRecording ? (
|
||||
<div className="w-5 h-5 animate-spin rounded-full border-2 border-white border-t-transparent" />
|
||||
) : isRecording ? (
|
||||
<SquareFill className="w-5 h-5" />
|
||||
) : (
|
||||
<Mic className="w-5 h-5" />
|
||||
)}
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
|
||||
@@ -8,6 +8,7 @@ import { downloadRepo } from "@/api/repos";
|
||||
import { showToast } from "@/lib/toast";
|
||||
import type { GitStatusResponse } from "@/types/git";
|
||||
import { SourceControlPanel } from "@/components/source-control/SourceControlPanel";
|
||||
import { DownloadDialog } from "@/components/ui/download-dialog";
|
||||
|
||||
interface RepoCardProps {
|
||||
repo: {
|
||||
@@ -36,7 +37,7 @@ export function RepoCard({
|
||||
gitStatus,
|
||||
}: RepoCardProps) {
|
||||
const navigate = useNavigate();
|
||||
const [isDownloading, setIsDownloading] = useState(false);
|
||||
const [showDownloadDialog, setShowDownloadDialog] = useState(false);
|
||||
const [showSourceControl, setShowSourceControl] = useState(false);
|
||||
|
||||
const repoName = repo.repoUrl
|
||||
@@ -63,6 +64,15 @@ export function RepoCard({
|
||||
action();
|
||||
};
|
||||
|
||||
const handleDownload = async () => {
|
||||
try {
|
||||
await downloadRepo(repo.id, repoName);
|
||||
showToast.success("Download complete");
|
||||
} catch (error: unknown) {
|
||||
showToast.error(error instanceof Error ? error.message : "Download failed");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={handleCardClick}
|
||||
@@ -155,25 +165,11 @@ export function RepoCard({
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={(e) => handleActionClick(e, async () => {
|
||||
setIsDownloading(true);
|
||||
try {
|
||||
await downloadRepo(repo.id, repoName);
|
||||
showToast.success("Download complete");
|
||||
} catch (error: unknown) {
|
||||
showToast.error(error instanceof Error ? error.message : "Download failed");
|
||||
} finally {
|
||||
setIsDownloading(false);
|
||||
}
|
||||
})}
|
||||
disabled={!isReady || isDownloading}
|
||||
onClick={(e) => handleActionClick(e, () => setShowDownloadDialog(true))}
|
||||
disabled={!isReady}
|
||||
className="h-8 w-8 p-0"
|
||||
>
|
||||
{isDownloading ? (
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
) : (
|
||||
<Download className="w-4 h-4" />
|
||||
)}
|
||||
<Download className="w-4 h-4" />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
@@ -203,6 +199,14 @@ export function RepoCard({
|
||||
isRepoWorktree={repo.isWorktree}
|
||||
repoName={repoName}
|
||||
/>
|
||||
<DownloadDialog
|
||||
open={showDownloadDialog}
|
||||
onOpenChange={setShowDownloadDialog}
|
||||
onDownload={handleDownload}
|
||||
title="Download Repository"
|
||||
description="This will create a ZIP archive of the entire repository."
|
||||
itemName={repoName}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ export function AccountSettings() {
|
||||
|
||||
const changePasswordMutation = useMutation({
|
||||
mutationFn: async ({ currentPassword, newPassword }: { currentPassword: string; newPassword: string }) => {
|
||||
const response = await changePassword({ currentPassword, newPassword })
|
||||
const response = await changePassword({ currentPassword, newPassword, revokeOtherSessions: true })
|
||||
if (response.error) {
|
||||
throw new Error(response.error.message || 'Failed to change password')
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -78,6 +78,7 @@ export function useSTT(userId = 'default') {
|
||||
|
||||
rec.onStart(() => {
|
||||
setIsRecording(true)
|
||||
setIsProcessing(false)
|
||||
setState('listening')
|
||||
setInterimTranscript('')
|
||||
})
|
||||
@@ -91,6 +92,7 @@ export function useSTT(userId = 'default') {
|
||||
recorder.setOnStateChange((recState) => {
|
||||
if (recState === 'recording') {
|
||||
setIsRecording(true)
|
||||
setIsProcessing(false)
|
||||
setState('listening')
|
||||
setInterimTranscript('Recording...')
|
||||
} else if (recState === 'stopped') {
|
||||
|
||||
@@ -357,3 +357,20 @@ body {
|
||||
.scrollbar-thin::-webkit-scrollbar-thumb:hover {
|
||||
background-color: var(--color-muted-foreground);
|
||||
}
|
||||
|
||||
/* Progress bar animation for download dialog */
|
||||
@keyframes progress {
|
||||
0% {
|
||||
width: 0%;
|
||||
}
|
||||
50% {
|
||||
width: 70%;
|
||||
}
|
||||
100% {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.animate-progress {
|
||||
animation: progress 2s ease-in-out infinite;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ const getBaseUrl = () => {
|
||||
if (typeof window !== 'undefined') {
|
||||
return `${window.location.origin}/api/auth`
|
||||
}
|
||||
return 'http://localhost:5001/api/auth'
|
||||
return 'http://localhost:5003/api/auth'
|
||||
}
|
||||
|
||||
export const authClient = createAuthClient({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react'
|
||||
import { Link, useLoaderData } from 'react-router-dom'
|
||||
import { useLoaderData } from 'react-router-dom'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { z } from 'zod'
|
||||
@@ -87,7 +87,6 @@ export function Login() {
|
||||
alt="OpenCode"
|
||||
className="h-8 w-auto"
|
||||
/>
|
||||
<p className="text-sm text-muted-foreground">Sign in to continue</p>
|
||||
</div>
|
||||
|
||||
<div className="rounded-lg border border-border bg-card p-6 space-y-4">
|
||||
@@ -204,7 +203,7 @@ export function Login() {
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
placeholder="you@example.com"
|
||||
placeholder=""
|
||||
className="bg-input border-border focus:border-primary"
|
||||
{...register('email')}
|
||||
aria-invalid={!!errors.email}
|
||||
@@ -218,7 +217,7 @@ export function Login() {
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
placeholder="Enter your password"
|
||||
placeholder=""
|
||||
className="bg-input border-border focus:border-primary"
|
||||
{...register('password')}
|
||||
aria-invalid={!!errors.password}
|
||||
@@ -239,14 +238,7 @@ export function Login() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{config.registrationEnabled && (
|
||||
<p className="text-center text-sm text-muted-foreground">
|
||||
Don't have an account?{' '}
|
||||
<Link to="/register" className="text-primary hover:underline transition-colors">
|
||||
Sign up
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -237,6 +237,7 @@ export function RepoDetail() {
|
||||
onClose={() => setFileBrowserOpen(false)}
|
||||
basePath={repo.localPath}
|
||||
repoName={displayName}
|
||||
repoId={repoId}
|
||||
/>
|
||||
|
||||
<RepoMcpDialog
|
||||
|
||||
@@ -521,6 +521,7 @@ export function SessionDetail() {
|
||||
onClose={handleFileBrowserClose}
|
||||
basePath={repo.localPath}
|
||||
repoName={repo.repoUrl?.split("/").pop()?.replace(".git", "") || repo.localPath || "Repository"}
|
||||
repoId={repoId}
|
||||
initialSelectedFile={selectedFilePath}
|
||||
/>
|
||||
|
||||
|
||||
Reference in new issue
Block a user