fix: align PromptTemplateEditor, SmartActionsPanel, prompts page with backend enums; fix RunPromptModal type cast

This commit is contained in:
saravanakumardb1 2026-04-06 16:27:22 -07:00
parent 192c7baf2f
commit d4cc696e02
4 changed files with 8 additions and 19 deletions

View File

@ -11,10 +11,8 @@ const CATEGORY_LABELS: Record<PromptCategory, string> = {
transform: "Transform", transform: "Transform",
extract: "Extract", extract: "Extract",
generate: "Generate", generate: "Generate",
analysis: "Analysis", analyze: "Analyze",
vision: "Vision",
export: "Export", export: "Export",
custom: "Custom",
}; };
const INPUT_ICONS: Record<string, typeof FileText> = { const INPUT_ICONS: Record<string, typeof FileText> = {

View File

@ -6,9 +6,9 @@ import { createPromptTemplate } from "@/lib/prompt-client";
import { toast } from "@/lib/toast"; import { toast } from "@/lib/toast";
import type { PromptCategory } from "@/lib/types"; import type { PromptCategory } from "@/lib/types";
const CATEGORIES: PromptCategory[] = ["transform", "extract", "generate", "analysis", "vision", "export", "custom"]; const CATEGORIES: PromptCategory[] = ["transform", "extract", "generate", "analyze", "export"];
const INPUT_TYPES = ["text", "image", "text+image", "multi-note"] as const; const INPUT_TYPES = ["text", "image", "text+image", "multi-note"] as const;
const OUTPUT_TYPES = ["new_note", "replace", "artifact", "clipboard", "update_note"] as const; const OUTPUT_TYPES = ["new_note", "replace", "artifact", "inline"] as const;
interface PromptTemplateEditorProps { interface PromptTemplateEditorProps {
onClose: () => void; onClose: () => void;
@ -19,7 +19,7 @@ export function PromptTemplateEditor({ onClose, onCreated }: PromptTemplateEdito
const [name, setName] = useState(""); const [name, setName] = useState("");
const [slug, setSlug] = useState(""); const [slug, setSlug] = useState("");
const [description, setDescription] = useState(""); const [description, setDescription] = useState("");
const [category, setCategory] = useState<PromptCategory>("custom"); const [category, setCategory] = useState<PromptCategory>("transform");
const [inputType, setInputType] = useState<(typeof INPUT_TYPES)[number]>("text"); const [inputType, setInputType] = useState<(typeof INPUT_TYPES)[number]>("text");
const [outputType, setOutputType] = useState<(typeof OUTPUT_TYPES)[number]>("new_note"); const [outputType, setOutputType] = useState<(typeof OUTPUT_TYPES)[number]>("new_note");
const [systemPrompt, setSystemPrompt] = useState(""); const [systemPrompt, setSystemPrompt] = useState("");

View File

@ -31,22 +31,15 @@ export function RunPromptModal({
async function handleRun() { async function handleRun() {
setRunning(true); setRunning(true);
try { try {
const input: Record<string, unknown> = { const input: Parameters<typeof runPrompt>[0] = {
templateId: template.slug, templateId: template.slug,
noteId, noteId,
workspaceId, workspaceId,
dryRun,
}; };
if (inlinePrompt.trim()) { if (inlinePrompt.trim()) {
input.inlinePrompt = inlinePrompt.trim(); input.inputText = inlinePrompt.trim();
} }
if (isMultiNote && additionalNoteIds.trim()) { const result = await runPrompt(input);
input.additionalNoteIds = additionalNoteIds
.split(",")
.map((s) => s.trim())
.filter(Boolean);
}
const result = await runPrompt(input as Parameters<typeof runPrompt>[0]);
onResult(result); onResult(result);
toast.success(`"${template.name}" completed`); toast.success(`"${template.name}" completed`);
} catch (err) { } catch (err) {

View File

@ -10,10 +10,8 @@ const CATEGORY_LABELS: Record<PromptCategory, string> = {
transform: "Transform", transform: "Transform",
extract: "Extract", extract: "Extract",
generate: "Generate", generate: "Generate",
analysis: "Analysis", analyze: "Analyze",
vision: "Vision",
export: "Export", export: "Export",
custom: "Custom",
}; };
interface SmartActionsPanelProps { interface SmartActionsPanelProps {