mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
fix: show error toast when adding non-git folder (#321)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,8 @@ import { toast } from 'sonner'
|
||||
import type { AppState } from '../types'
|
||||
import type { Repo } from '../../../../shared/types'
|
||||
|
||||
const ERROR_TOAST_DURATION = 60_000
|
||||
|
||||
export type RepoSlice = {
|
||||
repos: Repo[]
|
||||
activeRepoId: string | null
|
||||
@@ -58,6 +60,19 @@ export const createRepoSlice: StateCreator<AppState, [], [], RepoSlice> = (set,
|
||||
return repo
|
||||
} catch (err) {
|
||||
console.error('Failed to add repo:', err)
|
||||
const message = err instanceof Error ? err.message : String(err)
|
||||
const duration = ERROR_TOAST_DURATION
|
||||
if (message.includes('Not a valid git repository')) {
|
||||
toast.error('Not a git repository', {
|
||||
description: 'Only git repositories can be added. Initialize one with git init first.',
|
||||
duration
|
||||
})
|
||||
} else {
|
||||
toast.error('Failed to add repo', {
|
||||
description: message,
|
||||
duration
|
||||
})
|
||||
}
|
||||
return null
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user