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: require agents to check narrow-scene layout for user-facing UI (#89173)

Fernando Gomes8a6aa87bfa06
diff --git a/AGENTS.md b/AGENTS.md
index ff798fe80150..f8cbd429f945 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -211,6 +211,7 @@ See [.agents/security.md](.agents/security.md) for security guidelines — least
- Frontend (quill design system): before writing UI that imports `@posthog/quill` / `lib/ui/quill`, read [packages/quill/packages/primitives/AGENTS.md](packages/quill/packages/primitives/AGENTS.md) — component choice (dropdown vs select vs combobox, accordion vs collapsible, etc.), composition, and spacing rules. Charts: [packages/quill/packages/charts/AGENTS.md](packages/quill/packages/charts/AGENTS.md); DataTable/DateTimePicker: [packages/quill/packages/components/AGENTS.md](packages/quill/packages/components/AGENTS.md)
- Frontend (quill vs LemonUI): quill is for MCP apps and the desktop app. It is deliberately more compact than LemonUI, so its components look out of place in the main app, and there is no active migration of the main app onto it. In `frontend/src/` and `products/*/frontend/`, use LemonUI, including for menus — `LemonMenu` with a `LemonButton` trigger is the default there. `lib/ui/DropdownMenu` (Radix) is legacy; don't add new ones. Where quill is the right library, don't mix quill and Lemon components within one component's internals, and note that quill uses Base UI's `render` prop rather than Radix's `asChild`, so don't carry `asChild` over when converting
- Frontend: Any button or form submit that triggers a network request must guard against double-submission — disable the button and show a loading state (`loading` / `disabledReason` on `LemonButton`, or equivalent) while the request is in flight. Never leave a submit button clickable during an active mutation; reset the state in both success and error paths. This applies to `<form onSubmit>` handlers, `onClick` handlers that call `api.*`, and any kea `listener` that issues a request — wire the in-flight state (loader `*Loading` selectors, local `useState`, or a reducer) into the trigger's disabled/loading props.
+- Frontend: Any UI a person reads must hold up in a narrow scene. The nav sidebar and an open side panel leave a 1280px window about 520px of scene, so break on container queries rather than `md:`/`lg:`/`xl:`, wrap or truncate instead of clipping, and stack halves that no longer fit. Render the surface at a few widths before calling the work done. We do not support mobile — don't add phone-width layouts or touch-sized targets. See "Rule 6" in [frontend/src/AGENTS.md](frontend/src/AGENTS.md)
- Imports: Use oxfmt import sorting (automatically runs on format), avoid direct dayjs imports (use lib/dayjs)
- CSS: Use tailwind utility classes instead of inline styles
- Error handling: Prefer explicit error handling with typed errors
diff --git a/frontend/src/AGENTS.md b/frontend/src/AGENTS.md
index 43f711ab3daf..29a651bf686b 100644
--- a/frontend/src/AGENTS.md
+++ b/frontend/src/AGENTS.md
@@ -28,7 +28,7 @@ Common reinventions and what to use instead:
If nothing fits, say so and propose extending the existing component before adding a new one. Don't silently fork. If you do end up building custom, stay on brand: system tokens and primitives only, matching the surrounding scene's density and flatness — and none of the generic AI-generated look (purple/blue gradients, glassmorphism, gradient text, icon-tile card grids, decorative motion). The full slop-tell catalog is in the `/writing-ui-components` skill.
-The same goes for patterns, not just components: before building a new scene or view, read 2–3 comparable ones and model yours on those that follow these rules. Precedent that violates Rule 4 or `/writing-ui-components` is legacy to route around, not license to repeat — conventions outrank precedent, and compliant precedent outranks invention.
+The same goes for patterns, not just components: before building a new scene or view, read 2–3 comparable ones and model yours on those that follow these rules. Precedent that violates Rule 5 or `/writing-ui-components` is legacy to route around, not license to repeat — conventions outrank precedent, and compliant precedent outranks invention.
> LemonUI vs quill lives in the root `AGENTS.md` ("Code Style → Frontend (quill vs LemonUI)"). If you're working somewhere quill genuinely applies (an MCP app, the desktop app), `packages/quill/packages/primitives/AGENTS.md` has its component-choice and spacing rules, and the two libraries must not be mixed inside one component's internals.
@@ -60,7 +60,7 @@ When touching `lib/api`, `api.get<`, `api.create<`, or any handwritten API inter
Covered by the root `AGENTS.md` (Code Style → Frontend). The discovery hint for this tree: if a scene/component has a `*Logic.ts`, that's where actions/reducers/selectors/listeners belong. See `/writing-kea-logics` and `/using-kea-disposables`.
-## Rule 4 — Structure and abstraction
+## Rule 5 — Structure and abstraction
Full doctrine + convert-on-sight catalog: the `/writing-ui-components` skill. Load it before creating, moving, splitting, or restructuring any component or frontend file, extracting a shared component, or renaming frontend symbols. The always-on core:
@@ -70,6 +70,19 @@ Full doctrine + convert-on-sight catalog: the `/writing-ui-components` skill. Lo
- **Loading, empty, and error are three different screens.** Never derive "empty" from data that hasn't resolved — branch on the loading/unknown state first.
- **Renames sweep code symbols completely; wire strings stay frozen.** Event names, property names/values, flag keys, `data-attr` values, storage keys, and URL paths are API (dashboards, rollouts, and Playwright depend on them) — pin them with a comment instead of renaming.
+## Rule 6 — A narrow scene is normal; a phone is not
+
+Every surface a person reads has to hold up in a narrow scene.
+The width a component gets is not the window width: the nav sidebar takes ~215px, an open side panel ~512px more, and the scene pads 32px on top.
+So a 1280px window with the side panel open leaves a scene about 520px wide — narrower than a `md:` breakpoint ever fires at.
+That is a normal working setup, not an edge case, and it is the case agents skip.
+
+- **Break on the container, not the viewport.** `md:`/`lg:`/`xl:` track the window, so they fire long after the real space ran out. Container queries track the space the component actually has. `layout/navigation-3000/Navigation.tsx` names `main-content` and `main-content-container`, so `@min-[48rem]/main-content:` follows the main column. A shared component declares its own container instead, because it must respond wherever a caller places it — `lib/lemon-ui/LemonBanner/LemonBanner.tsx` is the pattern.
+- **Nothing clips and nothing scrolls sideways.** Rows of buttons, tags, or chips get `flex-wrap`. Long strings truncate. Side-by-side halves stack. An unwrapped action row is the most common miss.
+- **Cut decoration before content.** When something has to go at a narrow width, drop the illustration or the padding, not the explanation or the primary action.
+- **Do not build for mobile.** No phone-width layouts, no touch-sized targets, no `sm:` variants for a viewport nobody runs the app at. "Narrow" means a docked panel on a laptop.
+- **Look at it, don't reason about it.** Render the surface at a few widths before calling the work done. A story with a pinned container width snapshots the narrow case, so a regression shows up in visual review.
+
## Typecheck & typegen cadence (don't over-run these)
These are slow; run them at the right moment, not after every edit.