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:
Neil
2026-04-05 23:36:30 -07:00
committed by GitHub
co-authored by Claude Opus 4.6
parent deec6409df
commit 93de627208
+15
View File
@@ -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
}
},