{
return [
@@ -71,9 +73,16 @@ function buildSkillColumns(
width: '20%',
render: function renderName(_, skill) {
return (
-
- {skill.name}
-
+
+
+ {skill.name}
+
+ {skill.is_global && (
+ }>
+ Global
+
+ )}
+
)
},
},
@@ -150,55 +159,61 @@ function buildSkillColumns(
Download .zip
-
- {
- LemonDialog.openForm({
- title: 'Duplicate skill',
- initialValues: {
- newName: `${skill.name}-copy`,
- },
- content: (
-
-
-
- ),
- errors: {
- newName: (name: string) => validateSkillName(name),
- },
- onSubmit: async ({ newName }) => {
- duplicateSkill(skill.name, newName)
- },
- })
- }}
- data-attr="llma-skill-dropdown-duplicate"
- fullWidth
- >
- Duplicate
-
-
-
-
- openArchiveSkillDialog(() => deleteSkill(skill.name))}
- data-attr="llma-skill-dropdown-delete"
- fullWidth
- >
- Archive
-
-
+ {/* Duplicate and archive act on the owning team's skill, so a global surfaced
+ from another team is view/download-only here. */}
+ {skill.team_id === currentTeamId && (
+ <>
+
+ {
+ LemonDialog.openForm({
+ title: 'Duplicate skill',
+ initialValues: {
+ newName: `${skill.name}-copy`,
+ },
+ content: (
+
+
+
+ ),
+ errors: {
+ newName: (name: string) => validateSkillName(name),
+ },
+ onSubmit: async ({ newName }) => {
+ duplicateSkill(skill.name, newName)
+ },
+ })
+ }}
+ data-attr="llma-skill-dropdown-duplicate"
+ fullWidth
+ >
+ Duplicate
+
+
+
+
+ openArchiveSkillDialog(() => deleteSkill(skill.name))}
+ data-attr="llma-skill-dropdown-delete"
+ fullWidth
+ >
+ Archive
+
+
+ >
+ )}
>
}
/>
@@ -443,6 +458,7 @@ export function LLMSkillsScene(): JSX.Element {
visibleCategoryTabs,
} = useValues(llmSkillsLogic)
const { searchParams } = useValues(router)
+ const { currentTeamId } = useValues(teamLogic)
const skillUrl = (name: string): string => combineUrl(urls.skill(name), searchParams).url
const fileInputRef = useRef(null)
@@ -451,9 +467,12 @@ export function LLMSkillsScene(): JSX.Element {
// Memoize columns so the array reference doesn't change every render — otherwise every
// nested LemonTable inside the grouped tree reconciles on each parent re-render.
const columns = useMemo(
- () => buildSkillColumns(skillUrl, duplicateSkill, deleteSkill, downloadSkillZip, { showScoutOrigin }),
+ () =>
+ buildSkillColumns(skillUrl, duplicateSkill, deleteSkill, downloadSkillZip, currentTeamId, {
+ showScoutOrigin,
+ }),
// eslint-disable-next-line react-hooks/exhaustive-deps
- [searchParams, duplicateSkill, deleteSkill, downloadSkillZip, showScoutOrigin]
+ [searchParams, duplicateSkill, deleteSkill, downloadSkillZip, currentTeamId, showScoutOrigin]
)
const showGroupedView = filters.group_by_prefix && groupedSkills && !skillsLoading
diff --git a/products/skills/frontend/llmSkillLogic.ts b/products/skills/frontend/llmSkillLogic.ts
index 62b1449a7eb3b..bb9ccb4dc8507 100644
--- a/products/skills/frontend/llmSkillLogic.ts
+++ b/products/skills/frontend/llmSkillLogic.ts
@@ -13,6 +13,7 @@ import {
llmSkillsNameArchiveCreate,
llmSkillsNameFilesRetrieve,
llmSkillsNamePartialUpdate,
+ llmSkillsNameVisibilityCreate,
llmSkillsResolveNameRetrieve,
} from 'products/skills/frontend/generated/api'
import type {
@@ -137,6 +138,8 @@ export const llmSkillLogic = kea([
setCompareVersion: (compareVersion: number | null) => ({ compareVersion }),
downloadSkill: true,
setDownloadingZip: (downloadingZip: boolean) => ({ downloadingZip }),
+ setGlobalVisibility: (isGlobal: boolean) => ({ isGlobal }),
+ setSettingVisibility: (settingVisibility: boolean) => ({ settingVisibility }),
}),
reducers(({ props }) => ({
@@ -201,6 +204,12 @@ export const llmSkillLogic = kea([
setDownloadingZip: (_, { downloadingZip }) => downloadingZip,
},
],
+ settingVisibility: [
+ false,
+ {
+ setSettingVisibility: (_, { settingVisibility }) => settingVisibility,
+ },
+ ],
})),
loaders(({ props }) => ({
@@ -424,6 +433,34 @@ export const llmSkillLogic = kea([
}
},
+ setGlobalVisibility: async ({ isGlobal }) => {
+ const skill = values.skill
+ if (props.skillName === 'new' || !isSkill(skill)) {
+ return
+ }
+ actions.setSettingVisibility(true)
+ try {
+ const updated = await llmSkillsNameVisibilityCreate(String(ApiConfig.getCurrentTeamId()), skill.name, {
+ is_global: isGlobal,
+ })
+ const current = values.skill
+ if (isSkill(current)) {
+ actions.setSkill({ ...current, is_global: updated.is_global })
+ }
+ lemonToast.success(
+ isGlobal ? 'Skill is now visible to everyone.' : 'Skill is now private to this project.'
+ )
+ llmSkillsLogic.findMounted()?.actions.loadSkills(false)
+ } catch (e) {
+ console.error('Failed to update skill visibility', e)
+ const detail =
+ e !== null && typeof e === 'object' && 'detail' in e ? (e as { detail?: string }).detail : undefined
+ lemonToast.error(detail || 'Failed to update skill visibility')
+ } finally {
+ actions.setSettingVisibility(false)
+ }
+ },
+
deleteSkill: async () => {
if (props.skillName !== 'new' && values.skill && isSkill(values.skill)) {
try {
diff --git a/products/skills/frontend/skillSceneComponents.tsx b/products/skills/frontend/skillSceneComponents.tsx
index f1ee60021cbfc..733798abda54b 100644
--- a/products/skills/frontend/skillSceneComponents.tsx
+++ b/products/skills/frontend/skillSceneComponents.tsx
@@ -11,3 +11,23 @@ export function openArchiveSkillDialog(onConfirm: () => void): void {
secondaryButton: { children: 'Cancel' },
})
}
+
+export function openSkillVisibilityDialog(isGlobal: boolean, onConfirm: () => void): void {
+ LemonDialog.open(
+ isGlobal
+ ? {
+ title: 'Make this skill visible to everyone?',
+ description:
+ 'Every PostHog customer will be able to see and use this skill in their own projects. ' +
+ 'Only PostHog staff can do this.',
+ primaryButton: { children: 'Make visible to everyone', onClick: onConfirm },
+ secondaryButton: { children: 'Cancel' },
+ }
+ : {
+ title: 'Make this skill private?',
+ description: "It will stop appearing in other customers' projects and go back to this project only.",
+ primaryButton: { children: 'Make private', onClick: onConfirm },
+ secondaryButton: { children: 'Cancel' },
+ }
+ )
+}