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.

chore(frontend): inline Kea types by default (#71685)

Marius Andra300681e2bf9d
diff --git a/.agents/skills/writing-kea-logics/SKILL.md b/.agents/skills/writing-kea-logics/SKILL.md
index e63d5f9928ce..51433da3fb81 100644
--- a/.agents/skills/writing-kea-logics/SKILL.md
+++ b/.agents/skills/writing-kea-logics/SKILL.md
@@ -54,15 +54,26 @@ If your work overlaps it, read the companion skill first.
## Anatomy at a glance
```ts
-import { actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
-import type { fooLogicType } from './fooLogicType'
-
export interface FooLogicProps {
fooId: string
}
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface fooLogicValues {
+ name: string
+ nameUpper: string
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface fooLogicActions {
+ setName: (name: string) => { name: string }
+}
+
+export type fooLogicType = MakeLogicType<fooLogicValues, fooLogicActions, FooLogicProps>
+
export const fooLogic = kea<fooLogicType>([
props({} as FooLogicProps),
key((props) => props.fooId),
diff --git a/.agents/skills/writing-kea-logics/references/anti-patterns.md b/.agents/skills/writing-kea-logics/references/anti-patterns.md
index 17262c3580f5..dddacd33ed91 100644
--- a/.agents/skills/writing-kea-logics/references/anti-patterns.md
+++ b/.agents/skills/writing-kea-logics/references/anti-patterns.md
@@ -358,7 +358,7 @@ type FooState = ReturnType<typeof fooLogic.build>['values']
```ts
// do
-import type { fooLogicType } from './fooLogicType'
+import type { fooLogicType } from './fooLogic'
type FooState = fooLogicType['values']
```
diff --git a/.kearc b/.kearc
index 7cc7c609725b..c097318ad2a3 100644
--- a/.kearc
+++ b/.kearc
@@ -3,129 +3,5 @@
"rootPath": "./frontend/src",
"typesPath": "./frontend/src",
"writePaths": true,
- "inlinePaths": [
- "./frontend/src/scenes/notebooks",
- "./frontend/src/lib",
- "./.kea-inline-separator-01",
- "./.kea-inline-separator-01-b",
- "./frontend/src/scenes/StripeConfirmInstall",
- "./frontend/src/scenes/coupons",
- "./frontend/src/scenes/data-pipelines",
- "./frontend/src/scenes/groups",
- "./frontend/src/scenes/organization",
- "./frontend/src/scenes/surveys",
- "./products/ai_observability",
- "./products/business_knowledge",
- "./products/growth",
- "./products/links",
- "./products/metrics",
- "./products/session_summaries",
- "./.kea-inline-separator-02",
- "./.kea-inline-separator-02-b",
- "./frontend/src/models",
- "./frontend/src/queries",
- "./frontend/src/scenes/comments",
- "./frontend/src/scenes/feature-flags",
- "./frontend/src/scenes/health",
- "./frontend/src/scenes/projectLogic.ts",
- "./frontend/src/scenes/session-recordings",
- "./frontend/src/scenes/welcome",
- "./frontend/src/scenes/wizard",
- "./products/alerts",
- "./products/data_modeling",
- "./products/notifications",
- "./products/skills",
- "./products/visual_review",
- "./.kea-inline-separator-03",
- "./.kea-inline-separator-03-b",
- "./frontend/src/exporter",
- "./frontend/src/scenes/annotations",
- "./frontend/src/scenes/authentication",
- "./frontend/src/scenes/billing",
- "./frontend/src/scenes/dashboard",
- "./frontend/src/scenes/exports",
- "./frontend/src/scenes/integrations",
- "./frontend/src/scenes/onboarding",
- "./frontend/src/scenes/persons-management",
- "./frontend/src/scenes/project-homepage",
- "./frontend/src/scenes/sessions",
- "./products/logs",
- "./products/revenue_analytics",
- "./products/review_hog",
- "./.kea-inline-separator-04",
- "./.kea-inline-separator-04-b",
- "./frontend/src/scenes/audit-logs",
- "./frontend/src/scenes/data-warehouse",
- "./frontend/src/scenes/debug",
- "./frontend/src/scenes/heatmaps",
- "./frontend/src/scenes/inbox",
- "./frontend/src/scenes/paths-v2",
- "./frontend/src/scenes/persons",
- "./frontend/src/scenes/product-tours",
- "./frontend/src/scenes/saved-insights",
- "./products/ai_gateway",
- "./products/error_tracking",
- "./products/posthog_ai",
- "./products/wizard",
- "./.kea-inline-separator-05",
- "./.kea-inline-separator-05-b",
- "./frontend/src/scenes/appLogic.tsx",
- "./frontend/src/scenes/approvals",
- "./frontend/src/scenes/instance",
- "./frontend/src/scenes/max",
- "./frontend/src/scenes/organizationLogic.tsx",
- "./frontend/src/scenes/resource-transfer",
- "./frontend/src/scenes/userLogic.ts",
- "./frontend/src/toolbar",
- "./products/data_warehouse",
- "./products/engineering_analytics",
- "./products/feature_flags",
- "./products/mcp_store",
- "./products/workflows",
- "./.kea-inline-separator-06",
- "./.kea-inline-separator-06-b",
- "./frontend/src/scenes/appContextLogic.ts",
- "./frontend/src/scenes/cohorts",
- "./frontend/src/scenes/data-management",
- "./frontend/src/scenes/notebooks",
- "./frontend/src/scenes/sceneLogic.tsx",
- "./frontend/src/scenes/settings",
- "./frontend/src/scenes/teamLogic.tsx",
- "./frontend/src/scenes/trends",
- "./frontend/src/scenes/web-analytics",
- "./products/conversations",
- "./products/early_access_features",
- "./products/subscriptions",
- "./products/tasks",
- "./.kea-inline-separator-07",
- "./.kea-inline-separator-07-b",
- "./frontend/src/layout",
- "./frontend/src/scenes/activity",
- "./frontend/src/scenes/agentic",
- "./frontend/src/scenes/experiments",
- "./frontend/src/scenes/hog-functions",
- "./frontend/src/scenes/models",
- "./frontend/src/scenes/oauth",
- "./frontend/src/scenes/retention",
- "./frontend/src/scenes/startups",
- "./products/dashboards",
- "./products/managed_migrations",
- "./products/mcp_analytics",
- "./products/user_interviews",
- "./.kea-inline-separator-08",
- "./.kea-inline-separator-08-b",
- "./frontend/src/scenes/Unsubscribe",
- "./frontend/src/scenes/funnels",
- "./frontend/src/scenes/insights",
- "./frontend/src/scenes/marketing-analytics",
- "./frontend/src/scenes/paths",
- "./frontend/src/scenes/sites",
- "./products/actions",
- "./products/customer_analytics",
- "./products/endpoints",
- "./products/legal_documents",
- "./products/live_debugger",
- "./products/replay_vision",
- "./products/tracing"
- ]
+ "inline": true
}
diff --git a/frontend/src/AGENTS.md b/frontend/src/AGENTS.md
index 7204b3a4ee98..5e9e0e834c73 100644
--- a/frontend/src/AGENTS.md
+++ b/frontend/src/AGENTS.md
@@ -49,8 +49,8 @@ Covered by the root `AGENTS.md` (Code Style → Frontend). The discovery hint fo
These are slow; run them at the right moment, not after every edit.
- **TypeScript check** — `pnpm --filter=@posthog/frontend typescript:check` (runs `tsgo --noEmit` over the whole app). Rely on the editor/LSP while editing; run the full check **once before you call the work done**, not per-edit.
-- **kea typegen** (`*Type.ts` files) — regenerates automatically via `typegen:watch` while the dev server runs (`./bin/start` / `hogli start`). If you must regen one logic without the server, use `pnpm --filter=@posthog/frontend typegen:file <path>`. **Don't routinely run the full `typegen:write`** — it's a heavy whole-repo pass (multi-GB heap).
- Directories listed under `inlinePaths` in `.kearc` (currently `frontend/src/scenes/notebooks`) use **inline types** instead of `*Type.ts` files: a generated `MakeLogicType` block sits above each `kea()` call, marked "Generated by kea-typegen". Agents may update those blocks (typegen reconciles them anyway); humans should let the typegen commands keep them updated. Connected values/actions carry a `// sourceLogic` comment and sort first, grouped by source logic.
+- **kea typegen** (inline types) — regenerates automatically via `typegen:watch` while the dev server runs (`./bin/start` / `hogli start`). If you must regen one logic without the server, use `pnpm --filter=@posthog/frontend typegen:file <path>`. **Don't routinely run the full `typegen:write`** — it's a heavy whole-repo pass (multi-GB heap).
+ All logic files use **inline types** by default: a generated `MakeLogicType` block sits above each `kea()` call, marked "Generated by kea-typegen". Agents may update those blocks (typegen reconciles them anyway); humans should let the typegen commands keep them updated. Connected values/actions carry a `// sourceLogic` comment and sort first, grouped by source logic.
- **`hogli build:openapi`** — only needed when you changed a **backend serializer/viewset**. A pure `.tsx`/`.ts` change never needs it. Don't run it speculatively.
## Lint & format
diff --git a/frontend/src/kea-disposables.test.ts b/frontend/src/kea-disposables.test.ts
index 4b2e87c4fe74..43c5cbaec21e 100644
--- a/frontend/src/kea-disposables.test.ts
+++ b/frontend/src/kea-disposables.test.ts
@@ -1,9 +1,7 @@
-import { kea, path } from 'kea'
+import { MakeLogicType, kea, path } from 'kea'
import { initKeaTests } from '~/test/init'
-import type { logicType } from './kea-disposables.testType'
-
// Helper: trigger visibilitychange after mutating document.hidden
const setHidden = (hidden: boolean): void => {
Object.defineProperty(document, 'hidden', { configurable: true, get: () => hidden })
@@ -14,6 +12,9 @@ const setHidden = (hidden: boolean): void => {
document.dispatchEvent(new Event('visibilitychange'))
}
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export type logicType = MakeLogicType<{}, {}>
+
describe('disposablesPlugin', () => {
let logic: ReturnType<typeof kea<logicType>>
let setupCalls: number
diff --git a/products/stamphog/frontend/scenes/StamphogScene/stamphogSceneLogic.ts b/products/stamphog/frontend/scenes/StamphogScene/stamphogSceneLogic.ts
index 2a6ed848dc8a..f4e884999236 100644
--- a/products/stamphog/frontend/scenes/StamphogScene/stamphogSceneLogic.ts
+++ b/products/stamphog/frontend/scenes/StamphogScene/stamphogSceneLogic.ts
@@ -1,4 +1,4 @@
-import { actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
import { router, urlToAction } from 'kea-router'
@@ -18,7 +18,135 @@ import type {
StamphogRepoConfigApi,
StamphogSyncInstallationResponseApi,
} from '../../generated/api.schemas'
-import type { stamphogSceneLogicType } from './stamphogSceneLogicType'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface stamphogSceneLogicValues {
+ currentProjectId: number | string // teamLogic
+ filteredRepoConfigs: StamphogRepoConfigApi[]
+ installInfo: StamphogInstallInfoApi | null
+ installInfoLoading: boolean
+ installUrl: string
+ repoConfigs: StamphogRepoConfigApi[]
+ repoConfigsLoading: boolean
+ repoSearch: string
+ skippedRepos: readonly string[]
+ syncResult: StamphogSyncInstallationResponseApi | null
+ syncResultLoading: boolean
+ syncedRepos: readonly StamphogRepoConfigApi[]
+ updatingRepoIds: string[]
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface stamphogSceneLogicActions {
+ loadInstallInfo: () => any
+ loadInstallInfoFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadInstallInfoSuccess: (
+ installInfo: StamphogInstallInfoApi,
+ payload?: any
+ ) => {
+ installInfo: StamphogInstallInfoApi
+ payload?: any
+ }
+ loadRepoConfigs: () => any
+ loadRepoConfigsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadRepoConfigsSuccess: (
+ repoConfigs: StamphogRepoConfigApi[],
+ payload?: any
+ ) => {
+ repoConfigs: StamphogRepoConfigApi[]
+ payload?: any
+ }
+ repoUpdateDone: (id: string) => {
+ id: string
+ }
+ setDigestEnabled: (
+ id: string,
+ enabled: boolean
+ ) => {
+ enabled: boolean
+ id: string
+ }
+ setRepoEnabled: (
+ id: string,
+ enabled: boolean
+ ) => {
+ enabled: boolean
+ id: string
+ }
+ setRepoSearch: (search: string) => {
+ search: string
+ }
+ setReviewMode: (
+ id: string,
+ reviewMode: ReviewModeEnumApi
+ ) => {
+ id: string
+ reviewMode: ReviewModeEnumApi
+ }
+ setTriggerLabel: (
+ id: string,
+ triggerLabel: string
+ ) => {
+ id: string
+ triggerLabel: string
+ }
+ syncInstallation: ({ installationId, code, state }: { code: string; installationId: string; state: string }) => {
+ installationId: string
+ code: string
+ state: string
+ }
+ syncInstallationFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ syncInstallationSuccess: (
+ syncResult: StamphogSyncInstallationResponseApi,
+ payload?: {
+ installationId: string
+ code: string
+ state: string
+ }
+ ) => {
+ syncResult: StamphogSyncInstallationResponseApi
+ payload?: {
+ installationId: string
+ code: string
+ state: string
+ }
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface stamphogSceneLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ installUrl: (installInfo: StamphogInstallInfoApi | null) => string
+ syncedRepos: (syncResult: StamphogSyncInstallationResponseApi | null) => readonly StamphogRepoConfigApi[]
+ skippedRepos: (syncResult: StamphogSyncInstallationResponseApi | null) => readonly string[]
+ filteredRepoConfigs: (repoConfigs: StamphogRepoConfigApi[], repoSearch: string) => StamphogRepoConfigApi[]
+ }
+}
+
+export type stamphogSceneLogicType = MakeLogicType<
+ stamphogSceneLogicValues,
+ stamphogSceneLogicActions,
+ Record<string, any>,
+ stamphogSceneLogicMeta
+>
export const stamphogSceneLogic = kea<stamphogSceneLogicType>([
path(['products', 'stamphog', 'frontend', 'scenes', 'StamphogScene', 'stamphogSceneLogic']),