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.

feat(posthog-ai): keep the phone run composer on one row with a clear model (#124760)

Shy Alterc6b686d1c4f2
diff --git a/products/posthog_ai/frontend/components/composer/ComposerModelEffortPickers.tsx b/products/posthog_ai/frontend/components/composer/ComposerModelEffortPickers.tsx
index 0ed37e3daec8..57ca9ca1b4e0 100644
--- a/products/posthog_ai/frontend/components/composer/ComposerModelEffortPickers.tsx
+++ b/products/posthog_ai/frontend/components/composer/ComposerModelEffortPickers.tsx
@@ -1,6 +1,6 @@
import { useMemo, useRef, useState } from 'react'
-import { IconBrain, IconChevronDown, IconChevronLeft, IconGear, IconRevert } from '@posthog/icons'
+import { IconChevronDown, IconChevronLeft, IconGear, IconRevert } from '@posthog/icons'
import {
Button,
DropdownMenu,
@@ -43,6 +43,7 @@ import { ModelCostFooter } from '../ModelCostFooter'
import { COMPOSER_MENU_CLASS } from '../quill/composerMenuClass'
import type { ThreadSkin } from '../quill/quillThreadContext'
import { ComposerModelEffortSheet } from './ComposerModelEffortSheet'
+import { ComposerModelIcon } from './ComposerModelIcon'
import { ComposerReasoningSlider } from './ComposerReasoningSlider'
// Separates model and effort in a slider stop key; never appears in a model id or an effort.
@@ -292,14 +293,19 @@ export function ComposerModelEffortPickers({
<DropdownMenuTrigger
render={
<Button variant={chrome.triggerVariant} size="sm" aria-label="Model and reasoning">
- {chrome.modelIcon && <IconBrain className="shrink-0 text-muted-foreground" />}
+ {chrome.modelIcon && (
+ <ComposerModelIcon
+ model={selectedModel}
+ ownPlan={billing?.value === ModelAccessEnumApi.OwnSubscription}
+ />
+ )}
{isDefaultSelection && chrome.defaultPrefix ? `Default · ${modelLabel}` : modelLabel}
{effortOptions.length > 0 && (
<span className="text-muted @max-[400px]/composer:hidden">
{getEffortLabel(selectedEffort)}
</span>
)}
- {billing?.value === ModelAccessEnumApi.OwnSubscription && (
+ {!chrome.modelIcon && billing?.value === ModelAccessEnumApi.OwnSubscription && (
<span className="text-muted">ChatGPT plan</span>
)}
{chrome.icons && <IconChevronDown />}
diff --git a/products/posthog_ai/frontend/components/composer/ComposerModelEffortSheet.tsx b/products/posthog_ai/frontend/components/composer/ComposerModelEffortSheet.tsx
index 603e6c5c28fa..643e5cc7c337 100644
--- a/products/posthog_ai/frontend/components/composer/ComposerModelEffortSheet.tsx
+++ b/products/posthog_ai/frontend/components/composer/ComposerModelEffortSheet.tsx
@@ -1,6 +1,5 @@
import { useState } from 'react'
-import { IconBrain } from '@posthog/icons'
import { Button, ItemRadio, MenuLabel, ToggleGroup, ToggleGroupItem } from '@posthog/quill-primitives'
import { SHEET_PARTS } from '~/layout/today/todayMenuParts'
@@ -21,6 +20,7 @@ import {
import { ModelCostChip } from '../ModelCostChip'
import { ModelCostFooter } from '../ModelCostFooter'
import type { ComposerCodexBilling } from './ComposerModelEffortPickers'
+import { ComposerModelIcon } from './ComposerModelIcon'
export interface ComposerModelEffortSheetProps {
modelLabel: string
@@ -64,15 +64,20 @@ export function ComposerModelEffortSheet({
const [open, setOpen] = useState(false)
return (
<>
- <Button size="sm" onClick={() => setOpen(true)} data-attr="composer-model-sheet-open">
- <IconBrain className="shrink-0 text-muted-foreground" />
- <span className="max-w-32 truncate">{modelLabel}</span>
+ <Button
+ size="sm"
+ className="min-w-0 shrink"
+ onClick={() => setOpen(true)}
+ data-attr="composer-model-sheet-open"
+ >
+ <ComposerModelIcon
+ model={selectedModel}
+ ownPlan={billing?.value === ModelAccessEnumApi.OwnSubscription}
+ />
+ <span className="whitespace-nowrap">{modelLabel}</span>
{effortOptions.length > 0 && (
<span className="text-muted @max-[400px]/composer:hidden">{getEffortLabel(selectedEffort)}</span>
)}
- {billing?.value === ModelAccessEnumApi.OwnSubscription && (
- <span className="text-muted">ChatGPT plan</span>
- )}
</Button>
<TodaySheetMenu open={open} onOpenChange={setOpen} title="Model and reasoning">
{effortOptions.length > 0 && (
diff --git a/products/posthog_ai/frontend/components/composer/ComposerModelIcon.tsx b/products/posthog_ai/frontend/components/composer/ComposerModelIcon.tsx
new file mode 100644
index 000000000000..897e67a233f7
--- /dev/null
+++ b/products/posthog_ai/frontend/components/composer/ComposerModelIcon.tsx
@@ -0,0 +1,30 @@
+import { IconLogomark } from '@posthog/icons'
+
+import { AnthropicLogo } from 'scenes/onboarding/shared/logos/AnthropicLogo'
+import { OpenAILogo } from 'scenes/onboarding/shared/logos/OpenAILogo'
+
+import { normalizeModelId } from 'products/tasks/frontend/modelCatalog'
+
+export interface ComposerModelIconProps {
+ model: string
+ ownPlan: boolean
+}
+
+export function ComposerModelIcon({ model, ownPlan }: ComposerModelIconProps): JSX.Element {
+ const modelId = normalizeModelId(model)
+ const PlanLogo = !ownPlan
+ ? null
+ : modelId.startsWith('gpt-')
+ ? OpenAILogo
+ : modelId.startsWith('claude-')
+ ? AnthropicLogo
+ : null
+ return (
+ <span
+ className="inline-flex size-3.5 shrink-0 items-center justify-center [&_svg]:size-full"
+ title={ownPlan ? 'Billed to your plan' : 'Billed to PostHog credits'}
+ >
+ {PlanLogo ? <PlanLogo /> : <IconLogomark />}
+ </span>
+ )
+}
diff --git a/products/posthog_ai/frontend/components/quill/QuillComposerLayout.tsx b/products/posthog_ai/frontend/components/quill/QuillComposerLayout.tsx
index ec713cf0eee7..ee1424600953 100644
--- a/products/posthog_ai/frontend/components/quill/QuillComposerLayout.tsx
+++ b/products/posthog_ai/frontend/components/quill/QuillComposerLayout.tsx
@@ -1,7 +1,9 @@
-import { type ReactNode, type RefObject, useLayoutEffect, useRef } from 'react'
+import { type ReactNode, type RefObject, useLayoutEffect, useRef, useState } from 'react'
import { InputGroup, InputGroupAddon } from '@posthog/quill-primitives'
+import { cn } from 'lib/utils/css-classes'
+
export interface QuillComposerLayoutProps {
groupRef: RefObject<HTMLDivElement>
textAreaRef: RefObject<HTMLTextAreaElement>
@@ -10,6 +12,52 @@ export interface QuillComposerLayoutProps {
send: ReactNode
controls?: ReactNode
meta?: ReactNode
+ singleRow?: boolean
+}
+
+const SINGLE_ROW_CLASS =
+ 'pr-1.5 pb-1.5 ' +
+ '[&_.quill-button--size-sm]:h-7 [&_.quill-button--size-lg]:h-7 [&_.quill-button--size-lg]:px-2 [&_.quill-button--size-lg]:text-xs ' +
+ '[&_.quill-button--size-icon-sm]:size-7 [&_.quill-button--size-icon-sm_svg]:size-3.5 [&_[data-attr=task-composer-add-menu]]:-ml-[3px]'
+
+function useTwoRows(
+ rowRef: RefObject<HTMLDivElement>,
+ controlsRef: RefObject<HTMLDivElement>,
+ metaRef: RefObject<HTMLDivElement>,
+ sendRef: RefObject<HTMLDivElement>,
+ enabled: boolean
+): boolean {
+ const [twoRows, setTwoRows] = useState(false)
+
+ useLayoutEffect(() => {
+ const row = rowRef.current
+ const parts = [controlsRef.current, metaRef.current, sendRef.current]
+ if (!enabled || !row || parts.some((part) => !part) || typeof ResizeObserver === 'undefined') {
+ return
+ }
+ const [controls, metaGroup, sendGroup] = parts as HTMLDivElement[]
+ const measure = (): void => {
+ const style = getComputedStyle(row)
+ const available = row.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight)
+ const gap = parseFloat(style.columnGap) || 0
+ const metaWidth = Array.from(metaGroup.children).reduce((sum, child) => sum + child.scrollWidth, 0)
+ const needed = controls.scrollWidth + metaWidth + sendGroup.scrollWidth + gap * 2
+ setTwoRows(needed > available + 0.5)
+ }
+ measure()
+ const resizeObserver = new ResizeObserver(measure)
+ resizeObserver.observe(row)
+ resizeObserver.observe(controls)
+ Array.from(metaGroup.children).forEach((child) => resizeObserver.observe(child))
+ const mutationObserver = new MutationObserver(measure)
+ mutationObserver.observe(row, { childList: true, subtree: true, characterData: true })
+ return () => {
+ resizeObserver.disconnect()
+ mutationObserver.disconnect()
+ }
+ }, [rowRef, controlsRef, metaRef, sendRef, enabled])
+
+ return enabled && twoRows
}
export function QuillComposerLayout({
@@ -20,9 +68,15 @@ export function QuillComposerLayout({
send,
controls,
meta,
+ singleRow = false,
}: QuillComposerLayoutProps): JSX.Element {
const chipsRowRef = useRef<HTMLDivElement>(null)
const chipsContentRef = useRef<HTMLDivElement>(null)
+ const rowRef = useRef<HTMLDivElement>(null)
+ const controlsRef = useRef<HTMLDivElement>(null)
+ const metaRef = useRef<HTMLDivElement>(null)
+ const sendRef = useRef<HTMLDivElement>(null)
+ const twoRows = useTwoRows(rowRef, controlsRef, metaRef, sendRef, singleRow)
useLayoutEffect(() => {
const row = chipsRowRef.current
@@ -75,16 +129,45 @@ export function QuillComposerLayout({
</InputGroupAddon>
)}
<div className="relative w-full min-w-0">{field}</div>
- <div
- data-quill
- className="@container/composer flex w-full flex-wrap items-center gap-1 pr-1 pb-1 pl-1.5 text-[var(--muted-foreground)]"
- >
- {controls}
- <div className="ml-auto flex shrink-0 items-center gap-1">
- {meta}
- {send}
+ {singleRow ? (
+ <div
+ ref={rowRef}
+ data-quill
+ data-two-rows={twoRows || undefined}
+ className={cn(
+ '@container/composer w-full items-center gap-1 pl-1.5 text-[var(--muted-foreground)]',
+ SINGLE_ROW_CLASS,
+ twoRows ? 'grid grid-cols-[auto_1fr_auto]' : 'flex flex-nowrap'
+ )}
+ >
+ <div ref={controlsRef} className="col-start-1 row-start-1 flex shrink-0 items-center gap-1">
+ {controls}
+ </div>
+ <div
+ ref={metaRef}
+ className={cn(
+ 'flex min-w-0 items-center',
+ twoRows ? 'col-span-full row-start-2 -ml-1' : 'ml-auto'
+ )}
+ >
+ {meta}
+ </div>
+ <div ref={sendRef} className="col-start-3 row-start-1 flex shrink-0 items-center">
+ {send}
+ </div>
</div>
- </div>
+ ) : (
+ <div
+ data-quill
+ className="@container/composer flex w-full flex-wrap items-center gap-1 pr-1 pb-1 pl-1.5 text-[var(--muted-foreground)]"
+ >
+ {controls}
+ <div className="ml-auto flex shrink-0 items-center gap-1">
+ {meta}
+ {send}
+ </div>
+ </div>
+ )}
</InputGroup>
</div>
)
diff --git a/products/posthog_ai/frontend/components/quill/QuillComposerSendButton.tsx b/products/posthog_ai/frontend/components/quill/QuillComposerSendButton.tsx
index 0456bccebf22..791045d1e654 100644
--- a/products/posthog_ai/frontend/components/quill/QuillComposerSendButton.tsx
+++ b/products/posthog_ai/frontend/components/quill/QuillComposerSendButton.tsx
@@ -11,14 +11,14 @@ export const QuillComposerSendButton = forwardRef<HTMLSpanElement, { 'data-attr'
const button = showStop ? (
<Button
type="button"
- variant="destructive"
+ variant="secondary"
size="icon"
aria-label="Stop"
loading={stopLoading}
onClick={() => onStop?.()}
data-attr={dataAttr}
>
- <IconStopFilled />
+ <IconStopFilled className="size-2.5" />
</Button>
) : (
<Button
diff --git a/products/posthog_ai/frontend/components/quill/QuillContextUsage.tsx b/products/posthog_ai/frontend/components/quill/QuillContextUsage.tsx
index 2f9ba808e11f..d3d6e1c58314 100644
--- a/products/posthog_ai/frontend/components/quill/QuillContextUsage.tsx
+++ b/products/posthog_ai/frontend/components/quill/QuillContextUsage.tsx
@@ -39,7 +39,10 @@ export function QuillContextUsage(): JSX.Element | null {
render={
<span
tabIndex={0}
- className="flex items-center gap-1 text-xs tabular-nums whitespace-nowrap text-muted-foreground"
+ className={cn(
+ 'flex items-center gap-1 text-xs tabular-nums whitespace-nowrap text-muted-foreground',
+ (percentage === null || percentage < 80) && '@max-[359px]/composer:hidden'
+ )}
data-attr="max-sandbox-context-usage"
>
{percentage !== null && (
diff --git a/products/posthog_ai/frontend/components/quill/QuillModePicker.tsx b/products/posthog_ai/frontend/components/quill/QuillModePicker.tsx
index cd4c7552469d..5f8fdc6bf531 100644
--- a/products/posthog_ai/frontend/components/quill/QuillModePicker.tsx
+++ b/products/posthog_ai/frontend/components/quill/QuillModePicker.tsx
@@ -44,6 +44,7 @@ export function QuillModePicker({ selectedMode, onModeChange, modes }: QuillMode
const options = modes.flatMap((mode) => MODE_OPTIONS.filter((option) => option.value === mode))
const selectedLabel = getModeOption(selectedMode)?.label ?? 'Mode'
const unsupervised = UNSUPERVISED_MODES.includes(selectedMode)
+ const riskFill = unsupervised ? 'bg-[color-mix(in_oklab,var(--destructive)_30%,transparent)]' : undefined
const { todayRailEnabled, phoneLayout } = useValues(todayShellLogic)
if (todayRailEnabled && phoneLayout) {
@@ -53,6 +54,7 @@ export function QuillModePicker({ selectedMode, onModeChange, modes }: QuillMode
type="button"
variant={unsupervised ? 'destructive' : 'default'}
size="lg"
+ className={riskFill}
aria-label="Mode"
title={selectedLabel}
onClick={() => setOpen(true)}
@@ -89,6 +91,7 @@ export function QuillModePicker({ selectedMode, onModeChange, modes }: QuillMode
type="button"
variant={unsupervised ? 'destructive' : 'default'}
size="sm"
+ className={riskFill}
aria-label="Mode"
title={selectedLabel}
>
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunComposer.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunComposer.tsx
index 2704a9b0d379..40021f2c2dd3 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunComposer.tsx
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunComposer.tsx
@@ -26,7 +26,7 @@ import {
pickerModels,
} from 'products/posthog_ai/frontend/utils/composerModels'
import { cycleMode, getModesForRuntimeAdapter } from 'products/posthog_ai/frontend/utils/composerModes'
-import { ModelAccessEnumApi, RuntimeAdapterEnumApi } from 'products/tasks/frontend/generated/api.schemas'
+import { ModelAccessEnumApi } from 'products/tasks/frontend/generated/api.schemas'
import { AttachedContextChips } from '../../../components/composer/AttachedContextChips'
import { AttachedContextPicker } from '../../../components/composer/AttachedContextPicker'
@@ -34,8 +34,6 @@ import { CommandResultCard } from '../../../components/composer/CommandResultCar
import { CommentContextChips } from '../../../components/composer/CommentContextChips'
import { ComposerAttachmentChips } from '../../../components/composer/ComposerAttachmentChips'
import { ComposerAttachments, useComposerAttachmentPaste } from '../../../components/composer/ComposerAttachments'
-import { ComposerBillingIndicator } from '../../../components/composer/ComposerBillingIndicator'
-import { ComposerCodexBillingIndicator } from '../../../components/composer/ComposerCodexBillingIndicator'
import { ComposerCodexBillingPickers } from '../../../components/composer/ComposerCodexBillingPickers'
import { ComposerCommandMenu } from '../../../components/composer/ComposerCommandMenu'
import {
@@ -175,7 +173,6 @@ export function TaskRunComposer({
const lockedCodexModelAccess = isTerminal
? null
: (logicProps.currentCodexModelAccess ?? ModelAccessEnumApi.PosthogGateway)
- const billingAdapter = isTerminal ? getRuntimeAdapterForModel(catalogue, selectedModel) : composerAdapter
const modelPicker =
codexBillingEnabled && !isPiTask ? (
<ComposerCodexBillingPickers {...modelPickerProps} lockedCodexModelAccess={lockedCodexModelAccess} />
@@ -303,17 +300,16 @@ export function TaskRunComposer({
onOpenChange={setContextPickerOpen}
anchor={groupRef}
/>
- {pickers(modelPicker, modePicker)}
+ <div className="shrink-0">{pickers(modePicker, null)}</div>
</>
}
+ singleRow
meta={
- <div className="flex items-center divide-x divide-border *:px-2 *:last:pr-1">
- <QuillContextUsage />
- {codexBillingEnabled && !isPiTask && billingAdapter === RuntimeAdapterEnumApi.Codex ? (
- <ComposerCodexBillingIndicator lockedCodexModelAccess={lockedCodexModelAccess} />
- ) : (
- <ComposerBillingIndicator ownPlan={false} />
- )}
+ <div className="flex min-w-0 items-center gap-1 [&>fieldset]:min-w-0 [&>fieldset]:flex-nowrap">
+ <span className="px-1 empty:hidden">
+ <QuillContextUsage />
+ </span>
+ {pickers(modelPicker, null)}
</div>
}
/>