fix issues (#136)

* fix: prevent delete button click when card is not swiped open

* refactor: improve CreateRepoInput type safety

* security: require AUTH_SECRET and use secure random generation

* fix: SSH key path validation, async passphrase stripping, and port handling

* fix: use correct console methods for logger levels

* Add error handling to DB update functions and improve migration logging

* Add error handling for session lookup in auth middleware

* Add structured git error handling with user-friendly messages

- Parse git errors with specific error codes (AUTH_FAILED, REPO_NOT_FOUND,
  PUSH_REJECTED, MERGE_CONFLICT, etc.) and appropriate HTTP status codes
- Return structured error responses with summary and detail from backend
- Add GitErrorBanner component for better error display in UI
- Add optional onError callback to useGit hook for external error handling

* Make IPC server initialization/disposal async and fix SSH host key handler

* add try-catch error handling in frontend lib utilities

* remove unresolved promise handlers in speech synthesizer callbacks

* Extract error types to shared package

* Import GitErrorCode from shared package

* Refactor API layer to use shared FetchError and fetchWrapper

* Update prompt parser and source control components

* Extract MCP server list to separate component with improved badge menu UX

* merge useSettingsDialogUrl into useSettingsDialog and extract getRepoDisplayName utility

* add separate loading state for passkey sign in

* refactor hooks: use fetchWrapper, improve error handling, add proper types

* replace browser confirm() with DeleteDialog component in settings

* fix: add missing variables parameter in React Query onError callbacks

* Refactor message parts to use separate Zustand store

* Update QuestionPrompt styling for light/dark mode
This commit is contained in:
Chris Scott authored and GitHub committed 2026-02-15 19:48:03 -05:00
1 parent 7f7d106c28
commit 5de419ee28
75 files changed
+1990 -1367

No files matched your search

@@ -1,53 +1,41 @@
import { useState } from 'react'
import { useGitStatus, getApiErrorMessage } from '@/api/git'
import { useGitStatus } from '@/api/git'
import { useGit } from '@/hooks/useGit'
import { GitFlatFileList } from './GitFlatFileList'
import { Button } from '@/components/ui/button'
import { Textarea } from '@/components/ui/textarea'
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs'
import { FileDiffView } from '@/components/file-browser/FileDiffView'
import { Loader2, GitCommit, FileText, AlertCircle, X } from 'lucide-react'
import { Loader2, GitCommit, FileText, AlertCircle } from 'lucide-react'
interface ChangesTabProps {
repoId: number
onFileSelect: (path: string, staged: boolean) => void
selectedFile?: {path: string, staged: boolean}
isMobile: boolean
onError?: (error: unknown) => void
}
export function ChangesTab({ repoId, onFileSelect, selectedFile, isMobile }: ChangesTabProps) {
export function ChangesTab({ repoId, onFileSelect, selectedFile, isMobile, onError }: ChangesTabProps) {
const { data: status, isLoading, error } = useGitStatus(repoId)
const git = useGit(repoId)
const git = useGit(repoId, onError)
const [commitMessage, setCommitMessage] = useState('')
const [apiError, setApiError] = useState<string | null>(null)
const stagedFiles = status?.files.filter(f => f.staged) || []
const unstagedFiles = status?.files.filter(f => !f.staged) || []
const canCommit = commitMessage.trim() && stagedFiles.length > 0 && !git.commit.isPending
const handleGitAction = async (action: () => Promise<unknown>) => {
try {
setApiError(null)
await action()
} catch (error: unknown) {
const message = getApiErrorMessage(error)
setApiError(message)
}
}
const handleStage = (paths: string[]) => {
handleGitAction(() => git.stageFiles.mutateAsync(paths))
git.stageFiles.mutate(paths)
}
const handleUnstage = (paths: string[]) => {
handleGitAction(() => git.unstageFiles.mutateAsync(paths))
git.unstageFiles.mutate(paths)
}
const handleCommit = () => {
handleGitAction(async () => {
await git.commit.mutateAsync({ message: commitMessage.trim() })
setCommitMessage('')
})
git.commit.mutate({ message: commitMessage.trim() })
setCommitMessage('')
}
if (isLoading) {
@@ -73,16 +61,6 @@ export function ChangesTab({ repoId, onFileSelect, selectedFile, isMobile }: Cha
if (isMobile && selectedFile) {
return (
<div className="flex flex-col h-full">
{apiError && (
<div className="mx-3 mt-3 p-2 rounded border bg-destructive/10 border-destructive/20 flex items-center gap-2">
<AlertCircle className="w-4 h-4 text-destructive flex-shrink-0" />
<span className="text-sm text-destructive flex-1">{apiError}</span>
<Button variant="ghost" size="sm" className="h-6 w-6 p-0" onClick={() => setApiError(null)}>
<X className="w-3 h-3" />
</Button>
</div>
)}
<Tabs defaultValue="files" className="flex flex-col h-full">
<TabsList className="flex-shrink-0">
<TabsTrigger value="files">Files ({stagedFiles.length + unstagedFiles.length})</TabsTrigger>
@@ -164,16 +142,6 @@ export function ChangesTab({ repoId, onFileSelect, selectedFile, isMobile }: Cha
} else {
return (
<div className="flex flex-col h-full">
{apiError && (
<div className="mx-3 mt-3 p-2 rounded border bg-destructive/10 border-destructive/20 flex items-center gap-2">
<AlertCircle className="w-4 h-4 text-destructive flex-shrink-0" />
<span className="text-sm text-destructive flex-1">{apiError}</span>
<Button variant="ghost" size="sm" className="h-6 w-6 p-0" onClick={() => setApiError(null)}>
<X className="w-3 h-3" />
</Button>
</div>
)}
<div className="flex-1 overflow-y-auto p-3 space-y-4">
{status.hasChanges ? (
<>
@@ -0,0 +1,34 @@
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Button } from '@/components/ui/button'
import { AlertCircle, X } from 'lucide-react'
interface GitErrorBannerProps {
error: { summary: string; detail?: string }
onDismiss: () => void
}
export function GitErrorBanner({ error, onDismiss }: GitErrorBannerProps) {
return (
<Alert variant="destructive" className="mb-0 p-3 sm:p-4 [&>svg]:hidden [&>svg~*]:pl-0">
<div className="flex flex-col gap-2">
<div className="flex items-start gap-2">
<AlertCircle className="h-4 w-4 mt-0.5 flex-shrink-0" />
<AlertDescription className="flex-1 min-w-0 text-sm">{error.summary}</AlertDescription>
<Button
variant="ghost"
size="sm"
className="h-7 w-7 p-0 flex-shrink-0"
onClick={onDismiss}
>
<X className="w-3.5 h-3.5" />
</Button>
</div>
{error.detail && (
<pre className="p-2 rounded border bg-destructive/5 border-destructive/20 text-xs font-mono overflow-auto max-h-32">
{error.detail}
</pre>
)}
</div>
</Alert>
)
}
@@ -1,10 +1,12 @@
import { useState } from 'react'
import { FetchError } from '@opencode-manager/shared'
import { useGitStatus, getApiErrorMessage } from '@/api/git'
import { useGit } from '@/hooks/useGit'
import { ChangesTab } from './ChangesTab'
import { CommitsTab } from './CommitsTab'
import { BranchesTab } from './BranchesTab'
import { GitErrorBanner } from './GitErrorBanner'
import { FileDiffView } from '@/components/file-browser/FileDiffView'
import { Button } from '@/components/ui/button'
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
@@ -23,7 +25,6 @@ import {
} from 'lucide-react'
import { cn } from '@/lib/utils'
import { useMobile } from '@/hooks/useMobile'
import { showToast } from '@/lib/toast'
interface SourceControlPanelProps {
repoId: number
@@ -48,15 +49,26 @@ export function SourceControlPanel({
}: SourceControlPanelProps) {
const [activeTab, setActiveTab] = useState<Tab>('changes')
const [selectedFile, setSelectedFile] = useState<{path: string, staged: boolean} | undefined>()
const [gitError, setGitError] = useState<{ summary: string; detail?: string } | null>(null)
const { data: status } = useGitStatus(repoId)
const git = useGit(repoId)
const isMobile = useMobile()
const handleGitError = (error: unknown) => {
if (error instanceof FetchError) {
setGitError({ summary: getApiErrorMessage(error), detail: error.detail })
} else {
setGitError({ summary: getApiErrorMessage(error) })
}
}
const git = useGit(repoId, handleGitError)
const handleGitAction = async (action: () => Promise<unknown>) => {
try {
setGitError(null)
await action()
} catch (error: unknown) {
const message = getApiErrorMessage(error)
showToast.error(message)
} catch {
// error already handled by useGit's onError -> handleGitError
}
}
@@ -138,6 +150,10 @@ export function SourceControlPanel({
</div>
</div>
{gitError && (
<GitErrorBanner error={gitError} onDismiss={() => setGitError(null)} />
)}
<div className="flex border-b border-border flex-shrink-0">
{tabs.map((tab) => {
const Icon = tab.icon
@@ -175,6 +191,7 @@ export function SourceControlPanel({
onFileSelect={(path, staged) => setSelectedFile({ path, staged })}
selectedFile={selectedFile}
isMobile={isMobile}
onError={handleGitError}
/>
)}
{activeTab === 'commits' && (