:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(llma): add what-changed input to prompt publish review (#69183)
Juraj Majerik6bf698e4d6e7
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.tsindex 5dab268f4e3d..6f26ce1ef617 100644--- a/frontend/src/lib/api.ts+++ b/frontend/src/lib/api.ts@@ -7137,7 +7137,7 @@ const api = {async update(promptName: string,- data: { prompt: LLMPrompt['prompt']; base_version: number }+ data: { prompt: LLMPrompt['prompt']; base_version: number; version_description?: string }): Promise<LLMPrompt> {return await new ApiRequest().llmPromptByName(promptName).update({ data })},diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex ad7c12898c47..8a31ddf44cd8 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -7648,6 +7648,7 @@ export interface LLMPrompt {name: stringprompt: stringversion: number+ version_description?: string | nullcreated_by: UserBasicTypecreated_at: stringupdated_at: string@@ -7675,6 +7676,7 @@ export interface LLMPromptPublic {export interface LLMPromptVersionSummary {id: stringversion: number+ version_description?: string | nullcreated_by: UserBasicTypecreated_at: stringis_latest: booleandiff --git a/products/ai_observability/frontend/prompts/llmPromptLogic.test.ts b/products/ai_observability/frontend/prompts/llmPromptLogic.test.tsindex 4e3abd79d196..23a7251e10b0 100644--- a/products/ai_observability/frontend/prompts/llmPromptLogic.test.ts+++ b/products/ai_observability/frontend/prompts/llmPromptLogic.test.ts@@ -377,10 +377,16 @@ describe('llmPromptLogic', () => {expect(logic.values.isPublishReviewOpen).toBe(true)expect(updateSpy).not.toHaveBeenCalled()- // Confirming from the review publishes and closes it+ // Confirming from the review publishes with the typed description and closes it+ logic.actions.setVersionDescription('Tightened the refusal criteria')logic.actions.submitPromptForm()await expectLogic(logic).toDispatchActions(['submitPromptFormSuccess'])expect(updateSpy).toHaveBeenCalledTimes(1)+ expect(updateSpy).toHaveBeenCalledWith('my-test-prompt', {+ prompt: 'My edited prompt.',+ base_version: 2,+ version_description: 'Tightened the refusal criteria',+ })expect(logic.values.isPublishReviewOpen).toBe(false)logic.unmount()diff --git a/products/ai_observability/frontend/prompts/llmPromptLogic.ts b/products/ai_observability/frontend/prompts/llmPromptLogic.tsindex 450a5ba49a72..1234d9f77d2c 100644--- a/products/ai_observability/frontend/prompts/llmPromptLogic.ts+++ b/products/ai_observability/frontend/prompts/llmPromptLogic.ts@@ -125,6 +125,7 @@ function buildPromptVersionSummary(prompt: LLMPrompt, isLatest: boolean): LLMProreturn {id: prompt.id,version: prompt.version,+ version_description: prompt.version_description ?? null,created_by: prompt.created_by,created_at: prompt.created_at,is_latest: isLatest,@@ -166,6 +167,7 @@ export const llmPromptLogic = kea<llmPromptLogicType>([requestPublish: true,openPublishReview: true,closePublishReview: true,+ setVersionDescription: (versionDescription: string) => ({ versionDescription }),}),reducers(({ props }) => ({@@ -248,6 +250,15 @@ export const llmPromptLogic = kea<llmPromptLogicType>([setMode: () => false,},],+ versionDescription: [+ '',+ {+ setVersionDescription: (_, { versionDescription }) => versionDescription,+ submitPromptFormSuccess: () => '',+ closePublishReview: () => '',+ setMode: () => '',+ },+ ],})),loaders(({ props }) => ({@@ -303,9 +314,11 @@ export const llmPromptLogic = kea<llmPromptLogicType>([throw new Error('Cannot publish prompt version: prompt data not loaded')}+ const versionDescription = values.versionDescription.trim()savedPrompt = await api.llmPrompts.update(props.promptName, {prompt: formValues.prompt,base_version: currentPrompt.latest_version,+ ...(versionDescription ? { version_description: versionDescription } : {}),})llmPromptsLogic.findMounted()?.actions.loadPrompts(false)lemonToast.success(`Published v${savedPrompt.version}`)diff --git a/products/ai_observability/frontend/prompts/promptSceneComponents.tsx b/products/ai_observability/frontend/prompts/promptSceneComponents.tsxindex 15aa6865a69d..ca055c874e1a 100644--- a/products/ai_observability/frontend/prompts/promptSceneComponents.tsx+++ b/products/ai_observability/frontend/prompts/promptSceneComponents.tsx@@ -92,6 +92,12 @@ export function PromptViewDetails(): JSX.Element {</span></div>+ {prompt.version_description ? (+ <p className="text-secondary m-0 text-sm italic" data-attr="llma-prompt-version-description">+ {prompt.version_description}+ </p>+ ) : null}+<div><label className="text-xs font-semibold uppercase text-secondary">Name</label><p className="font-mono">{prompt.name}</p>@@ -171,8 +177,9 @@ export function PromptViewDetails(): JSX.Element {}export function PublishReviewModal(): JSX.Element | null {- const { isPublishReviewOpen, prompt, promptForm, nextVersion, isPromptFormSubmitting } = useValues(llmPromptLogic)- const { closePublishReview, submitPromptForm } = useActions(llmPromptLogic)+ const { isPublishReviewOpen, prompt, promptForm, nextVersion, isPromptFormSubmitting, versionDescription } =+ useValues(llmPromptLogic)+ const { closePublishReview, submitPromptForm, setVersionDescription } = useActions(llmPromptLogic)if (!isPrompt(prompt)) {return null@@ -210,32 +217,43 @@ export function PublishReviewModal(): JSX.Element | null {</>}>- <div className="overflow-hidden rounded border" data-attr="llma-prompt-publish-review-diff">- <Suspense- fallback={- <div className="space-y-2 p-4">- <LemonSkeleton active className="h-4 w-full" />- <LemonSkeleton active className="h-4 w-3/4" />- </div>- }- >- <MonacoDiffEditor- original={prompt.prompt}- value={promptForm.prompt}- modified={promptForm.prompt}- language="markdown"- options={{- readOnly: true,- renderSideBySide: true,- minimap: { enabled: false },- scrollBeyondLastLine: false,- wordWrap: 'on',- lineNumbers: 'off',- folding: false,- hideUnchangedRegions: { enabled: true },- }}+ <div className="space-y-3">+ <div className="overflow-hidden rounded border" data-attr="llma-prompt-publish-review-diff">+ <Suspense+ fallback={+ <div className="space-y-2 p-4">+ <LemonSkeleton active className="h-4 w-full" />+ <LemonSkeleton active className="h-4 w-3/4" />+ </div>+ }+ >+ <MonacoDiffEditor+ original={prompt.prompt}+ value={promptForm.prompt}+ modified={promptForm.prompt}+ language="markdown"+ options={{+ readOnly: true,+ renderSideBySide: true,+ minimap: { enabled: false },+ scrollBeyondLastLine: false,+ wordWrap: 'on',+ lineNumbers: 'off',+ folding: false,+ hideUnchangedRegions: { enabled: true },+ }}+ />+ </Suspense>+ </div>+ <LemonField.Pure label="What changed?" help="Optional — shown in the version history.">+ <LemonInput+ value={versionDescription}+ onChange={setVersionDescription}+ placeholder="e.g. Tightened the refusal criteria"+ maxLength={400}+ data-attr="llma-prompt-version-description-input"/>- </Suspense>+ </LemonField.Pure></div></LemonModal>)@@ -710,6 +728,14 @@ export function PromptVersionSidebar({/>)}</div>+ {versionPrompt.version_description ? (+ <div+ className="mb-1 line-clamp-2 text-xs"+ title={versionPrompt.version_description}+ >+ {versionPrompt.version_description}+ </div>+ ) : null}<div className="text-xs text-secondary">{dayjs(versionPrompt.created_at).format('MMM D, YYYY h:mm A')}</div>