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(frontend): delete modules only their own tests still import (#94111)

Paul D'Ambra28ebfcff4d82
diff --git a/common/storybook/storybook-timings.json b/common/storybook/storybook-timings.json
index 78fdecea4df2..94f96d2dcdca 100644
--- a/common/storybook/storybook-timings.json
+++ b/common/storybook/storybook-timings.json
@@ -187,10 +187,6 @@
"chromium": 1.667,
"webkit": 1.22
},
- "frontend/src/lib/components/MarkdownEditor/inline/InlineRichMarkdownEditor.stories.tsx": {
- "chromium": 12.076,
- "webkit": 2.125
- },
"frontend/src/lib/components/MarkdownEditor/rich/RichMarkdownEditor.stories.tsx": {
"chromium": 5.579,
"webkit": 1.455
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index f1261be3c0c0..a4bb895c9daf 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -1300,18 +1300,6 @@ snapshots:
hash: v1.k794b7964.8558b680a337aff8beac6a2af6c9a2664f27c3c00a950cbf90681bc4bd97351c.OKknzco6mhDt_Q1dAVpp2gG7pqZbdxif2b5S5Tq7dOk
components-itemperformanceevent--timed-out-body-display--light:
hash: v1.k794b7964.4c0a64785d3a9f20db8cfd594e5a44ff7c05a3d9d6ea5ee3f20010f5c38e975a.q5lMkH4L2ZG9W4fO6WHCjJ6WTdiJTTlJktU2DSQQMK8
- components-markdown-editor-inline--bubble-menu-and-slash-commands--dark:
- hash: v1.k794b7964.a2c70c465689c5fbcb781e3748805a3411d8312a3b6fb512bb662273bfa8a6ed.L3RvOOkAyB_85uLzfdti9I2h96tS45LTWamutDYIMoE
- components-markdown-editor-inline--bubble-menu-and-slash-commands--light:
- hash: v1.k794b7964.ce4cfb7a8049f4fef713a05190254a444a427ec7b0533edf160125ac5308c8c2.MvcH46gZn7QLQGEl_ObYBErnY4kVp4MfgCOUYkdAy8w
- components-markdown-editor-inline--with-markdown--dark:
- hash: v1.k794b7964.b835503cc27461cd5a39a25ebf964cb9088891766a83cd2342e69885a498217b.Fi34ztIL4RhH9UgVUiSodrrDJkHJD6Smfv5O6Cx3kN0
- components-markdown-editor-inline--with-markdown--light:
- hash: v1.k794b7964.587ee9c518e75964953ec4e4e3ccedbf70942c08bc63943eace138eb416545bd.WTMWMG3NUwQSLFzsSftsOFKReSf95reqd_Z2ZDpZb5Q
- components-markdown-editor-inline--with-slash-commands--dark:
- hash: v1.k794b7964.d0e2ad002bf6d7126c2939fcf65a95ad02f915061ac39616f897c4c8f0b9cdef.Rlro8jpQStkVB6I7sLqygnNvq6WiVlgWK8XFlbLSyy0
- components-markdown-editor-inline--with-slash-commands--light:
- hash: v1.k794b7964.8b10234bf99bc2e9b1bae52af562885e611b6e65f8849e91545db592f90d4fbb.lIly8VIiaje29Y8EYFuK5AZ9WKskSJqe97MmbpjLbDo
components-markdown-editor-metric-definition--default--dark:
hash: v1.k794b7964.06b0579ec23e05a6250c87e79ed080c2e4fb2b7296979f06186fb31e47ae12fd.bXC6YLv3mFz35mSChoJX0grLmFhHkpFf3N55gVBWE_4
components-markdown-editor-metric-definition--default--light:
diff --git a/frontend/src/lib/charts/utils/format.test.ts b/frontend/src/lib/charts/utils/format.test.ts
deleted file mode 100644
index 0d61010a0703..000000000000
--- a/frontend/src/lib/charts/utils/format.test.ts
+++ /dev/null
@@ -1,106 +0,0 @@
-import { formatValue } from './format'
-
-describe('formatValue', () => {
- describe('number format', () => {
- it.each([
- { value: 0, expected: '0' },
- { value: 1234, expected: '1,234' },
- { value: 1234.567, expected: '1,234.57' },
- { value: -42, expected: '-42' },
- { value: 0.1 + 0.2, expected: '0.3' },
- ])('formats $value as $expected', ({ value, expected }) => {
- expect(formatValue(value, 'number')).toBe(expected)
- })
-
- it('respects decimalPlaces', () => {
- expect(formatValue(1234.5, 'number', { decimalPlaces: 0 })).toBe('1,235')
- expect(formatValue(1234.5, 'number', { decimalPlaces: 3 })).toBe('1,234.500')
- })
-
- it('defaults to number format when format is omitted', () => {
- expect(formatValue(1234)).toBe('1,234')
- })
- })
-
- describe('compact format', () => {
- it.each([
- { value: 0, expected: '0' },
- { value: 999, expected: '999' },
- { value: 1000, expected: '1.0K' },
- { value: 1500, expected: '1.5K' },
- { value: 1_000_000, expected: '1.0M' },
- { value: 2_500_000, expected: '2.5M' },
- { value: 1_000_000_000, expected: '1.0B' },
- { value: -1500, expected: '-1.5K' },
- { value: -2_500_000, expected: '-2.5M' },
- ])('formats $value as $expected', ({ value, expected }) => {
- expect(formatValue(value, 'compact')).toBe(expected)
- })
-
- it('respects decimalPlaces', () => {
- expect(formatValue(1234, 'compact', { decimalPlaces: 2 })).toBe('1.23K')
- expect(formatValue(1_500_000, 'compact', { decimalPlaces: 0 })).toBe('2M')
- })
- })
-
- describe('percent format', () => {
- it.each([
- { value: 0, expected: '0.0%' },
- { value: 0.5, expected: '50.0%' },
- { value: 1, expected: '100.0%' },
- { value: 0.123, expected: '12.3%' },
- { value: -0.05, expected: '-5.0%' },
- ])('formats $value as $expected', ({ value, expected }) => {
- expect(formatValue(value, 'percent')).toBe(expected)
- })
-
- it('respects decimalPlaces', () => {
- expect(formatValue(0.12345, 'percent', { decimalPlaces: 2 })).toBe('12.35%')
- expect(formatValue(0.5, 'percent', { decimalPlaces: 0 })).toBe('50%')
- })
- })
-
- describe('duration format', () => {
- it.each([
- { value: 0, expected: '0.0s' },
- { value: 30, expected: '30.0s' },
- { value: 59.9, expected: '59.9s' },
- { value: 60, expected: '1m 0s' },
- { value: 90, expected: '1m 30s' },
- { value: 3600, expected: '1h 0m' },
- { value: 5400, expected: '1h 30m' },
- { value: 86400, expected: '1d 0h' },
- { value: 90000, expected: '1d 1h' },
- { value: -90, expected: '-1m 30s' },
- ])('formats $value seconds as $expected', ({ value, expected }) => {
- expect(formatValue(value, 'duration')).toBe(expected)
- })
- })
-
- describe('duration_ms format', () => {
- it('converts milliseconds to seconds before formatting', () => {
- expect(formatValue(30000, 'duration_ms')).toBe('30.0s')
- expect(formatValue(90000, 'duration_ms')).toBe('1m 30s')
- })
- })
-
- describe('none format', () => {
- it('returns the raw value as a string', () => {
- expect(formatValue(1234.567, 'none')).toBe('1234.567')
- })
- })
-
- describe('prefix and suffix', () => {
- it('prepends prefix', () => {
- expect(formatValue(1234, 'number', { prefix: '$' })).toBe('$1,234')
- })
-
- it('appends suffix', () => {
- expect(formatValue(1234, 'number', { suffix: ' USD' })).toBe('1,234 USD')
- })
-
- it('applies both', () => {
- expect(formatValue(42, 'number', { prefix: '~', suffix: ' items' })).toBe('~42 items')
- })
- })
-})
diff --git a/frontend/src/lib/charts/utils/format.ts b/frontend/src/lib/charts/utils/format.ts
deleted file mode 100644
index 679e84c2c910..000000000000
--- a/frontend/src/lib/charts/utils/format.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import type { AxisFormat } from '../types'
-
-export function formatValue(
- value: number,
- format: AxisFormat = 'number',
- options?: { prefix?: string; suffix?: string; decimalPlaces?: number }
-): string {
- const prefix = options?.prefix ?? ''
- const suffix = options?.suffix ?? ''
- const decimals = options?.decimalPlaces
-
- let formatted: string
-
- switch (format) {
- case 'number':
- formatted = formatNumber(value, decimals)
- break
- case 'compact':
- formatted = formatCompact(value, decimals)
- break
- case 'percent':
- formatted = formatPercent(value, decimals)
- break
- case 'duration':
- formatted = formatDuration(value)
- break
- case 'duration_ms':
- formatted = formatDuration(value / 1000)
- break
- case 'date':
- formatted = formatDate(value)
- break
- case 'datetime':
- formatted = formatDateTime(value)
- break
- case 'none':
- formatted = String(value)
- break
- default:
- formatted = formatNumber(value, decimals)
- }
-
- return `${prefix}${formatted}${suffix}`
-}
-
-function formatNumber(value: number, decimalPlaces?: number): string {
- return value.toLocaleString('en-US', {
- minimumFractionDigits: decimalPlaces,
- maximumFractionDigits: decimalPlaces ?? 2,
- })
-}
-
-function formatCompact(value: number, decimalPlaces?: number): string {
- const abs = Math.abs(value)
- const dp = decimalPlaces ?? 1
-
- if (abs >= 1_000_000_000) {
- return `${(value / 1_000_000_000).toFixed(dp)}B`
- }
- if (abs >= 1_000_000) {
- return `${(value / 1_000_000).toFixed(dp)}M`
- }
- if (abs >= 1_000) {
- return `${(value / 1_000).toFixed(dp)}K`
- }
- return formatNumber(value, decimalPlaces)
-}
-
-function formatPercent(value: number, decimalPlaces?: number): string {
- return `${(value * 100).toFixed(decimalPlaces ?? 1)}%`
-}
-
-function formatDuration(seconds: number): string {
- const abs = Math.abs(seconds)
- const sign = seconds < 0 ? '-' : ''
-
- if (abs < 60) {
- return `${sign}${abs.toFixed(1)}s`
- }
- if (abs < 3600) {
- const m = Math.floor(abs / 60)
- const s = Math.round(abs % 60)
- return `${sign}${m}m ${s}s`
- }
- if (abs < 86400) {
- const h = Math.floor(abs / 3600)
- const m = Math.round((abs % 3600) / 60)
- return `${sign}${h}h ${m}m`
- }
- const d = Math.floor(abs / 86400)
- const h = Math.round((abs % 86400) / 3600)
- return `${sign}${d}d ${h}h`
-}
-
-function formatDate(timestamp: number): string {
- return new Date(timestamp).toLocaleDateString('en-US', {
- month: 'short',
- day: 'numeric',
- })
-}
-
-function formatDateTime(timestamp: number): string {
- return new Date(timestamp).toLocaleString('en-US', {
- month: 'short',
- day: 'numeric',
- hour: 'numeric',
- minute: '2-digit',
- })
-}
diff --git a/frontend/src/lib/components/MarkdownEditor/inline/InlineRichMarkdownEditor.stories.tsx b/frontend/src/lib/components/MarkdownEditor/inline/InlineRichMarkdownEditor.stories.tsx
deleted file mode 100644
index de1cc558a45a..000000000000
--- a/frontend/src/lib/components/MarkdownEditor/inline/InlineRichMarkdownEditor.stories.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import type { Meta, StoryObj } from '@storybook/react'
-import { Placeholder } from '@tiptap/extension-placeholder'
-import { useState } from 'react'
-
-import { TEXT_CARD_MARKDOWN_EXTENSIONS, textCardConverter } from 'lib/components/Cards/TextCard/textCardMarkdown'
-
-import { InlineRichMarkdownEditor, InlineRichMarkdownEditorProps } from './InlineRichMarkdownEditor'
-
-const INLINE_EXTENSIONS = [
- ...TEXT_CARD_MARKDOWN_EXTENSIONS,
- Placeholder.configure({ placeholder: 'Select text to open the bubble menu…' }),
-]
-
-const INLINE_EXTENSIONS_BUBBLE_AND_SLASH = [
- ...TEXT_CARD_MARKDOWN_EXTENSIONS,
- Placeholder.configure({
- placeholder: 'Select text for the bubble menu, or type / for slash commands…',
- }),
-]
-
-const storyDefaults = {
- extensions: INLINE_EXTENSIONS,
- markdownToDoc: textCardConverter.markdownToDoc,
- docToMarkdown: textCardConverter.docToMarkdown,
- dataAttr: 'story-inline-rich-markdown-editor',
-}
-
-type Story = StoryObj<InlineRichMarkdownEditorProps>
-
-const meta: Meta<InlineRichMarkdownEditorProps> = {
- title: 'Components/Markdown editor/Inline',
- component: InlineRichMarkdownEditor,
- tags: ['autodocs'],
- render: (props) => {
- const [value, setValue] = useState(props.value ?? '')
- return <InlineRichMarkdownEditor {...storyDefaults} {...props} value={value} onChange={setValue} />
- },
-}
-
-export default meta
-
-export const WithMarkdown: Story = {
- args: {
- value: `Select this paragraph to format it with the bubble menu.
-
-## Or use headings
-
-**Bold** and *italic* work too.`,
- },
-}
-
-export const WithSlashCommands: Story = {
- args: {
- value: 'Type / in the editor to open the command menu.',
- controls: { slashCommands: true },
- },
-}
-
-/** Bubble menu (selection) and `/` slash menu both enabled — default in product, shown here with helper copy. */
-export const BubbleMenuAndSlashCommands: Story = {
- args: {
- extensions: INLINE_EXTENSIONS_BUBBLE_AND_SLASH,
- value: `Select this sentence to open the **bubble** toolbar (bold, link, image, emoji, etc.).
-
-On a new line, type \`/\` to open **slash** commands — same capabilities grouped as Style and Insert.`,
- controls: { slashCommands: true, imageUpload: true, emoji: true },
- },
-}
diff --git a/frontend/src/lib/components/MarkdownEditor/inline/InlineRichMarkdownEditor.test.tsx b/frontend/src/lib/components/MarkdownEditor/inline/InlineRichMarkdownEditor.test.tsx
deleted file mode 100644
index df3f0a1b3ed9..000000000000
--- a/frontend/src/lib/components/MarkdownEditor/inline/InlineRichMarkdownEditor.test.tsx
+++ /dev/null
@@ -1,257 +0,0 @@
-import '@testing-library/jest-dom'
-
-import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
-
-import { useUploadFiles } from 'lib/hooks/useUploadFiles'
-
-import { initKeaTests } from '~/test/init'
-
-import { InlineRichMarkdownEditor } from './InlineRichMarkdownEditor'
-
-jest.mock('lib/hooks/useUploadFiles')
-
-const setContentMock = jest.fn()
-
-const fakeChain = {
- focus: () => fakeChain,
- setImage: () => fakeChain,
- insertContent: () => fakeChain,
- run: () => true,
-}
-
-const fakeEditor = {
- commands: {
- focus: jest.fn(),
- setContent: setContentMock,
- },
- getJSON: jest.fn(() => ({ type: 'doc' })),
- chain: () => fakeChain,
- isActive: jest.fn(() => false),
- getAttributes: jest.fn(() => ({})),
- on: jest.fn(),
- off: jest.fn(),
- isDestroyed: false,
- isInitialized: true,
- editorView: {
- dom: document.createElement('div'),
- },
-}
-
-jest.mock('lib/components/RichContentEditor', () => ({
- useRichContentEditor: jest.fn(() => fakeEditor),
-}))
-
-const mockUseUploadFiles = jest.mocked(useUploadFiles)
-
-jest.mock('@tiptap/react', () => ({
- ...jest.requireActual('@tiptap/react'),
- EditorContent: ({ className, ...props }: any) => <div className={className} {...props} />,
-}))
-
-jest.mock('@tiptap/react/menus', () => ({
- BubbleMenu: ({ children }: any) => <div data-attr="inline-bubble-menu">{children}</div>,
-}))
-
-describe('InlineRichMarkdownEditor', () => {
- beforeEach(() => {
- initKeaTests()
- jest.clearAllMocks()
- fakeEditor.editorView.dom = document.createElement('div')
- mockUseUploadFiles.mockReturnValue({
- setFilesToUpload: jest.fn(),
- filesToUpload: [],
- uploading: false,
- })
- })
-
- afterEach(() => {
- cleanup()
- })
-
- it('shows destructive counter styling when max length is exceeded', () => {
- render(
- <InlineRichMarkdownEditor
- value="123456789"
- maxLength={5}
- extensions={[]}
- markdownToDoc={() => ({ type: 'doc', content: [] })}
- docToMarkdown={() => '123456789'}
- />
- )
-
- const counter = screen.getByText('9/5 characters (limit reached)')
- expect(counter).toBeInTheDocument()
- expect(counter).toHaveClass('text-danger')
- })
-
- it('hides character count footer when characterCount is off', () => {
- render(
- <InlineRichMarkdownEditor
- value="hello"
- controls={{ characterCount: false }}
- extensions={[]}
- markdownToDoc={() => ({ type: 'doc', content: [] })}
- docToMarkdown={() => 'hello'}
- />
- )
-
- expect(screen.queryByText(/characters/)).not.toBeInTheDocument()
- })
-
- it('mounts bubble menu after editor is ready', async () => {
- render(
- <InlineRichMarkdownEditor
- value=""
- extensions={[]}
- markdownToDoc={() => ({ type: 'doc', content: [] })}
- docToMarkdown={() => ''}
- />
- )
-
- await waitFor(() => {
- expect(screen.getByTestId('inline-bubble-menu')).toBeInTheDocument()
- })
- })
-
- it('syncs editor content when controlled value changes', () => {
- let currentMarkdown = 'old value'
- const markdownToDoc = jest.fn((markdown: string | null | undefined) => ({
- type: 'doc',
- content: markdown ? [{ type: 'paragraph' }] : [],
- }))
- const docToMarkdown = jest.fn(() => currentMarkdown)
-
- const { rerender } = render(
- <InlineRichMarkdownEditor
- value="old value"
- extensions={[]}
- markdownToDoc={markdownToDoc}
- docToMarkdown={docToMarkdown}
- />
- )
-
- currentMarkdown = 'stale editor value'
- rerender(
- <InlineRichMarkdownEditor
- value="new value"
- extensions={[]}
- markdownToDoc={markdownToDoc}
- docToMarkdown={docToMarkdown}
- />
- )
-
- expect(markdownToDoc).toHaveBeenCalledWith('new value')
- expect(setContentMock).toHaveBeenCalledWith(expect.any(Object), { emitUpdate: false })
- })
-
- it('syncs latest markdown on form submit capture', () => {
- const onChange = jest.fn()
- const markdownToDoc = jest.fn(() => ({ type: 'doc', content: [] }))
- const initialDocToMarkdown = jest.fn(() => 'old value')
- const submitDocToMarkdown = jest.fn(() => 'latest resized markdown')
-
- const { container, rerender } = render(
- <form data-attr="inline-editor-form">
- <InlineRichMarkdownEditor
- value="old value"
- onChange={onChange}
- extensions={[]}
- markdownToDoc={markdownToDoc}
- docToMarkdown={initialDocToMarkdown}
- dataAttr="inline-rich-markdown-editor-area"
- />
- </form>
- )
-
- const editorDom = container.querySelector('[data-attr="inline-rich-markdown-editor-area"]') as HTMLDivElement
- Object.assign(fakeEditor.editorView, { dom: editorDom })
-
- rerender(
- <form data-attr="inline-editor-form">
- <InlineRichMarkdownEditor
- value="old value"
- onChange={onChange}
- extensions={[]}
- markdownToDoc={markdownToDoc}
- docToMarkdown={submitDocToMarkdown}
- dataAttr="inline-rich-markdown-editor-area"
- />
- </form>
- )
-
- fireEvent.submit(container.querySelector('form') as HTMLFormElement)
-
- expect(onChange).toHaveBeenCalledWith('latest resized markdown')
- })
-
- it('calls focus when autoFocus is true and editor dom is available', async () => {
- render(
- <InlineRichMarkdownEditor
- value=""
- autoFocus
- extensions={[]}
- markdownToDoc={() => ({ type: 'doc', content: [] })}
- docToMarkdown={() => ''}
- />
- )
-
- await waitFor(() => {
- expect(fakeEditor.commands.focus).toHaveBeenCalled()
- })
- })
-
- it('applies custom className to shell', () => {
- const { container } = render(
- <InlineRichMarkdownEditor
- value=""
- className="my-inline-editor"
- extensions={[]}
- markdownToDoc={() => ({ type: 'doc', content: [] })}
- docToMarkdown={() => ''}
- />
- )
-
- expect(container.querySelector('.my-inline-editor')).toBeInTheDocument()
- })
-
- it('accepts slash commands without throwing', () => {
- const { container } = render(
- <InlineRichMarkdownEditor
- value=""
- controls={{ slashCommands: true }}
- extensions={[]}
- markdownToDoc={() => ({ type: 'doc', content: [] })}
- docToMarkdown={() => ''}
- />
- )
-
- expect(container.querySelector('[data-attr="inline-rich-markdown-editor-area"]')).toBeInTheDocument()
- })
-
- it('feeds the slash image file input into the markdown upload hook', () => {
- const setFilesToUpload = jest.fn()
- mockUseUploadFiles.mockReturnValue({
- setFilesToUpload,
- filesToUpload: [],
- uploading: false,
- })
-
- const { container } = render(
- <InlineRichMarkdownEditor
- value=""
- controls={{ imageUpload: true, slashCommands: true }}
- extensions={[]}
- markdownToDoc={() => ({ type: 'doc', content: [] })}
- docToMarkdown={() => ''}
- />
- )
-
- const input = container.querySelector(
- '[data-attr="inline-rich-markdown-slash-image-input"]'
- ) as HTMLInputElement
- const file = new File(['x'], 'shot.png', { type: 'image/png' })
- fireEvent.change(input, { target: { files: [file] } })
-
- expect(setFilesToUpload).toHaveBeenCalledWith([file])
- })
-})
diff --git a/frontend/src/lib/components/MarkdownEditor/inline/InlineRichMarkdownEditor.tsx b/frontend/src/lib/components/MarkdownEditor/inline/InlineRichMarkdownEditor.tsx
deleted file mode 100644
index 3d4409eb7e6d..000000000000
--- a/frontend/src/lib/components/MarkdownEditor/inline/InlineRichMarkdownEditor.tsx
+++ /dev/null
@@ -1,256 +0,0 @@
-import { Editor, JSONContent } from '@tiptap/core'
-import { EditorContent, Extensions } from '@tiptap/react'
-import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
-import { flushSync } from 'react-dom'
-
-import 'lib/components/MarkdownEditor/shared/RichMarkdownEditor.scss'
-import { MarkdownEditorCharacterCountFooter } from 'lib/components/MarkdownEditor/shared/MarkdownEditorCharacterCountFooter'
-import { getTiptapEditorDom } from 'lib/components/MarkdownEditor/shared/tiptapEditorDom'
-import { useMarkdownEditorControlledAndFormEffects } from 'lib/components/MarkdownEditor/shared/useMarkdownEditorControlledAndFormEffects'
-import { useMarkdownEditorImageUpload } from 'lib/components/MarkdownEditor/shared/useMarkdownEditorImageUpload'
-import { useRichContentEditor } from 'lib/components/RichContentEditor'
-
-import {
- createInlineMarkdownSlashCommandsExtension,
- DEFAULT_INLINE_MARKDOWN_SLASH_COMMANDS,
- INLINE_MARKDOWN_SLASH_COMMANDS_PLUGIN_KEY,
- type InlineMarkdownSlashCommandItem,
- type InlineMarkdownSlashImageHostRef,
- type InlineMarkdownSlashLinkHostRef,
-} from './inlineMarkdownSlashCommands'
-import { RichMarkdownEditorBubbleMenu } from './RichMarkdownEditorBubbleMenu'
-
-export type InlineRichMarkdownEditorProps = {
- value?: string
- onChange?: (value: string) => void
- minRows?: number
- maxRows?: number
- maxLength?: number
- dataAttr?: string
- extensions: Extensions
- markdownToDoc: (markdown: string | null | undefined) => JSONContent
- docToMarkdown: (doc: JSONContent) => string
- autoFocus?: boolean
- className?: string
- /** Toggle individual features on/off. Any key omitted keeps its default. */
- controls?: {
- /** Bubble menu + slash-command image upload (requires object storage). Default true. */
- imageUpload?: boolean
- /** Bubble menu emoji picker. Default true. */
- emoji?: boolean
- /** Append `/` slash command menu (grouped sections, filter as you type). Default false. */
- slashCommands?: boolean
- /** Character count footer. Default true. */
- characterCount?: boolean
- }
- /** Custom slash items when `controls.slashCommands` is on (defaults match bubble / rich formatting toolbar) */
- slashCommandItems?: InlineMarkdownSlashCommandItem[]
-}
-
-/**
- * BubbleMenu registers ProseMirror plugins that touch editor.view immediately. Tiptap only sets
- * editorView and emits `create` after mount (see Editor.mount). Defer the bubble until then so
- * Storybook / Strict Mode don't crash.
- */
-function useBubbleMenuSafeToMount(editor: Editor | null): boolean {
- const [ready, setReady] = useState(false)
-
- useEffect(() => {
- if (!editor) {
- setReady(false)
- return
- }
-
- const markReady = (): void => {
- setReady(true)
- }
-
- if (editor.isInitialized) {
- markReady()
- } else {
- editor.on('create', markReady)
- }
-
- return () => {
- editor.off('create', markReady)
- setReady(false)
- }
- }, [editor])
-
- return ready
-}
-
-/**
- * Markdown editor with a Notion-style bubble menu on text selection (no fixed formatting toolbar).
- * For tabs + toolbar + preview, use `RichMarkdownEditor` (`MarkdownEditor/rich/`).
- */
-export function InlineRichMarkdownEditor({
- value,
- onChange,
- minRows = 8,
- maxRows = 20,
- maxLength = 4000,
- dataAttr = 'inline-rich-markdown-editor-area',
- extensions,
- markdownToDoc,
- docToMarkdown,
- autoFocus = false,
- className = '',
- controls,
- slashCommandItems,
-}: InlineRichMarkdownEditorProps): JSX.Element {
- const showImageUpload = controls?.imageUpload ?? true
- const showEmoji = controls?.emoji ?? true
- const showSlashCommands = controls?.slashCommands ?? false
- const showCharacterCount = controls?.characterCount ?? true
- const [linkUrl, setLinkUrl] = useState('')
- const [showLinkPopover, setShowLinkPopover] = useState(false)
- const [linkPopoverReferenceElement, setLinkPopoverReferenceElement] = useState<HTMLElement | null>(null)
- const lastSyncedMarkdownRef = useRef(value || '')
- const dropRef = useRef<HTMLDivElement>(null)
- const slashImageFileInputRef = useRef<HTMLInputElement>(null)
- const slashImageHostRef = useRef<InlineMarkdownSlashImageHostRef | null>(null)
- const slashLinkHostRef = useRef<InlineMarkdownSlashLinkHostRef | null>(null)
- const setSlashImageFilesRef = useRef<(files: File[]) => void>(() => {})
-
- const clearLinkPopoverReference = useCallback(() => setLinkPopoverReferenceElement(null), [])
-
- const setShowLinkPopoverTracked = useCallback((visible: boolean): void => {
- setShowLinkPopover(visible)
- if (!visible) {
- setLinkPopoverReferenceElement(null)
- }
- }, [])
-
- const syncMarkdownFromEditor = useCallback(
- (nextMarkdown: string, options?: { force?: boolean }): void => {
- if (nextMarkdown === lastSyncedMarkdownRef.current) {
- return
- }
-
- lastSyncedMarkdownRef.current = nextMarkdown
- if (options?.force) {
- flushSync(() => onChange?.(nextMarkdown))
- return
- }
-
- onChange?.(nextMarkdown)
- },
- [onChange]
- )
-
- const resolvedExtensions = useMemo((): Extensions => {
- if (!showSlashCommands) {
- return extensions
- }
- return [
- ...extensions,
- createInlineMarkdownSlashCommandsExtension(
- INLINE_MARKDOWN_SLASH_COMMANDS_PLUGIN_KEY,
- slashCommandItems ?? DEFAULT_INLINE_MARKDOWN_SLASH_COMMANDS,
- { slashImageHostRef, slashLinkHostRef }
- ),
- ]
- }, [extensions, showSlashCommands, slashCommandItems])
-
- const editor = useRichContentEditor({
- extensions: resolvedExtensions,
- initialContent: markdownToDoc(value),
- onUpdate: (content) => syncMarkdownFromEditor(docToMarkdown(content)),
- })
-
- const { setFilesToUpload } = useMarkdownEditorImageUpload(editor)
-
- const bubbleMenuSafeToMount = useBubbleMenuSafeToMount(editor)
-
- useEffect(() => {
- if (!editor || !autoFocus || !getTiptapEditorDom(editor)) {
- return
- }
- // Match RichMarkdownEditor: defer focus so Safari does not race TipTap transactions.
- const id = window.setTimeout(() => {
- if (!editor.isDestroyed) {
- editor.commands.focus()
- }
- }, 0)
- return () => window.clearTimeout(id)
- }, [editor, autoFocus, editor?.isInitialized])
-
- useMarkdownEditorControlledAndFormEffects({
- editor,
- value,
- markdownToDoc,
- docToMarkdown,
- lastSyncedMarkdownRef,
- syncMarkdownFromEditor,
- })
-
- setSlashImageFilesRef.current = setFilesToUpload
- slashImageHostRef.current = {
- pick: () => {
- slashImageFileInputRef.current?.click()
- },
- showSlashImageUpload: showImageUpload,
- }
- slashLinkHostRef.current = {
- openLinkPopover: () => {
- if (!editor) {
- return
- }
- const previousUrl = editor.getAttributes('link').href || ''
- setLinkUrl(String(previousUrl ?? ''))
- setLinkPopoverReferenceElement(getTiptapEditorDom(editor) ?? null)
- setShowLinkPopover(true)
- },
- }
-
- const currentMarkdown = editor ? docToMarkdown(editor.getJSON()) : value || ''
-
- return (
- <div ref={dropRef} className={`RichMarkdownEditor border rounded overflow-hidden ${className}`.trim()}>
- {/*
- EditorContent must mount before BubbleMenu: Tiptap creates editor.view in EditorContent's
- componentDidMount; BubbleMenu reads view.dom on mount and crashes if this runs first.
- */}
- <EditorContent
- editor={editor}
- className="RichMarkdownEditor__content px-3 py-2 overflow-auto"
- style={{ minHeight: `${minRows * 1.5}em`, maxHeight: `${maxRows * 1.5}em` }}
- data-attr={dataAttr}
- />
- {bubbleMenuSafeToMount ? (
- <RichMarkdownEditorBubbleMenu
- editor={editor}
- linkUrl={linkUrl}
- setLinkUrl={setLinkUrl}
- showLinkPopover={showLinkPopover}
- setShowLinkPopover={setShowLinkPopoverTracked}
- linkPopoverReferenceElement={linkPopoverReferenceElement}
- clearLinkPopoverReference={clearLinkPopoverReference}
- alternativeDropTargetRef={dropRef}
- showImageUpload={showImageUpload}
- showEmoji={showEmoji}
- />
- ) : null}
- {showCharacterCount ? (
- <MarkdownEditorCharacterCountFooter currentLength={currentMarkdown.length} maxLength={maxLength} />
- ) : null}
- <input
- ref={slashImageFileInputRef}
- type="file"
- accept="image/*"
- className="hidden"
- aria-hidden
- tabIndex={-1}
- data-attr="inline-rich-markdown-slash-image-input"
- onChange={(e) => {
- const { files } = e.target
- if (files?.length) {
- setSlashImageFilesRef.current(Array.from(files))
- }
- e.target.value = ''
- }}
- />
- </div>
- )
-}
diff --git a/frontend/src/lib/components/MarkdownEditor/inline/RichMarkdownEditorBubbleMenu.tsx b/frontend/src/lib/components/MarkdownEditor/inline/RichMarkdownEditorBubbleMenu.tsx
deleted file mode 100644
index a554c2d20f49..000000000000
--- a/frontend/src/lib/components/MarkdownEditor/inline/RichMarkdownEditorBubbleMenu.tsx
+++ /dev/null
@@ -1,117 +0,0 @@
-import { Editor, isTextSelection } from '@tiptap/core'
-import type { EditorState } from '@tiptap/pm/state'
-import { BubbleMenu } from '@tiptap/react/menus'
-import { useCallback, useMemo, useRef, type RefObject } from 'react'
-
-import { LemonDivider } from '@posthog/lemon-ui'
-
-import { MarkdownEditorImageEmojiControls } from 'lib/components/MarkdownEditor/shared/MarkdownEditorImageEmojiControls'
-import { RichMarkdownEditorFormatControls } from 'lib/components/MarkdownEditor/shared/RichMarkdownEditorFormatControls'
-
-export type RichMarkdownEditorBubbleMenuProps = {
- editor: Editor | null
- linkUrl: string
- setLinkUrl: (url: string) => void
- showLinkPopover: boolean
- setShowLinkPopover: (visible: boolean) => void
- linkPopoverReferenceElement?: HTMLElement | null
- clearLinkPopoverReference?: () => void
- /** Editor shell (or content wrapper) used as drag-and-drop target for images */
- alternativeDropTargetRef: RefObject<HTMLElement | null>
- showImageUpload?: boolean
- showEmoji?: boolean
- emojiPopoverDataAttr?: string
-}
-
-export function RichMarkdownEditorBubbleMenu({
- editor,
- linkUrl,
- setLinkUrl,
- showLinkPopover,
- setShowLinkPopover,
- linkPopoverReferenceElement = null,
- clearLinkPopoverReference,
- alternativeDropTargetRef,
- showImageUpload = true,
- showEmoji = true,
- emojiPopoverDataAttr = 'inline-rich-markdown-bubble-emoji-popover',
-}: RichMarkdownEditorBubbleMenuProps): JSX.Element | null {
- const menuRef = useRef<HTMLDivElement>(null)
-
- // Stable references: BubbleMenu re-runs plugin registration when these identities change.
- const shouldShow = useCallback(
- ({
- editor: { isEditable },
- view,
- state,
- from,
- to,
- }: {
- editor: Editor
- view: Editor['view']
- state: EditorState
- from: number
- to: number
- }) => {
- if (!isEditable) {
- return false
- }
-
- const isChildOfMenu = menuRef.current?.contains(document.activeElement)
- if (isChildOfMenu) {
- return true
- }
-
- const focused = view.hasFocus()
- const isTextBlock = isTextSelection(state.selection)
-
- if (!focused || !isTextBlock) {
- return false
- }
-
- return state.doc.textBetween(from, to).length > 0
- },
- []
- )
-
- const bubbleOptions = useMemo(() => ({ placement: 'top-start' as const }), [])
-
- if (!editor) {
- return null
- }
-
- const showMedia = showImageUpload || showEmoji
-
- return (
- <BubbleMenu editor={editor} shouldShow={shouldShow} options={bubbleOptions}>
- <div
- ref={menuRef}
- className="RichMarkdownEditor__bubble flex max-w-[min(100vw-2rem,56rem)] flex-nowrap items-center gap-x-0.5 overflow-x-auto overscroll-x-contain rounded border border-primary bg-surface-primary p-1 text-secondary shadow-md [scrollbar-width:thin]"
- >
- <div className="flex shrink-0 items-center gap-0.5">
- <RichMarkdownEditorFormatControls
- editor={editor}
- linkUrl={linkUrl}
- setLinkUrl={setLinkUrl}
- showLinkPopover={showLinkPopover}
- setShowLinkPopover={setShowLinkPopover}
- linkPopoverReferenceElement={linkPopoverReferenceElement}
- clearLinkPopoverReference={clearLinkPopoverReference}
- />
- </div>
- {showMedia ? (
- <div className="flex shrink-0 items-center gap-0.5">
- <LemonDivider vertical className="mx-1 self-stretch" />
- <MarkdownEditorImageEmojiControls
- editor={editor}
- alternativeDropTargetRef={alternativeDropTargetRef}
- emojiPopoverDataAttr={emojiPopoverDataAttr}
- showImageUpload={showImageUpload}
- showEmoji={showEmoji}
- />
- </div>
- ) : null}
- </div>
- </BubbleMenu>
- )
-}
diff --git a/frontend/src/lib/hooks/useLingeringTooltip.test.tsx b/frontend/src/lib/hooks/useLingeringTooltip.test.tsx
deleted file mode 100644
index 9a9c6af25d5d..000000000000
--- a/frontend/src/lib/hooks/useLingeringTooltip.test.tsx
+++ /dev/null
@@ -1,107 +0,0 @@
-import { act, renderHook } from '@testing-library/react'
-
-import { LINGERING_TOOLTIP_MS, useLingeringTooltip } from './useLingeringTooltip'
-
-describe('useLingeringTooltip', () => {
- beforeEach(() => {
- jest.useFakeTimers()
- })
-
- afterEach(() => {
- jest.useRealTimers()
- })
-
- it('passes the chart visibility straight through when disabled', () => {
- const { result, rerender } = renderHook(({ chartVisible }) => useLingeringTooltip(chartVisible, false), {
- initialProps: { chartVisible: true },
- })
- expect(result.current.visible).toBe(true)
-
- rerender({ chartVisible: false })
- expect(result.current.visible).toBe(false)
- })
-
- it('lingers after the chart hides so the pointer can reach the tooltip, then hides', () => {
- const { result, rerender } = renderHook(({ chartVisible }) => useLingeringTooltip(chartVisible, true), {
- initialProps: { chartVisible: true },
- })
- expect(result.current.visible).toBe(true)
-
- rerender({ chartVisible: false })
- // Still up — this window is the whole point: without it the pointer never arrives.
- expect(result.current.visible).toBe(true)
-
- act(() => {
- jest.advanceTimersByTime(LINGERING_TOOLTIP_MS)
- })
- expect(result.current.visible).toBe(false)
- })
-
- it('holds the tooltip open indefinitely while the pointer is over it', () => {
- const { result, rerender } = renderHook(({ chartVisible }) => useLingeringTooltip(chartVisible, true), {
- initialProps: { chartVisible: true },
- })
-
- rerender({ chartVisible: false })
- act(() => {
- result.current.onMouseEnter()
- })
-
- act(() => {
- jest.advanceTimersByTime(LINGERING_TOOLTIP_MS * 20)
- })
- expect(result.current.visible).toBe(true)
- })
-
- it('hides once the pointer leaves the tooltip', () => {
- const { result, rerender } = renderHook(({ chartVisible }) => useLingeringTooltip(chartVisible, true), {
- initialProps: { chartVisible: true },
- })
-
- rerender({ chartVisible: false })
- act(() => {
- result.current.onMouseEnter()
- })
- act(() => {
- jest.advanceTimersByTime(LINGERING_TOOLTIP_MS * 5)
- })
- expect(result.current.visible).toBe(true)
-
- act(() => {
- result.current.onMouseLeave()
- })
- act(() => {
- jest.advanceTimersByTime(LINGERING_TOOLTIP_MS)
- })
- expect(result.current.visible).toBe(false)
- })
-
- it('re-shows immediately when the pointer returns to the chart mid-linger', () => {
- const { result, rerender } = renderHook(({ chartVisible }) => useLingeringTooltip(chartVisible, true), {
- initialProps: { chartVisible: true },
- })
-
- rerender({ chartVisible: false })
- rerender({ chartVisible: true })
- act(() => {
- jest.advanceTimersByTime(LINGERING_TOOLTIP_MS * 3)
- })
- expect(result.current.visible).toBe(true)
- })
-
- it('does not stay wedged open when the behaviour is disabled mid-hover', () => {
- const { result, rerender } = renderHook(
- ({ chartVisible, enabled }) => useLingeringTooltip(chartVisible, enabled),
- { initialProps: { chartVisible: true, enabled: true } }
- )
-
- rerender({ chartVisible: false, enabled: true })
- act(() => {
- result.current.onMouseEnter()
- })
- expect(result.current.visible).toBe(true)
-
- rerender({ chartVisible: false, enabled: false })
- expect(result.current.visible).toBe(false)
- })
-})
diff --git a/frontend/src/lib/hooks/useLingeringTooltip.ts b/frontend/src/lib/hooks/useLingeringTooltip.ts
deleted file mode 100644
index 55be0a57b076..000000000000
--- a/frontend/src/lib/hooks/useLingeringTooltip.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import { useEffect, useState } from 'react'
-
-/** How long the tooltip stays up after the chart stops reporting a hover, to let the pointer reach it. */
-export const LINGERING_TOOLTIP_MS = 300
-
-export interface LingeringTooltip {
- visible: boolean
- onMouseEnter: () => void
- onMouseLeave: () => void
-}
-
-/**
- * Keeps a chart's hover tooltip open long enough for the pointer to travel from the canvas onto the
- * tooltip itself, so one taller than its max height can be scrolled. Charting libraries hide the
- * tooltip the instant the pointer leaves the canvas — which is before it can ever reach the
- * tooltip — so without a grace period an interactive tooltip is unreachable.
- *
- * Pass the chart's own notion of tooltip visibility as `chartVisible`, and spread the returned
- * mouse handlers onto the tooltip overlay. While the pointer is over the overlay the tooltip is
- * held open indefinitely; once it leaves, the grace period runs again and then it hides.
- *
- * When `enabled` is false this is a pass-through, so callers can keep the default
- * non-interactive behaviour (an interactive tooltip overlays the canvas and swallows its clicks).
- */
-export function useLingeringTooltip(chartVisible: boolean, enabled: boolean): LingeringTooltip {
- const [hovered, setHovered] = useState(false)
- const [lingering, setLingering] = useState(false)
-
- useEffect(() => {
- if (!enabled) {
- return
- }
- if (chartVisible) {
- setLingering(true)
- return
- }
- // Hold indefinitely while the pointer is on the tooltip; the timer restarts when it leaves.
- if (!lingering || hovered) {
- return
- }
- const timeout = setTimeout(() => setLingering(false), LINGERING_TOOLTIP_MS)
- return () => clearTimeout(timeout)
- }, [enabled, chartVisible, lingering, hovered])
-
- useEffect(() => {
- // Turning the behaviour off mid-hover would otherwise wedge the tooltip open forever.
- if (!enabled) {
- setHovered(false)
- setLingering(false)
- }
- }, [enabled])
-
- return {
- visible: enabled ? chartVisible || lingering || hovered : chartVisible,
- onMouseEnter: () => setHovered(true),
- onMouseLeave: () => setHovered(false),
- }
-}
diff --git a/frontend/src/scenes/experiments/ExperimentForm/ExperimentTypePanel.test.tsx b/frontend/src/scenes/experiments/ExperimentForm/ExperimentTypePanel.test.tsx
deleted file mode 100644
index 99f555b53f60..000000000000
--- a/frontend/src/scenes/experiments/ExperimentForm/ExperimentTypePanel.test.tsx
+++ /dev/null
@@ -1,170 +0,0 @@
-import '@testing-library/jest-dom'
-
-import { cleanup, render, screen } from '@testing-library/react'
-import userEvent from '@testing-library/user-event'
-
-import { NEW_EXPERIMENT } from 'products/experiments/frontend/constants'
-
-import { ExperimentTypePanel } from './ExperimentTypePanel'
-
-describe('ExperimentTypePanel', () => {
- const mockSetExperimentType = jest.fn()
-
- beforeEach(() => {
- jest.clearAllMocks()
- })
-
- afterEach(() => {
- cleanup()
- })
-
- describe('rendering', () => {
- it('renders both experiment type options', () => {
- const { container } = render(
- <ExperimentTypePanel
- experiment={{ ...NEW_EXPERIMENT, type: 'product' }}
- setExperimentType={mockSetExperimentType}
- />
- )
-
- expect(screen.getByText('Product experiment')).toBeInTheDocument()
- expect(screen.getByText('Use custom code to manage how variants modify your product.')).toBeInTheDocument()
-
- expect(screen.getByText(/No-Code experiment/)).toBeInTheDocument()
- expect(
- screen.getByText('Define variants on your website using the PostHog toolbar, no coding required.')
- ).toBeInTheDocument()
-
- const cards = container.querySelectorAll('[role="button"]')
- expect(cards).toHaveLength(2)
- })
-
- it('shows Beta tag on no-code experiment option', () => {
- render(
- <ExperimentTypePanel
- experiment={{ ...NEW_EXPERIMENT, type: 'product' }}
- setExperimentType={mockSetExperimentType}
- />
- )
-
- expect(screen.getByText('Beta')).toBeInTheDocument()
- })
-
- it('highlights selected option with check icon', () => {
- const { container, rerender } = render(
- <ExperimentTypePanel
- experiment={{ ...NEW_EXPERIMENT, type: 'product' }}
- setExperimentType={mockSetExperimentType}
- />
- )
-
- const cards = container.querySelectorAll('[role="button"]')
- const productCard = cards[0]
- const noCodeCard = cards[1]
-
- expect(productCard).toHaveClass('border-accent')
- expect(productCard).toHaveAttribute('aria-pressed', 'true')
-
- expect(noCodeCard).not.toHaveClass('border-accent')
- expect(noCodeCard).toHaveAttribute('aria-pressed', 'false')
-
- rerender(
- <ExperimentTypePanel
- experiment={{ ...NEW_EXPERIMENT, type: 'web' }}
- setExperimentType={mockSetExperimentType}
- />
- )
-
- const updatedCards = container.querySelectorAll('[role="button"]')
- const updatedProductCard = updatedCards[0]
- const updatedNoCodeCard = updatedCards[1]
-
- expect(updatedProductCard).not.toHaveClass('border-accent')
- expect(updatedProductCard).toHaveAttribute('aria-pressed', 'false')
-
- expect(updatedNoCodeCard).toHaveClass('border-accent')
- expect(updatedNoCodeCard).toHaveAttribute('aria-pressed', 'true')
- })
- })
-
- describe('interactions', () => {
- it('calls setExperimentType with "product" when clicking product card', async () => {
- const { container } = render(
- <ExperimentTypePanel
- experiment={{ ...NEW_EXPERIMENT, type: 'web' }}
- setExperimentType={mockSetExperimentType}
- />
- )
-
- const cards = container.querySelectorAll('[role="button"]')
- const productCard = cards[0]
- await userEvent.click(productCard)
-
- expect(mockSetExperimentType).toHaveBeenCalledWith('product')
- expect(mockSetExperimentType).toHaveBeenCalledTimes(1)
- })
-
- it('calls setExperimentType with "web" when clicking no-code card', async () => {
- const { container } = render(
- <ExperimentTypePanel
- experiment={{ ...NEW_EXPERIMENT, type: 'product' }}
- setExperimentType={mockSetExperimentType}
- />
- )
-
- const cards = container.querySelectorAll('[role="button"]')
- const noCodeCard = cards[1]
- await userEvent.click(noCodeCard)
-
- expect(mockSetExperimentType).toHaveBeenCalledWith('web')
- expect(mockSetExperimentType).toHaveBeenCalledTimes(1)
- })
-
- it('supports keyboard navigation with Enter key', async () => {
- const { container } = render(
- <ExperimentTypePanel
- experiment={{ ...NEW_EXPERIMENT, type: 'product' }}
- setExperimentType={mockSetExperimentType}
- />
- )
-
- const cards = container.querySelectorAll('[role="button"]')
- const noCodeCard = cards[1] as HTMLElement
- noCodeCard.focus()
- await userEvent.keyboard('{Enter}')
-
- expect(mockSetExperimentType).toHaveBeenCalledWith('web')
- })
-
- it('supports keyboard navigation with Space key', async () => {
- const { container } = render(
- <ExperimentTypePanel
- experiment={{ ...NEW_EXPERIMENT, type: 'product' }}
- setExperimentType={mockSetExperimentType}
- />
- )
-
- const cards = container.querySelectorAll('[role="button"]')
- const noCodeCard = cards[1] as HTMLElement
- noCodeCard.focus()
- await userEvent.keyboard(' ')
-
- expect(mockSetExperimentType).toHaveBeenCalledWith('web')
- })
-
- it('calls setExperimentType even when clicking already selected option', async () => {
- const { container } = render(
- <ExperimentTypePanel
- experiment={{ ...NEW_EXPERIMENT, type: 'product' }}
- setExperimentType={mockSetExperimentType}
- />
- )
-
- const cards = container.querySelectorAll('[role="button"]')
- const productCard = cards[0]
- await userEvent.click(productCard)
-
- expect(mockSetExperimentType).toHaveBeenCalledWith('product')
- })
- })
-})
diff --git a/frontend/src/scenes/experiments/ExperimentForm/ExperimentTypePanel.tsx b/frontend/src/scenes/experiments/ExperimentForm/ExperimentTypePanel.tsx
deleted file mode 100644
index bf9e2075cea1..000000000000
--- a/frontend/src/scenes/experiments/ExperimentForm/ExperimentTypePanel.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import { LemonTag } from 'lib/lemon-ui/LemonTag'
-import { SelectableCard } from 'scenes/experiments/components/SelectableCard'
-
-import type { Experiment } from '~/types'
-
-type ExperimentTypePanelProps = {
- experiment: Experiment
- setExperimentType: (type: 'product' | 'web') => void
-}
-
-export const ExperimentTypePanel = ({ experiment, setExperimentType }: ExperimentTypePanelProps): JSX.Element => (
- <div className="flex gap-4">
- <SelectableCard
- title="Product experiment"
- description="Use custom code to manage how variants modify your product."
- selected={experiment.type === 'product'}
- onClick={() => setExperimentType('product')}
- />
- <SelectableCard
- title={
- <span>
- No-Code experiment&nbsp;
- <LemonTag type="option" size="small">
- Beta
- </LemonTag>
- </span>
- }
- description="Define variants on your website using the PostHog toolbar, no coding required."
- selected={experiment.type === 'web'}
- onClick={() => setExperimentType('web')}
- />
- </div>
-)
diff --git a/products/posthog_ai/frontend/components/RunComposer.test.tsx b/products/posthog_ai/frontend/components/RunComposer.test.tsx
deleted file mode 100644
index 9e694a200bba..000000000000
--- a/products/posthog_ai/frontend/components/RunComposer.test.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import '@testing-library/jest-dom'
-
-import { cleanup, fireEvent, render, screen } from '@testing-library/react'
-
-import { RunComposer } from './RunComposer'
-
-describe('RunComposer', () => {
- const onChange = jest.fn()
- const onSubmit = jest.fn()
-
- beforeEach(() => {
- jest.clearAllMocks()
- })
-
- afterEach(() => {
- cleanup()
- })
-
- const renderComposer = (props: Partial<Parameters<typeof RunComposer>[0]> = {}): ReturnType<typeof render> =>
- render(<RunComposer value="" onChange={onChange} onSubmit={onSubmit} {...props} />)
-
- const getSendButton = (container: HTMLElement): HTMLButtonElement =>
- container.querySelector('[data-attr="sandbox-composer-send"]') as HTMLButtonElement
-
- const getTextArea = (): HTMLTextAreaElement => screen.getByRole('textbox') as HTMLTextAreaElement
-
- it('shows the placeholder when empty and hides it once there is a value', () => {
- const { rerender } = renderComposer({ placeholder: 'Send a follow-up message…' })
- expect(screen.getByText('Send a follow-up message…')).toBeInTheDocument()
-
- rerender(
- <RunComposer value="hi" onChange={onChange} onSubmit={onSubmit} placeholder="Send a follow-up message…" />
- )
- expect(screen.queryByText('Send a follow-up message…')).not.toBeInTheDocument()
- })
-
- it('relays typing through onChange', () => {
- renderComposer()
- fireEvent.change(getTextArea(), { target: { value: 'hello' } })
- expect(onChange).toHaveBeenCalledWith('hello')
- })
-
- it('disables send and does not submit when the input is empty', () => {
- const { container } = renderComposer({ value: ' ' })
- expect(getSendButton(container)).toHaveAttribute('aria-disabled', 'true')
- fireEvent.click(getSendButton(container))
- expect(onSubmit).not.toHaveBeenCalled()
- })
-
- it('submits when there is a non-empty value', () => {
- const { container } = renderComposer({ value: 'ship it' })
- fireEvent.click(getSendButton(container))
- expect(onSubmit).toHaveBeenCalledTimes(1)
- })
-
- it('blocks submission while loading', () => {
- const { container } = renderComposer({ value: 'ship it', loading: true })
- expect(getSendButton(container)).toHaveAttribute('aria-disabled', 'true')
- fireEvent.click(getSendButton(container))
- expect(onSubmit).not.toHaveBeenCalled()
- })
-})
diff --git a/products/posthog_ai/frontend/components/RunComposer.tsx b/products/posthog_ai/frontend/components/RunComposer.tsx
deleted file mode 100644
index b33466a13591..000000000000
--- a/products/posthog_ai/frontend/components/RunComposer.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import { Composer } from './composer/Composer'
-
-export interface RunComposerProps {
- value: string
- onChange: (value: string) => void
- onSubmit: () => void
- placeholder?: string
- /** Shows the send button as in-flight and blocks submission while true. */
- loading?: boolean
- /** Extra reason to block the send button (empty input is handled internally). */
- disabledReason?: string
- autoFocus?: boolean
- className?: string
-}
-
-/**
- * Prepackaged composer for the sandbox run surface — a thin composition of the logic-free
- * {@link Composer} primitives that reproduces the PostHog AI input look (bordered rounded container,
- * large textarea with an overlaid placeholder, an absolutely-positioned primary send button) without
- * any of PostHog AI's conversation-only features. It holds no draft or send state of its own: callers
- * own the value and the submit handler. Surfaces that need to slot extra chrome should compose the
- * `Composer.*` parts directly instead of using this wrapper.
- */
-export function RunComposer({
- value,
- onChange,
- onSubmit,
- placeholder = 'Send a follow-up message…',
- loading = false,
- disabledReason,
- autoFocus,
- className,
-}: RunComposerProps): JSX.Element {
- return (
- <Composer.Root
- value={value}
- onChange={onChange}
- onSubmit={onSubmit}
- loading={loading}
- disabledReason={disabledReason}
- className={className}
- >
- <Composer.Frame>
- <Composer.Field>
- <Composer.Placeholder>{placeholder}</Composer.Placeholder>
- <Composer.Textarea data-attr="sandbox-composer-input" autoFocus={autoFocus} />
- </Composer.Field>
- </Composer.Frame>
- <Composer.Submit data-attr="sandbox-composer-send" />
- </Composer.Root>
- )
-}