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): show and edit skill owners (#88021)

posthog[bot]73f93bbd6d74
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 6a460b614a48..d708193e9b7d 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5661,17 +5661,21 @@ snapshots:
scenes-app-ai-observability-sentiment--tag-positive--light:
hash: v1.k794b7964.a89a05ca65812c28ec1b01e35aa4fc271a56c5d0ffd8fa3a9b9f479fd0f5cc3b.6ntaO7dlEBGxsnHCdx2Y7bfB28RtBznX3XNjcHdplZ8
scenes-app-ai-observability-skills--skill-detail-side-by-side-above-2-xl-breakpoint--superwide--dark:
- hash: v1.k794b7964.ad9d0b984ec3c4a23a2f1a3b863801892848d81684d99f1254b1104423028e41.cGKF-pISAWqt_Hz39QTszv-h1UihkgYmmTo8cig15Tw
+ hash: v1.k794b7964.39ca895c7d8f0aafdd041e9578ce552d37520442d6df7a2d6d554dfdc032b5ba.dqxACinzs4OesVScmWpwTnoPMejqxFaHIHSidJnXKOs
scenes-app-ai-observability-skills--skill-detail-side-by-side-above-2-xl-breakpoint--superwide--light:
- hash: v1.k794b7964.6e5e67c9285b77d544d4a771f361ee9bff7786412332d2a5b6cdff8520b39d60.jXK61KTlte4lIUEI716-eYZNCaDGwpnsBCAWmbsxev0
+ hash: v1.k794b7964.24d922cd75b23259cb13b89c0edff3a4d912f7f1bc750fa4240f7d834cd86bbd.Ll_EVQoF7bISDXNCxYBvSA20jDbIzWr5To9z7gGk2UY
scenes-app-ai-observability-skills--skill-detail-stacked-below-2-xl-breakpoint--medium--dark:
- hash: v1.k794b7964.3382740befef136d1848a657a5af241d9ad9fa28c39bb7f02228d356263ce0d9.YDS-u2Dx3QPhq6edOhA2TATy1orZTELu1DoTJ3GwYs0
+ hash: v1.k794b7964.0d38ad309a0e7a3960be4552c89c8e63aa97b6078404e030277aa7276dfff435.3VBB3P_-vzBa1RuSUHtrrLC9anxrf-93D813KBJpl4Y
scenes-app-ai-observability-skills--skill-detail-stacked-below-2-xl-breakpoint--medium--light:
- hash: v1.k794b7964.b243b3fc389755a5586c6c49c52ce62cca5b1e558e72e98ccd3134b4721c16d8.2tekzbtC5vpPtN6mTvYWrrC5ynHek4O5FZyojwuCit0
+ hash: v1.k794b7964.bd9c74ed128f59d7f00a216986075df7c1eb727c19d047e2b9d8917d7712baa2.c929FWWN7gu5bWrRnS6iGFAYFr8Hr1GXSMpJpLYsdpI
scenes-app-ai-observability-skills--skill-detail-stacked-below-2-xl-breakpoint--wide--dark:
- hash: v1.k794b7964.d59b23ff7ea79d090453024be82f23d944c42ff4a001906865a888ef02c8eb37.TxhPOL7p3GoWUJTPtpZFIJTHhZg80I3ZFA6Tw9E2c8U
+ hash: v1.k794b7964.3e5a2771b68f30d7f5c529616d1bc0c6023c64cfab79c90e40bc06fcc0173792.OgWzg-u_ZK_DYWoo7nBjondGsY1llTeSX9sp5UbDr9Q
scenes-app-ai-observability-skills--skill-detail-stacked-below-2-xl-breakpoint--wide--light:
- hash: v1.k794b7964.ca0464610a91d6c4c2d50c179ada7bb691d8fafc5c12f9a51905be5bb065d61b._OCu1SykTC84XfMECDhEOOcOsO8UWsp0zh8JTKoRYq0
+ hash: v1.k794b7964.4ce94e0415732ee8ee483b5be5eeffeda8b33ca70444bebe8ccaaef858159540.9XEuH7i8VEm-twy2jenDX5dusdL7ZUbxFYyTSsU_LPM
+ scenes-app-ai-observability-skills--skills-list--dark:
+ hash: v1.k794b7964.5f1884413c0c96dc63183fb7a32db8800aaff3919dc2df83fd80529a566cee8d.tvTf-dU6lFhAm8TR6j7CZKNqm-jcpBUgxey0PGK7nuI
+ scenes-app-ai-observability-skills--skills-list--light:
+ hash: v1.k794b7964.be983851dd216dffb0f8cdd9df2de912fa9d477a821e66eee7b1f82bd0000ca6.aiGZU3HoH-JsbDcEul_7etKK6iVsTktb0ZxZ2_vmfOk
scenes-app-ai-observability-trace--full--dark:
hash: v1.k794b7964.3ea0677df8e51f08cfd46ad1957c78cb0e0c14dff003b15959f9dc9434a239ca.GUZTGarCld-XKdmLqsfKRE1ZIWdWvfojoa2vHPGVVOA
scenes-app-ai-observability-trace--full--light:
diff --git a/products/skills/backend/api/skill_serializers.py b/products/skills/backend/api/skill_serializers.py
index d7d15972e4c3..af99a21dca22 100644
--- a/products/skills/backend/api/skill_serializers.py
+++ b/products/skills/backend/api/skill_serializers.py
@@ -152,6 +152,12 @@ class LLMSkillListQuerySerializer(serializers.Serializer):
required=False,
help_text="Filter skills by the ID of the user who created them.",
)
+ owner_id = serializers.IntegerField(
+ required=False,
+ help_text="Filter skills by the ID of a user who owns them. Ownership is keyed on the logical "
+ "skill, so this is stable across versions — unlike created_by_id, which tracks whoever "
+ "published the latest version.",
+ )
category = serializers.CharField(
required=False,
allow_blank=True,
diff --git a/products/skills/backend/api/skill_services.py b/products/skills/backend/api/skill_services.py
index fdcb488d52bb..c1b18057e641 100644
--- a/products/skills/backend/api/skill_services.py
+++ b/products/skills/backend/api/skill_services.py
@@ -753,6 +753,20 @@ def resolve_skill_owners_for_names(team: Team, skill_names: list[str]) -> dict[s
return owners_by_name
+def skill_names_owned_by(team: Team, user_id: int) -> "QuerySet[LLMSkillOwner, str]":
+ """Names of the logical skills one user owns — backs the list endpoint's owner filter.
+
+ Returns a lazy values queryset so the caller can use it as a subquery instead of pulling every
+ name into memory. Same current-access filter as `resolve_skill_owners`: filtering by a user who
+ lost access matches nothing, rather than surfacing skills through a stale owner row.
+ """
+ return (
+ _owner_qs(team)
+ .filter(user_id=user_id, user__in=team.all_users_with_access())
+ .values_list("skill_name", flat=True)
+ )
+
+
def clear_skill_owners(team: Team, skill_name: str) -> None:
"""Drop every owner row for a logical skill — called on archive so a later skill that reuses the
name (recreate / import / duplicate) doesn't inherit the archived skill's owners."""
diff --git a/products/skills/backend/api/skills.py b/products/skills/backend/api/skills.py
index 90bca8205579..ecd7eb3d3d76 100644
--- a/products/skills/backend/api/skills.py
+++ b/products/skills/backend/api/skills.py
@@ -104,6 +104,7 @@ from .skill_services import (
resolve_skill_owners_for_names,
resolve_versions_page,
set_skill_owners,
+ skill_names_owned_by,
)
logger = structlog.get_logger(__name__)
@@ -362,6 +363,12 @@ class LLMSkillViewSet(
if created_by_id:
queryset = queryset.filter(created_by_id=created_by_id)
+ # Owners are keyed on the logical skill name, not on a version row, so the filter matches by
+ # name across every version the queryset could surface.
+ owner_id = params.get("owner_id")
+ if owner_id:
+ queryset = queryset.filter(name__in=skill_names_owned_by(self.team, owner_id))
+
# Presence of the param — even as an empty string — is a filter: `?category=` returns only
# uncategorized skills, `?category=scout` only scouts. Omitting it returns every category.
if "category" in request.query_params:
diff --git a/products/skills/backend/api/test/test_skills.py b/products/skills/backend/api/test/test_skills.py
index e20bef174ad3..5975c9b21f34 100644
--- a/products/skills/backend/api/test/test_skills.py
+++ b/products/skills/backend/api/test/test_skills.py
@@ -1671,6 +1671,33 @@ class TestLLMSkillOwners(APIBaseTest):
assert [o.email for o in resolve_skill_owners(self.team, "reused")] == [self.user.email]
+ def test_list_filters_to_skills_owned_by_one_user(self) -> None:
+ # The owner filter has to match through LLMSkillOwner. created_by_id answers a different
+ # question (who published the latest version), so it can't stand in for this.
+ member = self._member("[email protected]")
+ create_skill(self.team, user=self.user, name="theirs", description="d", body="# b")
+ create_skill(self.team, user=self.user, name="mine", description="d", body="# b")
+ set_skill_owners(self.team, "theirs", [member])
+
+ response = self.client.get(self._url() + f"?owner_id={member.id}")
+
+ assert response.status_code == status.HTTP_200_OK, response.json()
+ assert [r["name"] for r in response.json()["results"]] == ["theirs"]
+
+ def test_list_owner_filter_excludes_owner_who_lost_access(self) -> None:
+ # Owner rows survive a member losing access, so filtering by that member must return nothing
+ # rather than surfacing the skills through a stale row.
+ member = self._member("[email protected]")
+ create_skill(self.team, user=self.user, name="orphaned", description="d", body="# b")
+ set_skill_owners(self.team, "orphaned", [member])
+
+ member.organization_memberships.filter(organization=self.organization).delete()
+
+ response = self.client.get(self._url() + f"?owner_id={member.id}")
+
+ assert response.status_code == status.HTTP_200_OK, response.json()
+ assert response.json()["results"] == []
+
def test_skill_get_excludes_owner_who_lost_access(self) -> None:
# An owner row survives the member losing access; the read path serializes UserBasic, so a
# former member's profile must not keep leaking through skill-get.
diff --git a/products/skills/frontend/LLMSkillScene.stories.tsx b/products/skills/frontend/LLMSkillScene.stories.tsx
index 0f449881885d..e52f75cefb5c 100644
--- a/products/skills/frontend/LLMSkillScene.stories.tsx
+++ b/products/skills/frontend/LLMSkillScene.stories.tsx
@@ -1,3 +1,5 @@
+import { MOCK_USER_UUID } from 'lib/api.mock'
+
import { Meta, StoryObj } from '@storybook/react'
import { App } from 'scenes/App'
@@ -14,9 +16,11 @@ import type {
UserBasicApi,
} from 'products/skills/frontend/generated/api.schemas'
+// Matches the mocked organization member, so the owner picker resolves it to a name rather than
+// falling back to the raw UUID.
const MOCK_AUTHOR: UserBasicApi = {
id: 178,
- uuid: '01853eba-3d18-0000-9d9b-000000000001',
+ uuid: MOCK_USER_UUID,
distinct_id: 'mock-user-178-distinct-id',
first_name: 'John',
@@ -122,6 +126,17 @@ const SKILL_LIST_ENTRY: LLMSkillListApi = {
first_version_created_at: SKILL.first_version_created_at,
}
+const UNOWNED_SKILL_LIST_ENTRY: LLMSkillListApi = {
+ ...SKILL_LIST_ENTRY,
+ id: 'skill-version-9',
+ name: 'invoice-parser',
+ description: 'Parse invoices into structured line items. Use when reconciling billing exports.',
+ owners: [],
+ version_count: 1,
+ version: 1,
+ latest_version: 1,
+}
+
const meta: Meta = {
component: App,
title: 'Scenes-App/AI observability/Skills',
@@ -137,7 +152,7 @@ const meta: Meta = {
decorators: [
mswDecorator({
get: {
- '/api/projects/:team_id/llm_skills/': toPaginatedResponse([SKILL_LIST_ENTRY]),
+ '/api/projects/:team_id/llm_skills/': toPaginatedResponse([SKILL_LIST_ENTRY, UNOWNED_SKILL_LIST_ENTRY]),
'/api/projects/:team_id/llm_skills/resolve/name/:name/': RESOLVE_RESPONSE,
},
}),
@@ -163,3 +178,9 @@ export const SkillDetailSideBySideAbove2xlBreakpoint: Story = {
},
},
}
+
+export const SkillsList: Story = {
+ parameters: {
+ pageUrl: urls.skills(),
+ },
+}
diff --git a/products/skills/frontend/LLMSkillScene.tsx b/products/skills/frontend/LLMSkillScene.tsx
index dc1927e6dc13..028414a0f8e6 100644
--- a/products/skills/frontend/LLMSkillScene.tsx
+++ b/products/skills/frontend/LLMSkillScene.tsx
@@ -46,6 +46,7 @@ import { SkillLogicProps, SkillMode, isSkill, llmSkillLogic } from './llmSkillLo
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'
const MonacoDiffEditor = lazyWithRetry(() => import('lib/components/MonacoDiffEditor'))
@@ -344,6 +345,8 @@ function SkillViewDetails(): JSX.Element {
<p className="text-sm">{skill.description}</p>
</div>
+ <SkillOwners />
+
<div>
<label className="text-xs font-semibold uppercase text-secondary">Frontmatter</label>
<div className="mt-1 grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 font-mono text-xs">
diff --git a/products/skills/frontend/LLMSkillsScene.tsx b/products/skills/frontend/LLMSkillsScene.tsx
index 7c2837aa467f..600373152745 100644
--- a/products/skills/frontend/LLMSkillsScene.tsx
+++ b/products/skills/frontend/LLMSkillsScene.tsx
@@ -14,9 +14,10 @@ import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { More } from 'lib/lemon-ui/LemonButton/More'
import { LemonCollapse } from 'lib/lemon-ui/LemonCollapse'
-import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'
+import { ProfileBubbles } from 'lib/lemon-ui/ProfilePicture/ProfileBubbles'
import { Spinner } from 'lib/lemon-ui/Spinner'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { fullName } from 'lib/utils/strings'
import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
@@ -102,14 +103,35 @@ function buildSkillColumns(
},
},
{
- title: 'Latest author',
+ title: 'Owners',
+ key: 'owners',
+ width: 140,
+ render: function renderOwners(_, skill) {
+ if (!skill.owners.length) {
+ return <span className="text-muted-alt text-sm">No owner</span>
+ }
+ return (
+ <ProfileBubbles
+ people={skill.owners.map((owner) => ({
+ email: owner.email,
+ name: fullName(owner) || owner.email,
+ }))}
+ limit={4}
+ />
+ )
+ },
+ },
+ {
+ // Plain text, not a second avatar column: this is whoever published the latest version,
+ // which is a weaker signal than ownership and reads as ownership when given a face.
+ title: 'Last published by',
dataIndex: 'created_by',
render: function renderCreatedBy(_, item) {
const { created_by } = item
return (
- <div className="flex flex-row items-center flex-nowrap">
- {created_by && <ProfilePicture user={created_by as any} size="md" showName />}
- </div>
+ <span className="text-muted text-sm">
+ {created_by ? fullName(created_by) || created_by.email : <i>-</i>}
+ </span>
)
},
},
@@ -571,6 +593,15 @@ export function LLMSkillsScene(): JSX.Element {
/>
<div className="text-muted-alt">{skillCountLabel}</div>
<div className="flex-1" />
+ <span>
+ <b>Owned by</b>
+ </span>
+ <MemberSelect
+ defaultLabel="Any user"
+ value={filters.owner_id ?? null}
+ size="xsmall"
+ onChange={(user) => setFilters({ owner_id: user?.id, page: 1 })}
+ />
<span>
<b>Created by</b>
</span>
diff --git a/products/skills/frontend/SkillOwners.tsx b/products/skills/frontend/SkillOwners.tsx
new file mode 100644
index 000000000000..0f16ac637d3f
--- /dev/null
+++ b/products/skills/frontend/SkillOwners.tsx
@@ -0,0 +1,118 @@
+import { useActions, useValues } from 'kea'
+
+import { IconPencil } from '@posthog/icons'
+import { LemonButton } from '@posthog/lemon-ui'
+
+import { AccessControlAction } from 'lib/components/AccessControlAction'
+import { MemberSelectMultiple } from 'lib/components/MemberSelectMultiple'
+import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'
+import { userLogic } from 'scenes/userLogic'
+
+import { AccessControlLevel, AccessControlResourceType } from '~/types'
+
+import { llmSkillLogic } from './llmSkillLogic'
+import { SKILL_OWNER_MAX_COUNT } from './skillConstants'
+
+/** Owners of a skill, with an inline editor. Ownership is keyed on the skill name rather than a
+ * version, so this saves through the owners-only write path and never publishes a version. */
+export function SkillOwners(): JSX.Element {
+ const { skillOwners, ownersEditing, ownerDraft, ownerDraftChanged, savingOwners } = useValues(llmSkillLogic)
+ const { openOwnersEditor, closeOwnersEditor, setOwnerDraft, saveOwners } = useActions(llmSkillLogic)
+ const { user } = useValues(userLogic)
+
+ return (
+ <div data-attr="llma-skill-owners">
+ <label className="text-xs font-semibold uppercase text-secondary">Owners</label>
+ {ownersEditing ? (
+ <div className="mt-1 flex max-w-lg flex-col gap-2">
+ <MemberSelectMultiple
+ idKey="uuid"
+ value={ownerDraft}
+ onChange={(users) => setOwnerDraft(users.map((selected) => selected.uuid))}
+ />
+ <p className="m-0 text-xs text-secondary">
+ Owners are who to ask about this skill. Saving them does not publish a new version.
+ </p>
+ <div className="flex gap-2">
+ <LemonButton
+ type="primary"
+ size="small"
+ onClick={() => saveOwners(ownerDraft)}
+ loading={savingOwners}
+ disabledReason={
+ ownerDraft.length > SKILL_OWNER_MAX_COUNT
+ ? `A skill can have at most ${SKILL_OWNER_MAX_COUNT} owners`
+ : !ownerDraftChanged
+ ? 'No changes to save'
+ : undefined
+ }
+ data-attr="llma-skill-owners-save"
+ >
+ Save
+ </LemonButton>
+ <LemonButton
+ type="secondary"
+ size="small"
+ onClick={closeOwnersEditor}
+ disabledReason={savingOwners ? 'Saving…' : undefined}
+ data-attr="llma-skill-owners-cancel"
+ >
+ Cancel
+ </LemonButton>
+ </div>
+ </div>
+ ) : (
+ <div className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1">
+ {skillOwners.length > 0 ? (
+ skillOwners.map((owner) => (
+ <ProfilePicture
+ key={owner.uuid}
+ // Not the generated owner object itself: its hedgehog_config is typed
+ // as a loose record, which ProfilePicture's prop type rejects.
+ user={{
+ first_name: owner.first_name,
+ last_name: owner.last_name,
+ email: owner.email,
+ }}
+ size="md"
+ showName
+ />
+ ))
+ ) : (
+ <span className="text-sm text-secondary">No owner</span>
+ )}
+ {skillOwners.length === 0 && user ? (
+ <AccessControlAction
+ resourceType={AccessControlResourceType.LlmSkill}
+ minAccessLevel={AccessControlLevel.Editor}
+ >
+ <LemonButton
+ size="xsmall"
+ type="secondary"
+ onClick={() => saveOwners([user.uuid])}
+ loading={savingOwners}
+ data-attr="llma-skill-owners-claim"
+ >
+ Claim it
+ </LemonButton>
+ </AccessControlAction>
+ ) : null}
+ <AccessControlAction
+ resourceType={AccessControlResourceType.LlmSkill}
+ minAccessLevel={AccessControlLevel.Editor}
+ >
+ <LemonButton
+ size="xsmall"
+ type="secondary"
+ icon={skillOwners.length > 0 ? <IconPencil /> : undefined}
+ onClick={openOwnersEditor}
+ data-attr="llma-skill-owners-edit"
+ >
+ {skillOwners.length > 0 ? 'Edit' : 'Pick someone else'}
+ </LemonButton>
+ </AccessControlAction>
+ </div>
+ )}
+ </div>
+ )
+}
diff --git a/products/skills/frontend/generated/api.schemas.ts b/products/skills/frontend/generated/api.schemas.ts
index 3bb9b58f96c5..93a9d3a0bc52 100644
--- a/products/skills/frontend/generated/api.schemas.ts
+++ b/products/skills/frontend/generated/api.schemas.ts
@@ -784,6 +784,10 @@ export type LlmSkillsListParams = {
* The initial index from which to return the results.
*/
offset?: number
+ /**
+ * Filter skills by the ID of a user who owns them. Ownership is keyed on the logical skill, so this is stable across versions — unlike created_by_id, which tracks whoever published the latest version.
+ */
+ owner_id?: number
/**
* Optional substring filter applied to skill names and descriptions.
*/
diff --git a/products/skills/frontend/llmSkillLogic.test.ts b/products/skills/frontend/llmSkillLogic.test.ts
index 321c0ae0a89f..6002d2c87e8c 100644
--- a/products/skills/frontend/llmSkillLogic.test.ts
+++ b/products/skills/frontend/llmSkillLogic.test.ts
@@ -34,6 +34,9 @@ const mockFilesRetrieve = llmSkillsNameFilesRetrieve as jest.MockedFunction<type
const MOCK_FILE = { path: 'scripts/run.sh', content: 'echo hi', content_type: 'text/x-shellscript' }
+const MOCK_OWNER = { id: 1, uuid: 'user-uuid-1', email: '[email protected]' }
+const MOCK_NEW_OWNER = { id: 2, uuid: 'user-uuid-2', email: '[email protected]' }
+
const mockSkill = {
id: 'skill-version-2',
name: 'my-test-skill',
@@ -53,6 +56,7 @@ const mockSkill = {
created_at: '2024-01-02T00:00:00Z',
updated_at: '2024-01-02T00:00:00Z',
created_by: { id: 1, email: '[email protected]' },
+ owners: [MOCK_OWNER],
files: [{ path: MOCK_FILE.path, content_type: MOCK_FILE.content_type }],
body_total_length: 10,
body_next_offset: null,
@@ -77,6 +81,11 @@ const mockSkill = {
has_more: false,
} as unknown as ResolvedLLMSkill
+function resolveResponse(skill: ResolvedLLMSkill): LLMSkillResolveResponseApi {
+ const { versions, has_more, ...skillFields } = skill
+ return { skill: skillFields, versions, has_more } as unknown as LLMSkillResolveResponseApi
+}
+
describe('llmSkillLogic', () => {
describe('publish flow', () => {
let logic: ReturnType<typeof llmSkillLogic.build>
@@ -91,11 +100,6 @@ describe('llmSkillLogic', () => {
logic?.unmount()
})
- const resolveResponse = (skill: ResolvedLLMSkill): LLMSkillResolveResponseApi => {
- const { versions, has_more, ...skillFields } = skill
- return { skill: skillFields, versions, has_more } as unknown as LLMSkillResolveResponseApi
- }
-
it('opens the review modal on requestPublish and sends the version description on publish', async () => {
mockResolve.mockResolvedValue(resolveResponse(mockSkill))
mockPartialUpdate.mockResolvedValue({
@@ -172,6 +176,66 @@ describe('llmSkillLogic', () => {
})
})
+ describe('owner editing', () => {
+ let logic: ReturnType<typeof llmSkillLogic.build>
+
+ beforeEach(async () => {
+ jest.clearAllMocks()
+ initKeaTests()
+ mockResolve.mockResolvedValue(resolveResponse(mockSkill))
+ logic = llmSkillLogic({ skillName: 'my-test-skill' })
+ logic.mount()
+ await expectLogic(logic).toDispatchActions(['loadSkillSuccess'])
+ })
+
+ afterEach(() => {
+ logic?.unmount()
+ })
+
+ it('saves owners alone and keeps the viewed version on screen', async () => {
+ mockPartialUpdate.mockResolvedValue({
+ ...mockSkill,
+ id: 'skill-version-3',
+ version: 3,
+ latest_version: 3,
+ owners: [MOCK_NEW_OWNER],
+ } as unknown as LLMSkillApi)
+
+ logic.actions.openOwnersEditor()
+ expect(logic.values.ownerDraft).toEqual([MOCK_OWNER.uuid])
+
+ logic.actions.saveOwners([MOCK_NEW_OWNER.uuid])
+ await expectLogic(logic).toFinishAllListeners()
+
+ // Owners only: any content field in this payload would publish a version for a field
+ // that isn't version-keyed.
+ expect(mockPartialUpdate).toHaveBeenCalledWith(expect.anything(), 'my-test-skill', {
+ owners: [MOCK_NEW_OWNER.uuid],
+ })
+ expect(logic.values.skillOwners).toEqual([MOCK_NEW_OWNER])
+ // The response describes the latest version, which isn't necessarily the one on screen.
+ expect(logic.values.skill).toMatchObject({ version: 2 })
+ expect(logic.values.ownersEditing).toBe(false)
+ })
+
+ it('keeps the editor open with the draft intact when the save fails', async () => {
+ mockPartialUpdate.mockRejectedValue(
+ new ApiError('invalid', 400, undefined, {
+ detail: "User 'user-uuid-2' is not a member of this project.",
+ })
+ )
+
+ logic.actions.openOwnersEditor()
+ logic.actions.saveOwners([MOCK_NEW_OWNER.uuid])
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.savingOwners).toBe(false)
+ expect(logic.values.ownersEditing).toBe(true)
+ expect(logic.values.skillOwners).toEqual([MOCK_OWNER])
+ expect(lemonToast.error).toHaveBeenCalledWith("User 'user-uuid-2' is not a member of this project.")
+ })
+ })
+
describe('file uploads', () => {
let logic: ReturnType<typeof llmSkillLogic.build>
diff --git a/products/skills/frontend/llmSkillLogic.ts b/products/skills/frontend/llmSkillLogic.ts
index 99480337e435..991536a32a2f 100644
--- a/products/skills/frontend/llmSkillLogic.ts
+++ b/products/skills/frontend/llmSkillLogic.ts
@@ -35,6 +35,7 @@ import type {
LLMSkillFileInputApi,
LLMSkillListApi,
LLMSkillVersionSummaryApi,
+ UserBasicApi,
} from 'products/skills/frontend/generated/api.schemas'
import { exportAndDownloadSkill, llmSkillsLogic, LLM_SKILLS_FORCE_RELOAD_PARAM } from './llmSkillsLogic'
@@ -214,7 +215,11 @@ export interface llmSkillLogicValues {
isViewMode: boolean
mode: SkillMode
nextVersion: number | null
+ ownerDraft: string[]
+ ownerDraftChanged: boolean
+ ownersEditing: boolean
publishConflict: PublishConflict | null
+ savingOwners: boolean
shouldDisplaySkeleton: boolean
showSkillFormErrors: boolean
skill: ResolvedLLMSkill | SkillFormValues | null
@@ -230,6 +235,7 @@ export interface llmSkillLogicValues {
skillFormTouches: Record<string, boolean>
skillFormValidationErrors: DeepPartialMap<SkillFormValues, ValidationErrorType>
skillLoading: boolean
+ skillOwners: readonly UserBasicApi[]
versionDescription: string
versions: LLMSkillVersionSummaryApi[]
versionsLoading: boolean
@@ -243,6 +249,9 @@ export interface llmSkillLogicActions {
cancelEditing: () => {
value: true
}
+ closeOwnersEditor: () => {
+ value: true
+ }
closePublishReview: () => {
value: true
}
@@ -288,6 +297,9 @@ export interface llmSkillLogicActions {
skill: ResolvedLLMSkill
payload?: any
}
+ openOwnersEditor: () => {
+ value: true
+ }
openPublishReview: () => {
value: true
}
@@ -297,6 +309,9 @@ export interface llmSkillLogicActions {
resetSkillForm: (values?: SkillFormValues) => {
values?: SkillFormValues
}
+ saveOwners: (ownerUuids: string[]) => {
+ ownerUuids: string[]
+ }
setCompareVersion: (compareVersion: number | null) => {
compareVersion: number | null
}
@@ -309,9 +324,15 @@ export interface llmSkillLogicActions {
setMode: (mode: SkillMode) => {
mode: SkillMode
}
+ setOwnerDraft: (ownerUuids: string[]) => {
+ ownerUuids: string[]
+ }
setPublishConflict: (publishConflict: PublishConflict | null) => {
publishConflict: PublishConflict | null
}
+ setSavingOwners: (saving: boolean) => {
+ saving: boolean
+ }
setSkill: (skill: ResolvedLLMSkill | SkillFormValues) => {
skill: ResolvedLLMSkill | SkillFormValues
}
@@ -401,6 +422,8 @@ export interface llmSkillLogicMeta {
label: string
value: number
}>
+ skillOwners: (skill: ResolvedLLMSkill | SkillFormValues | null) => readonly UserBasicApi[]
+ ownerDraftChanged: (ownerDraft: string[], skillOwners: readonly UserBasicApi[]) => boolean
}
}
@@ -435,6 +458,11 @@ export const llmSkillLogic = kea<llmSkillLogicType>([
closePublishReview: true,
setVersionDescription: (versionDescription: string) => ({ versionDescription }),
setSkillFormBaseline: (baseline: SkillFormValues | null) => ({ baseline }),
+ openOwnersEditor: true,
+ closeOwnersEditor: true,
+ setOwnerDraft: (ownerUuids: string[]) => ({ ownerUuids }),
+ saveOwners: (ownerUuids: string[]) => ({ ownerUuids }),
+ setSavingOwners: (saving: boolean) => ({ saving }),
}),
reducers(({ props }) => ({
@@ -537,6 +565,27 @@ export const llmSkillLogic = kea<llmSkillLogicType>([
setSkillFormBaseline: (_, { baseline }) => baseline,
},
],
+ ownersEditing: [
+ false,
+ {
+ openOwnersEditor: () => true,
+ closeOwnersEditor: () => false,
+ loadSkillSuccess: () => false,
+ },
+ ],
+ ownerDraft: [
+ [] as string[],
+ {
+ setOwnerDraft: (_, { ownerUuids }) => ownerUuids,
+ },
+ ],
+ savingOwners: [
+ false,
+ {
+ saveOwners: () => true,
+ setSavingOwners: (_, { saving }) => saving,
+ },
+ ],
})),
loaders(({ props }) => ({
@@ -813,6 +862,20 @@ export const llmSkillLogic = kea<llmSkillLogicType>([
}))
},
],
+
+ skillOwners: [
+ (s) => [s.skill],
+ (skill: ResolvedLLMSkill | SkillFormValues | null): readonly UserBasicApi[] =>
+ isSkill(skill) ? skill.owners : [],
+ ],
+
+ ownerDraftChanged: [
+ (s) => [s.ownerDraft, s.skillOwners],
+ (ownerDraft: string[], skillOwners: readonly UserBasicApi[]): boolean =>
+ // Order is server-owned (seed-creator first), so only membership counts as a change.
+ ownerDraft.length !== skillOwners.length ||
+ ownerDraft.some((uuid) => !skillOwners.some((owner) => owner.uuid === uuid)),
+ ],
}),
listeners(({ actions, props, values }) => ({
@@ -1016,6 +1079,38 @@ export const llmSkillLogic = kea<llmSkillLogicType>([
loadCompareSkillFailure: () => {
lemonToast.error('Failed to load comparison version')
},
+
+ openOwnersEditor: () => {
+ actions.setOwnerDraft(values.skillOwners.map((owner) => owner.uuid))
+ },
+
+ saveOwners: async ({ ownerUuids }) => {
+ const currentSkill = values.skill
+ if (props.skillName === 'new' || !isSkill(currentSkill)) {
+ actions.setSavingOwners(false)
+ return
+ }
+ try {
+ // Owners-only PATCH: the backend replaces ownership without publishing a version.
+ const updated = await llmSkillsNamePartialUpdate(
+ String(ApiConfig.getCurrentTeamId()),
+ props.skillName,
+ { owners: ownerUuids }
+ )
+ // Take only `owners` off the response: it describes the latest version, which is not
+ // necessarily the version on screen. Ownership is version-independent, so it applies
+ // to whichever version is shown.
+ actions.setSkill({ ...currentSkill, owners: updated.owners })
+ actions.closeOwnersEditor()
+ llmSkillsLogic.findMounted()?.actions.loadSkills(false)
+ lemonToast.success('Owners updated')
+ } catch (error) {
+ console.error('Failed to update skill owners', error)
+ lemonToast.error(getApiErrorDetail(error) || "Couldn't update owners. Try again.")
+ } finally {
+ actions.setSavingOwners(false)
+ }
+ },
})),
defaults(
diff --git a/products/skills/frontend/llmSkillsLogic.ts b/products/skills/frontend/llmSkillsLogic.ts
index 657b86d1b8f1..928df3432e5d 100644
--- a/products/skills/frontend/llmSkillsLogic.ts
+++ b/products/skills/frontend/llmSkillsLogic.ts
@@ -88,6 +88,7 @@ export interface SkillFilters {
order_by: string
group_by_prefix: boolean
created_by_id?: number
+ owner_id?: number
}
function parseBoolean(value: unknown): boolean {
@@ -107,6 +108,7 @@ function cleanFilters(values: Partial<SkillFilters>): SkillFilters {
order_by: values.order_by || '-created_at',
group_by_prefix: parseBoolean(values.group_by_prefix),
created_by_id: values.created_by_id ? Number(values.created_by_id) : undefined,
+ owner_id: values.owner_id ? Number(values.owner_id) : undefined,
}
}
@@ -117,6 +119,7 @@ function cleanFilterUrlParams(filters: SkillFilters): Record<string, unknown> {
order_by: filters.order_by === '-created_at' ? undefined : filters.order_by,
group_by_prefix: filters.group_by_prefix ? 'true' : undefined,
created_by_id: filters.created_by_id,
+ owner_id: filters.owner_id,
}
}
@@ -464,6 +467,7 @@ export const llmSkillsLogic = kea<llmSkillsLogicType>([
offset: 0,
limit: SKILLS_GROUP_LIMIT,
created_by_id: filters.created_by_id,
+ owner_id: filters.owner_id,
category,
}
: {
@@ -472,6 +476,7 @@ export const llmSkillsLogic = kea<llmSkillsLogicType>([
offset: Math.max(0, (filters.page - 1) * SKILLS_PER_PAGE),
limit: SKILLS_PER_PAGE,
created_by_id: filters.created_by_id,
+ owner_id: filters.owner_id,
category,
}
diff --git a/products/skills/frontend/skillConstants.ts b/products/skills/frontend/skillConstants.ts
index f3dda089c57b..d44adc92797d 100644
--- a/products/skills/frontend/skillConstants.ts
+++ b/products/skills/frontend/skillConstants.ts
@@ -3,6 +3,8 @@ export const SKILL_DESCRIPTION_MAX_LENGTH = 4096
// Kept in sync with MAX_SKILL_FILE_BYTES and MAX_SKILL_FILE_COUNT in the backend skill_serializers.
export const SKILL_FILE_MAX_BYTES = 1_000_000
export const SKILL_FILE_MAX_COUNT = 200
+// Kept in sync with MAX_SKILL_OWNERS in the backend skill_serializers.
+export const SKILL_OWNER_MAX_COUNT = 25
// Names that collide with reserved /skills routes: 'new' (the create form) and the tab slugs
// registered under /skills/<slug> in manifest.tsx. A skill with one of these names would be
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index bda981a5fd28..9c78dffaa212 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -92661,6 +92661,10 @@ export namespace Schemas {
* The initial index from which to return the results.
*/
offset?: number;
+ /**
+ * Filter skills by the ID of a user who owns them. Ownership is keyed on the logical skill, so this is stable across versions — unlike created_by_id, which tracks whoever published the latest version.
+ */
+ owner_id?: number;
/**
* Optional substring filter applied to skill names and descriptions.
*/
diff --git a/services/mcp/src/generated/skills/api.ts b/services/mcp/src/generated/skills/api.ts
index e8fa88d33490..5edebcd0e3ab 100644
--- a/services/mcp/src/generated/skills/api.ts
+++ b/services/mcp/src/generated/skills/api.ts
@@ -26,6 +26,12 @@ export const LlmSkillsListQueryParams = /* @__PURE__ */ zod.object({
created_by_id: zod.number().optional().describe('Filter skills by the ID of the user who created them.'),
limit: zod.number().optional().describe('Number of results to return per page.'),
offset: zod.number().optional().describe('The initial index from which to return the results.'),
+ owner_id: zod
+ .number()
+ .optional()
+ .describe(
+ 'Filter skills by the ID of a user who owns them. Ownership is keyed on the logical skill, so this is stable across versions — unlike created_by_id, which tracks whoever published the latest version.'
+ ),
search: zod.string().optional().describe('Optional substring filter applied to skill names and descriptions.'),
})
diff --git a/services/mcp/src/tools/generated/skills.ts b/services/mcp/src/tools/generated/skills.ts
index 592190f00804..3017b2ec4d6c 100644
--- a/services/mcp/src/tools/generated/skills.ts
+++ b/services/mcp/src/tools/generated/skills.ts
@@ -245,6 +245,7 @@ const skillList = (): ToolBase<typeof SkillListSchema, Schemas.PaginatedLLMSkill
created_by_id: params.created_by_id,
limit: params.limit,
offset: params.offset,
+ owner_id: params.owner_id,
search: params.search,
},
})
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-skill-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-skill-list.json
index b2b0e9e06f3a..d2406dbe1591 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-skill-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-skill-list.json
@@ -17,6 +17,10 @@
"description": "The initial index from which to return the results.",
"type": "number"
},
+ "owner_id": {
+ "description": "Filter skills by the ID of a user who owns them. Ownership is keyed on the logical skill, so this is stable across versions — unlike created_by_id, which tracks whoever published the latest version.",
+ "type": "number"
+ },
"search": {
"description": "Optional substring filter applied to skill names and descriptions.",
"type": "string"
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/skill-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/skill-list.json
index b2b0e9e06f3a..d2406dbe1591 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/skill-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/skill-list.json
@@ -17,6 +17,10 @@
"description": "The initial index from which to return the results.",
"type": "number"
},
+ "owner_id": {
+ "description": "Filter skills by the ID of a user who owns them. Ownership is keyed on the logical skill, so this is stable across versions — unlike created_by_id, which tracks whoever published the latest version.",
+ "type": "number"
+ },
"search": {
"description": "Optional substring filter applied to skill names and descriptions.",
"type": "string"