Merge branch 'cv-main-xx1jlt'

This commit is contained in:
xintaofei
2026-03-12 23:19:53 +08:00
5 changed files with 38 additions and 12 deletions

View File

@@ -297,8 +297,8 @@ pub fn get_agent_meta(agent_type: AgentType) -> AcpAgentMeta {
name: "Gemini CLI", name: "Gemini CLI",
description: "Google's official CLI for Gemini", description: "Google's official CLI for Gemini",
distribution: AgentDistribution::Npx { distribution: AgentDistribution::Npx {
version: "0.32.1", version: "0.33.0",
package: "@google/gemini-cli@0.32.1", package: "@google/gemini-cli@0.33.0",
args: &["--experimental-acp"], args: &["--experimental-acp"],
env: &[], env: &[],
node_required: None, node_required: None,

View File

@@ -432,15 +432,31 @@ pub async fn get_git_branch(path: String) -> Result<Option<String>, AppCommandEr
.await .await
.map_err(AppCommandError::io)?; .map_err(AppCommandError::io)?;
if !output.status.success() { if output.status.success() {
return Ok(None); let branch = String::from_utf8_lossy(&output.stdout).trim().to_string();
if !branch.is_empty() && branch != "HEAD" {
return Ok(Some(branch));
}
} }
let branch = String::from_utf8_lossy(&output.stdout).trim().to_string(); // Fallback: symbolic-ref works on unborn branches (after git init, before first commit)
if branch.is_empty() || branch == "HEAD" { let sym_output = crate::process::tokio_command("git")
return Ok(None); .args(["symbolic-ref", "--short", "HEAD"])
.current_dir(&path)
.output()
.await
.map_err(AppCommandError::io)?;
if sym_output.status.success() {
let branch = String::from_utf8_lossy(&sym_output.stdout)
.trim()
.to_string();
if !branch.is_empty() {
return Ok(Some(branch));
}
} }
Ok(Some(branch))
Ok(None)
} }
#[tauri::command] #[tauri::command]
@@ -2459,6 +2475,13 @@ pub async fn git_log(
.map_err(AppCommandError::io)?; .map_err(AppCommandError::io)?;
if !output.status.success() { 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)); return Err(git_command_error("log", &output.stderr));
} }

View File

@@ -13,6 +13,7 @@ import { revealItemInDir } from "@tauri-apps/plugin-opener"
import ignore from "ignore" import ignore from "ignore"
import { Check, ChevronRight } from "lucide-react" import { Check, ChevronRight } from "lucide-react"
import { useTranslations } from "next-intl" import { useTranslations } from "next-intl"
import { toErrorMessage } from "@/lib/app-error"
import { toast } from "sonner" import { toast } from "sonner"
import { useFolderContext } from "@/contexts/folder-context" import { useFolderContext } from "@/contexts/folder-context"
import { useAuxPanelContext } from "@/contexts/aux-panel-context" import { useAuxPanelContext } from "@/contexts/aux-panel-context"
@@ -947,7 +948,7 @@ export function FileTreeTab() {
setGitStatusByPath(new Map()) setGitStatusByPath(new Map())
} }
} catch (e) { } catch (e) {
setError(e instanceof Error ? e.message : String(e)) setError(toErrorMessage(e))
} finally { } finally {
if (!silent && !loadingReleased) setLoading(false) if (!silent && !loadingReleased) setLoading(false)
} }

View File

@@ -83,6 +83,7 @@ import {
} from "@/lib/tauri" } from "@/lib/tauri"
import type { GitBranchList, GitLogEntry, GitLogFileChange } from "@/lib/types" import type { GitBranchList, GitLogEntry, GitLogFileChange } from "@/lib/types"
import { toast } from "sonner" import { toast } from "sonner"
import { toErrorMessage } from "@/lib/app-error"
function formatRelativeTime( function formatRelativeTime(
dateStr: string, dateStr: string,
@@ -684,7 +685,7 @@ export function GitLogTab() {
} catch (e) { } catch (e) {
setBranchesError((prev) => ({ setBranchesError((prev) => ({
...prev, ...prev,
[fullHash]: e instanceof Error ? e.message : String(e), [fullHash]: toErrorMessage(e),
})) }))
} finally { } finally {
setBranchesLoading((prev) => ({ ...prev, [fullHash]: false })) setBranchesLoading((prev) => ({ ...prev, [fullHash]: false }))
@@ -727,7 +728,7 @@ export function GitLogTab() {
) )
} }
} catch (e) { } catch (e) {
setError(e instanceof Error ? e.message : String(e)) setError(toErrorMessage(e))
} finally { } finally {
if (inline) { if (inline) {
setRefreshing(false) setRefreshing(false)

View File

@@ -10,6 +10,7 @@ import {
useRef, useRef,
type ReactNode, type ReactNode,
} from "react" } from "react"
import { toErrorMessage } from "@/lib/app-error"
import { getFolder, listFolderConversations } from "@/lib/tauri" import { getFolder, listFolderConversations } from "@/lib/tauri"
import type { import type {
AgentType, AgentType,
@@ -174,7 +175,7 @@ export function FolderProvider({
} catch (e) { } catch (e) {
if (!mountedRef.current) return if (!mountedRef.current) return
if (!cached) { if (!cached) {
setError(e instanceof Error ? e.message : String(e)) setError(toErrorMessage(e))
} }
} finally { } finally {
if (mountedRef.current) { if (mountedRef.current) {