:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import clsx from 'clsx'
import { BuiltLogic, useValues } from 'kea'
import { uuid } from 'lib/utils/dom'
import { NotebookNodeChildRenderer } from '../Nodes/NodeWrapper'
import type { notebookNodeLogicType } from '../Nodes/notebookNodeLogic'
import { isMarkdownNotebookContent } from './markdownNotebookV2'
import { NotebookKernelInfo } from './NotebookKernelInfo'
import { notebookLogic } from './notebookLogic'
export const NotebookColumnRight = (): JSX.Element | null => {
const { content, isShowingLeftColumn, nodeLogicsWithChildren, showKernelInfo } = useValues(notebookLogic)
const shouldShowMarkdownKernelInfo = isMarkdownNotebookContent(content) && showKernelInfo
const isShowing = (nodeLogicsWithChildren.length > 0 || shouldShowMarkdownKernelInfo) && !isShowingLeftColumn
return (
<div
className={clsx('NotebookColumn NotebookColumn--right', {
'NotebookColumn--showing': isShowing,
})}
>
<div className="NotebookColumn__padding" />
<div className="NotebookColumn__content">
{isShowing ? (
<>
{shouldShowMarkdownKernelInfo ? <NotebookKernelInfo /> : null}
{nodeLogicsWithChildren.map((x, i) => (
<Widgets key={i} nodeLogic={x} />
))}
</>
) : null}
</div>
</div>
)
}
const Widgets = ({ nodeLogic }: { nodeLogic: BuiltLogic<notebookNodeLogicType> }): JSX.Element => {
const { children } = useValues(nodeLogic)
// TODO: IMPORTANT: The nodeId is basically now required, so we should be checking that in the logic
// otherwise we end up in horrible re-rendering loops
// A node's children attribute can be a non-array value, so guard before iterating.
const childNodes = Array.isArray(children) ? children : []
childNodes.forEach((content) => {
if (!content.attrs.nodeId) {
content.attrs.nodeId = uuid()
}
})
return (
<>
{childNodes.map((child) => (
<NotebookNodeChildRenderer key={child.attrs.nodeId} content={child} />
))}
</>
)
}