fix: align PromptTemplateEditor, SmartActionsPanel, prompts page with backend enums; fix RunPromptModal type cast
This commit is contained in:
parent
192c7baf2f
commit
d4cc696e02
@ -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> = {
|
||||||
|
|||||||
@ -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("");
|
||||||
|
|||||||
@ -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) {
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user