chore(kea): migrate kea logic types to inline MakeLogicType blocks - #70885
Conversation
First step of migrating generated logicType.ts files to inline types, using kea-typegen 3.8.1's new inlinePaths mode. Everything under frontend/src/scenes/notebooks now carries a generated MakeLogicType block above each kea() call instead of a separate logicType.ts file. Connected values/actions are marked with their source logic and selector combiner params carry explicit type annotations. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🤖 CI report✅ Bundle size — no changeUncompressed size of every built Total: 64.76 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 |
|---|---|
| 280.3 KiB | ../node_modules/.pnpm/posthog-js@1.400.1/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.7 KiB | ../node_modules/.pnpm/posthog-js@1.400.1/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.9 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 — 🔺 +115.4 KiB (+0.0%)
Total size of the built frontend/dist folder (all assets), compared against the base branch.
Total: 1307.87 MiB · 🔺 +115.4 KiB (+0.0%)
🦔 Hogbox preview · ✅ ready▶ Open the preview
commit |
👀 Auto-assigned reviewersThese soft owners were skipped because they only have minor changes here. Nothing blocks merge, so self-assign if you'd like a look:
Soft owners come from |
|
Reviews (1): Last reviewed commit: "chore(notebooks): migrate kea logic type..." | Re-trigger Greptile |
kea-typegen 3.8.2: the generated block marker now reads "Update if you're an agent, ignore if you're human", and inline Values/Actions interfaces sort connected entries first (grouped by source logic, alphabetical) followed by the logic's own entries alphabetically. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… 3.8.2 The npm package resolves the repo TypeScript (6.0.3) as its peer dependency, which prints optional properties differently than the 4.9.x used during local development (callback?: fn vs callback: fn | undefined). Regenerated with the published package so the blocks match what CI produces. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
✅ Visual changes approved by @mariusandra — baseline updated in 6 changed. |
6 updated Run: 60b582ff-3cbd-47a6-8c55-c84ba771023f Co-authored-by: mariusandra <53387+mariusandra@users.noreply.github.com>
Problem
Generated
logicType.tsfiles are invisible during review (gitignored), add an import indirection to every logic, and make it hard to see what a logic exposes without regenerating types locally.kea-typegen 3.8.0 introduced an inline mode that writes plain, readable interfaces directly above each
kea()call instead, and 3.8.1 addedinlinePathsso a repo this size can migrate directory by directory.This PR is the first step of that migration, converting everything under
frontend/src/scenes/notebooks.Changes
.kearcgains"inlinePaths": ["./frontend/src/scenes/notebooks"]andkea-typegenis bumped to 3.8.1. Directories on that list get a generated block above each logic instead of alogicType.tsfile; everything else keeps working exactly as before. Migrating another directory is just adding it to the list and runningtypegen:write.connectare marked with a// sourceLogiccomment.(counter: number) => ...).MakeLogicTypetypes combiner args asany, so without the annotations the inferred value types would silently degrade on later typegen runs.import type { xxxLogicType } from './xxxLogic'(type-only, so thenotebookLogic↔notebookNodeLogictype references don't become runtime import cycles).products/customer_analyticsdeclares@tiptap/coreas a"*"peer dependency (same asproducts/conversations): its regeneratedaccountNotebooksLogicType.tsreferencesimport("@tiptap/core").FocusPositionthrough a connected notebook action.frontend/src/AGENTS.mddocuments the inline mode so agents don't hand-edit the generated blocks.The blocks stay maintained by the usual commands (
typegen:write,typegen:watch, CItypegen:check), and the comparison in kea-typegen 3.8.1 is formatting-insensitive, so oxfmt reflowing a block doesn't cause rewrite churn. Logics manually typed withkea<MakeLogicType<...>>()are left alone entirely, so hand-written types remain an option.How did you test this code?
All automated, run locally by the agent:
pnpm --filter=@posthog/frontend typescript:check(tsgo) passes with 0 errors.pnpm --filter=@posthog/frontend typegen:checkwith the published kea-typegen 3.8.1 exits 0, including after an oxfmt pass over the converted files (no rewrite loop).frontend/src/scenes/notebookspass (507 tests).No runtime behavior changes intended; the diff is types, imports, and comments. I did not manually test the notebooks UI.
Automatic notifications
Docs update
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Built with Claude Code (Claude Fable 5). Marius drove the direction; Claude did the conversion and shipped kea-typegen 3.8.1 alongside it (
inlinePaths, sticky inline detection, selector param annotation, formatter-tolerant comparison, and a semantic fallback invisitConnect).Decisions worth knowing during review:
actionCreatorswalk (mapped type, not a literal); the 3.8.1 semantic fallback fixes this for both inline and classic consumers. That fallback resolves types to their true declaration, which is why customer_analytics newly needs the@tiptap/corepeer dep.any.themeLogicType.tsorphan (logic moved tolib/logicin chore(toolbar): move themeLogic and dataThemeLogic to lib/logic #69134) surfaced during typechecking; deleted locally only, since these files are gitignored.