: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
fix(today): keep the query stack off the today home eager path (#112133)
Paul D'Ambrac3f16db357e4
diff --git a/frontend/bin/check-eager-graph.mjs b/frontend/bin/check-eager-graph.mjsindex f8b1e955e289..97452627cedf 100644--- a/frontend/bin/check-eager-graph.mjs+++ b/frontend/bin/check-eager-graph.mjs@@ -143,6 +143,7 @@ const ROOTS = [forbidden: ['src/scenes/project-homepage/ai-first/AiFirstHomepage.tsx','src/scenes/project-homepage/today/TodayReportPage.tsx',+ 'src/queries/Query/Query.tsx',],},{diff --git a/frontend/src/scenes/project-homepage/today/TodayAskBox.tsx b/frontend/src/scenes/project-homepage/today/TodayAskBox.tsxindex d79a01019add..fa7dfbabc420 100644--- a/frontend/src/scenes/project-homepage/today/TodayAskBox.tsx+++ b/frontend/src/scenes/project-homepage/today/TodayAskBox.tsx@@ -1,7 +1,7 @@import { useActions } from 'kea'import { useRef, useState } from 'react'-import { Composer, QuillComposerLayout, QuillComposerSendButton } from 'products/posthog_ai/frontend/api/primitives'+import { Composer, QuillComposerLayout, QuillComposerSendButton } from 'products/posthog_ai/frontend/api/composer'import { todayLogic } from './todayLogic'diff --git a/frontend/src/scenes/project-homepage/today/TodayReportPrompts.tsx b/frontend/src/scenes/project-homepage/today/TodayReportPrompts.tsxindex 7d548f871ffa..d6bfe66620c3 100644--- a/frontend/src/scenes/project-homepage/today/TodayReportPrompts.tsx+++ b/frontend/src/scenes/project-homepage/today/TodayReportPrompts.tsx@@ -4,7 +4,7 @@ import { useState } from 'react'import { IconSparkles } from '@posthog/icons'import { LemonButton } from '@posthog/lemon-ui'-import { Composer } from 'products/posthog_ai/frontend/api/primitives'+import { Composer } from 'products/posthog_ai/frontend/api/composer'import {InboxQuestionSource,captureInboxReportAction,diff --git a/products/business_knowledge/frontend/scenes/playground/PlaygroundThread.tsx b/products/business_knowledge/frontend/scenes/playground/PlaygroundThread.tsxindex 57628e49b645..865a54b30077 100644--- a/products/business_knowledge/frontend/scenes/playground/PlaygroundThread.tsx+++ b/products/business_knowledge/frontend/scenes/playground/PlaygroundThread.tsx@@ -3,7 +3,8 @@ import { useEffect, useRef } from 'react'import { LemonBanner, LemonDivider } from '@posthog/lemon-ui'-import { Composer, RunLogSkeleton, Welcome } from 'products/posthog_ai/frontend/api/primitives'+import { Composer } from 'products/posthog_ai/frontend/api/composer'+import { RunLogSkeleton, Welcome } from 'products/posthog_ai/frontend/api/primitives'import { businessKnowledgePlaygroundLogic } from './businessKnowledgePlaygroundLogic'import { PlaygroundTurn } from './PlaygroundTurn'diff --git a/products/posthog_ai/frontend/AGENTS.md b/products/posthog_ai/frontend/AGENTS.mdindex d9a002b4535e..8dc57f8cc1b1 100644--- a/products/posthog_ai/frontend/AGENTS.md+++ b/products/posthog_ai/frontend/AGENTS.md@@ -18,12 +18,12 @@ them. There are four tiers, split along dependency/side-effect boundaries (not cpreserves code-splitting). Consumers pick the **lowest tier** that does the job. The full decision table,import rule, and copy-paste recipes live in the consumer-facing [`README.md`](./README.md); the summary:-| Tier | Module | What's in it |-| ------------------------------ | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| **1 — Prepackaged surfaces** | `api/readableRun` + `api/runSurface` + `api/runner` | `ReadonlyRunSurface` (lazy, code-split read-only embed); the `RunSurface` compound (`Root` + slots, eager) for custom layouts; `EmbeddedRunner` (lazy TaskTracker product for inline hosts) |-| **2 — Compound primitives** | `api/primitives` | `Thread` + atoms, `ThreadView`, `Composer.*`, `QueuedMessageList`, `RunLogSkeleton`, activity primitives + `RunActivity`, message presenters, permission/question surfaces |-| **3 — Headless logic + types** | `api/logics` + `api/types` | `runStreamLogic`, `runInteractionLogic`, status + thinking helpers; folded-thread + tool types |-| **4 — Extension seam** | `api/tools` | `toolRegistry`, `lookupToolRenderer`, `GenericMcpToolRenderer`, `DataToolRow`, `ToolActivity`, `FilePath`, diff helpers |+| Tier | Module | What's in it |+| ------------------------------ | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| **1 — Prepackaged surfaces** | `api/readableRun` + `api/runSurface` + `api/runner` | `ReadonlyRunSurface` (lazy, code-split read-only embed); the `RunSurface` compound (`Root` + slots, eager) for custom layouts; `EmbeddedRunner` (lazy TaskTracker product for inline hosts) |+| **2 — Compound primitives** | `api/primitives` + `api/composer` | `Thread` + atoms, `ThreadView`, `QueuedMessageList`, `RunLogSkeleton`, activity primitives + `RunActivity`, message presenters, permission/question surfaces; `Composer.*` and the quill composer frame in `api/composer` |+| **3 — Headless logic + types** | `api/logics` + `api/types` | `runStreamLogic`, `runInteractionLogic`, status + thinking helpers; folded-thread + tool types |+| **4 — Extension seam** | `api/tools` | `toolRegistry`, `lookupToolRenderer`, `GenericMcpToolRenderer`, `DataToolRow`, `ToolActivity`, `FilePath`, diff helpers |**Why the split, not one flat barrel:** the tool registry initializes from built-ins and the manifest at module load — a top-levelside effect that is _not_ tree-shaken. A single barrel statically re-exports it alongside the@@ -66,11 +66,13 @@ The headline exports per module:the standalone workspace embedded in another host, not a route-decoupled widget.- **`api/primitives`** — **`Thread`** (Radix-style compound: `Thread.Root` is the virtualized presenter, theatoms `Thread.Message/.Markdown/.Reasoning/.Failure/.Activity/.ToolCall` are the building blocks for- bespoke threads), **`Composer`** (logic-free compound input — the caller owns- `value`/`onChange`/`onSubmit`), **`RunLogSkeleton`** (the shared "run log is loading" loader — the+ bespoke threads), **`RunLogSkeleton`** (the shared "run log is loading" loader — the`ReadonlyRunSurface` Suspense fallback and the `RunSurface` bootstrap fallback, also used by the runnerscene), activity primitives, messagepresenters, and the permission/question surfaces.+- **`api/composer`** — **`Composer`** (logic-free compound input — the caller owns+ `value`/`onChange`/`onSubmit`) and the quill composer frame. It does not pull the thread, so an eager+ surface that only needs an input box imports it alone.- **`api/logics`** — **`runStreamLogic`** (SSE stream + thread projection, see §3),**`runInteractionLogic`** (Max-agnostic follow-up/queue facade), status helpers(`isTerminalRunStatus`, `INITIAL_PERMISSION_MODE`), thinking-message helpers,@@ -243,7 +245,8 @@ api/ # public API facade — the contract (import api/<module>, nreadableRun.ts # Tier 1: ReadonlyRunSurface (lazy read-only embed)runSurface.ts # Tier 1: RunSurface compound (Root + slots, eager) for custom layoutsrunner.ts # Tier 1: EmbeddedRunner (lazy TaskTracker product) for inline hosts- primitives.ts # Tier 2: Composer, Thread + atoms, ThreadView, QueuedMessageList, presenters, perm/question+ primitives.ts # Tier 2: Thread + atoms, ThreadView, QueuedMessageList, presenters, perm/question+ composer.ts # Tier 2: Composer + quill composer frame only, for eager surfaces that must not pull the threadlogics.ts # Tier 3: runStreamLogic, runInteractionLogic, context store + hooks, tool-event bus (headless)types.ts # Tier 3: folded-thread + tool domain types, AttachedContextItem, ToolStreamEvent (pure types)tools.ts # Tier 4: lookup + declaration contract (registry isolated)diff --git a/products/posthog_ai/frontend/README.md b/products/posthog_ai/frontend/README.mdindex b0518ccc61f4..355321267561 100644--- a/products/posthog_ai/frontend/README.md+++ b/products/posthog_ai/frontend/README.md@@ -26,6 +26,8 @@ import { isTerminalRunStatus } from 'products/posthog_ai/frontend/api/logics'side-effectful tool registry (`api/tools`) and the markdown/virtualization-heavy thread (`api/primitives`)must not leak into a bundle that only needs a status helper from `api/logics`. A status badge that importsa fat path drags presenters and the registry into its chunk; importing `api/logics` alone does not.+In the same way, an eager surface that only needs an input box imports `Composer` from `api/composer`,+because `api/primitives` pulls the query and insight stack through its thread presenters.There is deliberately **no root `index.ts` barrel** — a barrel that re-exports every tier wouldre-introduce the exact bundling problem the split solves. Always import an `api/<module>`.@@ -37,7 +39,7 @@ Pick the **lowest tier** that does the job.| Tier | Module | What's in it | Use when || ------------------------------ | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- || **1 — Prepackaged surfaces** | `api/readableRun` + `api/runSurface` + `api/runner` | `ReadonlyRunSurface` (lazy, code-split read-only embed); the `RunSurface` compound (`Root` + slots, eager) for custom layouts; `EmbeddedRunner` (lazy TaskTracker workspace for inline hosts) | "Just show a run" → `ReadonlyRunSurface` (inbox embeds). "Drive a run / custom layout" → `RunSurface` (tasks). "Embed the `/tasks` workspace" → `EmbeddedRunner` (Max). |-| **2 — Compound primitives** | `api/primitives` | `Thread` + atoms (`.Message/.Markdown/.Reasoning/.Failure/.Activity/.ToolCall`), `ThreadView`, `Composer.*`, `AttachedContextBar`, task navigation items and filters, `QueuedMessageList`, `RunLogSkeleton`, activity primitives + `RunActivity`, message presenters, permission/question/resource surfaces | Custom layout, shared navigation, or a bespoke/compact thread. |+| **2 — Compound primitives** | `api/primitives` + `api/composer` | `Thread` + atoms (`.Message/.Markdown/.Reasoning/.Failure/.Activity/.ToolCall`), `ThreadView`, `AttachedContextBar`, task navigation items and filters, `QueuedMessageList`, `RunLogSkeleton`, activity primitives + `RunActivity`, message presenters, permission/question/resource surfaces; `api/composer` holds `Composer.*` and the quill composer frame | Custom layout, shared navigation, or a bespoke/compact thread. An input box alone imports only `api/composer`. || **3 — Headless logic + types** | `api/logics` + `api/types` | `runStreamLogic`, `runInteractionLogic`, `tasksLogic`, status helpers (`isTerminalRunStatus`, `INITIAL_PERMISSION_MODE`), thinking-message helpers, context injection (`attachedContextLogic`, `useAttachedContext`, `contextPickerLogic`), tool-stream subscriptions (`toolStreamEventsLogic`, `useToolStreamListener`); folded-thread, task, and tool types | Status badge, automation, context injection, task navigation, tool-event listeners — no presenters or registry. || **4 — Extension seam** | `api/tools` | `toolRegistry`, `lookupToolRenderer`, `GenericMcpToolRenderer`, `DataToolRow`, `ToolActivity`, `FilePath`, diff helpers | Your product renders tool cards (insights, dashboards…). Declare them in your product list and include it in the central manifest. |@@ -73,7 +75,8 @@ own the composer. See `scenes/TaskTracker/components/TaskRunChat.tsx` for the fu```tsximport { RunSurface } from 'products/posthog_ai/frontend/api/runSurface'-import { Composer, QueuedMessageList } from 'products/posthog_ai/frontend/api/primitives'+import { Composer } from 'products/posthog_ai/frontend/api/composer'+import { QueuedMessageList } from 'products/posthog_ai/frontend/api/primitives'import { runInteractionLogic } from 'products/posthog_ai/frontend/api/logics'// Bind runInteractionLogic (the follow-up/queue facade) keyed by the same runId RunSurface.Root binds.@@ -274,7 +277,8 @@ resource changes) is an upsert — see `logics/contextPickerLogic.ts` for the fufree for the model/effort pickers):```tsx-import { AttachedContextBar, Composer } from 'products/posthog_ai/frontend/api/primitives'+import { Composer } from 'products/posthog_ai/frontend/api/composer'+import { AttachedContextBar } from 'products/posthog_ai/frontend/api/primitives';<Composer.Header><AttachedContextBar /></Composer.Header>diff --git a/products/posthog_ai/frontend/api/composer.ts b/products/posthog_ai/frontend/api/composer.tsnew file mode 100644index 000000000000..a35b68088d82--- /dev/null+++ b/products/posthog_ai/frontend/api/composer.ts@@ -0,0 +1,21 @@+// Tier 2 — the Composer compound and the quill composer frame, without the thread.+//+// LIGHT boundary: eager surfaces that only need an input box (the today home ask box) import from here.+// ./primitives also re-exports the thread presenters, and their static imports pull the whole query and+// insight stack onto the importer's eager path.+//+// Part of the `products/posthog_ai/frontend/api/<module>` public surface — import from here, not from+// deep `../components/*` paths. See ../README.md for the tier model and ../AGENTS.md for the coupling rule.++export { Composer } from '../components/composer/Composer'+export type {+ ComposerRootProps,+ ComposerFrameProps,+ ComposerTextareaProps,+ ComposerSubmitProps,+} from '../components/composer/Composer'++// The quill composer frame (bordered input group with an inline send button) and its send button.+export { QuillComposerLayout } from '../components/quill/QuillComposerLayout'+export type { QuillComposerLayoutProps } from '../components/quill/QuillComposerLayout'+export { QuillComposerSendButton } from '../components/quill/QuillComposerSendButton'diff --git a/products/posthog_ai/frontend/api/primitives.ts b/products/posthog_ai/frontend/api/primitives.tsindex 690fdcf42d0c..72d18fba4531 100644--- a/products/posthog_ai/frontend/api/primitives.ts+++ b/products/posthog_ai/frontend/api/primitives.ts@@ -1,12 +1,12 @@// Tier 2 — compound primitives & presenters: the broad presentational bucket for custom layouts and-// bespoke threads. The Composer compound, the Thread compound + atoms, the prepackaged `ThreadView`,+// bespoke threads. The Thread compound + atoms, the prepackaged `ThreadView`,// message presenters, the shared `RunLogSkeleton` loader, activity primitives, and the// permission/question/resource surfaces. Use when the prepackaged `ReadonlyRunSurface` (Tier 1,// ./readableRun) doesn't fit and you need to compose the pieces yourself — e.g. a compact inline thread via// `Thread.*` atoms.//-// (This is intentionally the wide presentational module; it can be subdivided later — e.g. thread.ts /-// composer.ts — if a consumer needs finer code-splitting.)+// (This is intentionally the wide presentational module. The Composer compound lives in ./composer so an+// eager input box does not pull the thread; split further, e.g. thread.ts, if a consumer needs it.)//// Part of the `products/posthog_ai/frontend/api/<module>` public surface — import from here, not from// deep `../components/*` paths. See ../README.md for the tier model and ../AGENTS.md for the coupling rule.@@ -15,19 +15,6 @@export { AttachedContextProvider } from '../components/AttachedContextProvider'export type { AttachedContextProviderProps } from '../components/AttachedContextProvider'-export { Composer } from '../components/composer/Composer'-export type {- ComposerRootProps,- ComposerFrameProps,- ComposerTextareaProps,- ComposerSubmitProps,-} from '../components/composer/Composer'--// The quill composer frame (bordered input group with an inline send button) and its send button.-export { QuillComposerLayout } from '../components/quill/QuillComposerLayout'-export type { QuillComposerLayoutProps } from '../components/quill/QuillComposerLayout'-export { QuillComposerSendButton } from '../components/quill/QuillComposerSendButton'-// Controlled model + reasoning-effort pickers for a composer footer.export { ComposerModelEffortPickers } from '../components/composer/ComposerModelEffortPickers'export type { ComposerModelEffortPickersProps } from '../components/composer/ComposerModelEffortPickers'diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskComposer.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskComposer.tsxindex 20ba267c97bd..f4ef8d069c26 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskComposer.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskComposer.tsx@@ -6,8 +6,8 @@ import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { AIConsentPopoverWrapper } from 'scenes/settings/organization/AIConsentPopoverWrapper'import { urls } from 'scenes/urls'+import { Composer } from 'products/posthog_ai/frontend/api/composer'import {- Composer,DEFAULT_SUGGESTIONS_DATA,type SuggestionItem,Suggestions,diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunComposer.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunComposer.tsxindex f66e9a546212..a963c1ee015b 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunComposer.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunComposer.tsx@@ -10,8 +10,9 @@ import { userLogic } from 'scenes/userLogic'import { todayShellLogic } from '~/layout/today/todayShellLogic'+import { Composer } from 'products/posthog_ai/frontend/api/composer'import { runInteractionLogic, type RunInteractionLogicProps } from 'products/posthog_ai/frontend/api/logics'-import { Composer, QueuedMessageList, useThreadSkin } from 'products/posthog_ai/frontend/api/primitives'+import { QueuedMessageList, useThreadSkin } from 'products/posthog_ai/frontend/api/primitives'import { modelCatalogueLogic } from 'products/posthog_ai/frontend/logics/modelCatalogueLogic'import { runSlashCommandsLogic } from 'products/posthog_ai/frontend/logics/runSlashCommandsLogic'import { taskRunDefaultsLogic } from 'products/posthog_ai/frontend/logics/taskRunDefaultsLogic'diff --git a/products/signals/frontend/inbox/components/detail/ReportDiscussionComposer.tsx b/products/signals/frontend/inbox/components/detail/ReportDiscussionComposer.tsxindex a443516a694f..38425aa00a99 100644--- a/products/signals/frontend/inbox/components/detail/ReportDiscussionComposer.tsx+++ b/products/signals/frontend/inbox/components/detail/ReportDiscussionComposer.tsx@@ -5,9 +5,9 @@ import { IconSparkles } from '@posthog/icons'import { cn } from 'lib/utils/css-classes'+import { Composer } from 'products/posthog_ai/frontend/api/composer'import {AttachedContextBar,- Composer,pickHeadline,type SuggestionGroup,type SuggestionItem,