chore(frontend): inline all kea logic types - #71010
Conversation
ef537fd to
0614aa4
Compare
🤖 CI reportℹ️ Bundle size — no base branch to compareUncompressed size of every built Total: 64.77 MiB (no base branch measurement to compare against yet) 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.1 KiB | ../node_modules/.pnpm/posthog-js@1.401.0/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.401.0/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 |
| 106.1 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 — no base branch to compare
Total size of the built frontend/dist folder (all assets), compared against the base branch.
Total: 1316.69 MiB (no base branch measurement to compare against yet)
|
Too many files changed for review. ( |
🦔 Hogbox preview · ✅ ready▶ Open the preview
commit |
👀 Auto-assigned reviewersThese soft owners were skipped because their changes are minor, or the reviewer list was getting long. Nothing blocks merge, so self-assign if you'd like a look:
Soft owners come from |
| password: string | ||
| } | ||
|
|
||
| // Generated by kea-typegen. Update if you're an agent, ignore if you're human. |
There was a problem hiding this comment.
are the block actually generated and injected in this file, or "generated" in the sense that an agent will write/update them? if the former they should probably be placed in their own type files to prevent conflicts, and if the latter i would remove the "generated" language.
There was a problem hiding this comment.
they're both. They're autogenerated, like the current typegen does, but the expectation is that when an agent does work around this logic, it'll also update the file here. We would still run typegen at the end of it all in CI, but this time it would be more of a "typecheck". The goal/expectation is that 90% of the time when adding a thing or two to a logic, agents will correctly also update the type here (cause there really isn't much to do here for most things), saving a whole extra CI run in the process.
There was a problem hiding this comment.
also, i'd avoid separate files cause this just adds bloat to the codebase. the current generated *Logic.ts files are extremely verbose (duplicate things a lot). we could commit the MakeLogicType stuff to a different file as well, but since all logics are anyway large containers, it doesn't feel like a few extra lines of generated metadata at the top will impact the experience for anyone
0614aa4 to
ba77547
Compare
ba77547 to
2114773
Compare
|
Superseded by the smaller, parallel migration series:
The batch PRs target |
|
Closing in favor of the smaller migration series above. |
Problem
Kea logic types currently live in generated
*LogicType.tsand*ModelType.tsfiles. That splits a logic from its inferred type and makes a clean typegen run regenerate roughly one thousand separate files.This PR completes the inline-mode migration started by
typegen-inlineand measures its effect on typegen and TypeScript performance.Changes
MakeLogicTypedeclarations..kearcand updated the repo guidance for future logic changes.kea@4.0.0-pre.6andkea-typegen@3.8.3, which include the required metadata and inline import support from keajs/kea#167 and keajs/kea-typegen#58.Benchmarks used three runs on the same local macOS checkout. Clean typegen deleted generated output before each uncached run. TypeScript used
tsgo --noEmit --incremental false. Times are wall-clock seconds from/usr/bin/time -p.The typegen improvement is clear. The TypeScript measurements do not demonstrate an improvement and remain within the observed run-to-run spread.
How did you test this code?
pnpm --filter=@posthog/frontend typegen:checkusing kea-typegen 3.8.3 and kea 4.0.0-pre.6hogli test frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.tshogli test frontend/src/scenes/cohorts/cohortCountWarningLogic.test.tshogli ci:preflight --strictyarn test --watchman=falseandyarn buildinkea-typegen(51 tests, including the pnpm physical-path regression)pnpm run test:typesandpnpm run test:tsdinkeapnpm --filter=@posthog/frontend exec tsgo --noEmit --incremental falsereaches only the pre-existingQuillDateFilter.tsxerror for the removedDateTimePickerProps.rangesproperty. It is not newly green on this branch.👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Automatic notifications
Docs update
Updated
frontend/src/AGENTS.mdand the repowriting-kea-logicsskill. No user-facing documentation changes are needed because this only changes generated TypeScript representation and developer workflow.🤖 Agent context
Codex (GPT-5) implemented the migration under human direction. No shareable session URL is available. Repo skills used:
/writing-kea-logics,/writing-skills,/writing-tests, and/running-ci-preflight.The required Kea and kea-typegen support was developed and verified in their upstream repositories. I switched the monorepo to the published releases once they became available, leaving no local package patches for this migration.
Autonomy: Human-driven (agent-assisted)