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.

fix(skills): show community in one tab row with skills (#82663)

Andrew Maguire6e3686e229a0
diff --git a/products/skills/frontend/CommunitySkillsScene.tsx b/products/skills/frontend/CommunitySkillsScene.tsx
index 43193b6636c2..05fde9b0da62 100644
--- a/products/skills/frontend/CommunitySkillsScene.tsx
+++ b/products/skills/frontend/CommunitySkillsScene.tsx
@@ -17,7 +17,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 { SkillsSceneShell } from './SkillsSceneShell'
+import { COMMUNITY_SKILLS_TAB_DESCRIPTION, COMMUNITY_SKILLS_TAB_KEY, SkillsSceneShell } from './SkillsSceneShell'
export const scene: SceneExport = {
component: CommunitySkillsScene,
@@ -148,7 +148,13 @@ function CommunitySkillsGrid({ skills, loading }: { skills: CommunitySkillListAp
}
export function CommunitySkillsScene(): JSX.Element {
- return <SkillsSceneShell activeTab="community" content={<CommunitySkillsContent />} />
+ return (
+ <SkillsSceneShell
+ activeTabKey={COMMUNITY_SKILLS_TAB_KEY}
+ description={COMMUNITY_SKILLS_TAB_DESCRIPTION}
+ content={<CommunitySkillsContent />}
+ />
+ )
}
function CommunitySkillsContent(): JSX.Element {
diff --git a/products/skills/frontend/LLMSkillsScene.tsx b/products/skills/frontend/LLMSkillsScene.tsx
index c2a46ee35430..d5c4bc3681e6 100644
--- a/products/skills/frontend/LLMSkillsScene.tsx
+++ b/products/skills/frontend/LLMSkillsScene.tsx
@@ -3,7 +3,7 @@ import { combineUrl, router } from 'kea-router'
import { useMemo, useRef } from 'react'
import { IconDownload, IconPlusSmall, IconUpload } from '@posthog/icons'
-import { LemonDivider, LemonModal, LemonSwitch, LemonTabs, LemonTag, Link } from '@posthog/lemon-ui'
+import { LemonDivider, LemonModal, LemonSwitch, LemonTag, Link } from '@posthog/lemon-ui'
import { AccessControlAction } from 'lib/components/AccessControlAction'
import { CodeSnippet, Language } from 'lib/components/CodeSnippet/CodeSnippet'
@@ -30,15 +30,7 @@ import { AccessControlLevel, AccessControlResourceType } from '~/types'
import type { LLMSkillListApi } from 'products/skills/frontend/generated/api.schemas'
-import {
- DEFAULT_SKILLS_TAB_KEY,
- SKILLS_GROUP_LIMIT,
- SKILLS_PER_PAGE,
- SkillGroupNode,
- SkillGroupTree,
- llmSkillsLogic,
- skillTabUrl,
-} from './llmSkillsLogic'
+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 { SkillsSceneShell } from './SkillsSceneShell'
@@ -441,7 +433,6 @@ export function LLMSkillsScene(): JSX.Element {
activeTabKey,
activeCategory,
activeTabDescription,
- visibleCategoryTabs,
} = useValues(llmSkillsLogic)
const { featureFlags } = useValues(featureFlagLogic)
const { searchParams } = useValues(router)
@@ -494,17 +485,6 @@ export function LLMSkillsScene(): JSX.Element {
</LemonBanner>
)}
- {visibleCategoryTabs.length > 0 && (
- <LemonTabs
- activeKey={activeTabKey}
- onChange={(key) => router.actions.push(skillTabUrl(key))}
- tabs={[
- { key: DEFAULT_SKILLS_TAB_KEY, label: 'Skills' },
- ...visibleCategoryTabs.map((tab) => ({ key: tab.key, label: tab.label })),
- ]}
- />
- )}
-
<div className="space-y-4">
<div className="flex gap-x-4 gap-y-2 items-center flex-wrap">
<LemonInput
@@ -586,7 +566,7 @@ export function LLMSkillsScene(): JSX.Element {
return (
<SkillsSceneShell
- activeTab="your"
+ activeTabKey={activeTabKey}
description={activeTabDescription}
actions={
<>
diff --git a/products/skills/frontend/SkillsSceneShell.tsx b/products/skills/frontend/SkillsSceneShell.tsx
index ba23b53db880..55db22d8e4d8 100644
--- a/products/skills/frontend/SkillsSceneShell.tsx
+++ b/products/skills/frontend/SkillsSceneShell.tsx
@@ -9,50 +9,50 @@ import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
-export type SkillsTab = 'your' | 'community'
+import { DEFAULT_SKILLS_TAB_KEY, skillTabUrl, skillTabsLogic, visibleCategoryTabs } from './skillTabsLogic'
-const TAB_DESCRIPTIONS: Record<SkillsTab, string> = {
- your: 'Manage versioned agent skills that any MCP-connected agent can discover and use.',
- community: 'Discover and install agent skills shared by the PostHog community.',
-}
+/** Tab key for the Community scene, which lives at its own URL rather than under /skills. */
+export const COMMUNITY_SKILLS_TAB_KEY = 'community'
+
+export const COMMUNITY_SKILLS_TAB_DESCRIPTION = 'Discover and install agent skills shared by the PostHog community.'
/**
- * Shared shell for the two Skills tabs ("Your skills" and "Community"). Each scene renders this
- * with only its own tab's content; the inactive tab navigates via its `link`, so its content is
- * never mounted here. This keeps the two scenes' logics (and URL contracts) independent while
- * presenting them as one tabbed surface. The Community tab is gated behind the community-skills
- * flag (but stays visible when it's already the active tab, so a direct URL still renders cleanly).
+ * Shared shell for every Skills tab. It renders one tab bar — the default "Skills" tab, the
+ * category tabs (Scouts, Code review), then "Community" — so the category tabs and Community sit
+ * in the same row instead of stacking two bars.
+ *
+ * Community is a separate scene at its own URL, so each scene renders this with only its own tab's
+ * content; the other tabs navigate via their `link` and are never mounted here. That keeps the two
+ * scenes' logics (and URL contracts) independent while presenting them as one tabbed surface. The
+ * Community tab is gated behind the community-skills flag (but stays visible when it's already the
+ * active tab, so a direct URL still renders cleanly).
*/
export function SkillsSceneShell({
- activeTab,
+ activeTabKey,
actions,
description,
content,
}: {
- activeTab: SkillsTab
+ activeTabKey: string
actions?: JSX.Element
- description?: string
+ description: string
content: JSX.Element
}): JSX.Element {
const { featureFlags } = useValues(featureFlagLogic)
+ // Mounted on the Community scene too, so switching to Community doesn't drop the category tabs
+ // out of the row. It only probes the per-category counts, not the skills list.
+ const { categoryCounts } = useValues(skillTabsLogic)
const communityEnabled = !!featureFlags[FEATURE_FLAGS.LLM_ANALYTICS_COMMUNITY_SKILLS]
- const tabs: LemonTab<SkillsTab>[] = [
- {
- key: 'your',
- label: 'Your skills',
- link: urls.skills(),
- content: activeTab === 'your' ? content : <></>,
- },
- ...(communityEnabled || activeTab === 'community'
- ? [
- {
- key: 'community' as SkillsTab,
- label: 'Community',
- link: urls.communitySkills(),
- content: activeTab === 'community' ? content : <></>,
- },
- ]
+ const tabs: LemonTab<string>[] = [
+ { key: DEFAULT_SKILLS_TAB_KEY, label: 'Skills', link: skillTabUrl(DEFAULT_SKILLS_TAB_KEY) },
+ ...visibleCategoryTabs(categoryCounts, activeTabKey).map((tab) => ({
+ key: tab.key,
+ label: tab.label,
+ link: skillTabUrl(tab.key),
+ })),
+ ...(communityEnabled || activeTabKey === COMMUNITY_SKILLS_TAB_KEY
+ ? [{ key: COMMUNITY_SKILLS_TAB_KEY, label: 'Community', link: urls.communitySkills() }]
: []),
]
@@ -60,17 +60,15 @@ export function SkillsSceneShell({
<SceneContent>
<SceneTitleSection
name="Skills"
- description={description ?? TAB_DESCRIPTIONS[activeTab]}
+ description={description}
resourceType={{ type: 'llm_analytics' }}
actions={actions}
/>
- {/* Only surface the tab bar once Community is reachable — otherwise the lone "Your skills"
- tab is noise, so flag-off users see the plain Skills scene exactly as before. */}
- {tabs.length > 1 ? (
- <LemonTabs activeKey={activeTab} data-attr="skills-tabs" tabs={tabs} sceneInset />
- ) : (
- content
- )}
+ {/* The bar carries no tab content, so `content` keeps its place in the tree when the
+ category counts land and the bar appears. Only surface the bar once there's
+ somewhere else to go — otherwise the lone "Skills" tab is noise. */}
+ {tabs.length > 1 && <LemonTabs activeKey={activeTabKey} data-attr="skills-tabs" tabs={tabs} sceneInset />}
+ {content}
</SceneContent>
)
}
diff --git a/products/skills/frontend/llmSkillsLogic.ts b/products/skills/frontend/llmSkillsLogic.ts
index 9ef6ad1fd6ac..d1c418270e4e 100644
--- a/products/skills/frontend/llmSkillsLogic.ts
+++ b/products/skills/frontend/llmSkillsLogic.ts
@@ -28,6 +28,15 @@ import type {
PaginatedLLMSkillListListApi,
} from 'products/skills/frontend/generated/api.schemas'
+import {
+ DEFAULT_SKILLS_TAB_KEY,
+ SKILL_CATEGORY_TABS,
+ skillCategoryForTabKey,
+ skillTabDescription,
+ skillTabUrl,
+ skillTabsLogic,
+} from './skillTabsLogic'
+
/** Builds the `/plugin marketplace add` command. The token is embedded once minted; until then
* a placeholder is shown. */
export function buildMarketplaceCommand(token: string | null): string {
@@ -71,58 +80,6 @@ export const SKILLS_GROUP_LIMIT = 500
export const SKILLS_GROUP_MAX_DEPTH = 4
export const LLM_SKILLS_FORCE_RELOAD_PARAM = 'llm_skills_force_reload'
-/** URL/UI key for the default tab — the uncategorized skills (everything not pulled into a category tab). */
-export const DEFAULT_SKILLS_TAB_KEY: string = 'skills'
-
-/** Sub-title shown for the default "Skills" tab. Category tabs carry their own copy (below). */
-export const DEFAULT_SKILLS_TAB_DESCRIPTION = 'Manage versioned agent skills that any agent can discover and use.'
-
-export interface SkillCategoryTab {
- /** Tab key, also the `/skills/<key>` URL segment. */
- key: string
- /** The `LLMSkill.category` value this tab filters to. */
- category: string
- label: string
- /** Sub-title shown under the scene title while this tab is active. */
- description: string
-}
-
-/**
- * Category-backed tabs shown alongside the default "Skills" tab. Each entry surfaces one
- * `LLMSkill.category` value as its own tab and removes it from the default list (which only shows
- * uncategorized skills). To add a tab — e.g. official AI-plugin skills — add an entry here, register
- * the matching `/skills/<key>` route in manifest.tsx, and have the producer stamp that `category`.
- */
-export const SKILL_CATEGORY_TABS: SkillCategoryTab[] = [
- {
- key: 'scouts',
- category: 'scout',
- label: 'Scouts',
- description:
- "Scouts — scheduled agents that scan your project and surface findings in your inbox. Includes PostHog's canonical scouts and any custom ones you author.",
- },
- {
- key: 'review-hog',
- category: 'review_hog',
- label: 'Code review',
- description:
- "ReviewHog's code-review skills: the specialist perspectives applied in parallel when reviewing a pull request (logic & correctness, contracts & security, performance & reliability) and the validation criteria that decide which findings are worth surfacing. Edit a skill to retune it for your team.",
- },
-]
-
-export function skillCategoryForTabKey(tabKey: string): string {
- return SKILL_CATEGORY_TABS.find((tab) => tab.key === tabKey)?.category ?? ''
-}
-
-export function skillTabDescription(tabKey: string): string {
- return SKILL_CATEGORY_TABS.find((tab) => tab.key === tabKey)?.description ?? DEFAULT_SKILLS_TAB_DESCRIPTION
-}
-
-/** The `/skills` or `/skills/<categoryKey>` path for a tab key. */
-export function skillTabUrl(tabKey: string): string {
- return tabKey === DEFAULT_SKILLS_TAB_KEY ? urls.skills() : urls.skillsCategoryTab(tabKey)
-}
-
export interface SkillFilters {
page: number
search: string
@@ -237,8 +194,6 @@ export interface llmSkillsLogicValues {
activeCategory: string
activeTabDescription: string
activeTabKey: string
- categoryCounts: Record<string, number>
- categoryCountsLoading: boolean
codexCommand: string
connectModalOpen: boolean
count: number
@@ -255,7 +210,6 @@ export interface llmSkillsLogicValues {
skills: PaginatedLLMSkillListListApi
skillsLoading: boolean
sorting: Sorting | null
- visibleCategoryTabs: SkillCategoryTab[]
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -279,31 +233,6 @@ export interface llmSkillsLogicActions {
issueMarketplaceCommand: (rotate?: boolean) => {
rotate: boolean
}
- loadCategoryCounts: () => {
- value: true
- }
- loadCategoryCountsFailure: (
- error: string,
- errorObject?: any
- ) => {
- error: string
- errorObject?: any
- }
- loadCategoryCountsSuccess: (
- categoryCounts: {
- [k: string]: number
- },
- payload?: {
- value: true
- }
- ) => {
- categoryCounts: {
- [k: string]: number
- }
- payload?: {
- value: true
- }
- }
loadMarketplaceState: () => {
value: true
}
@@ -363,7 +292,6 @@ export interface llmSkillsLogicMeta {
filters: (rawFilters: Partial<SkillFilters> | null) => SkillFilters
activeCategory: (activeTabKey: string) => string
activeTabDescription: (activeTabKey: string) => string
- visibleCategoryTabs: (categoryCounts: Record<string, number>, activeTabKey: string) => SkillCategoryTab[]
count: (skills: PaginatedLLMSkillListListApi) => number
marketplaceCommand: (marketplaceState: LLMSkillMarketplaceCommandApi | null) => string
codexCommand: (marketplaceState: LLMSkillMarketplaceCommandApi | null) => string
@@ -392,7 +320,6 @@ export const llmSkillsLogic = kea<llmSkillsLogicType>([
debounce,
}),
loadSkills: (debounce: boolean = true) => ({ debounce }),
- loadCategoryCounts: true,
setActiveTab: (tabKey: string) => ({ tabKey }),
deleteSkill: (skillName: string) => ({ skillName }),
duplicateSkill: (skillName: string, newName: string) => ({ skillName, newName }),
@@ -506,27 +433,6 @@ export const llmSkillsLogic = kea<llmSkillsLogicType>([
},
},
],
- // Per-category skill counts, used to decide which category tabs to show. Loaded once on
- // mount (and after a delete) with a cheap limit=1 probe per category — we only read `count`.
- categoryCounts: [
- {} as Record<string, number>,
- {
- loadCategoryCounts: async () => {
- const teamId = String(ApiConfig.getCurrentTeamId())
- const entries = await Promise.all(
- SKILL_CATEGORY_TABS.map(async (tab) => {
- const { count } = await llmSkillsList(teamId, {
- category: tab.category,
- limit: 1,
- offset: 0,
- })
- return [tab.category, count] as const
- })
- )
- return Object.fromEntries(entries)
- },
- },
- ],
})),
selectors({
@@ -545,17 +451,6 @@ export const llmSkillsLogic = kea<llmSkillsLogicType>([
(activeTabKey: string): string => skillTabDescription(activeTabKey),
],
- // A category tab is shown only once the team has at least one skill in that category.
- // The active tab is always kept visible so direct navigation to /skills/<key> (or deleting
- // the last skill while viewing the tab) doesn't strand the user on a tab that isn't listed.
- visibleCategoryTabs: [
- (s) => [s.categoryCounts, s.activeTabKey],
- (categoryCounts: Record<string, number>, activeTabKey: string): SkillCategoryTab[] =>
- SKILL_CATEGORY_TABS.filter(
- (tab) => (categoryCounts[tab.category] ?? 0) > 0 || tab.key === activeTabKey
- ),
- ],
-
count: [(s) => [s.skills], (skills: PaginatedLLMSkillListListApi) => skills.count],
marketplaceCommand: [
@@ -648,7 +543,7 @@ export const llmSkillsLogic = kea<llmSkillsLogicType>([
lemonToast.info(`${skillName || 'Skill'} has been archived.`)
await asyncActions.loadSkills(false)
// Archiving may have removed the last skill in a category — refresh tab visibility.
- actions.loadCategoryCounts()
+ skillTabsLogic.findMounted()?.actions.loadCategoryCounts()
} catch (e) {
console.error('Failed to archive skill', e)
lemonToast.error('Failed to archive skill')
@@ -784,6 +679,5 @@ export const llmSkillsLogic = kea<llmSkillsLogicType>([
afterMount(({ actions }) => {
actions.loadSkills()
- actions.loadCategoryCounts()
}),
])
diff --git a/products/skills/frontend/skillTabsLogic.ts b/products/skills/frontend/skillTabsLogic.ts
new file mode 100644
index 000000000000..76dc36cc687a
--- /dev/null
+++ b/products/skills/frontend/skillTabsLogic.ts
@@ -0,0 +1,133 @@
+import { MakeLogicType, afterMount, kea, path } from 'kea'
+import { loaders } from 'kea-loaders'
+
+import { ApiConfig } from '~/lib/api'
+import { urls } from '~/scenes/urls'
+
+import { llmSkillsList } from 'products/skills/frontend/generated/api'
+
+/** URL/UI key for the default tab — the uncategorized skills (everything not pulled into a category tab). */
+export const DEFAULT_SKILLS_TAB_KEY: string = 'skills'
+
+/** Sub-title shown for the default "Skills" tab. Category tabs carry their own copy (below). */
+export const DEFAULT_SKILLS_TAB_DESCRIPTION = 'Manage versioned agent skills that any agent can discover and use.'
+
+export interface SkillCategoryTab {
+ /** Tab key, also the `/skills/<key>` URL segment. */
+ key: string
+ /** The `LLMSkill.category` value this tab filters to. */
+ category: string
+ label: string
+ /** Sub-title shown under the scene title while this tab is active. */
+ description: string
+}
+
+/**
+ * Category-backed tabs shown alongside the default "Skills" tab. Each entry surfaces one
+ * `LLMSkill.category` value as its own tab and removes it from the default list (which only shows
+ * uncategorized skills). To add a tab — e.g. official AI-plugin skills — add an entry here, register
+ * the matching `/skills/<key>` route in manifest.tsx, and have the producer stamp that `category`.
+ */
+export const SKILL_CATEGORY_TABS: SkillCategoryTab[] = [
+ {
+ key: 'scouts',
+ category: 'scout',
+ label: 'Scouts',
+ description:
+ "Scouts — scheduled agents that scan your project and surface findings in your inbox. Includes PostHog's canonical scouts and any custom ones you author.",
+ },
+ {
+ key: 'review-hog',
+ category: 'review_hog',
+ label: 'Code review',
+ description:
+ "ReviewHog's code-review skills: the specialist perspectives applied in parallel when reviewing a pull request (logic & correctness, contracts & security, performance & reliability) and the validation criteria that decide which findings are worth surfacing. Edit a skill to retune it for your team.",
+ },
+]
+
+export function skillCategoryForTabKey(tabKey: string): string {
+ return SKILL_CATEGORY_TABS.find((tab) => tab.key === tabKey)?.category ?? ''
+}
+
+export function skillTabDescription(tabKey: string): string {
+ return SKILL_CATEGORY_TABS.find((tab) => tab.key === tabKey)?.description ?? DEFAULT_SKILLS_TAB_DESCRIPTION
+}
+
+/** The `/skills` or `/skills/<categoryKey>` path for a tab key. */
+export function skillTabUrl(tabKey: string): string {
+ return tabKey === DEFAULT_SKILLS_TAB_KEY ? urls.skills() : urls.skillsCategoryTab(tabKey)
+}
+
+/** A category tab is shown only once the team has at least one skill in that category. The active
+ * tab is always kept visible so direct navigation to /skills/<key> (or deleting the last skill while
+ * viewing the tab) doesn't strand the user on a tab that isn't listed. */
+export function visibleCategoryTabs(categoryCounts: Record<string, number>, activeTabKey: string): SkillCategoryTab[] {
+ return SKILL_CATEGORY_TABS.filter((tab) => (categoryCounts[tab.category] ?? 0) > 0 || tab.key === activeTabKey)
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface skillTabsLogicValues {
+ categoryCounts: Record<string, number>
+ categoryCountsLoading: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface skillTabsLogicActions {
+ loadCategoryCounts: () => any
+ loadCategoryCountsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadCategoryCountsSuccess: (
+ categoryCounts: {
+ [k: string]: number
+ },
+ payload?: any
+ ) => {
+ categoryCounts: {
+ [k: string]: number
+ }
+ payload?: any
+ }
+}
+
+export type skillTabsLogicType = MakeLogicType<skillTabsLogicValues, skillTabsLogicActions>
+
+/**
+ * Which category tabs the skills tab bar shows. Kept apart from `llmSkillsLogic` so the Community
+ * scene can render the same tab bar without mounting the skills list and its loaders.
+ */
+export const skillTabsLogic = kea<skillTabsLogicType>([
+ path(['scenes', 'skills', 'skillTabsLogic']),
+
+ loaders({
+ // Per-category skill counts, used to decide which category tabs to show. Loaded once on
+ // mount (and after a delete) with a cheap limit=1 probe per category — we only read `count`.
+ categoryCounts: [
+ {} as Record<string, number>,
+ {
+ loadCategoryCounts: async () => {
+ const teamId = String(ApiConfig.getCurrentTeamId())
+ const entries = await Promise.all(
+ SKILL_CATEGORY_TABS.map(async (tab) => {
+ const { count } = await llmSkillsList(teamId, {
+ category: tab.category,
+ limit: 1,
+ offset: 0,
+ })
+ return [tab.category, count] as const
+ })
+ )
+ return Object.fromEntries(entries)
+ },
+ },
+ ],
+ }),
+
+ afterMount(({ actions }) => {
+ actions.loadCategoryCounts()
+ }),
+])