: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
revert(phai): restore LemonTextArea in composers (#69739)
Georgiy Tarasov1aad46855b56
diff --git a/frontend/src/scenes/max/components/QuestionInput.tsx b/frontend/src/scenes/max/components/QuestionInput.tsxindex 12ec31fd0443..97c41d3cf2e9 100644--- a/frontend/src/scenes/max/components/QuestionInput.tsx+++ b/frontend/src/scenes/max/components/QuestionInput.tsx@@ -7,7 +7,7 @@ import React, { ReactNode, useEffect, useMemo, useRef, useState } from 'react'import { useDebouncedCallback } from 'use-debounce'import { IconArrowRight, IconCheck, IconPencil, IconStopFilled, IconTrash, IconX } from '@posthog/icons'-import { LemonButton, LemonSwitch, Spinner } from '@posthog/lemon-ui'+import { LemonButton, LemonSwitch, LemonTextArea, Spinner } from '@posthog/lemon-ui'import { KeyboardShortcut } from 'lib/components/KeyboardShortcut/KeyboardShortcut'import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'@@ -18,8 +18,6 @@ import { userLogic } from 'scenes/userLogic'import { AgentMode } from '~/queries/schema/schema-assistant-messages'import { ConversationQueueMessage } from '~/types'-import { AutosizeTextArea } from 'products/posthog_ai/frontend/api/primitives'-import { ContextDisplay } from '../Context'import { handsFreeLogic } from '../handsFreeLogic'import { maxGlobalLogic } from '../maxGlobalLogic'@@ -77,7 +75,7 @@ function QueuedMessageItem({if (isEditing) {return (<div className="space-y-2">- <AutosizeTextArea+ <LemonTextArearef={textAreaRef}value={draft}onChange={setDraft}@@ -390,7 +388,7 @@ export const QuestionInput = React.forwardRef<HTMLDivElement, QuestionInputProps<FillInHint text={inputValue} hint={fillInHint} /></div>)}- <AutosizeTextArea+ <LemonTextAreaaria-describedby={!inputValue ? 'textarea-hint' : undefined}id="question-input"data-attr="max-chat-input"@@ -448,9 +446,8 @@ export const QuestionInput = React.forwardRef<HTMLDivElement, QuestionInputPropsdisabled={inputDisabled}minRows={1}maxRows={10}- className="py-2 pl-2"- textareaClassName={cn(- '!border-none !bg-transparent min-h-16 resize-none',+ className={cn(+ '!border-none !bg-transparent min-h-16 py-2 pl-2 resize-none',handsFreeFlagEnabled ? 'pr-20' : 'pr-12',// Hide the native caret so only the enlarged fill-in caret shows.showFillInHint && 'caret-transparent'diff --git a/frontend/src/scenes/max/components/SlashCommandAutocomplete.tsx b/frontend/src/scenes/max/components/SlashCommandAutocomplete.tsxindex 73d4cf40ccca..ae97588e680a 100644--- a/frontend/src/scenes/max/components/SlashCommandAutocomplete.tsx+++ b/frontend/src/scenes/max/components/SlashCommandAutocomplete.tsx@@ -67,7 +67,7 @@ export function SlashCommandAutocomplete({ onClose, visible, children }: SlashCoactivateCommand(filteredCommands[activeItemIndex])}}- document.addEventListener('keydown', handleKeyDown, { capture: true }) // Capture phase to run this before AutosizeTextArea's onEnter+ document.addEventListener('keydown', handleKeyDown, { capture: true }) // Capture phase to run this before LemonTextArea's onEnterreturn () => document.removeEventListener('keydown', handleKeyDown, { capture: true })}, [visible, filteredCommands, activeItemIndex, activateCommand, selectCommand, onClose])diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 3ee9117aae99..be7d18e71a57 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -3992,9 +3992,6 @@ importers:react-intersection-observer:specifier: ^9.5.3version: 9.5.3([email protected])- react-textarea-autosize:- specifier: '*'- version: 8.5.9(@types/[email protected])([email protected])tailwind-merge:specifier: '*'version: 2.2.2diff --git a/products/posthog_ai/frontend/api/primitives.ts b/products/posthog_ai/frontend/api/primitives.tsindex b95e3211fa80..60813dff43fd 100644--- a/products/posthog_ai/frontend/api/primitives.ts+++ b/products/posthog_ai/frontend/api/primitives.ts@@ -19,11 +19,6 @@ export type {ComposerSubmitProps,} from '../components/composer/Composer'-// Self-sizing textarea (native field-sizing with a react-textarea-autosize fallback) — the input-// element behind Composer.Textarea, for surfaces that need the bare control (e.g. message editing).-export { AutosizeTextArea } from '../components/AutosizeTextArea'-export type { AutosizeTextAreaProps } from '../components/AutosizeTextArea'-// Controlled model + reasoning-effort pickers for a composer footer.export { ComposerModelEffortPickers } from '../components/composer/ComposerModelEffortPickers'export type { ComposerModelEffortPickersProps } from '../components/composer/ComposerModelEffortPickers'diff --git a/products/posthog_ai/frontend/components/AutosizeTextArea.scss b/products/posthog_ai/frontend/components/AutosizeTextArea.scssdeleted file mode 100644index a9c1ca4abb71..000000000000--- a/products/posthog_ai/frontend/components/AutosizeTextArea.scss+++ /dev/null@@ -1,31 +0,0 @@-.AutosizeTextArea {- display: block;- width: 100%;- min-height: 2.5rem;- padding: 0.5rem;- font-size: 0.875rem;- line-height: 1.4;- color: var(--text-3000);- text-align: left;- text-overflow: ellipsis;- cursor: text;- resize: none;- background: none;- background-color: var(--color-bg-fill-input);- outline: none;- box-shadow: none;-- &:disabled {- cursor: not-allowed;- opacity: var(--opacity-disabled);- }-}--// Native autosizing where supported. The 1rem term is the vertical padding (0.5rem × 2);-// rows are clamped via min/max-height since field-sizing ignores the `rows` attribute.-.AutosizeTextArea--native {- /* stylelint-disable-next-line property-no-unknown -- field-sizing is a valid CSS property */- field-sizing: content;- min-height: max(2.5rem, calc(var(--autosize-textarea-min-rows, 1) * 1lh + 1rem));- max-height: calc(var(--autosize-textarea-max-rows, 1000) * 1lh + 1rem);-}diff --git a/products/posthog_ai/frontend/components/AutosizeTextArea.tsx b/products/posthog_ai/frontend/components/AutosizeTextArea.tsxdeleted file mode 100644index 7511304dec2e..000000000000--- a/products/posthog_ai/frontend/components/AutosizeTextArea.tsx+++ /dev/null@@ -1,111 +0,0 @@-import './AutosizeTextArea.scss'--import React, { useRef } from 'react'-import TextareaAutosize from 'react-textarea-autosize'--import { cn } from 'lib/utils/css-classes'--// Native CSS autosizing where supported. The JS fallback (react-textarea-autosize) calls-// getComputedStyle on every keystroke, which forces a synchronous whole-document style recalc —-// hundreds of ms on threads with lots of mounted content.-const SUPPORTS_FIELD_SIZING =- typeof CSS !== 'undefined' && typeof CSS.supports === 'function' && CSS.supports('field-sizing', 'content')--export interface AutosizeTextAreaProps extends Pick<- React.TextareaHTMLAttributes<HTMLTextAreaElement>,- 'id' | 'placeholder' | 'disabled' | 'maxLength' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'aria-describedby'-> {- value?: string- onChange?: (newValue: string) => void- /** Called when Enter is pressed without Shift (Shift+Enter inserts a newline). */- onPressEnter?: (currentValue: string) => void- /** Called when Cmd/Ctrl+Enter is pressed (plain Enter inserts a newline). */- onPressCmdEnter?: (currentValue: string) => void- minRows?: number- maxRows?: number- autoFocus?: boolean- /** Classes for the wrapper element around the textarea. */- className?: string- /**- * Classes for the `<textarea>` itself. Padding utilities belong here (not on the wrapper), so the- * text is inset while the scrollbar still renders at the textarea's true edge.- */- textareaClassName?: string- /** Skip the `input-like` border/focus frame around the textarea. */- hideFocus?: boolean- 'data-attr'?: string-}--/** A self-sizing `textarea` for the agent composer surfaces. */-export const AutosizeTextArea = React.forwardRef<HTMLTextAreaElement, AutosizeTextAreaProps>(function AutosizeTextArea(- {- className,- textareaClassName,- onChange,- onPressEnter,- onPressCmdEnter,- minRows = 1,- maxRows,- onKeyDown,- autoFocus,- hideFocus = false,- ...textProps- },- ref-): JSX.Element {- const _ref = useRef<HTMLTextAreaElement | null>(null)- const textRef = ref || _ref-- const textareaClasses = cn('AutosizeTextArea w-full rounded', textareaClassName)- const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>): void => {- if (e.key === 'Enter' && !e.nativeEvent.isComposing) {- const target = e.currentTarget- // When shift is pressed, we always just want to add a new line- if (!e.shiftKey) {- if ((e.metaKey || e.ctrlKey) && onPressCmdEnter) {- onPressCmdEnter(target.value)- e.preventDefault()- } else if (onPressEnter) {- onPressEnter(target.value)- e.preventDefault()- }- }- }- onKeyDown?.(e)- }- const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>): void => {- onChange?.(event.currentTarget.value ?? '')- }-- return (- <div className={cn('flex flex-col rounded', !hideFocus && 'input-like', className)}>- {SUPPORTS_FIELD_SIZING ? (- <textarea- ref={textRef}- className={cn('AutosizeTextArea--native', textareaClasses)}- style={- {- '--autosize-textarea-min-rows': minRows,- '--autosize-textarea-max-rows': maxRows,- } as React.CSSProperties- }- onKeyDown={handleKeyDown}- onChange={handleChange}- autoFocus={!!autoFocus}- {...textProps}- />- ) : (- <TextareaAutosize- minRows={minRows}- maxRows={maxRows}- ref={textRef}- className={textareaClasses}- onKeyDown={handleKeyDown}- onChange={handleChange}- autoFocus={!!autoFocus}- {...textProps}- />- )}- </div>- )-})diff --git a/products/posthog_ai/frontend/components/QueuedMessageList.tsx b/products/posthog_ai/frontend/components/QueuedMessageList.tsxindex ea5e9f02f2e7..c2359f47140a 100644--- a/products/posthog_ai/frontend/components/QueuedMessageList.tsx+++ b/products/posthog_ai/frontend/components/QueuedMessageList.tsx@@ -1,10 +1,9 @@import { useEffect, useRef, useState } from 'react'import { IconCheck, IconPencil, IconTrash, IconX } from '@posthog/icons'-import { LemonButton } from '@posthog/lemon-ui'+import { LemonButton, LemonTextArea } from '@posthog/lemon-ui'import type { QueuedMessage } from '../logics/runInteractionLogic'-import { AutosizeTextArea } from './AutosizeTextArea'export interface QueuedMessageListProps {messages: QueuedMessage[]@@ -49,7 +48,7 @@ function QueuedMessageItem({if (isEditing) {return (<div className="space-y-2">- <AutosizeTextArea+ <LemonTextArearef={textAreaRef}value={draft}onChange={setDraft}diff --git a/products/posthog_ai/frontend/components/composer/Composer.tsx b/products/posthog_ai/frontend/components/composer/Composer.tsxindex ef4abf2686e6..f4548a2ff20c 100644--- a/products/posthog_ai/frontend/components/composer/Composer.tsx+++ b/products/posthog_ai/frontend/components/composer/Composer.tsx@@ -12,12 +12,10 @@ import {} from 'react'import { IconArrowRight, IconStopFilled } from '@posthog/icons'-import { LemonButton } from '@posthog/lemon-ui'+import { LemonButton, LemonTextArea } from '@posthog/lemon-ui'import { cn } from 'lib/utils/css-classes'-import { AutosizeTextArea } from '../AutosizeTextArea'-// Radix-style compound composer: a set of logic-free, presentational surfaces that reproduce the// PostHog AI input look (see scenes/max/components/QuestionInput.tsx) without any of its conversation// logic. `Composer.Root` owns nothing but the controlled value/submit plumbing it's handed; every@@ -292,7 +290,7 @@ function ComposerTextarea({}: ComposerTextareaProps): JSX.Element {const { value, onChange, submit, textAreaRef, disabled, id } = useComposerContext()return (- <AutosizeTextArea+ <LemonTextAreaid={id}aria-describedby={!value ? `${id}-hint` : undefined}ref={textAreaRef}@@ -302,8 +300,7 @@ function ComposerTextarea({minRows={minRows}maxRows={maxRows}autoFocus={autoFocus}- className={cn('py-2 pl-2', className)}- textareaClassName="!border-none !bg-transparent min-h-16 pr-12 resize-none"+ className={cn('!border-none !bg-transparent min-h-16 py-2 pl-2 pr-12 resize-none', className)}hideFocusonPressEnter={() => submit()}{...rest}diff --git a/products/posthog_ai/package.json b/products/posthog_ai/package.jsonindex 45798502e23f..58d80781288d 100644--- a/products/posthog_ai/package.json+++ b/products/posthog_ai/package.json@@ -12,7 +12,6 @@"monaco-editor": "^0.55.1","posthog-js": "catalog:","react-intersection-observer": "^9.5.3",- "react-textarea-autosize": "*","tailwind-merge": "*"},"devDependencies": {