Resolve merge conflicts

This commit is contained in:
吉鑫升 committed 2026-06-05 10:28:45 +08:00
1 parent e96cc97462
commit 22be6325a8
3 files changed
+53 -35

No files matched your search

@@ -7,7 +7,7 @@ import {
Settings2Icon,
Trash2Icon,
} from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useCallback, useEffect, useRef, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
@@ -28,8 +28,7 @@ import {
} from "@/components/ui/select";
import { Switch } from "@/components/ui/switch";
import { Textarea } from "@/components/ui/textarea";
import { useAgents } from "@/core/agents/hooks";
import { getStoredAuth } from "@/core/auth";
import { useAgentSelector } from "@/core/agents/hooks";
import {
useCreateCustomPrompt,
useCustomPrompts,
@@ -165,10 +164,9 @@ function ManagePromptsDialog({
const createPrompt = useCreateCustomPrompt();
const updatePrompt = useUpdateCustomPrompt();
const deletePrompt = useDeleteCustomPrompt();
const { agents } = useAgents();
const { agents } = useAgentSelector();
const preferences = useUserPreferences();
const updatePreferences = useUpdateUserPreferences();
const currentUserId = getStoredAuth()?.user_id ?? null;
const [editingId, setEditingId] = useState<string | null>(null);
const [title, setTitle] = useState("");
const [content, setContent] = useState("");
@@ -176,16 +174,7 @@ function ManagePromptsDialog({
const saving = createPrompt.isPending || updatePrompt.isPending;
const selectableAgents = useMemo(() => {
const owned = currentUserId
? agents.filter((agent) => agent.user_id === currentUserId)
: [];
if (agentId && !owned.some((agent) => agent.id === agentId)) {
const bound = agents.find((agent) => agent.id === agentId);
if (bound) return [bound, ...owned];
}
return owned;
}, [agents, agentId, currentUserId]);
const selectableAgents = agents;
const agentNameById = (id?: string | null) =>
id ? agents.find((agent) => agent.id === id)?.name ?? null : null;
@@ -235,7 +224,11 @@ function ManagePromptsDialog({
setEditingId(id);
setTitle(target.title);
setContent(target.content);
setAgentId(target.agent_id || undefined);
setAgentId(
target.agent_id && selectableAgents.some((agent) => agent.id === target.agent_id)
? target.agent_id
: undefined,
);
};
const handleToggleHideAdmin = async (next: boolean) => {