Skip to content

: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.

feat(skills): publish to community from the single-skill view (#89851)

posthog[bot]749f2392a361
diff --git a/products/skills/frontend/LLMSkillScene.tsx b/products/skills/frontend/LLMSkillScene.tsx
index 028414a0f8e6..6049f54d5a6b 100644
--- a/products/skills/frontend/LLMSkillScene.tsx
+++ b/products/skills/frontend/LLMSkillScene.tsx
@@ -18,6 +18,7 @@ import { LemonBanner, LemonButton, LemonSelect, LemonTag, LemonTextArea, Link }
import { AccessControlAction } from 'lib/components/AccessControlAction'
import { CodeSnippet, Language } from 'lib/components/CodeSnippet/CodeSnippet'
import { NotFound } from 'lib/components/NotFound'
+import { FEATURE_FLAGS } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
import { IconLink } from 'lib/lemon-ui/icons'
import { More } from 'lib/lemon-ui/LemonButton/More'
@@ -26,11 +27,13 @@ import { LemonInput } from 'lib/lemon-ui/LemonInput'
import { LemonMarkdownWithMermaid } from 'lib/lemon-ui/LemonMarkdown/LemonMarkdownWithMermaid'
import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { userHasAccess } from 'lib/utils/accessControlUtils'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { lazyWithRetry } from 'lib/utils/retryImport'
import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
+import { userLogic } from 'scenes/userLogic'
import { themeLogic } from '~/layout/navigation-3000/themeLogic'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
@@ -43,11 +46,12 @@ import type { LLMSkillFileManifestApi, LLMSkillVersionSummaryApi } from 'product
import type { SkillFormFileValues } from './llmSkillLogic'
import { SkillLogicProps, SkillMode, isSkill, llmSkillLogic } from './llmSkillLogic'
+import { llmSkillsLogic } from './llmSkillsLogic'
import { SKILL_NAME_MAX_LENGTH, SKILL_DESCRIPTION_MAX_LENGTH } from './skillConstants'
import { skillFileLogic } from './skillFileLogic'
import { collectFilesFromDrop } from './skillFileUpload'
import { SkillOwners } from './SkillOwners'
-import { SkillPublishReviewModal, openArchiveSkillDialog } from './skillSceneComponents'
+import { SkillPublishReviewModal, openArchiveSkillDialog, openPublishToCommunityDialog } from './skillSceneComponents'
const MonacoDiffEditor = lazyWithRetry(() => import('lib/components/MonacoDiffEditor'))
@@ -83,6 +87,12 @@ export function LLMSkillScene(): JSX.Element {
nextVersion,
} = useValues(llmSkillLogic)
const { searchParams } = useValues(router)
+ // Reuse the list scene's publish flow: its action, per-skill in-flight guard, and resolved
+ // GitHub handle. Mounting llmSkillsLogic here shares that single source of truth.
+ const { publishingSkills, githubLogin } = useValues(llmSkillsLogic)
+ const { publishToCommunity } = useActions(llmSkillsLogic)
+ const { featureFlags } = useValues(featureFlagLogic)
+ const { user } = useValues(userLogic)
const {
submitSkillForm,
@@ -112,6 +122,26 @@ export function LLMSkillScene(): JSX.Element {
// A direct link with `?edit=true` shouldn't grant edit access the New version button
// wouldn't otherwise give — fall back to the read-only view when the user can't actually publish.
const canEditSkill = userHasAccess(AccessControlResourceType.LlmSkill, AccessControlLevel.Editor)
+
+ const communitySkillsEnabled = !!featureFlags[FEATURE_FLAGS.LLM_ANALYTICS_COMMUNITY_SKILLS]
+ const skillOwners = isSkill(skill) ? skill.owners : []
+ const isOwner = !!user && skillOwners.some((owner) => owner.uuid === user.uuid)
+ // Publishing is owner-only on the backend, so mirror that here instead of letting a non-owner's
+ // click come back a 403. In-flight guard keyed on the skill name matches the list view.
+ // The backend publishes the latest version by name, so block publishing from a historical
+ // version to avoid pushing content the user is not viewing.
+ const publishDisabledReason = isSkill(skill)
+ ? publishingSkills[skill.name]
+ ? 'Publishing…'
+ : skillOwners.length === 0
+ ? 'Add an owner before publishing to the community'
+ : !isOwner
+ ? "Only the skill's owners can publish it"
+ : isHistoricalVersion
+ ? 'Switch to the latest version to publish'
+ : undefined
+ : undefined
+
const content =
isViewMode || !canEditSkill ? (
<SceneContent>
@@ -169,19 +199,43 @@ export function LLMSkillScene(): JSX.Element {
<More
size="small"
overlay={
- <AccessControlAction
- resourceType={AccessControlResourceType.LlmSkill}
- minAccessLevel={AccessControlLevel.Editor}
- >
- <LemonButton
- status="danger"
- onClick={() => openArchiveSkillDialog(deleteSkill)}
- data-attr="llma-skill-delete-button"
- fullWidth
+ <>
+ {communitySkillsEnabled && isSkill(skill) && (
+ <AccessControlAction
+ resourceType={AccessControlResourceType.LlmSkill}
+ minAccessLevel={AccessControlLevel.Editor}
+ >
+ <LemonButton
+ onClick={() =>
+ openPublishToCommunityDialog({
+ skillName: skill.name,
+ githubLogin,
+ onPublish: publishToCommunity,
+ })
+ }
+ disabledReason={publishDisabledReason}
+ data-attr="llma-skill-publish-community-button"
+ fullWidth
+ >
+ Publish to community
+ </LemonButton>
+ </AccessControlAction>
+ )}
+
+ <AccessControlAction
+ resourceType={AccessControlResourceType.LlmSkill}
+ minAccessLevel={AccessControlLevel.Editor}
>
- Archive
- </LemonButton>
- </AccessControlAction>
+ <LemonButton
+ status="danger"
+ onClick={() => openArchiveSkillDialog(deleteSkill)}
+ data-attr="llma-skill-delete-button"
+ fullWidth
+ >
+ Archive
+ </LemonButton>
+ </AccessControlAction>
+ </>
}
/>
</>
diff --git a/products/skills/frontend/LLMSkillsScene.tsx b/products/skills/frontend/LLMSkillsScene.tsx
index 600373152745..41fdd2efe8ce 100644
--- a/products/skills/frontend/LLMSkillsScene.tsx
+++ b/products/skills/frontend/LLMSkillsScene.tsx
@@ -34,7 +34,7 @@ import type { LLMSkillListApi } from 'products/skills/frontend/generated/api.sch
import { llmSkillsEmptyState } from './emptyState/llmSkillsEmptyState'
import { SKILLS_GROUP_LIMIT, SKILLS_PER_PAGE, SkillGroupNode, SkillGroupTree, llmSkillsLogic } from './llmSkillsLogic'
import { SKILL_NAME_MAX_LENGTH, validateSkillName } from './skillConstants'
-import { openArchiveSkillDialog } from './skillSceneComponents'
+import { openArchiveSkillDialog, openPublishToCommunityDialog } from './skillSceneComponents'
import { SkillsSceneShell } from './SkillsSceneShell'
export const scene: SceneExport = {
@@ -491,42 +491,7 @@ export function LLMSkillsScene(): JSX.Element {
const showCommunityDiscovery = communitySkillsEnabled && !skillsLoading && skills.count === 0 && !filters.search
const openPublishDialog = (skill: LLMSkillListApi): void => {
- LemonDialog.openForm({
- title: 'Publish to community',
- description:
- "Publishing commits the skill's instructions and every bundled file to a public GitHub repo, then opens a pull request for a maintainer to review. The contents are public from the moment you submit, so don't include credentials or internal details.",
- initialValues: {
- display_name: skill.name.replace(/-/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase()),
- tags: '',
- // Prefill with the user's resolved GitHub handle when we have one; the field stays
- // editable so users without a linked GitHub identity can still type one (free-text fallback).
- author_handle: githubLogin ?? '',
- },
- content: (
- <div className="flex flex-col gap-2">
- <LemonField name="display_name" label="Display name">
- <LemonInput data-attr="llma-publish-display-name" autoFocus />
- </LemonField>
- <LemonField name="tags" label="Tags (comma-separated)">
- <LemonInput data-attr="llma-publish-tags" placeholder="web-analytics, triage" />
- </LemonField>
- <LemonField name="author_handle" label="Your GitHub handle (optional)">
- <LemonInput data-attr="llma-publish-author-handle" placeholder="octocat" />
- </LemonField>
- </div>
- ),
- onSubmit: ({ display_name, tags, author_handle }) =>
- publishToCommunity(skill.name, {
- display_name: display_name?.trim() || undefined,
- tags: tags
- ? tags
- .split(',')
- .map((t: string) => t.trim())
- .filter(Boolean)
- : undefined,
- author_handle: author_handle?.trim() || undefined,
- }),
- })
+ openPublishToCommunityDialog({ skillName: skill.name, githubLogin, onPublish: publishToCommunity })
}
// Memoize columns so the array reference doesn't change every render — otherwise every
diff --git a/products/skills/frontend/skillSceneComponents.tsx b/products/skills/frontend/skillSceneComponents.tsx
index 6cef2b8ea48b..efa9d34eaa89 100644
--- a/products/skills/frontend/skillSceneComponents.tsx
+++ b/products/skills/frontend/skillSceneComponents.tsx
@@ -27,6 +27,61 @@ export function openArchiveSkillDialog(onConfirm: () => void): void {
})
}
+interface PublishToCommunityOptions {
+ display_name?: string
+ tags?: string[]
+ author_handle?: string
+}
+
+/** Collect the publish fields, then hand them to `onPublish`. Shared so the list view and the
+ * single-skill view open the identical dialog. */
+export function openPublishToCommunityDialog({
+ skillName,
+ githubLogin,
+ onPublish,
+}: {
+ skillName: string
+ githubLogin: string | null
+ onPublish: (skillName: string, options: PublishToCommunityOptions) => void
+}): void {
+ LemonDialog.openForm({
+ title: 'Publish to community',
+ description:
+ "Publishing commits the skill's instructions and every bundled file to a public GitHub repo, then opens a pull request for a maintainer to review. The contents are public from the moment you submit, so don't include credentials or internal details.",
+ initialValues: {
+ display_name: skillName.replace(/-/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase()),
+ tags: '',
+ // Prefill with the user's resolved GitHub handle when we have one; the field stays
+ // editable so users without a linked GitHub identity can still type one (free-text fallback).
+ author_handle: githubLogin ?? '',
+ },
+ content: (
+ <div className="flex flex-col gap-2">
+ <LemonField name="display_name" label="Display name">
+ <LemonInput data-attr="llma-publish-display-name" autoFocus />
+ </LemonField>
+ <LemonField name="tags" label="Tags (comma-separated)">
+ <LemonInput data-attr="llma-publish-tags" placeholder="web-analytics, triage" />
+ </LemonField>
+ <LemonField name="author_handle" label="Your GitHub handle (optional)">
+ <LemonInput data-attr="llma-publish-author-handle" placeholder="octocat" />
+ </LemonField>
+ </div>
+ ),
+ onSubmit: ({ display_name, tags, author_handle }) =>
+ onPublish(skillName, {
+ display_name: display_name?.trim() || undefined,
+ tags: tags
+ ? tags
+ .split(',')
+ .map((t: string) => t.trim())
+ .filter(Boolean)
+ : undefined,
+ author_handle: author_handle?.trim() || undefined,
+ }),
+ })
+}
+
interface FileChanges {
added: string[]
removed: string[]