From cd15813f341c4465284646016534628502c5dfa8 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Thu, 23 Apr 2026 11:25:16 +0800 Subject: [PATCH] refactor(tooltip): use native title for folder picker and sidebar more-options --- .../chat/conversation-context-bar.tsx | 104 ++++++------- src/components/layout/sidebar.tsx | 144 ++++++++---------- 2 files changed, 111 insertions(+), 137 deletions(-) diff --git a/src/components/chat/conversation-context-bar.tsx b/src/components/chat/conversation-context-bar.tsx index 203caac..3209e53 100644 --- a/src/components/chat/conversation-context-bar.tsx +++ b/src/components/chat/conversation-context-bar.tsx @@ -23,12 +23,6 @@ import { CommandItem, CommandList, } from "@/components/ui/command" -import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from "@/components/ui/tooltip" import { cn } from "@/lib/utils" interface ConversationContextBarProps { @@ -65,53 +59,51 @@ export const ConversationContextBar = memo(function ConversationContextBar({ branches.get(ownFolder.id) ?? ownFolder.git_branch ?? null return ( - -
- { - const target = folders.find((f) => f.id === folderId) - if (!target) return - try { - setTabFolder(ownTab.id, target.id, target.path) - toast.success(t("toasts.folderChanged", { name: target.name })) - } catch (err) { - console.error( - "[ConversationContextBar] switch folder failed:", - err - ) - toast.error(t("toasts.openFolderFailed")) - } - }} - labelEmpty={t("noFolders")} - labelSearch={t("searchFolder")} - /> +
+ { + const target = folders.find((f) => f.id === folderId) + if (!target) return + try { + setTabFolder(ownTab.id, target.id, target.path) + toast.success(t("toasts.folderChanged", { name: target.name })) + } catch (err) { + console.error( + "[ConversationContextBar] switch folder failed:", + err + ) + toast.error(t("toasts.openFolderFailed")) + } + }} + labelEmpty={t("noFolders")} + labelSearch={t("searchFolder")} + /> - { - const taskId = `checkout-${ownFolder.id}-${Date.now()}` - addTask(taskId, tBd("tasks.checkoutTo", { branchName })) - updateTask(taskId, { status: "running" }) - try { - await gitCheckout(ownFolder.path, branchName) - setBranch(ownFolder.id, branchName) - await refreshFolder(ownFolder.id) - updateTask(taskId, { status: "completed" }) - } catch (err) { - const msg = err instanceof Error ? err.message : String(err) - updateTask(taskId, { status: "failed", error: msg }) - toast.error(msg) - } - }} - /> -
- + { + const taskId = `checkout-${ownFolder.id}-${Date.now()}` + addTask(taskId, tBd("tasks.checkoutTo", { branchName })) + updateTask(taskId, { status: "running" }) + try { + await gitCheckout(ownFolder.path, branchName) + setBranch(ownFolder.id, branchName) + await refreshFolder(ownFolder.id) + updateTask(taskId, { status: "completed" }) + } catch (err) { + const msg = err instanceof Error ? err.message : String(err) + updateTask(taskId, { status: "failed", error: msg }) + toast.error(msg) + } + }} + /> +
) }) @@ -146,6 +138,7 @@ const FolderPicker = memo(function FolderPicker({ - - - - - - - - - - {t("moreOptions")} - - - - - {t("showCompleted")} - - - {t("sortBy")} - - - {t("sortByCreatedAt")} - - - {t("sortByUpdatedAt")} - - - - - +
+
+

+ {t("title")} +

- +
+ + + + + + + + + {t("showCompleted")} + + + {t("sortBy")} + + + {t("sortByCreatedAt")} + + + {t("sortByUpdatedAt")} + + + + +
+
{/* On mobile, clicking a conversation card auto-closes the Sheet */}