fix(conversation-context-bar): exclude removed folders from folder picker
This commit is contained in:
@@ -41,14 +41,8 @@ export const ConversationContextBar = memo(function ConversationContextBar({
|
|||||||
const t = useTranslations("Folder.conversationContextBar")
|
const t = useTranslations("Folder.conversationContextBar")
|
||||||
const tBd = useTranslations("Folder.branchDropdown")
|
const tBd = useTranslations("Folder.branchDropdown")
|
||||||
const { tabs, activeTabId, setTabFolder } = useTabContext()
|
const { tabs, activeTabId, setTabFolder } = useTabContext()
|
||||||
const {
|
const { folders, allFolders, branches, setBranch, refreshFolder } =
|
||||||
folders,
|
useAppWorkspace()
|
||||||
allFolders,
|
|
||||||
branches,
|
|
||||||
setBranch,
|
|
||||||
addFolderToWorkspaceById,
|
|
||||||
refreshFolder,
|
|
||||||
} = useAppWorkspace()
|
|
||||||
const { addTask, updateTask } = useTaskContext()
|
const { addTask, updateTask } = useTaskContext()
|
||||||
|
|
||||||
const ownTab = useMemo(() => {
|
const ownTab = useMemo(() => {
|
||||||
@@ -74,20 +68,16 @@ export const ConversationContextBar = memo(function ConversationContextBar({
|
|||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
<div className="flex shrink-0 items-center gap-1.5 px-2 pt-2 text-xs text-muted-foreground">
|
<div className="flex shrink-0 items-center gap-1.5 px-2 pt-2 text-xs text-muted-foreground">
|
||||||
<FolderPicker
|
<FolderPicker
|
||||||
folders={allFolders}
|
folders={folders}
|
||||||
currentFolderId={ownFolder.id}
|
currentFolderId={ownFolder.id}
|
||||||
currentFolderName={ownFolder.name}
|
currentFolderName={ownFolder.name}
|
||||||
editable={isNewConversation}
|
editable={isNewConversation}
|
||||||
onSelect={async (folderId) => {
|
onSelect={async (folderId) => {
|
||||||
const target = allFolders.find((f) => f.id === folderId)
|
const target = folders.find((f) => f.id === folderId)
|
||||||
if (!target) return
|
if (!target) return
|
||||||
const isOpen = folders.some((f) => f.id === folderId)
|
|
||||||
try {
|
try {
|
||||||
const detail = isOpen
|
setTabFolder(ownTab.id, target.id, target.path)
|
||||||
? target
|
toast.success(t("toasts.folderChanged", { name: target.name }))
|
||||||
: await addFolderToWorkspaceById(folderId)
|
|
||||||
setTabFolder(ownTab.id, detail.id, detail.path)
|
|
||||||
toast.success(t("toasts.folderChanged", { name: detail.name }))
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(
|
console.error(
|
||||||
"[ConversationContextBar] switch folder failed:",
|
"[ConversationContextBar] switch folder failed:",
|
||||||
|
|||||||
Reference in New Issue
Block a user