diff --git a/src/components/chat/conversation-context-bar.tsx b/src/components/chat/conversation-context-bar.tsx index e7cf48c..ceb807d 100644 --- a/src/components/chat/conversation-context-bar.tsx +++ b/src/components/chat/conversation-context-bar.tsx @@ -3,23 +3,13 @@ import { memo, useCallback, useEffect, useMemo, useState } from "react" import { useTranslations } from "next-intl" import { toast } from "sonner" -import { - Check, - ChevronsUpDown, - Folder, - FolderOpen, - GitBranch, - Loader2, - Plus, -} from "lucide-react" +import { Check, ChevronsUpDown, Folder, GitBranch, Loader2 } from "lucide-react" import { useAppWorkspace } from "@/contexts/app-workspace-context" import { useTabContext } from "@/contexts/tab-context" import { useTaskContext } from "@/contexts/task-context" -import { gitListAllBranches, gitCheckout, gitNewBranch } from "@/lib/api" -import { isDesktop, openFileDialog } from "@/lib/platform" +import { gitListAllBranches, gitCheckout } from "@/lib/api" import type { GitBranchList } from "@/lib/types" import { Button } from "@/components/ui/button" -import { Input } from "@/components/ui/input" import { Popover, PopoverContent, @@ -32,15 +22,7 @@ import { CommandInput, CommandItem, CommandList, - CommandSeparator, } from "@/components/ui/command" -import { - Dialog, - DialogContent, - DialogFooter, - DialogHeader, - DialogTitle, -} from "@/components/ui/dialog" import { Tooltip, TooltipContent, @@ -64,7 +46,6 @@ export const ConversationContextBar = memo(function ConversationContextBar({ allFolders, branches, setBranch, - openFolder, addFolderToWorkspaceById, refreshFolder, } = useAppWorkspace() @@ -115,25 +96,6 @@ export const ConversationContextBar = memo(function ConversationContextBar({ toast.error(t("toasts.openFolderFailed")) } }} - onOpenNewFolder={async () => { - try { - if (isDesktop()) { - const result = await openFileDialog({ - directory: true, - multiple: false, - }) - if (!result) return - const selected = Array.isArray(result) ? result[0] : result - const detail = await openFolder(selected) - setTabFolder(ownTab.id, detail.id, detail.path) - toast.success(t("toasts.folderChanged", { name: detail.name })) - } - } catch (err) { - console.error("[ConversationContextBar] open folder failed:", err) - toast.error(t("toasts.openFolderFailed")) - } - }} - labelOpenNew={t("openNewFolder")} labelEmpty={t("noFolders")} labelSearch={t("searchFolder")} /> @@ -157,21 +119,6 @@ export const ConversationContextBar = memo(function ConversationContextBar({ toast.error(msg) } }} - onNewBranch={async (branchName, startPoint) => { - const taskId = `new-branch-${ownFolder.id}-${Date.now()}` - addTask(taskId, tBd("tasks.newBranch", { name: branchName })) - updateTask(taskId, { status: "running" }) - try { - await gitNewBranch(ownFolder.path, branchName, startPoint) - 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) - } - }} /> @@ -190,8 +137,6 @@ interface FolderPickerProps { currentFolderName: string editable: boolean onSelect: (folderId: number) => void | Promise - onOpenNewFolder: () => void | Promise - labelOpenNew: string labelEmpty: string labelSearch: string } @@ -202,8 +147,6 @@ const FolderPicker = memo(function FolderPicker({ currentFolderName, editable, onSelect, - onOpenNewFolder, - labelOpenNew, labelEmpty, labelSearch, }: FolderPickerProps) { @@ -236,8 +179,8 @@ const FolderPicker = memo(function FolderPicker({ return ( {trigger} - - + + {labelEmpty} @@ -264,18 +207,6 @@ const FolderPicker = memo(function FolderPicker({ ))} - - - { - setOpen(false) - void onOpenNewFolder() - }} - > - - {labelOpenNew} - - @@ -292,7 +223,6 @@ interface BranchPickerProps { folderPath: string currentBranch: string | null onCheckout: (branchName: string) => Promise - onNewBranch: (branchName: string, startPoint?: string) => Promise } const BranchPicker = memo(function BranchPicker({ @@ -300,15 +230,12 @@ const BranchPicker = memo(function BranchPicker({ folderPath, currentBranch, onCheckout, - onNewBranch, }: BranchPickerProps) { const t = useTranslations("Folder.conversationContextBar") const tBd = useTranslations("Folder.branchDropdown") const [open, setOpen] = useState(false) const [branchList, setBranchList] = useState(null) const [loading, setLoading] = useState(false) - const [newBranchOpen, setNewBranchOpen] = useState(false) - const [newBranchName, setNewBranchName] = useState("") const loadBranches = useCallback(async () => { setLoading(true) @@ -333,135 +260,79 @@ const BranchPicker = memo(function BranchPicker({ }, [folderId]) return ( - <> - - - - - - - - - {loading ? ( -
- -
- ) : ( - <> - {t("noBranches")} - - { - setOpen(false) - setNewBranchName("") - setNewBranchOpen(true) - }} - > - - {tBd("newBranch")} - - - {branchList && branchList.local.length > 0 && ( - <> - - + + + + + + + + {loading ? ( +
+ +
+ ) : ( + <> + {t("noBranches")} + {branchList && branchList.local.length > 0 && ( + + {branchList.local.map((b) => ( + { + setOpen(false) + if (b !== currentBranch) void onCheckout(b) + }} > - {branchList.local.map((b) => ( - { - setOpen(false) - if (b !== currentBranch) void onCheckout(b) - }} - > - - {b} - {b === currentBranch && ( - - )} - - ))} - - - )} - {branchList && branchList.remote.length > 0 && ( - - {branchList.remote.map((b) => ( - { - setOpen(false) - void onCheckout(b) - }} - > - - - {b} - - - ))} - - )} - - )} -
-
-
-
- - - - - {tBd("dialogs.newBranchTitle")} - -
- {tBd("dialogs.newBranchDescription", { - branch: currentBranch ?? "-", - })} -
- setNewBranchName(e.target.value)} - autoFocus - /> - - - - -
-
- + + {b} + {b === currentBranch && ( + + )} + + ))} + + )} + {branchList && branchList.remote.length > 0 && ( + + {branchList.remote.map((b) => ( + { + setOpen(false) + void onCheckout(b) + }} + > + + + {b} + + + ))} + + )} + + )} + +
+
+
) }) diff --git a/src/i18n/messages/ar.json b/src/i18n/messages/ar.json index 0140197..f701f2e 100644 --- a/src/i18n/messages/ar.json +++ b/src/i18n/messages/ar.json @@ -1797,9 +1797,6 @@ "noFolders": "No folders", "noBranches": "No branches", "noBranch": "(no branch)", - "openNewFolder": "Open folder from disk...", - "cancel": "Cancel", - "create": "Create", "commit": "Commit", "push": "Push", "merge": "Merge", diff --git a/src/i18n/messages/de.json b/src/i18n/messages/de.json index 1d34cf0..3455b9c 100644 --- a/src/i18n/messages/de.json +++ b/src/i18n/messages/de.json @@ -1797,9 +1797,6 @@ "noFolders": "No folders", "noBranches": "No branches", "noBranch": "(no branch)", - "openNewFolder": "Open folder from disk...", - "cancel": "Cancel", - "create": "Create", "commit": "Commit", "push": "Push", "merge": "Merge", diff --git a/src/i18n/messages/en.json b/src/i18n/messages/en.json index 03feaea..a941361 100644 --- a/src/i18n/messages/en.json +++ b/src/i18n/messages/en.json @@ -1797,9 +1797,6 @@ "noFolders": "No folders", "noBranches": "No branches", "noBranch": "(no branch)", - "openNewFolder": "Open folder from disk...", - "cancel": "Cancel", - "create": "Create", "commit": "Commit", "push": "Push", "merge": "Merge", diff --git a/src/i18n/messages/es.json b/src/i18n/messages/es.json index 5b68689..c3b5fee 100644 --- a/src/i18n/messages/es.json +++ b/src/i18n/messages/es.json @@ -1797,9 +1797,6 @@ "noFolders": "No folders", "noBranches": "No branches", "noBranch": "(no branch)", - "openNewFolder": "Open folder from disk...", - "cancel": "Cancel", - "create": "Create", "commit": "Commit", "push": "Push", "merge": "Merge", diff --git a/src/i18n/messages/fr.json b/src/i18n/messages/fr.json index 27a3156..a220aaa 100644 --- a/src/i18n/messages/fr.json +++ b/src/i18n/messages/fr.json @@ -1797,9 +1797,6 @@ "noFolders": "No folders", "noBranches": "No branches", "noBranch": "(no branch)", - "openNewFolder": "Open folder from disk...", - "cancel": "Cancel", - "create": "Create", "commit": "Commit", "push": "Push", "merge": "Merge", diff --git a/src/i18n/messages/ja.json b/src/i18n/messages/ja.json index ba04950..a527743 100644 --- a/src/i18n/messages/ja.json +++ b/src/i18n/messages/ja.json @@ -1797,9 +1797,6 @@ "noFolders": "No folders", "noBranches": "No branches", "noBranch": "(no branch)", - "openNewFolder": "Open folder from disk...", - "cancel": "Cancel", - "create": "Create", "commit": "Commit", "push": "Push", "merge": "Merge", diff --git a/src/i18n/messages/ko.json b/src/i18n/messages/ko.json index 4c07a3e..82141ee 100644 --- a/src/i18n/messages/ko.json +++ b/src/i18n/messages/ko.json @@ -1797,9 +1797,6 @@ "noFolders": "No folders", "noBranches": "No branches", "noBranch": "(no branch)", - "openNewFolder": "Open folder from disk...", - "cancel": "Cancel", - "create": "Create", "commit": "Commit", "push": "Push", "merge": "Merge", diff --git a/src/i18n/messages/pt.json b/src/i18n/messages/pt.json index e8cf838..d1e5d5a 100644 --- a/src/i18n/messages/pt.json +++ b/src/i18n/messages/pt.json @@ -1797,9 +1797,6 @@ "noFolders": "No folders", "noBranches": "No branches", "noBranch": "(no branch)", - "openNewFolder": "Open folder from disk...", - "cancel": "Cancel", - "create": "Create", "commit": "Commit", "push": "Push", "merge": "Merge", diff --git a/src/i18n/messages/zh-CN.json b/src/i18n/messages/zh-CN.json index b84c668..a9af9c8 100644 --- a/src/i18n/messages/zh-CN.json +++ b/src/i18n/messages/zh-CN.json @@ -1797,9 +1797,6 @@ "noFolders": "暂无文件夹", "noBranches": "暂无分支", "noBranch": "(无分支)", - "openNewFolder": "从磁盘打开文件夹...", - "cancel": "取消", - "create": "创建", "commit": "提交", "push": "推送", "merge": "合并", diff --git a/src/i18n/messages/zh-TW.json b/src/i18n/messages/zh-TW.json index 117f862..15c5b18 100644 --- a/src/i18n/messages/zh-TW.json +++ b/src/i18n/messages/zh-TW.json @@ -1797,9 +1797,6 @@ "noFolders": "No folders", "noBranches": "No branches", "noBranch": "(no branch)", - "openNewFolder": "Open folder from disk...", - "cancel": "Cancel", - "create": "Create", "commit": "Commit", "push": "Push", "merge": "Merge",