: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): templated community skills UI (7/7) (#65016)
Andrew Maguireaf8d4f94933b
diff --git a/products/skills/frontend/CommunitySkillsScene.tsx b/products/skills/frontend/CommunitySkillsScene.tsxindex 05fde9b0da62..57efa3930897 100644--- a/products/skills/frontend/CommunitySkillsScene.tsx+++ b/products/skills/frontend/CommunitySkillsScene.tsx@@ -4,6 +4,8 @@ import { IconGithub, IconThumbsUp } from '@posthog/icons'import { Link } from '@posthog/lemon-ui'import { LemonButton } from 'lib/lemon-ui/LemonButton'+import { LemonDialog } from 'lib/lemon-ui/LemonDialog'+import { LemonField } from 'lib/lemon-ui/LemonField'import { LemonInput } from 'lib/lemon-ui/LemonInput'import { LemonSelect } from 'lib/lemon-ui/LemonSelect'import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'@@ -16,7 +18,7 @@ import { ProductKey } from '~/queries/schema/schema-general'import { communitySkillsLogic } from './communitySkillsLogic'import { TrustTierEnumApi } from './generated/api.schemas'-import type { CommunitySkillListApi } from './generated/api.schemas'+import type { CommunitySkillListApi, CommunitySkillTemplateVariableApi } from './generated/api.schemas'import { COMMUNITY_SKILLS_TAB_DESCRIPTION, COMMUNITY_SKILLS_TAB_KEY, SkillsSceneShell } from './SkillsSceneShell'export const scene: SceneExport = {@@ -64,18 +66,52 @@ function AuthorHandle({ handle }: { handle: string }): JSX.Element {)}+// A template declares variables that must be bound before install. Collect a value per variable,+// then install with them. Defaults prefill; required variables are guarded.+function openTemplateInstallDialog(+ skill: CommunitySkillListApi,+ variables: readonly CommunitySkillTemplateVariableApi[],+ install: (slug: string, newName?: string, values?: Record<string, string>) => void+): void {+ LemonDialog.openForm({+ title: `Install "${skill.name}"`,+ description: 'This is a template. Provide a value for each variable to customize the installed skill.',+ initialValues: Object.fromEntries(variables.map((v) => [v.name, v.default ?? ''])),+ content: (+ <div className="flex flex-col gap-2">+ {variables.map((v) => (+ <LemonField key={v.name} name={v.name} label={v.prompt || v.name}>+ <LemonInput data-attr={`community-skill-template-var-${v.name}`} autoFocus={false} />+ </LemonField>+ ))}+ </div>+ ),+ errors: Object.fromEntries(+ variables+ .filter((v) => v.is_required)+ .map((v) => [v.name, (value: string) => (!value?.trim() ? 'This variable is required' : undefined)])+ ),+ onSubmit: (values) => install(skill.slug, undefined, values as Record<string, string>),+ })+}+function CommunitySkillCard({ skill }: { skill: CommunitySkillListApi }): JSX.Element {const { installingSlugs, votingSlugs } = useValues(communitySkillsLogic)const { installSkill, toggleVote } = useActions(communitySkillsLogic)const installing = !!installingSlugs[skill.slug]const voting = !!votingSlugs[skill.slug]const sourceUrl = skill.github_url ? githubSourceUrl(skill.github_url) : null+ const templateVariables = skill.template_variables ?? []+ const isTemplate = templateVariables.length > 0return (<div className="flex flex-col gap-2 border rounded p-4 bg-bg-light h-full"><div className="flex items-start justify-between gap-2"><h3 className="font-semibold m-0">{skill.name}</h3>- <TrustTierBadge tier={skill.trust_tier} />+ <div className="flex items-center gap-1 shrink-0">+ {isTemplate ? <LemonTag type="highlight">Template</LemonTag> : null}+ <TrustTierBadge tier={skill.trust_tier} />+ </div></div><p className="text-muted text-sm grow line-clamp-3">{skill.description}</p><div className="flex flex-wrap gap-1">@@ -113,9 +149,13 @@ function CommunitySkillCard({ skill }: { skill: CommunitySkillListApi }): JSX.Eltype="primary"loading={installing}disabledReason={installing ? 'Installing…' : undefined}- onClick={() => installSkill(skill.slug)}+ onClick={() =>+ isTemplate+ ? openTemplateInstallDialog(skill, templateVariables, installSkill)+ : installSkill(skill.slug)+ }>- Install+ {isTemplate ? 'Install…' : 'Install'}</LemonButton></div></div>diff --git a/products/skills/frontend/communitySkillsLogic.ts b/products/skills/frontend/communitySkillsLogic.tsindex 0c009779869f..8d2fb7c0d056 100644--- a/products/skills/frontend/communitySkillsLogic.ts+++ b/products/skills/frontend/communitySkillsLogic.ts@@ -77,10 +77,12 @@ export interface communitySkillsLogicValues {export interface communitySkillsLogicActions {installSkill: (slug: string,- newName?: string+ newName?: string,+ variables?: Record<string, string>) => {newName: string | undefinedslug: string+ variables: Record<string, string> | undefined}installSkillFailure: (slug: string) => {slug: string@@ -176,7 +178,11 @@ export const communitySkillsLogic = kea<communitySkillsLogicType>([debounce,}),loadSkills: (debounce: boolean = true) => ({ debounce }),- installSkill: (slug: string, newName?: string) => ({ slug, newName }),+ installSkill: (slug: string, newName?: string, variables?: Record<string, string>) => ({+ slug,+ newName,+ variables,+ }),installSkillSuccess: (slug: string) => ({ slug }),installSkillFailure: (slug: string) => ({ slug }),toggleVote: (slug: string) => ({ slug }),@@ -287,10 +293,11 @@ export const communitySkillsLogic = kea<communitySkillsLogicType>([}},- installSkill: async ({ slug, newName }) => {+ installSkill: async ({ slug, newName, variables }) => {try {await communitySkillsInstallCreate(String(ApiConfig.getCurrentTeamId()), slug, {new_name: newName,+ variables,})lemonToast.success(`Installed "${newName || slug}" into your project.`)actions.installSkillSuccess(slug)