Skip to content

feat(skills): add global visibility controls to the skills UI - #71360

Closed
ceyniustranberg wants to merge 1 commit into
posthog-code/skills-global-visibility-backendfrom
posthog-code/skills-global-visibility-frontend
Closed

ceyniustranberg wants to merge 1 commit into
posthog-code/skills-global-visibility-backendfrom
posthog-code/skills-global-visibility-frontend

Conversation

@ceyniustranberg

Copy link
Copy Markdown
Contributor

Problem

Staff need to flip a skill to "visible to everyone" straight from the skill, and everyone needs to see which skills are global and which are read-only in their project. Wires the backend capability into the Skills UI.

Note

Top of a 3-PR stack: #71358 (model) → #71359 (backend) → this. Targets the backend branch, so its diff is UI-only. Consumes the generated types added in #71359.

Changes

  • Staff toggle on the skill scene: a "Make visible to everyone" / "Make private" button (staff-only, with a confirm dialog and in-flight loading state) that calls the visibility endpoint and updates the skill in place.
  • "Global" badge on the skill scene title and on rows in the skills list.
  • Read-only for consumers: a global skill surfaced from another team hides edit, archive, and duplicate. Ownership is skill.team_id === currentTeamId; download stays available to everyone.

How did you test this code?

Automated (run by me, the agent):

  • tsgo --noEmit reports no products/skills type errors; kea logic types regenerated for the new setGlobalVisibility action and settingVisibility state.
  • oxlint + oxfmt clean on the changed files (CI toolchain versions).

I could not run the app or capture screenshots. No Jest/Playwright added: the new behavior is a staff-gated button plus ownership-gated rendering, both thin wrappers over the endpoint from #71359, which is covered by backend tests. A reviewer should verify the toggle, badge, and read-only view visually.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

None. No public docs cover the skills store UI yet.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Directed by @ceyniustranberg, implemented by Claude (PostHog Code). Third of a 3-PR stack (model → backend → frontend). Invoked /adopting-generated-api-types — the visibility call uses the generated llmSkillsNameVisibilityCreate and the is_global / team_id fields from the generated schemas, no handwritten API types. Business logic lives in llmSkillLogic (kea), not the component. Gating edit/archive/duplicate on team_id === currentTeamId is what makes a consumed global read-only instead of showing write buttons that would 404 against the owning team.


Created with PostHog Code

@ceyniustranberg ceyniustranberg self-assigned this Jul 15, 2026
@ceyniustranberg
ceyniustranberg marked this pull request as ready for review July 15, 2026 22:00
@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

🦔 Hogbox preview · ✅ ready

▶ Open the preview

🔑 Login test@posthog.com / 12345678 (demo data)
🧩 Running this PR's backend and frontend, on the PostHog :master base
🔗 Link stable across rebuilds — a re-push swaps the box underneath, the URL stays
🔒 Access tailnet only (PostHog VPN)
🛠️ Admin inspect & debug state in hogland
💤 Idle sleeps after ~30 min idle (snapshot to S3, zero node cost) and wakes on your next visit in ~30s, behind a brief "waking up" screen

commit ea462c1 · box box-ea6d9d868a20 · ready in 693s (push → usable) · build log · rebuilds on every push, torn down on close

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

✅ Bundle size — no change

Uncompressed size of every built .js bundle, compared against the base branch.

Total: 64.77 MiB · no change

No file changed by more than 1000 B.

Posted automatically by build-bundle-size-report · uncompressed bytes from dist-report

✅ Eager graph — within budget

How much code each root ships on the eager path — downloaded and parsed before the surface is interactive. Measured from the esbuild output chunks (post-tree-shake, static imports only); lazy import() / React.lazy chunks are not counted.

Root Eager (shipped) Δ vs base Budget
entry (logged-out pages, app bootstrap)
src/index.tsx
1.22 MiB · 22 files no change ███░░░░░░░ 28.4% of 4.29 MiB
authenticated shell (every logged-in page)
src/scenes/AuthenticatedShell.tsx
8.13 MiB · 2,978 files no change █████████░ 87.9% of 9.25 MiB

🟢 node_modules/monaco-editor/ stays out of src/index.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 node_modules/monaco-editor/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx

Largest files eagerly shipped from src/index.tsx
Size File
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
24.6 KiB ../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js
6.3 KiB ../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
4.5 KiB ../node_modules/.pnpm/@jspm+core@2.1.0/node_modules/@jspm/core/nodelibs/browser/process.js
3.9 KiB ../node_modules/.pnpm/scheduler@0.23.2/node_modules/scheduler/cjs/scheduler.production.min.js
1.4 KiB ../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
1.3 KiB src/RootErrorBoundary.tsx
912 B ../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js
789 B src/scenes/ChunkLoadErrorBoundary.tsx
762 B src/index.tsx
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx
Size File
281.3 KiB ../node_modules/.pnpm/posthog-js@1.402.2/node_modules/posthog-js/dist/rrweb.js
267.7 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
235.5 KiB src/taxonomy/core-filter-definitions-by-group.json
222.9 KiB ../node_modules/.pnpm/posthog-js@1.402.2/node_modules/posthog-js/dist/module.js
164.0 KiB src/queries/validators.js
154.3 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
105.8 KiB src/lib/api.ts
93.3 KiB ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js
92.7 KiB ../packages/quill/packages/quill/dist/index.js

Posted automatically by check-eager-graph · sizes are eager output bytes (shipped, post-tree-shake) from the esbuild metafile · part of #32479

✅ Dist folder size — 🔺 +11.1 KiB (+0.0%)

Total size of the built frontend/dist folder (all assets), compared against the base branch.

Total: 1312.46 MiB · 🔺 +11.1 KiB (+0.0%)

@trunk-io

trunk-io Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

Adds a staff-only "Make visible to everyone" / "Make private" toggle on the
skill scene (with a confirm dialog and in-flight state) and a "Global" badge
wherever a global skill appears. A global skill surfaced from another team is
read-only for the viewing team: edit, archive, and duplicate are hidden unless
the current project owns it (compared via the skill's team_id).

Generated-By: PostHog Code
Task-Id: ff3f8fe9-0598-414b-b8b7-617108960d53
@posthog

posthog Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

🦔 ReviewHog reviewed this pull request

Found 0 must fix, 1 should fix, 2 consider.

Published 1 finding (view the review).
2 findings stayed below the author's "Should fix" urgency threshold in their ReviewHog settings, so they were not published.

@posthog

posthog Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

ReviewHog Alpha 🦔 If you find any issues helpful - please reply "valid", "invalid", etc., for evaluation purposes 🙏

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReviewHog Report

Changes

Issues: 1 issue

Files (5)
  • products/skills/frontend/LLMSkillScene.stories.tsx
  • products/skills/frontend/LLMSkillScene.tsx
  • products/skills/frontend/LLMSkillsScene.tsx
  • products/skills/frontend/llmSkillLogic.ts
  • products/skills/frontend/skillSceneComponents.tsx

Comment on lines +70 to +71
is_global: false,
team_id: 1,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Story mock's team_id doesn't match the mocked current team, silently hiding Edit/Archive actions

Priority: should_fix | Category: testing | Lines: 70-71, 108-109

Issue description

The new team_id: 1 field hardcoded on the SKILL mock (and copied onto SKILL_LIST_ENTRY) does not match the team the Storybook App actually bootstraps as the current team. mswDecorator only overrides the llm_skills list/resolve endpoints here; the bootstrap endpoints /api/environments/@current/ and /api/projects/@current/ fall through to the default handler in frontend/src/mocks/handlers.ts, which returns MOCK_DEFAULT_TEAM (id: 997, from frontend/src/lib/api.mock.ts). Since LLMSkillScene.tsx now derives isOwnedByCurrentTeam = isSkill(skill) && skill.team_id === currentTeamId, and 1 !== 997, both SkillDetailStackedBelow2xlBreakpoint and SkillDetailSideBySideAbove2xlBreakpoint will render this PR's new 'read-only, consumed-global-skill' code path: 'Edit latest'/'Use as latest' and 'Archive' will no longer render even though these stories are meant to depict an ordinary owned skill (they exist specifically to test the action-bar/sidebar layout at different breakpoints). This silently changes what the stories exercise and is likely to break any existing visual-regression baselines for these two stories, since they'll suddenly render with fewer action buttons than before this PR.

Suggested fix

Set team_id on the SKILL/SKILL_LIST_ENTRY mocks to the same team ID the Storybook bootstrap mocks resolve to (e.g. import and use MOCK_TEAM_ID from frontend/src/lib/api.mock, or explicitly override the /api/environments/@current/ and /api/projects/@current/ handlers in this story's mswDecorator to return a team with id: 1), so isOwnedByCurrentTeam evaluates true and the stories keep exercising the full owned-skill action bar as intended.

Why we think it's a valid issue

Confirmed against the codebase. In LLMSkillScene.tsx:97, isOwnedByCurrentTeam = isSkill(skill) && skill.team_id === currentTeamId, and the Edit/Use-as-latest (line 129) and Archive (line 208) actions are gated on it; only Download (gated on isSkill, line 172) survives. The story sets SKILL.team_id = 1 (line 71, copied to SKILL_LIST_ENTRY line 109) and its mswDecorator overrides only the llm_skills list/resolve endpoints. The bootstrap endpoints /api/environments/@current/ and /api/projects/@current/ fall through to the default handler (handlers.ts:204-205) which returns MOCK_DEFAULT_TEAM, whose id is MOCK_TEAM_ID = 997 (api.mock.ts:32,48). teamLogic loads currentTeam from api/environments/@current and exposes currentTeamId = currentTeam.id = 997. Therefore 1 !== 997, isOwnedByCurrentTeam is false, and both SkillDetailStackedBelow2xlBreakpoint and SkillDetailSideBySideAbove2xlBreakpoint render the new read-only consumer path with Edit/Archive hidden — not the owned-skill action bar these breakpoint stories were built to depict. This silently changes what the stories exercise and shifts the visual-regression baselines. The mock is also internally incoherent: is_global: false (private) combined with not-owned is a state that can't occur in production, since only global skills surface across teams. Fix is trivial (use MOCK_TEAM_ID / 997). Impact is confined to Storybook/VRT with no production effect, but it degrades the only visual coverage for this scene in the very PR that introduces the ownership gating, so should_fix is appropriate.

Prompt to fix with AI (copy-paste)
## Context
@products/skills/frontend/LLMSkillScene.stories.tsx#L70-71
@products/skills/frontend/LLMSkillScene.stories.tsx#L108-109

<issue_description>
The new `team_id: 1` field hardcoded on the `SKILL` mock (and copied onto `SKILL_LIST_ENTRY`) does not match the team the Storybook `App` actually bootstraps as the current team. `mswDecorator` only overrides the `llm_skills` list/resolve endpoints here; the bootstrap endpoints `/api/environments/@current/` and `/api/projects/@current/` fall through to the default handler in `frontend/src/mocks/handlers.ts`, which returns `MOCK_DEFAULT_TEAM` (`id: 997`, from `frontend/src/lib/api.mock.ts`). Since `LLMSkillScene.tsx` now derives `isOwnedByCurrentTeam = isSkill(skill) && skill.team_id === currentTeamId`, and `1 !== 997`, both `SkillDetailStackedBelow2xlBreakpoint` and `SkillDetailSideBySideAbove2xlBreakpoint` will render this PR's new 'read-only, consumed-global-skill' code path: 'Edit latest'/'Use as latest' and 'Archive' will no longer render even though these stories are meant to depict an ordinary owned skill (they exist specifically to test the action-bar/sidebar layout at different breakpoints). This silently changes what the stories exercise and is likely to break any existing visual-regression baselines for these two stories, since they'll suddenly render with fewer action buttons than before this PR.
</issue_description>

<issue_validation>
Confirmed against the codebase. In LLMSkillScene.tsx:97, isOwnedByCurrentTeam = isSkill(skill) && skill.team_id === currentTeamId, and the Edit/Use-as-latest (line 129) and Archive (line 208) actions are gated on it; only Download (gated on isSkill, line 172) survives. The story sets SKILL.team_id = 1 (line 71, copied to SKILL_LIST_ENTRY line 109) and its mswDecorator overrides only the llm_skills list/resolve endpoints. The bootstrap endpoints /api/environments/@current/ and /api/projects/@current/ fall through to the default handler (handlers.ts:204-205) which returns MOCK_DEFAULT_TEAM, whose id is MOCK_TEAM_ID = 997 (api.mock.ts:32,48). teamLogic loads currentTeam from api/environments/@current and exposes currentTeamId = currentTeam.id = 997. Therefore 1 !== 997, isOwnedByCurrentTeam is false, and both SkillDetailStackedBelow2xlBreakpoint and SkillDetailSideBySideAbove2xlBreakpoint render the new read-only consumer path with Edit/Archive hidden — not the owned-skill action bar these breakpoint stories were built to depict. This silently changes what the stories exercise and shifts the visual-regression baselines. The mock is also internally incoherent: is_global: false (private) combined with not-owned is a state that can't occur in production, since only global skills surface across teams. Fix is trivial (use MOCK_TEAM_ID / 997). Impact is confined to Storybook/VRT with no production effect, but it degrades the only visual coverage for this scene in the very PR that introduces the ownership gating, so should_fix is appropriate.
</issue_validation>

## Task
Investigate the issue and solve it

<potential_solution>
Set `team_id` on the `SKILL`/`SKILL_LIST_ENTRY` mocks to the same team ID the Storybook bootstrap mocks resolve to (e.g. import and use `MOCK_TEAM_ID` from `frontend/src/lib/api.mock`, or explicitly override the `/api/environments/@current/` and `/api/projects/@current/` handlers in this story's `mswDecorator` to return a team with `id: 1`), so `isOwnedByCurrentTeam` evaluates true and the stories keep exercising the full owned-skill action bar as intended.
</potential_solution>

@scheduled-actions-posthog

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the stale label – otherwise this will be closed in another week. If you want to permanently keep it open, use the waiting label.

@posthog

posthog Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

👋 Visual changes detected for this PR.

Review and approve in PostHog Visual Review

If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix.

@scheduled-actions-posthog

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the stale label – otherwise this will be closed in another week. If you want to permanently keep it open, use the waiting label.

@scheduled-actions-posthog

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the stale label – otherwise this will be closed in another week. If you want to permanently keep it open, use the waiting label.

@scheduled-actions-posthog

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the stale label – otherwise this will be closed in another week. If you want to permanently keep it open, use the waiting label.

@scheduled-actions-posthog

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the stale label – otherwise this will be closed in another week. If you want to permanently keep it open, use the waiting label.

@scheduled-actions-posthog

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the stale label – otherwise this will be closed in another week. If you want to permanently keep it open, use the waiting label.

@scheduled-actions-posthog

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the stale label – otherwise this will be closed in another week. If you want to permanently keep it open, use the waiting label.

@scheduled-actions-posthog

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the stale label – otherwise this will be closed in another week. If you want to permanently keep it open, use the waiting label.

@scheduled-actions-posthog

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the stale label – otherwise this will be closed in another week. If you want to permanently keep it open, use the waiting label.

@scheduled-actions-posthog

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the stale label – otherwise this will be closed in another week. If you want to permanently keep it open, use the waiting label.

@scheduled-actions-posthog

Copy link
Copy Markdown
Contributor

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

This branch was successfully deployed

1 active deployment
preview-pr-71360 — ea462c17 Deployed Jul 15, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants