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.

fix(posthog_ai): stop the mode menu jumping under the pointer (#88038)

Jake Ruthda42d4f2a238
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index a6b928b29f7a..14cf8ad0d6a5 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6025,9 +6025,9 @@ snapshots:
scenes-app-customer-analytics-track-rules--configured--light:
hash: v1.k794b7964.de5a3e9672100bbd083b4608693261a0e5624693afd5de70b0014a9adfa13b3e.k9pAMbCur-xOSs_utBsXvuCXde14rcNor-R-C89EedA
scenes-app-customer-analytics-track-rules--feature-gate-off--dark:
- hash: v1.k794b7964.247e31dff1b806907ec4c327f1ad132fc186861cbe8f2265fa05296f1aa2a95b.KZZKeqM5D6IpwNrMdlEf5EbTm6KGmcdapADEzg755Gw
+ hash: v1.k794b7964.68dfb562def4db8fb8b8082b864115e315caf6662c6be713af5572a9f263bc57.z9X01dYMXIIFZXt9s1TM1GrALc0HZlSgEzRxu85W9Kg
scenes-app-customer-analytics-track-rules--feature-gate-off--light:
- hash: v1.k794b7964.5bf2ef575702ea1997fa9c147c10662b40445407894616a915c9e330cbc8c06a.0vS8B765QPDhC4h_KtJPlL5o3f5b_PZ-giJD2DPRkd4
+ hash: v1.k794b7964.365fcdc6fae12bf1f704d0bc3a6d8992b7fea05cb5d48eb78bfc1f2f24fac929.ad9HX_I4T-esxuMW3YamDdHs0pZbTQRDjBRsSvX8ReA
scenes-app-customer-analytics-track-rules--preview--dark:
hash: v1.k794b7964.4d60ac636f3d4b309108ff038058f81c38dfd65d4badfb9dcf780b2dedf88c25.ZUVE6wN40QhrIaL0iR-shEMXZja7utjNvptDYTLVxPY
scenes-app-customer-analytics-track-rules--preview--light:
diff --git a/packages/quill/packages/primitives/AGENTS.md b/packages/quill/packages/primitives/AGENTS.md
index b78b7da6add2..e2e1c60c0a58 100644
--- a/packages/quill/packages/primitives/AGENTS.md
+++ b/packages/quill/packages/primitives/AGENTS.md
@@ -352,6 +352,8 @@ Switch has sizes: `<Switch size="sm" />` or `<Switch size="default" />`
Small trigger: `<SelectTrigger size="sm">`
+Attached panel outside the popup: pass `popupSibling` on `SelectContent` — rendered in the positioner beside the popup, outside its overflow and scroll mask; position it absolute so it never resizes the option list.
+
### Combobox (searchable select)
```tsx
diff --git a/packages/quill/packages/primitives/src/select.tsx b/packages/quill/packages/primitives/src/select.tsx
index 194a19333fde..e5377fa86008 100644
--- a/packages/quill/packages/primitives/src/select.tsx
+++ b/packages/quill/packages/primitives/src/select.tsx
@@ -54,14 +54,20 @@ function SelectTrigger({
function SelectContent({
className,
children,
+ popupSibling,
side = 'bottom',
sideOffset = 4,
align = 'center',
alignOffset = 0,
alignItemWithTrigger = true,
...props
-}: SelectPrimitive.Popup.Props &
- Pick<
+}: SelectPrimitive.Popup.Props & {
+ /**
+ * Rendered in the positioner as the popup's sibling, escaping the popup's overflow and scroll
+ * mask. Use position: absolute — in-flow content here resizes the box the positioner measures.
+ */
+ popupSibling?: React.ReactNode
+} & Pick<
SelectPrimitive.Positioner.Props,
'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'
>): React.ReactElement {
@@ -77,6 +83,7 @@ function SelectContent({
alignItemWithTrigger={alignItemWithTrigger}
className="isolate"
>
+ {popupSibling}
<SelectPrimitive.Popup
data-slot="select-content"
data-align-trigger={alignItemWithTrigger}
diff --git a/products/posthog_ai/frontend/components/composer/ComposerModePicker.test.tsx b/products/posthog_ai/frontend/components/composer/ComposerModePicker.test.tsx
index d77f8d0a2767..52e8701cb20d 100644
--- a/products/posthog_ai/frontend/components/composer/ComposerModePicker.test.tsx
+++ b/products/posthog_ai/frontend/components/composer/ComposerModePicker.test.tsx
@@ -25,22 +25,27 @@ describe('ComposerModePicker', () => {
// Never-ask modes are gated out, as they are in the desktop app by default.
expect(screen.queryByText('Full auto')).not.toBeInTheDocument()
- // The footer describes the selected mode on open; the other descriptions stay out of the menu.
- expect(
- screen.getByText(
- 'Accepts file edits and shell commands automatically. Always asks before PostHog tools that change live data. Creating or publishing content asks only while you watch the run.'
- )
- ).toBeInTheDocument()
+ // The strip renders twice (top and bottom edge, CSS picks one by open direction).
+ const strips = screen.getAllByText(
+ 'Accepts file edits and shell commands automatically. Always asks before PostHog tools that change live data. Creating or publishing content asks only while you watch the run.'
+ )
+ expect(strips).not.toHaveLength(0)
+ // Inside the popup, its overflow and scroll mask hide the strips entirely.
+ for (const strip of strips) {
+ expect(strip.closest('[data-slot="select-content"]')).toBeNull()
+ }
expect(
screen.queryByText('Plans the work first. Nothing runs until you approve the plan.')
).not.toBeInTheDocument()
- // Hovering another option swaps the footer to its description. This breaks if ModeItemRow
+ // Hovering another option swaps the strip to its description. This breaks if ModeItemRow
// stops forwarding Base UI's ref — the item then never registers for hover highlighting.
const planOption = screen.getByText('Plan').closest('[role="option"]')
expect(planOption).not.toBeNull()
fireEvent.mouseMove(planOption!)
- expect(screen.getByText('Plans the work first. Nothing runs until you approve the plan.')).toBeInTheDocument()
+ expect(screen.getAllByText('Plans the work first. Nothing runs until you approve the plan.')).not.toHaveLength(
+ 0
+ )
expect(
screen.queryByText(
'Accepts file edits and shell commands automatically. Always asks before PostHog tools that change live data. Creating or publishing content asks only while you watch the run.'
@@ -64,8 +69,10 @@ describe('ComposerModePicker', () => {
fireEvent.click(screen.getByLabelText('Mode'))
- // The selected mode is filtered out, so the footer falls back to the first offered mode.
- expect(screen.getByText('Plans the work first. Nothing runs until you approve the plan.')).toBeInTheDocument()
+ // The selected mode is filtered out, so the strip falls back to the first offered mode.
+ expect(screen.getAllByText('Plans the work first. Nothing runs until you approve the plan.')).not.toHaveLength(
+ 0
+ )
expect(
screen.queryByText(
'Accepts file edits and shell commands automatically. Always asks before PostHog tools that change live data. Creating or publishing content asks only while you watch the run.'
diff --git a/products/posthog_ai/frontend/components/composer/ComposerModePicker.tsx b/products/posthog_ai/frontend/components/composer/ComposerModePicker.tsx
index 2cfc949615b2..c486fe2e439b 100644
--- a/products/posthog_ai/frontend/components/composer/ComposerModePicker.tsx
+++ b/products/posthog_ai/frontend/components/composer/ComposerModePicker.tsx
@@ -47,7 +47,7 @@ interface ModeItemRowProps extends HTMLAttributes<HTMLDivElement> {
/**
* Row body for a mode option. Rendered through the item's `render` prop so it can watch Base UI's
* `highlighted` state — both pointer hover and keyboard navigation — and report it up for the
- * description footer. Must forward the ref: Base UI registers the element into its item list through
+ * description strip. Must forward the ref: Base UI registers the element into its item list through
* it, and an unregistered item is invisible to hover highlighting.
*/
const ModeItemRow = forwardRef<HTMLDivElement, ModeItemRowProps>(function ModeItemRow(
@@ -77,20 +77,20 @@ export interface ComposerModePickerProps {
* model/effort pickers. The caller owns the selection and its side effects. Also reused by the plan-approval
* card, where `modes` narrows the menu to the wire-offered modes.
*
- * The menu keeps each option to one line (icon + label); the highlighted option's description renders in
- * a footer strip pinned to two lines of height, so the menu never jumps while moving between modes.
+ * The highlighted option's description renders in a panel attached to the menu's growing edge, so its
+ * height changes never move the option rows.
*/
export function ComposerModePicker({ selectedMode, onModeChange, modes }: ComposerModePickerProps): JSX.Element {
// Ordered by `modes`, not by MODE_OPTIONS: each runtime lists its modes in its own order.
const offered = modes ?? getModesForRuntimeAdapter(RuntimeAdapterEnumApi.Claude)
const options = offered.flatMap((mode) => MODE_OPTIONS.filter((option) => option.value === mode))
const selectedOption = getModeOption(selectedMode)
- // The mode whose description the footer shows. Base UI highlights the selected item on open, which
+ // The mode the description strip shows. Base UI highlights the selected item on open, which
// seeds this; reset on open so a hover from the previous open can't leak into the next one.
const [highlightedMode, setHighlightedMode] = useState<PermissionMode | null>(null)
- // Resolve against `options`, not all modes: when `modes` narrows the menu, the footer must never
+ // Resolve against `options`, not all modes: when `modes` narrows the menu, the strip must never
// describe a mode that isn't offered (e.g. a selected mode the plan-approval card filtered out).
- const footerOption =
+ const descriptionOption =
options.find((option) => option.value === highlightedMode) ??
options.find((option) => option.value === selectedMode) ??
options[0]
@@ -115,7 +115,23 @@ export function ComposerModePicker({ selectedMode, onModeChange, modes }: Compos
)}
</SelectValue>
</SelectTrigger>
- <SelectContent align="start" alignItemWithTrigger={false}>
+ <SelectContent
+ align="start"
+ alignItemWithTrigger={false}
+ className="min-w-60 data-[side=top]:rounded-t-none data-[side=bottom]:rounded-b-none"
+ popupSibling={
+ descriptionOption && (
+ <>
+ <div className="absolute bottom-full left-0 right-0 hidden min-h-[3.25rem] items-center rounded-t-[var(--radius-md)] border border-b-0 border-[var(--border)] bg-[var(--card)] px-3 py-1.5 text-xs text-secondary [[data-side=top]_&]:flex">
+ {descriptionOption.description}
+ </div>
+ <div className="absolute top-full left-0 right-0 hidden min-h-[3.25rem] items-center rounded-b-[var(--radius-md)] border border-t-0 border-[var(--border)] bg-[var(--card)] px-3 py-1.5 text-xs text-secondary [[data-side=bottom]_&]:flex">
+ {descriptionOption.description}
+ </div>
+ </>
+ )
+ }
+ >
{options.map((option) => (
<SelectItem
key={option.value}
@@ -133,11 +149,6 @@ export function ComposerModePicker({ selectedMode, onModeChange, modes }: Compos
{option.label}
</SelectItem>
))}
- {footerOption && (
- <div className="-mx-1 -mb-1 mt-1 flex min-h-[3.25rem] w-60 items-center border-t px-3 py-1.5 text-xs text-secondary">
- {footerOption.description}
- </div>
- )}
</SelectContent>
</Select>
)