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(kea): migrate kea logic types to inline MakeLogicType blocks (#70885)

Marius Andra79cffa791116
diff --git a/.kearc b/.kearc
index 442c3de107fa..d4ae51476b54 100644
--- a/.kearc
+++ b/.kearc
@@ -2,5 +2,6 @@
"tsConfigPath": "./tsconfig.kea-typegen.json",
"rootPath": "./frontend/src",
"typesPath": "./frontend/src",
- "writePaths": true
+ "writePaths": true,
+ "inlinePaths": ["./frontend/src/scenes/notebooks"]
}
diff --git a/frontend/package.json b/frontend/package.json
index 68c9694e4ed6..a25277228b1e 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -335,7 +335,7 @@
"jest-environment-jsdom": "^29.3.1",
"jest-image-snapshot": "^6.1.0",
"jest-junit": "^16.0.0",
- "kea-typegen": "3.7.1",
+ "kea-typegen": "3.8.2",
"less": "^3.12.2",
"lint-staged": "catalog:",
"mockdate": "^3.0.5",
diff --git a/frontend/src/AGENTS.md b/frontend/src/AGENTS.md
index dd74600ab4b2..7204b3a4ee98 100644
--- a/frontend/src/AGENTS.md
+++ b/frontend/src/AGENTS.md
@@ -50,6 +50,7 @@ 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.
- **`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/lib/components/Scenes/InsightOrDashboard/SceneNotebookMenuItems.tsx b/frontend/src/lib/components/Scenes/InsightOrDashboard/SceneNotebookMenuItems.tsx
index 5319c3c714f6..479b67dc11d1 100644
--- a/frontend/src/lib/components/Scenes/InsightOrDashboard/SceneNotebookMenuItems.tsx
+++ b/frontend/src/lib/components/Scenes/InsightOrDashboard/SceneNotebookMenuItems.tsx
@@ -9,8 +9,8 @@ import { Combobox } from 'lib/ui/Combobox/Combobox'
import { DropdownMenuGroup, DropdownMenuSeparator } from 'lib/ui/DropdownMenu/DropdownMenu'
import { Label } from 'lib/ui/Label/Label'
import { useNotebookNode } from 'scenes/notebooks/Nodes/NotebookNodeContext'
-import { notebookNodeLogicType } from 'scenes/notebooks/Nodes/notebookNodeLogicType'
-import { notebookLogicType } from 'scenes/notebooks/Notebook/notebookLogicType'
+import type { notebookNodeLogicType } from 'scenes/notebooks/Nodes/notebookNodeLogic'
+import type { notebookLogicType } from 'scenes/notebooks/Notebook/notebookLogic'
import {
NotebookSelectButtonLogicProps,
notebookSelectButtonLogic,
diff --git a/frontend/src/models/notebooksModel.ts b/frontend/src/models/notebooksModel.ts
index 8a494a16e7e5..a902fcfff59d 100644
--- a/frontend/src/models/notebooksModel.ts
+++ b/frontend/src/models/notebooksModel.ts
@@ -10,7 +10,7 @@ import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { deleteWithUndo } from 'lib/utils/deleteWithUndo'
import { addProductIntent } from 'lib/utils/product-intents'
import { notebookLogic } from 'scenes/notebooks/Notebook/notebookLogic'
-import type { notebookLogicType } from 'scenes/notebooks/Notebook/notebookLogicType'
+import type { notebookLogicType } from 'scenes/notebooks/Notebook/notebookLogic'
import { notebookPanelLogic } from 'scenes/notebooks/NotebookPanel/notebookPanelLogic'
import { LOCAL_NOTEBOOK_TEMPLATES } from 'scenes/notebooks/NotebookTemplates/notebookTemplates'
import { NotebookListItemType, NotebookNodeType, NotebookTarget } from 'scenes/notebooks/types'
diff --git a/frontend/src/scenes/notebooks/AddExperimentsToNotebookModal/addExperimentsToNotebookModalLogic.ts b/frontend/src/scenes/notebooks/AddExperimentsToNotebookModal/addExperimentsToNotebookModalLogic.ts
index 0534d9ac68b8..05baced7bea9 100644
--- a/frontend/src/scenes/notebooks/AddExperimentsToNotebookModal/addExperimentsToNotebookModalLogic.ts
+++ b/frontend/src/scenes/notebooks/AddExperimentsToNotebookModal/addExperimentsToNotebookModalLogic.ts
@@ -1,4 +1,4 @@
-import { actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
import api, { CountedPaginatedResponse } from 'lib/api'
@@ -9,8 +9,6 @@ import { teamLogic } from 'scenes/teamLogic'
import { Experiment } from '~/types'
-import type { addExperimentsToNotebookModalLogicType } from './addExperimentsToNotebookModalLogicType'
-
export interface ExperimentsModalFilters {
search?: string
page?: number
@@ -19,6 +17,67 @@ export interface ExperimentsModalFilters {
const EXPERIMENTS_PER_PAGE = 10
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface addExperimentsToNotebookModalLogicValues {
+ currentTeamId: number | null // teamLogic
+ count: number
+ experiments: CountedPaginatedResponse<Experiment>
+ experimentsLoading: boolean
+ experimentsPerPage: number
+ filters: ExperimentsModalFilters
+ insertionPosition: number | null
+ isAddExperimentsToNotebookModalOpen: boolean
+ modalPage: number
+ rawModalFilters: ExperimentsModalFilters
+ sorting: Sorting | null
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface addExperimentsToNotebookModalLogicActions {
+ closeModal: () => {
+ value: true
+ }
+ loadExperiments: () => {
+ value: true
+ }
+ loadExperimentsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadExperimentsSuccess: (
+ experiments: CountedPaginatedResponse<Experiment>,
+ payload?: {
+ value: true
+ }
+ ) => {
+ experiments: CountedPaginatedResponse<Experiment>
+ payload?: {
+ value: true
+ }
+ }
+ openModal: (insertionPosition: number | null) => {
+ insertionPosition: number | null
+ }
+ setModalFilters: (
+ filters: Partial<ExperimentsModalFilters>,
+ merge?: boolean
+ ) => {
+ filters: Partial<ExperimentsModalFilters>
+ merge: boolean
+ }
+ setModalPage: (page: number) => {
+ page: number
+ }
+}
+
+export type addExperimentsToNotebookModalLogicType = MakeLogicType<
+ addExperimentsToNotebookModalLogicValues,
+ addExperimentsToNotebookModalLogicActions
+>
+
export const addExperimentsToNotebookModalLogic = kea<addExperimentsToNotebookModalLogicType>([
path(['scenes', 'notebooks', 'AddExperimentsToNotebookModal', 'addExperimentsToNotebookModalLogic']),
connect(() => ({
@@ -89,18 +148,18 @@ export const addExperimentsToNotebookModalLogic = kea<addExperimentsToNotebookMo
selectors({
filters: [
(s) => [s.rawModalFilters],
- (rawModalFilters): ExperimentsModalFilters => ({
+ (rawModalFilters: ExperimentsModalFilters): ExperimentsModalFilters => ({
page: 1,
order: '-created_at',
...rawModalFilters,
}),
],
experimentsPerPage: [() => [], (): number => EXPERIMENTS_PER_PAGE],
- count: [(s) => [s.experiments], (experiments) => experiments.count],
- modalPage: [(s) => [s.filters], (filters) => filters.page || 1],
+ count: [(s) => [s.experiments], (experiments: CountedPaginatedResponse<Experiment>) => experiments.count],
+ modalPage: [(s) => [s.filters], (filters: ExperimentsModalFilters) => filters.page || 1],
sorting: [
(s) => [s.filters],
- (filters): Sorting | null =>
+ (filters: ExperimentsModalFilters): Sorting | null =>
filters.order
? filters.order.startsWith('-')
? { columnKey: filters.order.slice(1), order: -1 }
@@ -108,7 +167,7 @@ export const addExperimentsToNotebookModalLogic = kea<addExperimentsToNotebookMo
: null,
],
}),
- listeners(({ actions, values, selectors }) => ({
+ listeners(({ actions, values, selectors, props }) => ({
openModal: () => {
actions.loadExperiments()
},
@@ -116,7 +175,7 @@ export const addExperimentsToNotebookModalLogic = kea<addExperimentsToNotebookMo
actions.setModalFilters({ page }, true)
},
setModalFilters: (_, __, ___, previousState) => {
- const oldFilters = selectors.filters(previousState)
+ const oldFilters = selectors.filters(previousState, props)
const newFilters = values.filters
if (!objectsEqual(oldFilters, newFilters)) {
diff --git a/frontend/src/scenes/notebooks/AddInsightsToNotebookModal/addInsightsToNotebookModalLogic.ts b/frontend/src/scenes/notebooks/AddInsightsToNotebookModal/addInsightsToNotebookModalLogic.ts
index 0cbd6f78f05a..0490b50f8fa0 100644
--- a/frontend/src/scenes/notebooks/AddInsightsToNotebookModal/addInsightsToNotebookModalLogic.ts
+++ b/frontend/src/scenes/notebooks/AddInsightsToNotebookModal/addInsightsToNotebookModalLogic.ts
@@ -1,6 +1,25 @@
-import { actions, kea, path, reducers } from 'kea'
+import { MakeLogicType, actions, kea, path, reducers } from 'kea'
-import type { addInsightsToNotebookModalLogicType } from './addInsightsToNotebookModalLogicType'
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface addInsightsToNotebookModalLogicValues {
+ insertionPosition: number | null
+ isAddInsightsToNotebookModalOpen: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface addInsightsToNotebookModalLogicActions {
+ closeModal: () => {
+ value: true
+ }
+ openModal: (insertionPosition: number | null) => {
+ insertionPosition: number | null
+ }
+}
+
+export type addInsightsToNotebookModalLogicType = MakeLogicType<
+ addInsightsToNotebookModalLogicValues,
+ addInsightsToNotebookModalLogicActions
+>
export const addInsightsToNotebookModalLogic = kea<addInsightsToNotebookModalLogicType>([
path(['scenes', 'notebooks', 'AddInsightsToNotebookModal', 'addInsightsToNotebookModalLogic']),
diff --git a/frontend/src/scenes/notebooks/Nodes/NotebookNodeContext.ts b/frontend/src/scenes/notebooks/Nodes/NotebookNodeContext.ts
index ac1183bf5152..a3c02095c1d4 100644
--- a/frontend/src/scenes/notebooks/Nodes/NotebookNodeContext.ts
+++ b/frontend/src/scenes/notebooks/Nodes/NotebookNodeContext.ts
@@ -1,7 +1,7 @@
import { BuiltLogic } from 'kea'
import { createContext, useContext } from 'react'
-import type { notebookNodeLogicType } from './notebookNodeLogicType'
+import type { notebookNodeLogicType } from './notebookNodeLogic'
export const NotebookNodeContext = createContext<BuiltLogic<notebookNodeLogicType> | undefined>(undefined)
diff --git a/frontend/src/scenes/notebooks/Nodes/NotebookNodeFlagLogic.tsx b/frontend/src/scenes/notebooks/Nodes/NotebookNodeFlagLogic.tsx
index 738dc0dfb77a..c34003097055 100644
--- a/frontend/src/scenes/notebooks/Nodes/NotebookNodeFlagLogic.tsx
+++ b/frontend/src/scenes/notebooks/Nodes/NotebookNodeFlagLogic.tsx
@@ -1,11 +1,11 @@
-import { connect, kea, key, listeners, path, props, selectors } from 'kea'
+import { MakeLogicType, connect, kea, key, listeners, path, props, selectors } from 'kea'
import { JSONContent, RichContentNode } from 'lib/components/RichContentEditor/types'
import { FeatureFlagLogicProps, featureFlagLogic } from 'scenes/feature-flags/featureFlagLogic'
+import type { EarlyAccessFeatureType, FeatureFlagType, Survey } from '../../../types'
import { NotebookNodeType } from '../types'
import { buildEarlyAccessFeatureContent } from './NotebookNodeEarlyAccessFeature'
-import type { notebookNodeFlagLogicType } from './NotebookNodeFlagLogicType'
import { buildSurveyContent } from './NotebookNodeSurvey'
export type NotebookNodeFlagLogicProps = {
@@ -13,6 +13,39 @@ export type NotebookNodeFlagLogicProps = {
insertAfter: (content: JSONContent) => void
}
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookNodeFlagLogicValues {
+ featureFlag: FeatureFlagType // featureFlagLogic
+ hasEarlyAccessFeatures: boolean // featureFlagLogic
+ hasSurveys: boolean | null // featureFlagLogic
+ shouldDisableInsertEarlyAccessFeature: (nextNode: RichContentNode | null) => boolean
+ shouldDisableInsertSurvey: (nextNode: RichContentNode | null) => boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookNodeFlagLogicActions {
+ createEarlyAccessFeatureSuccess: (
+ newEarlyAccessFeature: EarlyAccessFeatureType,
+ payload?: any
+ ) => {
+ newEarlyAccessFeature: EarlyAccessFeatureType
+ payload?: any
+ } // featureFlagLogic
+ createSurveySuccess: (
+ newSurvey: Survey,
+ payload?: any
+ ) => {
+ newSurvey: Survey
+ payload?: any
+ } // featureFlagLogic
+}
+
+export type notebookNodeFlagLogicType = MakeLogicType<
+ notebookNodeFlagLogicValues,
+ notebookNodeFlagLogicActions,
+ NotebookNodeFlagLogicProps
+>
+
export const notebookNodeFlagLogic = kea<notebookNodeFlagLogicType>([
props({} as NotebookNodeFlagLogicProps),
path((key) => ['scenes', 'notebooks', 'Notebook', 'Nodes', 'notebookNodeFlagLogic', key]),
@@ -33,7 +66,7 @@ export const notebookNodeFlagLogic = kea<notebookNodeFlagLogicType>([
selectors({
shouldDisableInsertEarlyAccessFeature: [
(s) => [s.featureFlag, s.hasEarlyAccessFeatures],
- (featureFlag, hasEarlyAccessFeatures) =>
+ (featureFlag: FeatureFlagType, hasEarlyAccessFeatures: boolean) =>
(nextNode: RichContentNode | null): boolean => {
return (
(nextNode?.type.name === NotebookNodeType.EarlyAccessFeature &&
@@ -46,7 +79,7 @@ export const notebookNodeFlagLogic = kea<notebookNodeFlagLogicType>([
],
shouldDisableInsertSurvey: [
(s) => [s.featureFlag, s.hasSurveys],
- (featureFlag, hasSurveys) =>
+ (featureFlag: FeatureFlagType, hasSurveys: boolean | null) =>
(nextNode: RichContentNode | null): boolean => {
return (
(nextNode?.type.name === NotebookNodeType.Survey &&
diff --git a/frontend/src/scenes/notebooks/Nodes/NotebookNodePersonFeed/notebookNodePersonFeedLogic.ts b/frontend/src/scenes/notebooks/Nodes/NotebookNodePersonFeed/notebookNodePersonFeedLogic.ts
index 3e92f3b094b6..217be703fd48 100644
--- a/frontend/src/scenes/notebooks/Nodes/NotebookNodePersonFeed/notebookNodePersonFeedLogic.ts
+++ b/frontend/src/scenes/notebooks/Nodes/NotebookNodePersonFeed/notebookNodePersonFeedLogic.ts
@@ -1,4 +1,4 @@
-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 api from 'lib/api'
@@ -12,12 +12,84 @@ import { setLatestVersionsOnQuery } from '~/queries/utils'
import { CUSTOMER_ANALYTICS_DEFAULT_QUERY_TAGS } from 'products/customer_analytics/frontend/constants'
-import type { notebookNodePersonFeedLogicType } from './notebookNodePersonFeedLogicType'
+import type { TimelineEntry } from '../../../../queries/schema/schema-general'
export type NotebookNodePersonFeedLogicProps = {
personId: string
}
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookNodePersonFeedLogicValues {
+ isCloudOrDev: boolean | undefined // preflightLogic
+ canSummarize: boolean
+ numFailedSummaries: number
+ numProcessedSessions: number
+ numSessionsWithRecording: number
+ numSummaries: number
+ progressText: string
+ sessionIdsWithRecording: string[]
+ sessionSummary: Record<string, SessionSummaryContent> | null
+ sessionSummaryLoading: boolean
+ sessions: SessionsTimelineQueryResponse['results'] | null
+ sessionsLoading: boolean
+ summaries: Record<string, SessionSummaryContent>
+ summariesLoading: boolean
+ summarizingState: 'completed' | 'idle' | 'loading'
+ summaryErrors: string[]
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookNodePersonFeedLogicActions {
+ loadSessionsTimeline: () => any
+ loadSessionsTimelineFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadSessionsTimelineSuccess: (
+ sessions: TimelineEntry[],
+ payload?: any
+ ) => {
+ sessions: TimelineEntry[]
+ payload?: any
+ }
+ setSummarizingState: (state: 'completed' | 'idle' | 'loading') => {
+ state: 'completed' | 'idle' | 'loading'
+ }
+ summarizeSession: (sessionId: string) => {
+ sessionId: string
+ }
+ summarizeSessionFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ summarizeSessionSuccess: (
+ sessionSummary: Record<string, SessionSummaryContent>,
+ payload?: {
+ sessionId: string
+ }
+ ) => {
+ sessionSummary: Record<string, SessionSummaryContent>
+ payload?: {
+ sessionId: string
+ }
+ }
+ summarizeSessions: () => {
+ value: true
+ }
+}
+
+export type notebookNodePersonFeedLogicType = MakeLogicType<
+ notebookNodePersonFeedLogicValues,
+ notebookNodePersonFeedLogicActions,
+ NotebookNodePersonFeedLogicProps
+>
+
export const notebookNodePersonFeedLogic = kea<notebookNodePersonFeedLogicType>([
props({} as NotebookNodePersonFeedLogicProps),
path((key) => ['scenes', 'notebooks', 'Notebook', 'Nodes', 'notebookNodePersonFeedLogic', key]),
@@ -104,26 +176,29 @@ export const notebookNodePersonFeedLogic = kea<notebookNodePersonFeedLogicType>(
selectors({
// AI session summaries are PostHog Cloud only, so hide the whole block on self-hosted.
- canSummarize: [(s) => [s.isCloudOrDev], (isCloudOrDev): boolean => !!isCloudOrDev],
+ canSummarize: [(s) => [s.isCloudOrDev], (isCloudOrDev: boolean | undefined): boolean => !!isCloudOrDev],
numSessionsWithRecording: [
(s) => [s.sessionIdsWithRecording],
- (sessionIdsWithRecording) => sessionIdsWithRecording.length,
+ (sessionIdsWithRecording: string[]) => sessionIdsWithRecording.length,
+ ],
+ numSummaries: [
+ (s) => [s.summaries],
+ (summaries: Record<string, SessionSummaryContent>) => Object.keys(summaries).length,
],
- numSummaries: [(s) => [s.summaries], (summaries) => Object.keys(summaries).length],
- summariesLoading: [(s) => [s.sessionSummaryLoading], (sessionSummaryLoading) => sessionSummaryLoading],
- numFailedSummaries: [(s) => [s.summaryErrors], (summaryErrors) => summaryErrors.length],
+ summariesLoading: [(s) => [s.sessionSummaryLoading], (sessionSummaryLoading: boolean) => sessionSummaryLoading],
+ numFailedSummaries: [(s) => [s.summaryErrors], (summaryErrors: string[]) => summaryErrors.length],
numProcessedSessions: [
(s) => [s.numSummaries, s.numFailedSummaries],
- (numSummaries, numFailedSummaries) => numSummaries + numFailedSummaries,
+ (numSummaries: number, numFailedSummaries: number) => numSummaries + numFailedSummaries,
],
progressText: [
(s) => [s.numProcessedSessions, s.numSessionsWithRecording],
- (numProcessedSessions, numSessionsWithRecording) =>
+ (numProcessedSessions: number, numSessionsWithRecording: number) =>
`${numProcessedSessions} out of ${pluralize(numSessionsWithRecording, 'session')} analyzed.`,
],
sessionIdsWithRecording: [
(s) => [s.sessions],
- (sessions) =>
+ (sessions: TimelineEntry[] | null) =>
(sessions
?.filter((session) => !!session.recording_duration_s)
.map((session) => session.sessionId)
diff --git a/frontend/src/scenes/notebooks/Nodes/notebookNodeLogic.ts b/frontend/src/scenes/notebooks/Nodes/notebookNodeLogic.ts
index 986e119b652c..6ea09064674f 100644
--- a/frontend/src/scenes/notebooks/Nodes/notebookNodeLogic.ts
+++ b/frontend/src/scenes/notebooks/Nodes/notebookNodeLogic.ts
@@ -1,4 +1,5 @@
import {
+ MakeLogicType,
BuiltLogic,
actions,
afterMount,
@@ -24,7 +25,9 @@ import { SQLEditorMode } from 'scenes/data-warehouse/editor/sqlEditorModes'
import { isHogQLQuery, isNodeWithSource } from '~/queries/utils'
-import { notebookLogicType } from '../Notebook/notebookLogicType'
+import type { CommentType } from '../../../types'
+import type { NotebookKernelInfo } from '../Notebook/notebookKernelInfoLogic'
+import type { notebookLogicType } from '../Notebook/notebookLogic'
import {
CustomNotebookNodeAttributes,
NotebookNodeAction,
@@ -35,6 +38,7 @@ import {
NotebookNodeSettingsPlacement,
NotebookNodeType,
} from '../types'
+import type { NotebookEditor, NotebookType } from '../types'
import { getNotebookSqlEditorTabId } from './components/NotebookSQLEditor'
import { NotebookNodeMessages, NotebookNodeMessagesListeners } from './messaging/notebook-node-messages'
import {
@@ -50,7 +54,7 @@ import {
resolveDuckSqlReturnVariable,
resolveHogqlReturnVariable,
} from './notebookNodeContent'
-import type { notebookNodeLogicType } from './notebookNodeLogicType'
+import type { PythonNodeSummary, SqlV2NodeSummary } from './notebookNodeContent'
import {
NotebookDataframeResult,
PythonExecutionResult,
@@ -904,6 +908,226 @@ export type NotebookNodeLogicProps = {
settingsPlacement?: NotebookNodeSettingsPlacement
} & NotebookNodeAttributeProperties<any>
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookNodeLogicValues {
+ comments: CommentType[] | null // props.notebookLogic
+ dependencyGraph: NotebookDependencyGraph // props.notebookLogic
+ duckSqlNodeSummaries: DuckSqlNodeSummary[] // props.notebookLogic
+ editor: NotebookEditor | null // props.notebookLogic
+ hogqlSqlNodeSummaries: HogqlSqlNodeSummary[] // props.notebookLogic
+ isEditable: boolean // props.notebookLogic
+ kernelInfo: NotebookKernelInfo | null // props.notebookLogic
+ notebook: NotebookType | null // props.notebookLogic
+ pythonNodeSummaries: PythonNodeSummary[] // props.notebookLogic
+ sqlV2NodeSummaries: SqlV2NodeSummary[] // props.notebookLogic
+ Settings: NotebookNodeSettings | null
+ actions: NotebookNodeAction[]
+ children: NotebookNodeResource[]
+ customMenuItems: LemonMenuItems | null
+ dataframeError: string | null
+ dataframeLoading: boolean
+ dataframePage: number
+ dataframePageSize: number
+ dataframeResult: NotebookDataframeResult | null
+ dataframeRowCount: number
+ dataframeVariableName: string | null
+ displayedGlobals: {
+ hogqlQuery?: string
+ name: string
+ type: string
+ }[]
+ duckSqlNodeIndex: number
+ duckSqlReturnVariable: string
+ duckSqlReturnVariableUsage: NotebookDependencyUsage[]
+ duckSqlRunLoading: boolean
+ duckSqlRunQueued: boolean
+ duckSqlTablesUsed: string[]
+ duckSqlUpstreamTableSources: Record<string, NotebookDependencyUsage>
+ expanded: boolean
+ exportedGlobals: {
+ name: string
+ type: string
+ }[]
+ hogqlReturnVariableUsage: NotebookDependencyUsage[]
+ hogqlSqlNodeIndex: number
+ hogqlSqlReturnVariable: string
+ hogqlSqlRunLoading: boolean
+ hogqlSqlRunQueued: boolean
+ isEditingTitle: boolean
+ messageListeners: NotebookNodeMessagesListeners
+ nextNode: RichContentNode | null
+ nodeAttributes: NotebookNodeAttributes<any>
+ nodeId: string
+ nodeType: NotebookNodeType
+ notebookLogic: BuiltLogic<notebookLogicType>
+ previousNode: RichContentNode | null
+ pythonExecution: PythonExecutionResult | null
+ pythonNodeIndex: number
+ pythonRunLoading: boolean
+ pythonRunQueued: boolean
+ ref: HTMLElement | null
+ resizeable: boolean
+ sendMessage: <T extends keyof NotebookNodeMessages>(message: T, payload: NotebookNodeMessages[T]) => boolean
+ settingsPlacement: NotebookNodeSettingsPlacement
+ sourceComment: CommentType | null | undefined
+ sqlV2ReturnVariable: string
+ sqlV2ReturnVariableUsage: NotebookDependencyUsage[]
+ title: any
+ titlePlaceholder: string
+ usageByVariable: Record<string, NotebookDependencyUsage[]>
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookNodeLogicActions {
+ onUpdateEditor: () => {
+ value: true
+ } // props.notebookLogic
+ setTextSelection: (selection: number | import('@tiptap/core').Range) => {
+ selection: number | import('@tiptap/core').Range
+ } // props.notebookLogic
+ convertToBacklink: (href: string) => {
+ href: string
+ }
+ copyToClipboard: () => {
+ value: true
+ }
+ deleteNode: () => {
+ value: true
+ }
+ initializeNode: () => {
+ value: true
+ }
+ insertAfter: (content: JSONContent) => {
+ content: JSONContent
+ }
+ insertAfterLastNodeOfType: (
+ nodeType: string,
+ content: JSONContent
+ ) => {
+ content: JSONContent
+ nodeType: string
+ }
+ insertOrSelectNextLine: () => {
+ value: true
+ }
+ loadDataframePage: (payload: { pageSize?: number; variableName: string }) => {
+ pageSize?: number | undefined
+ variableName: string
+ }
+ navigateToNode: (nodeId: string) => {
+ nodeId: string
+ }
+ resetDataframeResults: () => {
+ value: true
+ }
+ runDuckSqlNode: () => {
+ value: true
+ }
+ runDuckSqlNodeWithMode: (payload: { mode: DuckSqlRunMode }) => {
+ mode: DuckSqlRunMode
+ }
+ runHogqlSqlNode: () => {
+ value: true
+ }
+ runHogqlSqlNodeWithMode: (payload: { mode: HogqlSqlRunMode }) => {
+ mode: HogqlSqlRunMode
+ }
+ runPythonNode: (payload: { code: string }) => {
+ code: string
+ }
+ runPythonNodeWithMode: (payload: { mode: PythonRunMode }) => {
+ mode: PythonRunMode
+ }
+ scrollIntoView: () => {
+ value: true
+ }
+ selectNode: (scroll?: boolean) => {
+ scroll: boolean | undefined
+ }
+ setActions: (actions: (NotebookNodeAction | undefined)[]) => {
+ actions: (NotebookNodeAction | undefined)[]
+ }
+ setDataframeError: (error: string | null) => {
+ error: string | null
+ }
+ setDataframeLoading: (loading: boolean) => {
+ loading: boolean
+ }
+ setDataframePage: (page: number) => {
+ page: number
+ }
+ setDataframePageSize: (pageSize: number) => {
+ pageSize: number
+ }
+ setDataframeResult: (result: NotebookDataframeResult | null) => {
+ result: NotebookDataframeResult | null
+ }
+ setDataframeVariableName: (
+ variableName: string | null,
+ initialResult?: NotebookDataframeResult | null
+ ) => {
+ initialResult: NotebookDataframeResult | null | undefined
+ variableName: string | null
+ }
+ setDuckSqlRunLoading: (loading: boolean) => {
+ loading: boolean
+ }
+ setDuckSqlRunQueued: (queued: boolean) => {
+ queued: boolean
+ }
+ setExpanded: (expanded: boolean) => {
+ expanded: boolean
+ }
+ setHogqlSqlRunLoading: (loading: boolean) => {
+ loading: boolean
+ }
+ setHogqlSqlRunQueued: (queued: boolean) => {
+ queued: boolean
+ }
+ setMenuItems: (menuItems: LemonMenuItems | null) => {
+ menuItems: LemonMenuItems | null
+ }
+ setMessageListeners: (listeners: NotebookNodeMessagesListeners) => {
+ listeners: NotebookNodeMessagesListeners
+ }
+ setNextNode: (node: RichContentNode | null) => {
+ node: RichContentNode | null
+ }
+ setPreviousNode: (node: RichContentNode | null) => {
+ node: RichContentNode | null
+ }
+ setPythonRunLoading: (loading: boolean) => {
+ loading: boolean
+ }
+ setPythonRunQueued: (queued: boolean) => {
+ queued: boolean
+ }
+ setRef: (ref: HTMLElement | null) => {
+ ref: HTMLElement | null
+ }
+ setResizeable: (resizeable: boolean) => {
+ resizeable: boolean
+ }
+ setTitlePlaceholder: (titlePlaceholder: string) => {
+ titlePlaceholder: string
+ }
+ toggleEditing: (visible?: boolean) => {
+ visible: boolean | undefined
+ }
+ toggleEditingTitle: (editing?: boolean) => {
+ editing: boolean | undefined
+ }
+ updateAttributes: (attributes: Partial<NotebookNodeAttributes<any>>) => {
+ attributes: Partial<any>
+ }
+}
+
+export type notebookNodeLogicType = MakeLogicType<
+ notebookNodeLogicValues,
+ notebookNodeLogicActions,
+ NotebookNodeLogicProps
+>
+
export const notebookNodeLogic = kea<notebookNodeLogicType>([
props({} as NotebookNodeLogicProps),
path((key) => ['scenes', 'notebooks', 'Notebook', 'Nodes', 'notebookNodeLogic', key]),
@@ -1116,13 +1340,16 @@ export const notebookNodeLogic = kea<notebookNodeLogicType>([
})),
selectors({
- notebookLogic: [(_, p) => [p.notebookLogic], (notebookLogic): BuiltLogic<notebookLogicType> => notebookLogic],
+ notebookLogic: [
+ (_, p) => [p.notebookLogic],
+ (notebookLogic: BuiltLogic<notebookLogicType>): BuiltLogic<notebookLogicType> => notebookLogic,
+ ],
nodeAttributes: [(_, p) => [p.attributes], (nodeAttributes): NotebookNodeAttributes<any> => nodeAttributes],
nodeId: [
(_, p) => [p.attributes],
(nodeAttributes: NotebookNodeAttributes<any>): string => nodeAttributes.nodeId,
],
- nodeType: [(_, p) => [p.nodeType], (nodeType) => nodeType],
+ nodeType: [(_, p) => [p.nodeType], (nodeType: NotebookNodeType) => nodeType],
Settings: [() => [(_, props) => props], (props): NotebookNodeSettings | null => props.Settings ?? null],
settingsPlacement: [
() => [(_, props) => props],
@@ -1131,7 +1358,7 @@ export const notebookNodeLogic = kea<notebookNodeLogicType>([
title: [
(s) => [s.titlePlaceholder, s.nodeAttributes],
- (titlePlaceholder, nodeAttributes) => nodeAttributes.title || titlePlaceholder,
+ (titlePlaceholder: string, nodeAttributes) => nodeAttributes.title || titlePlaceholder,
],
// TODO: Fix the typing of nodeAttributes
children: [(s) => [s.nodeAttributes], (nodeAttributes): NotebookNodeResource[] => nodeAttributes.children],
@@ -1146,7 +1373,13 @@ export const notebookNodeLogic = kea<notebookNodeLogicType>([
],
displayedGlobals: [
(s) => [s.exportedGlobals, s.pythonExecution],
- (exportedGlobals, pythonExecution): { name: string; type: string; hogqlQuery?: string }[] => {
+ (
+ exportedGlobals: {
+ name: string
+ type: string
+ }[],
+ pythonExecution: PythonExecutionResult | null
+ ): { name: string; type: string; hogqlQuery?: string }[] => {
if (!pythonExecution?.variables?.length) {
return exportedGlobals
}
@@ -1167,60 +1400,85 @@ export const notebookNodeLogic = kea<notebookNodeLogicType>([
pythonNodeIndex: [
(s) => [s.pythonNodeSummaries, s.nodeId],
- (pythonNodeSummaries, nodeId) => pythonNodeSummaries.findIndex((node) => node.nodeId === nodeId),
+ (pythonNodeSummaries: PythonNodeSummary[], nodeId: string) =>
+ pythonNodeSummaries.findIndex((node) => node.nodeId === nodeId),
],
duckSqlNodeIndex: [
(s) => [s.duckSqlNodeSummaries, s.nodeId],
- (duckSqlNodeSummaries, nodeId) => duckSqlNodeSummaries.findIndex((node) => node.nodeId === nodeId),
+ (duckSqlNodeSummaries: DuckSqlNodeSummary[], nodeId: string) =>
+ duckSqlNodeSummaries.findIndex((node) => node.nodeId === nodeId),
],
duckSqlReturnVariable: [
(s) => [s.duckSqlNodeSummaries, s.nodeId, s.nodeAttributes],
- (duckSqlNodeSummaries, nodeId, nodeAttributes): string =>
+ (duckSqlNodeSummaries: DuckSqlNodeSummary[], nodeId: string, nodeAttributes): string =>
getUniqueDuckSqlReturnVariable(duckSqlNodeSummaries, nodeId, nodeAttributes.returnVariable ?? ''),
],
hogqlSqlNodeIndex: [
(s) => [s.hogqlSqlNodeSummaries, s.nodeId],
- (hogqlSqlNodeSummaries, nodeId) => hogqlSqlNodeSummaries.findIndex((node) => node.nodeId === nodeId),
+ (hogqlSqlNodeSummaries: HogqlSqlNodeSummary[], nodeId: string) =>
+ hogqlSqlNodeSummaries.findIndex((node) => node.nodeId === nodeId),
],
hogqlSqlReturnVariable: [
(s) => [s.hogqlSqlNodeSummaries, s.nodeId, s.nodeAttributes],
- (hogqlSqlNodeSummaries, nodeId, nodeAttributes): string =>
+ (hogqlSqlNodeSummaries: HogqlSqlNodeSummary[], nodeId: string, nodeAttributes): string =>
getUniqueHogqlReturnVariable(hogqlSqlNodeSummaries, nodeId, nodeAttributes.returnVariable ?? ''),
],
- dataframeRowCount: [(s) => [s.dataframeResult], (dataframeResult): number => dataframeResult?.rowCount ?? 0],
+ dataframeRowCount: [
+ (s) => [s.dataframeResult],
+ (dataframeResult: NotebookDataframeResult | null): number => dataframeResult?.rowCount ?? 0,
+ ],
duckSqlTablesUsed: [
(s) => [s.dependencyGraph, s.nodeId],
- (dependencyGraph, nodeId): string[] => dependencyGraph.nodesById[nodeId]?.uses ?? [],
+ (dependencyGraph: NotebookDependencyGraph, nodeId: string): string[] =>
+ dependencyGraph.nodesById[nodeId]?.uses ?? [],
],
duckSqlUpstreamTableSources: [
(s) => [s.dependencyGraph, s.nodeId],
- (dependencyGraph, nodeId): Record<string, NotebookDependencyUsage> =>
+ (dependencyGraph: NotebookDependencyGraph, nodeId: string): Record<string, NotebookDependencyUsage> =>
dependencyGraph.upstreamSourcesByNode[nodeId] ?? {},
],
duckSqlReturnVariableUsage: [
(s) => [s.dependencyGraph, s.nodeId, s.duckSqlReturnVariable],
- (dependencyGraph, nodeId, duckSqlReturnVariable): NotebookDependencyUsage[] =>
+ (
+ dependencyGraph: NotebookDependencyGraph,
+ nodeId: string,
+ duckSqlReturnVariable: string
+ ): NotebookDependencyUsage[] =>
dependencyGraph.downstreamUsageByNode[nodeId]?.[duckSqlReturnVariable] ?? [],
],
hogqlReturnVariableUsage: [
(s) => [s.dependencyGraph, s.nodeId, s.hogqlSqlReturnVariable],
- (dependencyGraph, nodeId, hogqlSqlReturnVariable): NotebookDependencyUsage[] =>
+ (
+ dependencyGraph: NotebookDependencyGraph,
+ nodeId: string,
+ hogqlSqlReturnVariable: string
+ ): NotebookDependencyUsage[] =>
dependencyGraph.downstreamUsageByNode[nodeId]?.[hogqlSqlReturnVariable] ?? [],
],
sqlV2ReturnVariable: [
(s) => [s.sqlV2NodeSummaries, s.nodeId, s.nodeAttributes],
- (sqlV2NodeSummaries, nodeId, nodeAttributes): string =>
+ (sqlV2NodeSummaries: SqlV2NodeSummary[], nodeId: string, nodeAttributes): string =>
getUniqueSqlV2ReturnVariable(sqlV2NodeSummaries, nodeId, nodeAttributes.returnVariable ?? ''),
],
sqlV2ReturnVariableUsage: [
(s) => [s.dependencyGraph, s.nodeId, s.sqlV2ReturnVariable],
- (dependencyGraph, nodeId, sqlV2ReturnVariable): NotebookDependencyUsage[] =>
- dependencyGraph.downstreamUsageByNode[nodeId]?.[sqlV2ReturnVariable] ?? [],
+ (
+ dependencyGraph: NotebookDependencyGraph,
+ nodeId: string,
+ sqlV2ReturnVariable: string
+ ): NotebookDependencyUsage[] => dependencyGraph.downstreamUsageByNode[nodeId]?.[sqlV2ReturnVariable] ?? [],
],
usageByVariable: [
(s) => [s.dependencyGraph, s.exportedGlobals, s.nodeId],
- (dependencyGraph, exportedGlobals, nodeId): Record<string, NotebookDependencyUsage[]> => {
+ (
+ dependencyGraph: NotebookDependencyGraph,
+ exportedGlobals: {
+ name: string
+ type: string
+ }[],
+ nodeId: string
+ ): Record<string, NotebookDependencyUsage[]> => {
const usageMap: Record<string, NotebookDependencyUsage[]> = {}
exportedGlobals.forEach(({ name }) => {
@@ -1234,7 +1492,7 @@ export const notebookNodeLogic = kea<notebookNodeLogicType>([
sendMessage: [
(s) => [s.messageListeners],
- (messageListeners) => {
+ (messageListeners: NotebookNodeMessagesListeners) => {
return <T extends keyof NotebookNodeMessages>(
message: T,
payload: NotebookNodeMessages[T]
@@ -1251,7 +1509,7 @@ export const notebookNodeLogic = kea<notebookNodeLogicType>([
sourceComment: [
(s) => [s.comments, s.nodeId],
- (comments, nodeId) =>
+ (comments: CommentType[] | null, nodeId: string) =>
comments &&
comments.find(
(comment) => comment.item_context?.type === 'node' && comment.item_context?.id === nodeId
diff --git a/frontend/src/scenes/notebooks/Nodes/notebookNodeSQLV2Logic.ts b/frontend/src/scenes/notebooks/Nodes/notebookNodeSQLV2Logic.ts
index 103b6ef4f2c5..e2740d294648 100644
--- a/frontend/src/scenes/notebooks/Nodes/notebookNodeSQLV2Logic.ts
+++ b/frontend/src/scenes/notebooks/Nodes/notebookNodeSQLV2Logic.ts
@@ -1,4 +1,17 @@
-import { actions, afterMount, beforeUnmount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
+import {
+ MakeLogicType,
+ actions,
+ afterMount,
+ beforeUnmount,
+ connect,
+ kea,
+ key,
+ listeners,
+ path,
+ props,
+ reducers,
+ selectors,
+} from 'kea'
import api from 'lib/api'
import { JSONContent } from 'lib/components/RichContentEditor/types'
@@ -7,7 +20,6 @@ import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { NotebookOperation, notebookOperationsLogic } from '../Notebook/notebookOperationsLogic'
import { collectPythonKernelNodes, collectSqlV2Nodes } from './notebookNodeContent'
import { NotebookNodeSQLV2Result } from './NotebookNodeSQLV2'
-import type { notebookNodeSQLV2LogicType } from './notebookNodeSQLV2LogicType'
export type SqlV2RunRef = {
node_id: string
@@ -72,6 +84,77 @@ export interface NotebookNodeSQLV2LogicProps {
}) => void
}
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookNodeSQLV2LogicValues {
+ activeOperation: NotebookOperation | null // notebookOperationsLogic
+ isBusy: boolean // notebookOperationsLogic
+ isRunning: boolean
+ operationBlockReason: string | null
+ page: number
+ pageLoading: boolean
+ pageResult: NotebookNodeSQLV2Page | null
+ pageSize: number
+ runError: string | null
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookNodeSQLV2LogicActions {
+ finishNodeOperations: (nodeId: string) => {
+ nodeId: string
+ } // notebookOperationsLogic
+ finishOperation: (id: string) => {
+ id: string
+ } // notebookOperationsLogic
+ startOperation: (operation: NotebookOperation) => {
+ operation: NotebookOperation
+ } // notebookOperationsLogic
+ pollResult: (runId: string) => {
+ runId: string
+ }
+ resetPaging: () => {
+ value: true
+ }
+ runQuery: (
+ code: string,
+ refs?: Record<string, SqlV2RunRef>,
+ opts?: RunQueryOptions
+ ) => {
+ code: string
+ opts: RunQueryOptions
+ refs: Record<string, SqlV2RunRef>
+ }
+ setIsRunning: (isRunning: boolean) => {
+ isRunning: boolean
+ }
+ setPage: (page: number) => {
+ page: number
+ }
+ setPageLoading: (pageLoading: boolean) => {
+ pageLoading: boolean
+ }
+ setPageResult: (pageResult: NotebookNodeSQLV2Page | null) => {
+ pageResult: NotebookNodeSQLV2Page | null
+ }
+ setPageSize: (pageSize: number) => {
+ pageSize: number
+ }
+ setRunError: (runError: string | null) => {
+ runError: string | null
+ }
+ startPolling: (runId: string) => {
+ runId: string
+ }
+ stopPolling: () => {
+ value: true
+ }
+}
+
+export type notebookNodeSQLV2LogicType = MakeLogicType<
+ notebookNodeSQLV2LogicValues,
+ notebookNodeSQLV2LogicActions,
+ NotebookNodeSQLV2LogicProps
+>
+
export const notebookNodeSQLV2Logic = kea<notebookNodeSQLV2LogicType>([
path((key) => ['scenes', 'notebooks', 'Nodes', 'notebookNodeSQLV2Logic', key]),
props({} as NotebookNodeSQLV2LogicProps),
@@ -363,7 +446,7 @@ export const notebookNodeSQLV2Logic = kea<notebookNodeSQLV2LogicType>([
// Set while another node's operation is in flight — wire into disabledReason props.
operationBlockReason: [
(s) => [s.activeOperation],
- (activeOperation): string | null =>
+ (activeOperation: NotebookOperation | null): string | null =>
activeOperation && activeOperation.nodeId !== props.nodeId
? 'Another operation is running in this notebook'
: null,
diff --git a/frontend/src/scenes/notebooks/Notebook/NotebookColumnLeft.tsx b/frontend/src/scenes/notebooks/Notebook/NotebookColumnLeft.tsx
index 49df17443e42..6b3422aa2c39 100644
--- a/frontend/src/scenes/notebooks/Notebook/NotebookColumnLeft.tsx
+++ b/frontend/src/scenes/notebooks/Notebook/NotebookColumnLeft.tsx
@@ -10,7 +10,7 @@ import { LemonWidget } from 'lib/lemon-ui/LemonWidget'
import { ErrorBoundary } from '~/layout/ErrorBoundary'
import { notebookNodeLogic } from '../Nodes/notebookNodeLogic'
-import { notebookNodeLogicType } from '../Nodes/notebookNodeLogicType'
+import type { notebookNodeLogicType } from '../Nodes/notebookNodeLogic'
import { isMarkdownNotebookContent } from './markdownNotebookV2'
import { NotebookHistory } from './NotebookHistory'
import { NotebookKernelInfo } from './NotebookKernelInfo'
@@ -83,7 +83,7 @@ export const NotebookNodeSettingsOffset = ({ logic }: { logic: BuiltLogic<notebo
updateHeight()
return () => clearInterval(interval)
- }, [ref, offsetRef.current, height, isPageVisible])
+ }, [ref, height, isPageVisible])
return (
<div
diff --git a/frontend/src/scenes/notebooks/Notebook/NotebookColumnRight.tsx b/frontend/src/scenes/notebooks/Notebook/NotebookColumnRight.tsx
index 0b3a08f3f120..d465baf4b41d 100644
--- a/frontend/src/scenes/notebooks/Notebook/NotebookColumnRight.tsx
+++ b/frontend/src/scenes/notebooks/Notebook/NotebookColumnRight.tsx
@@ -4,7 +4,7 @@ import { BuiltLogic, useValues } from 'kea'
import { uuid } from 'lib/utils/dom'
import { NotebookNodeChildRenderer } from '../Nodes/NodeWrapper'
-import { notebookNodeLogicType } from '../Nodes/notebookNodeLogicType'
+import type { notebookNodeLogicType } from '../Nodes/notebookNodeLogic'
import { isMarkdownNotebookContent } from './markdownNotebookV2'
import { NotebookKernelInfo } from './NotebookKernelInfo'
import { notebookLogic } from './notebookLogic'
diff --git a/frontend/src/scenes/notebooks/Notebook/notebookCollabLogic.ts b/frontend/src/scenes/notebooks/Notebook/notebookCollabLogic.ts
index 2dd78150bbf5..9d16010500b7 100644
--- a/frontend/src/scenes/notebooks/Notebook/notebookCollabLogic.ts
+++ b/frontend/src/scenes/notebooks/Notebook/notebookCollabLogic.ts
@@ -1,7 +1,7 @@
import { EventSourceMessage } from '@microsoft/fetch-event-source'
import { getVersion, receiveTransaction, sendableSteps } from '@tiptap/pm/collab'
import { Step } from '@tiptap/pm/transform'
-import { actions, beforeUnmount, kea, key, listeners, path, props, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, beforeUnmount, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import posthog from 'posthog-js'
import api from 'lib/api'
@@ -11,7 +11,7 @@ import { getCurrentTeamId } from 'lib/utils/getAppContext'
import { notebooksCollabPresenceCreate } from 'products/notebooks/frontend/generated/api'
-import type { notebookCollabLogicType } from './notebookCollabLogicType'
+import type { Editor } from '../../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@tiptap/core/dist/index'
import {
getNotebookRemoteParticipants,
type NotebookRemoteParticipant,
@@ -89,6 +89,73 @@ export function applyRemoteStep(editor: TTEditor, remote: RemoteStep): void {
editor.view.dispatch(tr)
}
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookCollabLogicValues {
+ clientID: string
+ isConnecting: boolean
+ remoteParticipants: NotebookRemoteParticipant[]
+ remotePresence: Record<string, ClientPresence>
+ streamConnected: boolean
+ streamError: string | null
+ ttEditor: TTEditor | null
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookCollabLogicActions {
+ ackLocalSteps: (
+ steps: Record<string, any>[],
+ clientID: string
+ ) => {
+ clientID: string
+ steps: Record<string, any>[]
+ }
+ applyRemoteSteps: (steps: RemoteStep[]) => {
+ steps: RemoteStep[]
+ }
+ bindEditor: (editor: TTEditor) => {
+ editor: Editor
+ }
+ connectStream: () => {
+ value: true
+ }
+ disconnectStream: () => {
+ value: true
+ }
+ handleRemotePresence: (presence: ClientPresence) => {
+ presence: ClientPresence
+ }
+ pruneRemotePresence: (now?: number) => {
+ now: number
+ }
+ publishPresence: () => {
+ value: true
+ }
+ rebaseFailed: (params: { localContent: JSONContent; localText: string }) => {
+ localContent: JSONContent
+ localText: string
+ }
+ streamClosed: (error?: string | null) => {
+ error: string | null
+ }
+ streamOpened: () => {
+ value: true
+ }
+ unbindEditor: () => {
+ value: true
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookCollabLogicProps {
+ shortId: string
+}
+
+export type notebookCollabLogicType = MakeLogicType<
+ notebookCollabLogicValues,
+ notebookCollabLogicActions,
+ notebookCollabLogicProps
+>
+
export const notebookCollabLogic = kea<notebookCollabLogicType>([
props({} as { shortId: string }),
path((key) => ['scenes', 'notebooks', 'Notebook', 'notebookCollabLogic', key]),
@@ -161,7 +228,8 @@ export const notebookCollabLogic = kea<notebookCollabLogicType>([
selectors({
remoteParticipants: [
(s) => [s.remotePresence],
- (remotePresence): NotebookRemoteParticipant[] => getNotebookRemoteParticipants(remotePresence),
+ (remotePresence: Record<string, ClientPresence>): NotebookRemoteParticipant[] =>
+ getNotebookRemoteParticipants(remotePresence),
],
}),
diff --git a/frontend/src/scenes/notebooks/Notebook/notebookKernelInfoLogic.ts b/frontend/src/scenes/notebooks/Notebook/notebookKernelInfoLogic.ts
index 5f22858d9837..34ed7dbe0221 100644
--- a/frontend/src/scenes/notebooks/Notebook/notebookKernelInfoLogic.ts
+++ b/frontend/src/scenes/notebooks/Notebook/notebookKernelInfoLogic.ts
@@ -1,10 +1,21 @@
-import { actions, afterMount, beforeUnmount, kea, key, listeners, path, props, reducers, selectors } from 'kea'
+import {
+ MakeLogicType,
+ actions,
+ afterMount,
+ beforeUnmount,
+ kea,
+ key,
+ listeners,
+ path,
+ props,
+ reducers,
+ selectors,
+} from 'kea'
import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { PythonKernelExecuteResponse } from '../Nodes/pythonExecution'
-import type { notebookKernelInfoLogicType } from './notebookKernelInfoLogicType'
export type NotebookKernelInfo = {
backend: 'docker' | 'modal' | null
@@ -59,6 +70,133 @@ const findClosestOptionIndex = (options: number[], value?: number | null): numbe
}, 0)
}
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookKernelInfoLogicValues {
+ actionInFlight: KernelActionInFlight
+ code: string
+ cpuIndex: number
+ currentCpu: number
+ currentIdleTimeout: number
+ currentMemory: number
+ executionResult: PythonKernelExecuteResponse | null
+ executionResultLoading: boolean
+ hasActionInFlight: boolean
+ hasConfigChanges: boolean
+ idleTimeoutSeconds: number
+ isBusyStatus: boolean
+ isEditingConfig: boolean
+ isModalKernel: boolean
+ isRunning: boolean
+ isStarting: boolean
+ kernelInfo: NotebookKernelInfo | null
+ kernelInfoLoading: boolean
+ memoryIndex: number
+ selectedCpu: number
+ selectedMemory: number
+ statusInfo: {
+ label: string
+ tone: 'danger' | 'default' | 'success' | 'warning'
+ } | null
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookKernelInfoLogicActions {
+ clearExecution: () => {
+ value: true
+ }
+ executeKernel: (code: any) => {
+ code: any
+ }
+ executeKernelFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ executeKernelSuccess: (
+ executionResult: PythonKernelExecuteResponse | null,
+ payload?: {
+ code: any
+ }
+ ) => {
+ executionResult: PythonKernelExecuteResponse | null
+ payload?: {
+ code: any
+ }
+ }
+ loadKernelInfo: () => any
+ loadKernelInfoFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadKernelInfoSuccess: (
+ kernelInfo: NotebookKernelInfo | null,
+ payload?: any
+ ) => {
+ kernelInfo: NotebookKernelInfo | null
+ payload?: any
+ }
+ resetConfigToKernel: () => {
+ value: true
+ }
+ restartKernel: () => {
+ value: true
+ }
+ saveKernelConfig: (
+ config: {
+ cpu_cores?: number
+ idle_timeout_seconds?: number
+ memory_gb?: number
+ },
+ nextAction: 'restart' | 'start'
+ ) => {
+ config: {
+ cpu_cores?: number | undefined
+ idle_timeout_seconds?: number | undefined
+ memory_gb?: number | undefined
+ }
+ nextAction: 'restart' | 'start'
+ }
+ saveKernelConfigFailure: () => {
+ value: true
+ }
+ setCode: (code: string) => {
+ code: string
+ }
+ setConfigFromKernelInfo: (config: { cpuIndex: number; idleTimeoutSeconds: number; memoryIndex: number }) => {
+ config: {
+ cpuIndex: number
+ idleTimeoutSeconds: number
+ memoryIndex: number
+ }
+ }
+ setCpuIndex: (cpuIndex: number) => {
+ cpuIndex: number
+ }
+ setIdleTimeoutSeconds: (idleTimeoutSeconds: number) => {
+ idleTimeoutSeconds: number
+ }
+ setMemoryIndex: (memoryIndex: number) => {
+ memoryIndex: number
+ }
+ startKernel: () => {
+ value: true
+ }
+ stopKernel: () => {
+ value: true
+ }
+}
+
+export type notebookKernelInfoLogicType = MakeLogicType<
+ notebookKernelInfoLogicValues,
+ notebookKernelInfoLogicActions,
+ NotebookKernelInfoLogicProps
+>
+
export const notebookKernelInfoLogic = kea<notebookKernelInfoLogicType>([
props({} as NotebookKernelInfoLogicProps),
path((key) => ['scenes', 'notebooks', 'Notebook', 'notebookKernelInfoLogic', key]),
@@ -193,13 +331,13 @@ export const notebookKernelInfoLogic = kea<notebookKernelInfoLogicType>([
selectors({
isRunning: [
(s) => [s.kernelInfo],
- (kernelInfo) =>
+ (kernelInfo: NotebookKernelInfo | null) =>
kernelInfo?.status === 'running' ||
(kernelInfo?.status === 'starting' && kernelInfo?.last_error == null),
],
statusInfo: [
(s) => [s.kernelInfo, s.actionInFlight],
- (kernelInfo, actionInFlight) => {
+ (kernelInfo: NotebookKernelInfo | null, actionInFlight: KernelActionInFlight) => {
if (!kernelInfo) {
return null
}
@@ -231,28 +369,35 @@ export const notebookKernelInfoLogic = kea<notebookKernelInfoLogicType>([
],
isStarting: [
(s) => [s.kernelInfo, s.actionInFlight],
- (kernelInfo, actionInFlight) =>
+ (kernelInfo: NotebookKernelInfo | null, actionInFlight: KernelActionInFlight) =>
(kernelInfo?.status === 'starting' && kernelInfo?.last_error == null) || actionInFlight.start,
],
isBusyStatus: [
(s) => [s.isStarting, s.actionInFlight],
- (isStarting, actionInFlight) => isStarting || actionInFlight.stop || actionInFlight.restart,
+ (isStarting: boolean, actionInFlight: KernelActionInFlight) =>
+ isStarting || actionInFlight.stop || actionInFlight.restart,
+ ],
+ hasActionInFlight: [
+ (s) => [s.actionInFlight],
+ (actionInFlight: KernelActionInFlight) => Object.values(actionInFlight).some(Boolean),
+ ],
+ isModalKernel: [
+ (s) => [s.kernelInfo],
+ (kernelInfo: NotebookKernelInfo | null) => kernelInfo?.backend === 'modal',
],
- hasActionInFlight: [(s) => [s.actionInFlight], (actionInFlight) => Object.values(actionInFlight).some(Boolean)],
- isModalKernel: [(s) => [s.kernelInfo], (kernelInfo) => kernelInfo?.backend === 'modal'],
- selectedCpu: [(s) => [s.cpuIndex], (cpuIndex) => cpuCoreOptions[cpuIndex]],
- selectedMemory: [(s) => [s.memoryIndex], (memoryIndex) => memoryGbOptions[memoryIndex]],
+ selectedCpu: [(s) => [s.cpuIndex], (cpuIndex: number) => cpuCoreOptions[cpuIndex]],
+ selectedMemory: [(s) => [s.memoryIndex], (memoryIndex: number) => memoryGbOptions[memoryIndex]],
currentCpu: [
(s) => [s.kernelInfo, s.selectedCpu],
- (kernelInfo, selectedCpu) => kernelInfo?.cpu_cores ?? selectedCpu,
+ (kernelInfo: NotebookKernelInfo | null, selectedCpu: number) => kernelInfo?.cpu_cores ?? selectedCpu,
],
currentMemory: [
(s) => [s.kernelInfo, s.selectedMemory],
- (kernelInfo, selectedMemory) => kernelInfo?.memory_gb ?? selectedMemory,
+ (kernelInfo: NotebookKernelInfo | null, selectedMemory: number) => kernelInfo?.memory_gb ?? selectedMemory,
],
currentIdleTimeout: [
(s) => [s.kernelInfo],
- (kernelInfo) => kernelInfo?.idle_timeout_seconds ?? idleTimeoutOptions[1].value,
+ (kernelInfo: NotebookKernelInfo | null) => kernelInfo?.idle_timeout_seconds ?? idleTimeoutOptions[1].value,
],
hasConfigChanges: [
(s) => [
@@ -265,13 +410,13 @@ export const notebookKernelInfoLogic = kea<notebookKernelInfoLogicType>([
s.currentIdleTimeout,
],
(
- kernelInfo,
- selectedCpu,
- selectedMemory,
- idleTimeoutSeconds,
- currentCpu,
- currentMemory,
- currentIdleTimeout
+ kernelInfo: NotebookKernelInfo | null,
+ selectedCpu: number,
+ selectedMemory: number,
+ idleTimeoutSeconds: number,
+ currentCpu: number,
+ currentMemory: number,
+ currentIdleTimeout: number
) =>
Boolean(
kernelInfo &&
diff --git a/frontend/src/scenes/notebooks/Notebook/notebookLogic.ts b/frontend/src/scenes/notebooks/Notebook/notebookLogic.ts
index 100954a5a913..eb19cd7eae0a 100644
--- a/frontend/src/scenes/notebooks/Notebook/notebookLogic.ts
+++ b/frontend/src/scenes/notebooks/Notebook/notebookLogic.ts
@@ -1,6 +1,7 @@
import { EventSourceMessage } from '@microsoft/fetch-event-source'
import { sendableSteps } from '@tiptap/pm/collab'
import {
+ MakeLogicType,
BuiltLogic,
actions,
afterMount,
@@ -72,6 +73,11 @@ import {
import { notebooksCollabPresenceCreate } from 'products/notebooks/frontend/generated/api'
import type { NotebookCollabCursorApi } from 'products/notebooks/frontend/generated/api.schemas'
+import type { Range } from '../../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@tiptap/core/dist/index'
+import type { TTEditor } from '../../../lib/components/RichContentEditor/types'
+import type { FeatureFlagsSet } from '../../../lib/logic/featureFlagLogic'
+import type { UserType } from '../../../types'
+import type { CommentContext } from '../../comments/commentsLogic'
import {
buildNotebookDependencyGraph,
collectDuckSqlNodes,
@@ -80,7 +86,14 @@ import {
collectPythonNodes,
collectSqlV2Nodes,
} from '../Nodes/notebookNodeContent'
-import { notebookNodeLogicType } from '../Nodes/notebookNodeLogicType'
+import type {
+ DuckSqlNodeSummary,
+ HogqlSqlNodeSummary,
+ NotebookDependencyGraph,
+ PythonNodeSummary,
+ SqlV2NodeSummary,
+} from '../Nodes/notebookNodeContent'
+import type { notebookNodeLogicType } from '../Nodes/notebookNodeLogic'
// NOTE: Annoyingly, if we import this then kea logic type-gen generates
// two imports and fails so, we reimport it from the types file
import {
@@ -91,6 +104,7 @@ import {
NotebookType,
TableOfContentData,
} from '../types'
+import type { NotebookListItemType } from '../types'
import { updateContentHeading } from '../utils'
import { NotebookArtifactApplyMode } from './markdownNotebookRuntime'
import {
@@ -110,7 +124,7 @@ import { buildNotebookOpenedEvent } from './notebookAnalytics'
import { shouldWarnBeforeLeavingNotebook } from './notebookBeforeUnload'
import { notebookCollabLogic } from './notebookCollabLogic'
import { notebookKernelInfoLogic } from './notebookKernelInfoLogic'
-import type { notebookLogicType } from './notebookLogicType'
+import type { NotebookKernelInfo } from './notebookKernelInfoLogic'
import {
NOTEBOOK_AI_PRESENCE_CLIENT_ID,
NOTEBOOK_AI_PRESENCE_NAME,
@@ -297,6 +311,424 @@ function buildCommentContexts(editor: NotebookEditor, comments: CommentType[]):
return contexts
}
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookLogicValues {
+ commentContexts: Record<string, string> // commentsLogic
+ comments: CommentType[] | null // commentsLogic
+ itemContext: CommentContext | null // commentsLogic
+ selectedCommentId: string | null // commentsLogic
+ featureFlags: FeatureFlagsSet // featureFlagLogic
+ remoteParticipants: NotebookRemoteParticipant[] // notebookCollabLogic
+ ttEditor: TTEditor | null // notebookCollabLogic
+ kernelInfo: NotebookKernelInfo | null // notebookKernelInfoLogic
+ showKernelInfo: boolean // notebookSettingsLogic
+ showTableOfContents: boolean // notebookSettingsLogic
+ notebookTemplates: NotebookType[] // notebooksModel
+ scratchpadNotebook: NotebookListItemType // notebooksModel
+ user: UserType | null // userLogic
+ accessDeniedToNotebook: boolean
+ activeCommentMarkId: string | null
+ autosavePaused: boolean
+ cachedInlineQueryResultsByNodeId: Record<string, AnyResponseType>
+ cachedInsightsByShortId: Record<string, InsightModel>
+ canvasFiltersOverride: any
+ collabConflict: {
+ localContent: JSONContent
+ localText: string
+ serverContent: JSONContent
+ } | null
+ collabEnabled: boolean
+ conflictWarningVisible: boolean
+ containerSize: 'medium' | 'small'
+ content: JSONContent
+ dependencyGraph: NotebookDependencyGraph
+ duckSqlNodeIndices: Map<string, number>
+ duckSqlNodeSummaries: DuckSqlNodeSummary[]
+ editingNodeIds: Record<string, true>
+ editingNodeLogics: any[]
+ editingNodeLogicsForLeft: BuiltLogic<notebookNodeLogicType>[]
+ editor: NotebookEditor | null
+ experimentIdsInNotebook: number[]
+ findNodeLogic: (type: NotebookNodeType, attributes: Record<string, any>) => notebookNodeLogicType | null
+ findNodeLogicById: (id: string) => any
+ getSharedCachedInlineQueryResults: (nodeId: string | null | undefined) => AnyResponseType | null
+ getSharedCachedInsight: (shortId: string | null | undefined) => InsightModel | null
+ hogqlSqlNodeIndices: Map<string, number>
+ hogqlSqlNodeSummaries: HogqlSqlNodeSummary[]
+ insightShortIdsInNotebook: any[] | undefined
+ isEditable: boolean
+ isLocalOnly: boolean
+ isShareModalOpen: boolean
+ isShared: boolean
+ isShowingLeftColumn: boolean
+ isTemplate: boolean
+ localContent: JSONContent | null
+ markdownAIPresenceActive: boolean
+ markdownEditorBuffer: string | null
+ markdownEditorDraft: string | null
+ markdownEditorInteractionActive: boolean
+ markdownEditorMarkdown: string
+ markdownEditorNodeId: string
+ markdownEditorValue: string
+ markdownMergeConflictDetails: NotebookCollaborationConflict[] | null
+ markdownRealtimeEnabled: boolean
+ markdownRemoteCarets: RemoteNotebookCaret[]
+ markdownRemoteParticipants: NotebookRemoteParticipant[]
+ markdownRemotePresence: Record<string, NotebookRemotePresenceState>
+ mode: NotebookLogicMode
+ newNotebook: NotebookType | null
+ newNotebookLoading: boolean
+ nodeLogics: Record<string, BuiltLogic<notebookNodeLogicType>>
+ nodeLogicsWithChildren: any[]
+ notebook: NotebookType | null
+ notebookLoading: boolean
+ notebookMissing: boolean
+ notebookPresenceParticipants: NotebookPresenceParticipant[]
+ personUUIDFromCanvasOverride: string | null
+ previewContent: JSONContent | null
+ pythonNodeIndices: Map<string, number>
+ pythonNodeSummaries: PythonNodeSummary[]
+ ready: boolean
+ shortId: string
+ shouldBeEditable: boolean
+ showHistory: boolean
+ sqlNodeIndices: Map<string, number>
+ sqlV2NodeSummaries: SqlV2NodeSummary[]
+ syncStatus: NotebookSyncStatus
+ tableOfContents: TableOfContentData
+ title: string
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookLogicActions {
+ maybeLoadComments: () => {
+ value: true
+ } // commentsLogic
+ setCommentContexts: (contexts: Record<string, string>) => {
+ contexts: Record<string, string>
+ } // commentsLogic
+ setItemContext: (
+ context: Record<string, any> | null,
+ callback?: (event: { sent: boolean }) => void
+ ) => {
+ callback: ((event: { sent: boolean }) => void) | undefined
+ context: Record<string, any> | null
+ } // commentsLogic
+ setSelectedComment: (commentId: string | null) => {
+ commentId: string | null
+ } // commentsLogic
+ ackLocalSteps: (
+ steps: Record<string, any>[],
+ clientID: string
+ ) => {
+ clientID: string
+ steps: Record<string, any>[]
+ } // notebookCollabLogic
+ applyRemoteSteps: (steps: import('./notebookCollabLogic').RemoteStep[]) => {
+ steps: import('./notebookCollabLogic').RemoteStep[]
+ } // notebookCollabLogic
+ rebaseFailed: (params: { localContent: JSONContent; localText: string }) => {
+ localContent: JSONContent
+ localText: string
+ } // notebookCollabLogic
+ receiveNotebookUpdate: (notebook: NotebookListItemType) => {
+ notebook: NotebookListItemType
+ } // notebooksModel
+ openSidePanel: (
+ tab: SidePanelTab,
+ options?: string
+ ) => {
+ options: string | undefined
+ tab: SidePanelTab
+ } // sidePanelStateLogic
+ addExperimentToNotebook: (
+ experimentId: number,
+ insertionPosition?: number | null
+ ) => {
+ experimentId: number
+ insertionPosition: number | null
+ }
+ addSavedInsightToNotebook: (
+ insightShortId: InsightShortId,
+ insertionPosition?: number | null
+ ) => {
+ insertionPosition: number | null
+ insightShortId: InsightShortId
+ }
+ applyNotebookArtifactMarkdown: (
+ content: NotebookArtifactContent,
+ conversationId?: string,
+ mode?: NotebookArtifactApplyMode
+ ) => {
+ content: NotebookArtifactContent
+ conversationId: string | undefined
+ mode: NotebookArtifactApplyMode
+ }
+ applyRemoteNotebookContent: (
+ content: JSONContent,
+ version: number
+ ) => {
+ content: JSONContent
+ version: number
+ }
+ clearLocalContent: () => {
+ value: true
+ }
+ clearPreviewContent: () => {
+ value: true
+ }
+ closeShareModal: () => {
+ value: true
+ }
+ connectMarkdownUpdateStream: () => {
+ value: true
+ }
+ copyMarkdown: () => {
+ value: true
+ }
+ copyUnsavedToNewNotebook: () => {
+ value: true
+ }
+ discardLocalChanges: () => {
+ value: true
+ }
+ disconnectMarkdownUpdateStream: () => {
+ value: true
+ }
+ dismissCollabConflict: () => {
+ value: true
+ }
+ dismissMarkdownMergeConflictDetails: () => {
+ value: true
+ }
+ downloadMarkdown: () => {
+ value: true
+ }
+ duplicateNotebook: () => any
+ duplicateNotebookFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ duplicateNotebookSuccess: (
+ newNotebook: NotebookType | null,
+ payload?: any
+ ) => {
+ newNotebook: NotebookType | null
+ payload?: any
+ }
+ editorIsReady: () => {
+ value: true
+ }
+ exportJSON: () => {
+ value: true
+ }
+ handleMarkdownEditorChange: (markdown: string) => {
+ markdown: string
+ }
+ handleMarkdownStreamEvent: (event: MarkdownStreamEvent) => {
+ event: MarkdownStreamEvent
+ }
+ handleRemotePresence: (presence: Omit<NotebookRemotePresenceState, 'lastSeenAt'>) => {
+ presence: Omit<NotebookRemotePresenceState, 'lastSeenAt'>
+ receivedAt: number
+ }
+ insertAfterLastNode: (content: JSONContent) => {
+ content: JSONContent
+ }
+ insertAfterLastNodeOfType: (
+ nodeType: string,
+ content: JSONContent,
+ knownStartingPosition: any
+ ) => {
+ content: JSONContent
+ knownStartingPosition: any
+ nodeType: string
+ }
+ insertComment: (context: Record<string, any>) => {
+ context: Record<string, any>
+ }
+ loadNotebook: () => {
+ value: true
+ }
+ loadNotebookFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadNotebookSuccess: (
+ notebook: NotebookType | null,
+ payload?: {
+ value: true
+ }
+ ) => {
+ notebook: NotebookType | null
+ payload?: {
+ value: true
+ }
+ }
+ onEditorSelectionUpdate: () => {
+ value: true
+ }
+ onEditorUpdate: () => {
+ value: true
+ }
+ onUpdateEditor: () => {
+ value: true
+ }
+ openShareModal: () => {
+ value: true
+ }
+ pasteAfterLastNode: (content: string) => {
+ content: string
+ }
+ processPendingMarkdownStreamEvents: () => {
+ value: true
+ }
+ pruneRemotePresence: () => {
+ now: number
+ }
+ publishMarkdownCaret: (position: MarkdownNotebookCaretPosition | null) => {
+ position: MarkdownNotebookCaretPosition | null
+ }
+ registerNodeLogic: (
+ nodeId: string,
+ nodeLogic: BuiltLogic<notebookNodeLogicType>
+ ) => {
+ nodeId: string
+ nodeLogic: BuiltLogic<notebookNodeLogicType>
+ }
+ renameNotebook: (title: string) => {
+ title: string
+ }
+ renameNotebookFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ renameNotebookSuccess: (
+ notebook: NotebookType | null,
+ payload?: {
+ title: string
+ }
+ ) => {
+ notebook: NotebookType | null
+ payload?: {
+ title: string
+ }
+ }
+ reportMarkdownMergeConflicts: (conflicts: NotebookCollaborationConflict[]) => {
+ conflicts: NotebookCollaborationConflict[]
+ }
+ saveNotebook: (notebook: Pick<NotebookType, 'content' | 'title'>) => {
+ notebook: Pick<NotebookType, 'content' | 'title'>
+ }
+ saveNotebookFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ saveNotebookSuccess: (
+ notebook: NotebookType | null,
+ payload?: {
+ notebook: Pick<NotebookType, 'content' | 'title'>
+ }
+ ) => {
+ notebook: NotebookType | null
+ payload?: {
+ notebook: Pick<NotebookType, 'content' | 'title'>
+ }
+ }
+ scheduleNotebookRefresh: () => {
+ value: true
+ }
+ scrollToSelection: () => {
+ value: true
+ }
+ selectComment: (itemContextId: string) => {
+ itemContextId: string
+ }
+ setAccessDeniedToNotebook: () => {
+ value: true
+ }
+ setAutosavePaused: (paused: boolean) => {
+ paused: boolean
+ }
+ setContainerSize: (containerSize: 'medium' | 'small') => {
+ containerSize: 'medium' | 'small'
+ }
+ setEditable: (editable: boolean) => {
+ editable: boolean
+ }
+ setEditingNodeEditing: (
+ nodeId: string,
+ editing: boolean
+ ) => {
+ editing: boolean
+ nodeId: string
+ }
+ setEditor: (editor: NotebookEditor) => {
+ editor: NotebookEditor
+ }
+ setLocalContent: (
+ jsonContent: JSONContent,
+ updateEditor?: any,
+ skipCapture?: any
+ ) => {
+ jsonContent: JSONContent
+ skipCapture: any
+ updateEditor: any
+ }
+ setMarkdownAIPresenceActive: (active: boolean) => {
+ active: boolean
+ }
+ setMarkdownEditorBuffer: (buffered: string | null) => {
+ buffered: string | null
+ }
+ setMarkdownEditorDraft: (draft: string | null) => {
+ draft: string | null
+ }
+ setMarkdownEditorInteractionActive: (active: boolean) => {
+ active: boolean
+ }
+ setPreviewContent: (jsonContent: JSONContent) => {
+ jsonContent: JSONContent
+ }
+ setShowHistory: (showHistory: boolean) => {
+ showHistory: boolean
+ }
+ setTableOfContents: (tableOfContents: TableOfContentData) => {
+ tableOfContents: TableOfContentData
+ }
+ setTextSelection: (selection: number | EditorRange) => {
+ selection: number | Range
+ }
+ showCollabConflict: (params: { localContent: JSONContent; localText: string; serverContent: JSONContent }) => {
+ localContent: JSONContent
+ localText: string
+ serverContent: JSONContent
+ }
+ showConflictWarning: () => {
+ value: true
+ }
+ showMarkdownMergeConflictDetails: (conflicts: NotebookCollaborationConflict[]) => {
+ conflicts: NotebookCollaborationConflict[]
+ }
+ unregisterNodeLogic: (nodeId: string) => {
+ nodeId: string
+ }
+}
+
+export type notebookLogicType = MakeLogicType<notebookLogicValues, notebookLogicActions, NotebookLogicProps>
+
export const notebookLogic = kea<notebookLogicType>([
props({} as NotebookLogicProps),
path((key) => ['scenes', 'notebooks', 'Notebook', 'notebookLogic', key]),
@@ -1008,12 +1440,12 @@ export const notebookLogic = kea<notebookLogicType>([
}),
selectors({
canvasFiltersOverride: [() => [(_, props) => props], (props) => props.canvasFiltersOverride || []],
- shortId: [(_, p) => [p.shortId], (shortId) => shortId],
+ shortId: [(_, p) => [p.shortId], (shortId: string) => shortId],
mode: [() => [(_, props) => props], (props): NotebookLogicMode => props.mode ?? 'notebook'],
- isTemplate: [(s) => [s.shortId], (shortId): boolean => shortId.startsWith('template-')],
+ isTemplate: [(s) => [s.shortId], (shortId: string): boolean => shortId.startsWith('template-')],
isLocalOnly: [
(s) => [(_, props) => props, s.isTemplate],
- (props, isTemplate): boolean => {
+ (props, isTemplate: boolean): boolean => {
return props.shortId === 'scratchpad' || props.mode === 'canvas' || isTemplate
},
],
@@ -1043,13 +1475,13 @@ export const notebookLogic = kea<notebookLogicType>([
],
notebookMissing: [
(s) => [s.notebook, s.notebookLoading, s.mode],
- (notebook, notebookLoading, mode): boolean => {
+ (notebook: NotebookType | null, notebookLoading: boolean, mode: NotebookLogicMode): boolean => {
return (['notebook', 'template'].includes(mode) && !notebook && !notebookLoading) ?? false
},
],
markdownRemoteCarets: [
(s) => [s.markdownRemotePresence],
- (markdownRemotePresence): RemoteNotebookCaret[] => {
+ (markdownRemotePresence: Record<string, NotebookRemotePresenceState>): RemoteNotebookCaret[] => {
const carets: RemoteNotebookCaret[] = []
for (const presence of Object.values(markdownRemotePresence)) {
const position = apiCursorToCaretPosition(presence.cursor)
@@ -1068,13 +1500,13 @@ export const notebookLogic = kea<notebookLogicType>([
],
markdownRemoteParticipants: [
(s) => [s.markdownRemotePresence],
- (markdownRemotePresence): NotebookRemoteParticipant[] =>
+ (markdownRemotePresence: Record<string, NotebookRemotePresenceState>): NotebookRemoteParticipant[] =>
getNotebookRemoteParticipants(markdownRemotePresence),
],
notebookPresenceParticipants: [
(s) => [s.user, s.markdownRemoteParticipants, s.remoteParticipants, s.markdownAIPresenceActive],
(
- user,
+ user: UserType | null,
markdownRemoteParticipants: NotebookRemoteParticipant[],
remoteParticipants: NotebookRemoteParticipant[],
markdownAIPresenceActive: boolean
@@ -1109,15 +1541,22 @@ export const notebookLogic = kea<notebookLogicType>([
return convertNotebookContentForRender(content, !!featureFlags[FEATURE_FLAGS.MARKDOWN_NOTEBOOKS]) || []
},
],
- markdownEditorMarkdown: [(s) => [s.content], (content): string => getMarkdownNotebookMarkdown(content)],
- markdownEditorNodeId: [(s) => [s.content], (content): string => getMarkdownNotebookNodeId(content)],
+ markdownEditorMarkdown: [
+ (s) => [s.content],
+ (content: JSONContent): string => getMarkdownNotebookMarkdown(content),
+ ],
+ markdownEditorNodeId: [
+ (s) => [s.content],
+ (content: JSONContent): string => getMarkdownNotebookNodeId(content),
+ ],
markdownEditorValue: [
(s) => [s.markdownEditorDraft, s.markdownEditorMarkdown],
- (markdownEditorDraft, markdownEditorMarkdown): string => markdownEditorDraft ?? markdownEditorMarkdown,
+ (markdownEditorDraft: string | null, markdownEditorMarkdown: string): string =>
+ markdownEditorDraft ?? markdownEditorMarkdown,
],
title: [
(s) => [s.notebook, s.content],
- (notebook, content): string => {
+ (notebook: NotebookType | null, content: JSONContent): string => {
const firstTextNode = content?.content?.[0]?.content?.[0]
const contentTitle = isMarkdownNotebookContent(content)
? getMarkdownNotebookTitle(content)
@@ -1129,7 +1568,13 @@ export const notebookLogic = kea<notebookLogicType>([
],
syncStatus: [
(s) => [s.notebook, s.notebookLoading, s.localContent, s.isLocalOnly, s.previewContent],
- (notebook, notebookLoading, localContent, isLocalOnly, previewContent): NotebookSyncStatus => {
+ (
+ notebook: NotebookType | null,
+ notebookLoading: boolean,
+ localContent: JSONContent | null,
+ isLocalOnly: boolean,
+ previewContent: JSONContent | null
+ ): NotebookSyncStatus => {
if (previewContent || notebook?.is_template) {
return 'synced'
}
@@ -1150,7 +1595,7 @@ export const notebookLogic = kea<notebookLogicType>([
],
editingNodeLogics: [
(s) => [s.editingNodeIds, s.nodeLogics, s.isShared],
- (editingNodeIds, nodeLogics, isShared) => {
+ (editingNodeIds: Record<string, true>, nodeLogics: Record<string, any>, isShared: boolean) => {
// Editing UI is meaningless for anonymous shared viewers and `editingNodeIds` can
// arrive pre-populated from persisted local state — zero it out at the source so
// the Settings panel never renders for them.
@@ -1176,7 +1621,7 @@ export const notebookLogic = kea<notebookLogicType>([
],
findNodeLogic: [
(s) => [s.nodeLogics],
- (nodeLogics) => {
+ (nodeLogics: Record<string, any>) => {
return (type: NotebookNodeType, attributes: Record<string, any>): notebookNodeLogicType | null => {
const attrEntries = Object.entries(attributes || {})
return (
@@ -1194,7 +1639,7 @@ export const notebookLogic = kea<notebookLogicType>([
],
findNodeLogicById: [
(s) => [s.nodeLogics],
- (nodeLogics) => {
+ (nodeLogics: Record<string, any>) => {
return (id: string) => {
return Object.values(nodeLogics).find((nodeLogic) => nodeLogic.values.nodeId === id) ?? null
}
@@ -1204,26 +1649,26 @@ export const notebookLogic = kea<notebookLogicType>([
nodeLogicsWithChildren: [
(s) => [s.nodeLogics, s.content],
// oxlint-disable-next-line @typescript-eslint/no-unused-vars
- (nodeLogics, _content) => {
+ (nodeLogics: Record<string, any>, _content: JSONContent) => {
// NOTE: _content is not but is needed to retrigger as it could mean the children have changed
return Object.values(nodeLogics).filter((nodeLogic) => nodeLogic.props.attributes?.children)
},
],
- pythonNodeSummaries: [(s) => [s.content], (content) => collectPythonNodes(content)],
- duckSqlNodeSummaries: [(s) => [s.content], (content) => collectDuckSqlNodes(content)],
- hogqlSqlNodeSummaries: [(s) => [s.content], (content) => collectHogqlSqlNodes(content)],
- sqlV2NodeSummaries: [(s) => [s.content], (content) => collectSqlV2Nodes(content)],
- dependencyGraph: [(s) => [s.content], (content) => buildNotebookDependencyGraph(content)],
+ pythonNodeSummaries: [(s) => [s.content], (content: JSONContent) => collectPythonNodes(content)],
+ duckSqlNodeSummaries: [(s) => [s.content], (content: JSONContent) => collectDuckSqlNodes(content)],
+ hogqlSqlNodeSummaries: [(s) => [s.content], (content: JSONContent) => collectHogqlSqlNodes(content)],
+ sqlV2NodeSummaries: [(s) => [s.content], (content: JSONContent) => collectSqlV2Nodes(content)],
+ dependencyGraph: [(s) => [s.content], (content: JSONContent) => buildNotebookDependencyGraph(content)],
pythonNodeIndices: [
(s) => [s.content],
- (content) => collectNodeIndices(content, (node) => node.type === NotebookNodeType.Python),
+ (content: JSONContent) => collectNodeIndices(content, (node) => node.type === NotebookNodeType.Python),
],
sqlNodeIndices: [
(s) => [s.content],
- (content) =>
+ (content: JSONContent) =>
collectNodeIndices(
content,
(node) =>
@@ -1234,11 +1679,11 @@ export const notebookLogic = kea<notebookLogicType>([
],
duckSqlNodeIndices: [
(s) => [s.content],
- (content) => collectNodeIndices(content, (node) => node.type === NotebookNodeType.DuckSQL),
+ (content: JSONContent) => collectNodeIndices(content, (node) => node.type === NotebookNodeType.DuckSQL),
],
hogqlSqlNodeIndices: [
(s) => [s.content],
- (content) => collectNodeIndices(content, (node) => node.type === NotebookNodeType.HogQLSQL),
+ (content: JSONContent) => collectNodeIndices(content, (node) => node.type === NotebookNodeType.HogQLSQL),
],
isShowingLeftColumn: [
@@ -1270,7 +1715,12 @@ export const notebookLogic = kea<notebookLogicType>([
isEditable: [
(s) => [s.shouldBeEditable, s.previewContent, s.notebook, s.mode],
- (shouldBeEditable, previewContent, notebook, mode) =>
+ (
+ shouldBeEditable: boolean,
+ previewContent: JSONContent | null,
+ notebook: NotebookType | null,
+ mode: NotebookLogicMode
+ ) =>
shouldBeEditable &&
(mode === 'canvas' ||
(!previewContent &&
@@ -1297,7 +1747,7 @@ export const notebookLogic = kea<notebookLogicType>([
getSharedCachedInsight: [
(s) => [s.isShared, s.cachedInsightsByShortId],
- (isShared, cachedInsightsByShortId) =>
+ (isShared: boolean, cachedInsightsByShortId: Record<string, InsightModel>) =>
(shortId: string | null | undefined): InsightModel | null => {
if (!isShared || !shortId) {
return null
@@ -1307,7 +1757,7 @@ export const notebookLogic = kea<notebookLogicType>([
],
getSharedCachedInlineQueryResults: [
(s) => [s.isShared, s.cachedInlineQueryResultsByNodeId],
- (isShared, cachedInlineQueryResultsByNodeId) =>
+ (isShared: boolean, cachedInlineQueryResultsByNodeId: Record<string, AnyResponseType>) =>
(nodeId: string | null | undefined): AnyResponseType | null => {
if (!isShared || !nodeId) {
return null
@@ -1318,7 +1768,7 @@ export const notebookLogic = kea<notebookLogicType>([
insightShortIdsInNotebook: [
(s) => [s.content],
- (content) => {
+ (content: JSONContent) => {
if (!content) {
return []
}
@@ -1331,7 +1781,7 @@ export const notebookLogic = kea<notebookLogicType>([
experimentIdsInNotebook: [
(s) => [s.content],
- (content): number[] => {
+ (content: JSONContent): number[] => {
if (!content) {
return []
}
@@ -1353,7 +1803,7 @@ export const notebookLogic = kea<notebookLogicType>([
activeCommentMarkId: [
(s) => [s.selectedCommentId, s.comments],
- (selectedCommentId, comments): string | null => {
+ (selectedCommentId: string | null, comments: CommentType[] | null): string | null => {
if (!selectedCommentId) {
return null
}
diff --git a/frontend/src/scenes/notebooks/Notebook/notebookOperationsLogic.ts b/frontend/src/scenes/notebooks/Notebook/notebookOperationsLogic.ts
index 284d4592f48d..fb31217a755c 100644
--- a/frontend/src/scenes/notebooks/Notebook/notebookOperationsLogic.ts
+++ b/frontend/src/scenes/notebooks/Notebook/notebookOperationsLogic.ts
@@ -1,6 +1,4 @@
-import { actions, kea, key, path, props, reducers, selectors } from 'kea'
-
-import type { notebookOperationsLogicType } from './notebookOperationsLogicType'
+import { MakeLogicType, actions, kea, key, path, props, reducers, selectors } from 'kea'
export interface NotebookOperationsLogicProps {
shortId: string
@@ -13,6 +11,32 @@ export type NotebookOperation = {
kind: 'run' | 'page'
}
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookOperationsLogicValues {
+ activeOperation: NotebookOperation | null
+ isBusy: boolean
+ operations: Record<string, NotebookOperation>
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookOperationsLogicActions {
+ finishNodeOperations: (nodeId: string) => {
+ nodeId: string
+ }
+ finishOperation: (id: string) => {
+ id: string
+ }
+ startOperation: (operation: NotebookOperation) => {
+ operation: NotebookOperation
+ }
+}
+
+export type notebookOperationsLogicType = MakeLogicType<
+ notebookOperationsLogicValues,
+ notebookOperationsLogicActions,
+ NotebookOperationsLogicProps
+>
+
/**
* Notebook-wide registry of in-flight data operations (query runs, page fetches).
*
@@ -55,6 +79,9 @@ export const notebookOperationsLogic = kea<notebookOperationsLogicType>([
(operations: Record<string, NotebookOperation>): NotebookOperation | null =>
Object.values(operations)[0] ?? null,
],
- isBusy: [(s) => [s.operations], (operations): boolean => Object.keys(operations).length > 0],
+ isBusy: [
+ (s) => [s.operations],
+ (operations: Record<string, NotebookOperation>): boolean => Object.keys(operations).length > 0,
+ ],
}),
])
diff --git a/frontend/src/scenes/notebooks/Notebook/notebookSettingsLogic.ts b/frontend/src/scenes/notebooks/Notebook/notebookSettingsLogic.ts
index 99fadfaf1107..7852c88de074 100644
--- a/frontend/src/scenes/notebooks/Notebook/notebookSettingsLogic.ts
+++ b/frontend/src/scenes/notebooks/Notebook/notebookSettingsLogic.ts
@@ -1,6 +1,30 @@
-import { actions, kea, path, reducers } from 'kea'
+import { MakeLogicType, actions, kea, path, reducers } from 'kea'
-import type { notebookSettingsLogicType } from './notebookSettingsLogicType'
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookSettingsLogicValues {
+ isExpanded: boolean
+ isMarkdownExpanded: boolean
+ showKernelInfo: boolean
+ showTableOfContents: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookSettingsLogicActions {
+ setIsExpanded: (expanded: boolean) => {
+ expanded: boolean
+ }
+ setIsMarkdownExpanded: (expanded: boolean) => {
+ expanded: boolean
+ }
+ setShowKernelInfo: (showKernelInfo: boolean) => {
+ showKernelInfo: boolean
+ }
+ setShowTableOfContents: (showTOC: boolean) => {
+ showTOC: boolean
+ }
+}
+
+export type notebookSettingsLogicType = MakeLogicType<notebookSettingsLogicValues, notebookSettingsLogicActions>
// This logic contains settings that should persist across all notebooks
export const notebookSettingsLogic = kea<notebookSettingsLogicType>([
diff --git a/frontend/src/scenes/notebooks/NotebookPanel/NotebookPanelDropzone.tsx b/frontend/src/scenes/notebooks/NotebookPanel/NotebookPanelDropzone.tsx
index 526eaaf77ce4..90c3a04260a6 100644
--- a/frontend/src/scenes/notebooks/NotebookPanel/NotebookPanelDropzone.tsx
+++ b/frontend/src/scenes/notebooks/NotebookPanel/NotebookPanelDropzone.tsx
@@ -4,7 +4,7 @@ import { DragEventHandler, useState } from 'react'
import { LemonButton } from '@posthog/lemon-ui'
-import { notebookLogicType } from '../Notebook/notebookLogicType'
+import type { notebookLogicType } from '../Notebook/notebookLogic'
import { NotebookSelectList } from '../NotebookSelectButton/NotebookSelectButton'
import { NotebookNodeType } from '../types'
import { notebookPanelLogic } from './notebookPanelLogic'
diff --git a/frontend/src/scenes/notebooks/NotebookPanel/notebookPanelLogic.ts b/frontend/src/scenes/notebooks/NotebookPanel/notebookPanelLogic.ts
index 5c23c526ab22..ac517958a68d 100644
--- a/frontend/src/scenes/notebooks/NotebookPanel/notebookPanelLogic.ts
+++ b/frontend/src/scenes/notebooks/NotebookPanel/notebookPanelLogic.ts
@@ -1,4 +1,4 @@
-import { actions, beforeUnmount, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, beforeUnmount, connect, kea, listeners, path, reducers, selectors } from 'kea'
import { HTMLProps } from 'react'
import { EditorFocusPosition } from 'lib/components/RichContentEditor/types'
@@ -7,8 +7,61 @@ import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'
import { SidePanelTab } from '~/types'
+import type { FocusPosition } from '../../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@tiptap/core/dist/index'
+import type { FeatureFlagsSet } from '../../../lib/logic/featureFlagLogic'
import { NotebookNodeResource } from '../types'
-import type { notebookPanelLogicType } from './notebookPanelLogicType'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookPanelLogicValues {
+ featureFlags: FeatureFlagsSet // featureFlagLogic
+ selectedTab: SidePanelTab | null // sidePanelStateLogic
+ sidePanelOpen: boolean // sidePanelStateLogic
+ dropMode: boolean
+ dropProperties: Pick<HTMLProps<HTMLDivElement>, 'onDragEnter' | 'onDragLeave' | 'style'>
+ droppedResource: string | NotebookNodeResource | null
+ initialAutofocus: EditorFocusPosition
+ selectedNotebook: string
+ visibility: 'hidden' | 'visible'
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookPanelLogicActions {
+ closeSidePanel: (tab?: SidePanelTab) => {
+ tab: SidePanelTab | undefined
+ } // sidePanelStateLogic
+ openSidePanel: (
+ tab: SidePanelTab,
+ options?: string
+ ) => {
+ options: string | undefined
+ tab: SidePanelTab
+ } // sidePanelStateLogic
+ endDropMode: () => {
+ value: true
+ }
+ selectNotebook: (
+ id: string,
+ options?: {
+ autofocus?: EditorFocusPosition
+ silent?: boolean
+ }
+ ) => {
+ autofocus?: FocusPosition | undefined
+ id: string
+ silent?: boolean | undefined
+ }
+ setDroppedResource: (resource: string | NotebookNodeResource | null) => {
+ resource: string | NotebookNodeResource | null
+ }
+ startDropMode: () => {
+ value: true
+ }
+ toggleVisibility: () => {
+ value: true
+ }
+}
+
+export type notebookPanelLogicType = MakeLogicType<notebookPanelLogicValues, notebookPanelLogicActions>
export const notebookPanelLogic = kea<notebookPanelLogicType>([
path(['scenes', 'notebooks', 'Notebook', 'notebookPanelLogic']),
@@ -61,14 +114,14 @@ export const notebookPanelLogic = kea<notebookPanelLogicType>([
selectors(({ cache, actions }) => ({
visibility: [
(s) => [s.selectedTab, s.sidePanelOpen],
- (selectedTab, sidePanelOpen): 'hidden' | 'visible' => {
+ (selectedTab: SidePanelTab | null, sidePanelOpen: boolean): 'hidden' | 'visible' => {
return selectedTab === SidePanelTab.Notebooks && sidePanelOpen ? 'visible' : 'hidden'
},
],
dropProperties: [
(s) => [s.dropMode],
- (dropMode): Pick<HTMLProps<HTMLDivElement>, 'onDragEnter' | 'onDragLeave' | 'style'> => {
+ (dropMode: boolean): Pick<HTMLProps<HTMLDivElement>, 'onDragEnter' | 'onDragLeave' | 'style'> => {
return dropMode
? {
onDragEnter: () => {
diff --git a/frontend/src/scenes/notebooks/NotebookSelectButton/NotebookSelectButton.tsx b/frontend/src/scenes/notebooks/NotebookSelectButton/NotebookSelectButton.tsx
index 814da012d87f..87d79cb3fa5e 100644
--- a/frontend/src/scenes/notebooks/NotebookSelectButton/NotebookSelectButton.tsx
+++ b/frontend/src/scenes/notebooks/NotebookSelectButton/NotebookSelectButton.tsx
@@ -22,8 +22,8 @@ import {
import { notebooksModel, openNotebook } from '~/models/notebooksModel'
import { AccessControlLevel, AccessControlResourceType } from '~/types'
-import { notebookNodeLogicType } from '../Nodes/notebookNodeLogicType'
-import { notebookLogicType } from '../Notebook/notebookLogicType'
+import type { notebookNodeLogicType } from '../Nodes/notebookNodeLogic'
+import type { notebookLogicType } from '../Notebook/notebookLogic'
import { NotebookListItemType, NotebookTarget } from '../types'
import { NOTEBOOK_DROPDOWN_LIMIT } from './notebookSelectButtonLogic'
diff --git a/frontend/src/scenes/notebooks/NotebookSelectButton/notebookSelectButtonLogic.ts b/frontend/src/scenes/notebooks/NotebookSelectButton/notebookSelectButtonLogic.ts
index 07cff3c12491..ddf1798c1bec 100644
--- a/frontend/src/scenes/notebooks/NotebookSelectButton/notebookSelectButtonLogic.ts
+++ b/frontend/src/scenes/notebooks/NotebookSelectButton/notebookSelectButtonLogic.ts
@@ -1,10 +1,9 @@
-import { actions, kea, key, listeners, path, props, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { NotebookListItemType, NotebookNodeResource, NotebookNodeType } from '../types'
-import type { notebookSelectButtonLogicType } from './notebookSelectButtonLogicType'
export const NOTEBOOK_DROPDOWN_LIMIT = 50
@@ -18,6 +17,80 @@ export interface NotebookSelectButtonLogicProps {
visible?: boolean
}
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookSelectButtonLogicValues {
+ allNotebooks: NotebookListItemType[]
+ allNotebooksLoading: boolean
+ createdBy: string | null
+ notebooksContainingResource: NotebookListItemType[]
+ notebooksContainingResourceLoading: boolean
+ notebooksLoading: boolean
+ notebooksNotContainingResource: NotebookListItemType[]
+ searchQuery: string
+ showPopover: boolean | undefined
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookSelectButtonLogicActions {
+ loadAllNotebooks: () => {
+ value: true
+ }
+ loadAllNotebooksFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadAllNotebooksSuccess: (
+ allNotebooks: NotebookListItemType[],
+ payload?: {
+ value: true
+ }
+ ) => {
+ allNotebooks: NotebookListItemType[]
+ payload?: {
+ value: true
+ }
+ }
+ loadNotebooksContainingResource: () => {
+ value: true
+ }
+ loadNotebooksContainingResourceFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadNotebooksContainingResourceSuccess: (
+ notebooksContainingResource: NotebookListItemType[],
+ payload?: {
+ value: true
+ }
+ ) => {
+ notebooksContainingResource: NotebookListItemType[]
+ payload?: {
+ value: true
+ }
+ }
+ setCreatedBy: (userUuid: string | null) => {
+ userUuid: string | null
+ }
+ setSearchQuery: (query: string) => {
+ query: string
+ }
+ setShowPopover: (visible: boolean) => {
+ visible: boolean
+ }
+}
+
+export type notebookSelectButtonLogicType = MakeLogicType<
+ notebookSelectButtonLogicValues,
+ notebookSelectButtonLogicActions,
+ NotebookSelectButtonLogicProps
+>
+
export const notebookSelectButtonLogic = kea<notebookSelectButtonLogicType>([
path((key) => ['scenes', 'session-recordings', 'NotebookSelectButton', 'multiNotebookSelectButtonLogic', key]),
props({} as NotebookSelectButtonLogicProps),
@@ -114,14 +187,14 @@ export const notebookSelectButtonLogic = kea<notebookSelectButtonLogicType>([
selectors(() => ({
notebooksNotContainingResource: [
(s) => [s.allNotebooks, s.notebooksContainingResource],
- (allNotebooks, notebooksContainingResource) =>
+ (allNotebooks: NotebookListItemType[], notebooksContainingResource: NotebookListItemType[]) =>
allNotebooks.filter(
(notebook) => !notebooksContainingResource.find((n) => n.short_id === notebook.short_id)
),
],
notebooksLoading: [
(s) => [s.allNotebooksLoading, s.notebooksContainingResourceLoading],
- (allNotebooksLoading, notebooksContainingResourceLoading) =>
+ (allNotebooksLoading: boolean, notebooksContainingResourceLoading: boolean) =>
allNotebooksLoading || notebooksContainingResourceLoading,
],
})),
diff --git a/frontend/src/scenes/notebooks/NotebooksTable/notebooksTableLogic.ts b/frontend/src/scenes/notebooks/NotebooksTable/notebooksTableLogic.ts
index fb872f1017dc..4f6f4cf49d90 100644
--- a/frontend/src/scenes/notebooks/NotebooksTable/notebooksTableLogic.ts
+++ b/frontend/src/scenes/notebooks/NotebooksTable/notebooksTableLogic.ts
@@ -1,4 +1,4 @@
-import { actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
import { PaginationManual, Sorting } from '@posthog/lemon-ui'
@@ -11,7 +11,7 @@ import { notebooksModel } from '~/models/notebooksModel'
import { ActivityScope, Breadcrumb } from '~/types'
import { NotebookListItemType, NotebookNodeType } from '../types'
-import type { notebooksTableLogicType } from './notebooksTableLogicType'
+import type { NotebookType } from '../types'
export interface NotebooksListFilters {
search: string
@@ -29,6 +29,71 @@ export const DEFAULT_FILTERS: NotebooksListFilters = {
const RESULTS_PER_PAGE = 50
const DEFAULT_SORTING: Sorting = { columnKey: '-created_at', order: 1 }
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebooksTableLogicValues {
+ notebookTemplates: NotebookType[] // notebooksModel
+ breadcrumbs: Breadcrumb[]
+ filters: NotebooksListFilters
+ notebooks: NotebookListItemType[]
+ notebooksAndTemplates: NotebookListItemType[]
+ notebooksResponse: CountedPaginatedResponse<NotebookListItemType> | null
+ notebooksResponseLoading: boolean
+ page: number
+ pagination: PaginationManual
+ sidePanelContext: SidePanelSceneContext
+ sortValue: string | null
+ tableSorting: Sorting
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebooksTableLogicActions {
+ deleteNotebookSuccess: (
+ notebooks: NotebookListItemType[],
+ payload?: {
+ shortId: string
+ title: string | undefined
+ }
+ ) => {
+ notebooks: NotebookListItemType[]
+ payload?: {
+ shortId: string
+ title: string | undefined
+ }
+ } // notebooksModel
+ loadNotebooks: () => {
+ value: true
+ }
+ loadNotebooksFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadNotebooksSuccess: (
+ notebooksResponse: CountedPaginatedResponse<NotebookListItemType>,
+ payload?: {
+ value: true
+ }
+ ) => {
+ notebooksResponse: CountedPaginatedResponse<NotebookListItemType>
+ payload?: {
+ value: true
+ }
+ }
+ setFilters: (filters: Partial<NotebooksListFilters>) => {
+ filters: Partial<NotebooksListFilters>
+ }
+ setPage: (page: number) => {
+ page: number
+ }
+ tableSortingChanged: (sorting: Sorting | null) => {
+ sorting: Sorting | null
+ }
+}
+
+export type notebooksTableLogicType = MakeLogicType<notebooksTableLogicValues, notebooksTableLogicActions>
+
export const notebooksTableLogic = kea<notebooksTableLogicType>([
path(['scenes', 'notebooks', 'NotebooksTable', 'notebooksTableLogic']),
actions({
@@ -113,7 +178,11 @@ export const notebooksTableLogic = kea<notebooksTableLogicType>([
selectors(({ actions }) => ({
notebooksAndTemplates: [
(s) => [s.notebooks, s.notebookTemplates, s.filters],
- (notebooks, notebookTemplates, filters): NotebookListItemType[] => {
+ (
+ notebooks: NotebookListItemType[],
+ notebookTemplates: NotebookType[],
+ filters: NotebooksListFilters
+ ): NotebookListItemType[] => {
const includeTemplates = objectsEqual(filters, DEFAULT_FILTERS)
return [...(includeTemplates ? (notebookTemplates as NotebookListItemType[]) : []), ...notebooks]
},
@@ -121,14 +190,17 @@ export const notebooksTableLogic = kea<notebooksTableLogicType>([
notebooks: [
(s) => [s.notebooksResponse],
- (notebooksResponse): NotebookListItemType[] => {
+ (notebooksResponse: CountedPaginatedResponse<NotebookListItemType> | null): NotebookListItemType[] => {
return notebooksResponse?.results || []
},
],
pagination: [
(s) => [s.page, s.notebooksResponse],
- (page, notebooksResponse): PaginationManual => {
+ (
+ page: number,
+ notebooksResponse: CountedPaginatedResponse<NotebookListItemType> | null
+ ): PaginationManual => {
return {
controlled: true,
pageSize: RESULTS_PER_PAGE,
diff --git a/frontend/src/scenes/notebooks/Suggestions/insertionSuggestionsLogic.ts b/frontend/src/scenes/notebooks/Suggestions/insertionSuggestionsLogic.ts
index e5f76f9e1aad..c2a118077539 100644
--- a/frontend/src/scenes/notebooks/Suggestions/insertionSuggestionsLogic.ts
+++ b/frontend/src/scenes/notebooks/Suggestions/insertionSuggestionsLogic.ts
@@ -1,11 +1,45 @@
-import { actions, events, kea, listeners, path, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, events, kea, listeners, path, reducers, selectors } from 'kea'
import { RichContentEditorType, RichContentNode } from 'lib/components/RichContentEditor/types'
import { InsertionSuggestion } from './InsertionSuggestion'
-import type { insertionSuggestionsLogicType } from './insertionSuggestionsLogicType'
import SlashCommands from './SlashCommands'
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface insertionSuggestionsLogicValues {
+ activeSuggestion: InsertionSuggestion
+ editor: RichContentEditorType | null
+ previousNode: RichContentNode | null
+ suggestions: InsertionSuggestion[]
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface insertionSuggestionsLogicActions {
+ onEscape: () => {
+ value: true
+ }
+ onTab: () => {
+ value: true
+ }
+ resetSuggestions: () => {
+ value: true
+ }
+ setEditor: (editor: RichContentEditorType | null) => {
+ editor: RichContentEditorType | null
+ }
+ setPreviousNode: (node: RichContentNode | null) => {
+ node: RichContentNode | null
+ }
+ setSuggestions: (suggestions: InsertionSuggestion[]) => {
+ suggestions: InsertionSuggestion[]
+ }
+}
+
+export type insertionSuggestionsLogicType = MakeLogicType<
+ insertionSuggestionsLogicValues,
+ insertionSuggestionsLogicActions
+>
+
export const insertionSuggestionsLogic = kea<insertionSuggestionsLogicType>([
path(['scenes', 'notebooks', 'Suggestions', 'insertionSuggestionsLogic']),
diff --git a/frontend/src/scenes/notebooks/notebookSceneLogic.ts b/frontend/src/scenes/notebooks/notebookSceneLogic.ts
index 1a4835292bae..151131fd6b05 100644
--- a/frontend/src/scenes/notebooks/notebookSceneLogic.ts
+++ b/frontend/src/scenes/notebooks/notebookSceneLogic.ts
@@ -1,4 +1,5 @@
-import { afterMount, connect, kea, key, path, props, selectors } from 'kea'
+import { MakeLogicType, afterMount, connect, kea, key, path, props, selectors } from 'kea'
+import type { BuiltLogic } from 'kea'
import { Scene } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
@@ -7,12 +8,54 @@ import { SIDE_PANEL_CONTEXT_KEY, SidePanelSceneContext } from '~/layout/navigati
import { notebooksModel } from '~/models/notebooksModel'
import { ActivityScope, Breadcrumb, ProjectTreeRef } from '~/types'
+import type { JSONContent } from '../../lib/components/RichContentEditor/types'
import { notebookLogic } from './Notebook/notebookLogic'
-import type { notebookSceneLogicType } from './notebookSceneLogicType'
+import type { notebookLogicType } from './Notebook/notebookLogic'
+import type { NotebookTarget } from './types'
+import type { NotebookType } from './types'
export type NotebookSceneLogicProps = {
shortId: string
}
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookSceneLogicValues {
+ isLocalOnly: boolean // notebookLogic
+ notebook: NotebookType | null // notebookLogic
+ notebookLoading: boolean // notebookLogic
+ notebooksLoading: boolean // notebooksModel
+ breadcrumbs: Breadcrumb[]
+ loading: boolean
+ notebookId: string
+ projectTreeRef: ProjectTreeRef | null
+ sidePanelContext: SidePanelSceneContext | null
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface notebookSceneLogicActions {
+ loadNotebook: () => {
+ value: true
+ } // notebookLogic
+ createNotebook: (
+ location: NotebookTarget,
+ title?: string,
+ content?: JSONContent[],
+ onCreate?: (notebook: BuiltLogic<notebookLogicType>) => void,
+ shortId?: string
+ ) => {
+ content: JSONContent[] | undefined
+ location: NotebookTarget
+ onCreate: ((notebook: BuiltLogic<notebookLogicType>) => void) | undefined
+ shortId: string | undefined
+ title: string | undefined
+ } // notebooksModel
+}
+
+export type notebookSceneLogicType = MakeLogicType<
+ notebookSceneLogicValues,
+ notebookSceneLogicActions,
+ NotebookSceneLogicProps
+>
+
export const notebookSceneLogic = kea<notebookSceneLogicType>([
path((key) => ['scenes', 'notebooks', 'notebookSceneLogic', key]),
props({} as NotebookSceneLogicProps),
@@ -27,16 +70,16 @@ export const notebookSceneLogic = kea<notebookSceneLogicType>([
actions: [notebookLogic(props), ['loadNotebook'], notebooksModel, ['createNotebook']],
})),
selectors(() => ({
- notebookId: [(_, p) => [p.shortId], (shortId) => shortId],
+ notebookId: [(_, p) => [p.shortId], (shortId: string) => shortId],
loading: [
(s) => [s.notebookLoading, s.notebooksLoading],
- (notebookLoading, notebooksLoading) => notebookLoading || notebooksLoading,
+ (notebookLoading: boolean, notebooksLoading: boolean) => notebookLoading || notebooksLoading,
],
breadcrumbs: [
(s) => [s.notebook, s.loading],
- (notebook, loading): Breadcrumb[] => {
+ (notebook: NotebookType | null, loading: boolean): Breadcrumb[] => {
const parent: Breadcrumb =
notebook?.parent_resource?.type === 'account'
? {
@@ -64,12 +107,13 @@ export const notebookSceneLogic = kea<notebookSceneLogicType>([
projectTreeRef: [
() => [(_, props: NotebookSceneLogicProps) => props.shortId],
- (shortId): ProjectTreeRef | null => (shortId === 'new' ? null : { type: 'notebook', ref: String(shortId) }),
+ (shortId: string): ProjectTreeRef | null =>
+ shortId === 'new' ? null : { type: 'notebook', ref: String(shortId) },
],
[SIDE_PANEL_CONTEXT_KEY]: [
(s) => [s.notebookId, s.isLocalOnly],
- (notebookId, isLocalOnly): SidePanelSceneContext | null => {
+ (notebookId: string, isLocalOnly: boolean): SidePanelSceneContext | null => {
return notebookId && !isLocalOnly
? {
activity_scope: ActivityScope.NOTEBOOK,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 145609d87cc9..6a8eb07c0b51 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1396,8 +1396,8 @@ importers:
specifier: ^16.0.0
version: 16.0.0
kea-typegen:
- specifier: 3.7.1
- version: 3.7.1([email protected])
+ specifier: 3.8.2
+ version: 3.8.2([email protected])
less:
specifier: ^3.12.2
version: 3.13.1
@@ -2995,6 +2995,9 @@ importers:
'@testing-library/user-event':
specifier: '*'
version: 14.6.1(@testing-library/[email protected])
+ '@tiptap/core':
+ specifier: 3.20.6
+ version: 3.20.6(@tiptap/[email protected])
'@types/react':
specifier: 18.3.27
version: 18.3.27
@@ -17759,8 +17762,8 @@ packages:
peerDependencies:
kea: '>= 3'
- resolution: {integrity: sha512-hQuV38I9OyCui/0HviWsgblabeN6iE8t2sOCF8cmoAd1Zk5nR3/5kkaepQGvkaqgwBjy8XcWzVgkCimE8jExoQ==}
+ resolution: {integrity: sha512-EiRWMT2c61p+uJlerEgKcZs7bLrUTku03sVceSAZXb0lZr/8vqios3UcnnP3H3Xag/vtb8RFsPoxgme8O4Xycg==}
hasBin: true
peerDependencies:
typescript: 6.0.3
@@ -39894,7 +39897,7 @@ snapshots:
kea: 4.0.0-pre.5([email protected])
dependencies:
'@babel/core': 7.29.0
'@babel/preset-env': 7.23.5(@babel/[email protected])
diff --git a/products/customer_analytics/package.json b/products/customer_analytics/package.json
index b541c14cd0b2..220ea4fb0953 100644
--- a/products/customer_analytics/package.json
+++ b/products/customer_analytics/package.json
@@ -23,6 +23,7 @@
"@testing-library/dom": "*",
"@testing-library/react": "*",
"@testing-library/user-event": "*",
+ "@tiptap/core": "*",
"@types/react": "*",
"clsx": "*",
"fuse.js": "*",