From 93de62720868e7368776a2bcafaccae11c2bdc4e Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 5 Apr 2026 23:36:30 -0700 Subject: [PATCH] fix: show error toast when adding non-git folder (#321) Co-authored-by: Claude Opus 4.6 --- src/renderer/src/store/slices/repos.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/renderer/src/store/slices/repos.ts b/src/renderer/src/store/slices/repos.ts index fc38f0664fd..bca4c75997e 100644 --- a/src/renderer/src/store/slices/repos.ts +++ b/src/renderer/src/store/slices/repos.ts @@ -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 = (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 } },