diff --git a/src-tauri/src/commands/folders.rs b/src-tauri/src/commands/folders.rs index e250084..b790a04 100644 --- a/src-tauri/src/commands/folders.rs +++ b/src-tauri/src/commands/folders.rs @@ -2475,6 +2475,13 @@ pub async fn git_log( .map_err(AppCommandError::io)?; if !output.status.success() { + // Empty repo (no commits yet) — return empty list instead of error + let stderr_str = String::from_utf8_lossy(&output.stderr); + if stderr_str.contains("does not have any commits yet") + || stderr_str.contains("unknown revision or path not in the working tree") + { + return Ok(Vec::new()); + } return Err(git_command_error("log", &output.stderr)); } diff --git a/src/components/layout/aux-panel-file-tree-tab.tsx b/src/components/layout/aux-panel-file-tree-tab.tsx index 8cda1d6..4df8655 100644 --- a/src/components/layout/aux-panel-file-tree-tab.tsx +++ b/src/components/layout/aux-panel-file-tree-tab.tsx @@ -13,6 +13,7 @@ import { revealItemInDir } from "@tauri-apps/plugin-opener" import ignore from "ignore" import { Check, ChevronRight } from "lucide-react" import { useTranslations } from "next-intl" +import { toErrorMessage } from "@/lib/app-error" import { toast } from "sonner" import { useFolderContext } from "@/contexts/folder-context" import { useAuxPanelContext } from "@/contexts/aux-panel-context" @@ -947,7 +948,7 @@ export function FileTreeTab() { setGitStatusByPath(new Map()) } } catch (e) { - setError(e instanceof Error ? e.message : String(e)) + setError(toErrorMessage(e)) } finally { if (!silent && !loadingReleased) setLoading(false) } diff --git a/src/components/layout/aux-panel-git-log-tab.tsx b/src/components/layout/aux-panel-git-log-tab.tsx index b195100..4a805dc 100644 --- a/src/components/layout/aux-panel-git-log-tab.tsx +++ b/src/components/layout/aux-panel-git-log-tab.tsx @@ -83,6 +83,7 @@ import { } from "@/lib/tauri" import type { GitBranchList, GitLogEntry, GitLogFileChange } from "@/lib/types" import { toast } from "sonner" +import { toErrorMessage } from "@/lib/app-error" function formatRelativeTime( dateStr: string, @@ -684,7 +685,7 @@ export function GitLogTab() { } catch (e) { setBranchesError((prev) => ({ ...prev, - [fullHash]: e instanceof Error ? e.message : String(e), + [fullHash]: toErrorMessage(e), })) } finally { setBranchesLoading((prev) => ({ ...prev, [fullHash]: false })) @@ -727,7 +728,7 @@ export function GitLogTab() { ) } } catch (e) { - setError(e instanceof Error ? e.message : String(e)) + setError(toErrorMessage(e)) } finally { if (inline) { setRefreshing(false) diff --git a/src/contexts/folder-context.tsx b/src/contexts/folder-context.tsx index 475bdf6..2786458 100644 --- a/src/contexts/folder-context.tsx +++ b/src/contexts/folder-context.tsx @@ -10,6 +10,7 @@ import { useRef, type ReactNode, } from "react" +import { toErrorMessage } from "@/lib/app-error" import { getFolder, listFolderConversations } from "@/lib/tauri" import type { AgentType, @@ -174,7 +175,7 @@ export function FolderProvider({ } catch (e) { if (!mountedRef.current) return if (!cached) { - setError(e instanceof Error ? e.message : String(e)) + setError(toErrorMessage(e)) } } finally { if (mountedRef.current) {