Repository navigation
feat(skills): add global visibility controls to the skills UI - #71360
ceyniustranberg wants to merge 1 commit into
Conversation
🦔 Hogbox preview · ✅ ready▶ Open the preview
commit |
🤖 CI report✅ Bundle size — no changeUncompressed size of every built 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 budgetHow 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
🟢 Largest files eagerly shipped from
|
| 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%)
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
807c2b7 to
ea462c1
Compare
🦔 ReviewHog reviewed this pull requestFound 0 must fix, 1 should fix, 2 consider. Published 1 finding (view the review). |
|
ReviewHog Alpha 🦔 If you find any issues helpful - please reply "valid", "invalid", etc., for evaluation purposes 🙏 |
There was a problem hiding this comment.
ReviewHog Report
Changes
Issues: 1 issue
Files (5)
products/skills/frontend/LLMSkillScene.stories.tsxproducts/skills/frontend/LLMSkillScene.tsxproducts/skills/frontend/LLMSkillsScene.tsxproducts/skills/frontend/llmSkillLogic.tsproducts/skills/frontend/skillSceneComponents.tsx
| is_global: false, | ||
| team_id: 1, |
There was a problem hiding this comment.
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>
|
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 |
|
👋 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. |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
This PR was closed due to lack of activity. Feel free to reopen if it's still relevant. |
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
skill.team_id === currentTeamId; download stays available to everyone.How did you test this code?
Automated (run by me, the agent):
tsgo --noEmitreports noproducts/skillstype errors; kea logic types regenerated for the newsetGlobalVisibilityaction andsettingVisibilitystate.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
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 generatedllmSkillsNameVisibilityCreateand theis_global/team_idfields from the generated schemas, no handwritten API types. Business logic lives inllmSkillLogic(kea), not the component. Gating edit/archive/duplicate onteam_id === currentTeamIdis what makes a consumed global read-only instead of showing write buttons that would 404 against the owning team.Created with PostHog Code