import { StringParam, useQueryParam } from "use-query-params"; import { NewPromptForm } from "@/src/features/prompts/components/NewPromptForm"; import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL"; import { api } from "@/src/utils/api"; import Page from "@/src/components/layouts/page"; export const NewPrompt = () => { const projectId = useProjectIdFromURL(); const [initialPromptId] = useQueryParam("promptId", StringParam); const { data: initialPrompt, isInitialLoading } = api.prompts.byId.useQuery( { projectId: projectId as string, // Typecast as query is enabled only when projectId is present id: initialPromptId ?? "", }, { enabled: Boolean(initialPromptId && projectId), refetchOnWindowFocus: false, refetchOnReconnect: false, }, ); if (isInitialLoading) { return
Loading...
; } const breadcrumb: { name: string; href?: string }[] = [ { name: "Prompts", href: `/project/${projectId}/prompts/`, }, { name: "New prompt", }, ]; if (initialPrompt) { breadcrumb.pop(); // Remove "New prompt" breadcrumb.push( { name: initialPrompt.name, href: `/project/${projectId}/prompts/${encodeURIComponent(initialPrompt.name)}`, }, { name: "New version" }, ); } return ( {initialPrompt ? (

Prompts are immutable in Langfuse. To update a prompt, create a new version.

) : null}
); };