: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { MakeLogicType, actions, kea, key, listeners, path, props, reducers } from 'kea'
import { loaders } from 'kea-loaders'
import { ApiConfig } from '~/lib/api'
import { llmSkillsNameFilesRetrieve } from 'products/skills/frontend/generated/api'
import type { LLMSkillFileApi } from 'products/skills/frontend/generated/api.schemas'
export interface SkillFileLogicProps {
skillName: string
filePath: string
version?: number
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface skillFileLogicValues {
content: string | null
contentLoading: boolean
expanded: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface skillFileLogicActions {
autoOpen: () => {
value: true
}
loadContent: () => any
loadContentFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
loadContentSuccess: (
content: string,
payload?: any
) => {
content: string
payload?: any
}
toggleExpand: () => {
value: true
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface skillFileLogicMeta {
key: string
}
export type skillFileLogicType = MakeLogicType<
skillFileLogicValues,
skillFileLogicActions,
SkillFileLogicProps,
skillFileLogicMeta
>
export const skillFileLogic = kea<skillFileLogicType>([
path(['scenes', 'skills', 'skillFileLogic']),
props({ skillName: '', filePath: '' } as SkillFileLogicProps),
key(({ skillName, filePath, version }) => `skill-file-${skillName}:${filePath}:${version ?? 'latest'}`),
actions({
toggleExpand: true,
autoOpen: true,
}),
reducers({
expanded: [
false,
{
toggleExpand: (state) => !state,
autoOpen: () => true,
},
],
}),
loaders(({ props }) => ({
content: {
__default: null as string | null,
loadContent: async () => {
try {
const fileData: LLMSkillFileApi = await llmSkillsNameFilesRetrieve(
String(ApiConfig.getCurrentTeamId()),
props.skillName,
props.filePath,
{ version: props.version }
)
return fileData.content
} catch (e) {
console.error('Failed to load file content', e)
return 'Failed to load file content.'
}
},
},
})),
listeners(({ actions, values }) => ({
toggleExpand: () => {
if (values.expanded && values.content === null && !values.contentLoading) {
actions.loadContent()
}
},
autoOpen: () => {
if (values.content === null && !values.contentLoading) {
actions.loadContent()
}
},
})),
])