diff --git a/.claude/skills/studio-testing/SKILL.md b/.claude/skills/studio-testing/SKILL.md
new file mode 100644
index 0000000000000..3e7d16b8f5a1d
--- /dev/null
+++ b/.claude/skills/studio-testing/SKILL.md
@@ -0,0 +1,103 @@
+---
+name: studio-testing
+description: Testing strategy for Supabase Studio. Use when writing tests, deciding what
+ type of test to write, extracting logic from components into testable utility
+ functions, or reviewing test coverage. Covers unit tests, component tests,
+ and E2E test selection criteria.
+---
+
+# Studio Testing Strategy
+
+How to write and structure tests for `apps/studio/`. The core principle: push
+logic out of React components into pure utility functions, then test those
+functions exhaustively. Only use component tests for complex UI interactions.
+Use E2E tests for features shared between self-hosted and platform.
+
+## When to Apply
+
+Reference these guidelines when:
+
+- Writing new tests for Studio code
+- Deciding which type of test to write (unit, component, E2E)
+- Extracting logic from a component to make it testable
+- Reviewing whether test coverage is sufficient
+- Adding a new feature that needs tests
+
+## Rule Categories by Priority
+
+| Priority | Category | Impact | Prefix |
+| -------- | ---------------- | -------- | ---------- |
+| 1 | Logic Extraction | CRITICAL | `testing-` |
+| 2 | Test Coverage | CRITICAL | `testing-` |
+| 3 | Component Tests | HIGH | `testing-` |
+| 4 | E2E Tests | HIGH | `testing-` |
+
+## Quick Reference
+
+### 1. Logic Extraction (CRITICAL)
+
+- `testing-extract-logic` - Remove logic from components into `.utils.ts` files
+ as pure functions: args in, return out
+
+### 2. Test Coverage (CRITICAL)
+
+- `testing-exhaustive-permutations` - Test every permutation of utility functions:
+ happy path, malformed input, empty values, edge cases
+
+### 3. Component Tests (HIGH)
+
+- `testing-component-tests-ui-only` - Only write component tests for complex UI
+ interaction logic, not business logic
+
+### 4. E2E Tests (HIGH)
+
+- `testing-e2e-shared-features` - Write E2E tests for features used in both
+ self-hosted and platform; cover clicks AND keyboard shortcuts
+
+## Decision Tree: Which Test Type?
+
+```
+Is the logic a pure transformation (parse, format, validate, compute)?
+ YES -> Extract to .utils.ts, write unit test with vitest
+ NO -> Does the feature involve complex UI interactions?
+ YES -> Is it used in both self-hosted and platform?
+ YES -> Write E2E test in e2e/studio/features/
+ NO -> Write component test with customRender
+ NO -> Can you extract the logic to make it pure?
+ YES -> Do that, then unit test it
+ NO -> Write a component test
+```
+
+## How to Use
+
+Read individual rule files for detailed explanations and code examples:
+
+```
+rules/testing-extract-logic.md
+rules/testing-exhaustive-permutations.md
+```
+
+Each rule file contains:
+
+- Brief explanation of why it matters
+- Incorrect code example with explanation
+- Correct code example with explanation
+- Real codebase references
+
+## Full Compiled Document
+
+For the complete guide with all rules expanded: `AGENTS.md`
+
+## Codebase References
+
+| What | Where |
+| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Util test examples | `tests/components/Grid/Grid.utils.test.ts`, `tests/components/Billing/TaxID.utils.test.ts`, `tests/components/Editor/SpreadsheetImport.utils.test.ts` |
+| Component test examples | `tests/features/logs/LogsFilterPopover.test.tsx`, `tests/components/CopyButton.test.tsx` |
+| E2E test example | `e2e/studio/features/filter-bar.spec.ts` |
+| E2E helpers pattern | `e2e/studio/utils/filter-bar-helpers.ts` |
+| Custom render | `tests/lib/custom-render.tsx` |
+| MSW mock setup | `tests/lib/msw.ts` (`addAPIMock`) |
+| Test README | `tests/README.md` |
+| Vitest config | `vitest.config.ts` |
+| Related skills | `e2e-studio-tests` (running E2E), `vitest` (API reference), `vercel-composition-patterns` (component architecture) |
diff --git a/.claude/skills/studio-testing/rules/testing-component-tests-ui-only.md b/.claude/skills/studio-testing/rules/testing-component-tests-ui-only.md
new file mode 100644
index 0000000000000..4ba7b3e6cb644
--- /dev/null
+++ b/.claude/skills/studio-testing/rules/testing-component-tests-ui-only.md
@@ -0,0 +1,86 @@
+---
+title: Component Tests Are for Complex UI Logic Only
+impact: HIGH
+impactDescription: prevents slow, brittle tests that should be unit tests
+tags: testing, components, ui, react
+---
+
+## Component Tests Are for Complex UI Logic Only
+
+Only write component tests (`.test.tsx`) when there is complex UI interaction
+logic that cannot be captured by testing utility functions alone.
+
+**Valid reasons for a component test:**
+
+- Conditional rendering based on user interaction sequences
+- Popover/dropdown open/close behavior with keyboard and mouse
+- Form state transitions across multiple steps
+- Components that coordinate multiple async operations visually
+
+**Not a valid reason:** testing a calculation, transformation, parsing, or
+validation that happens to live inside a component. Extract that logic into a
+`.utils.ts` file and unit test it instead.
+
+**Incorrect (rendering a component just to test logic):**
+
+```tsx
+test('formats the display value correctly', () => {
+ render()
+ expect(screen.getByText('$12.34')).toBeInTheDocument()
+})
+```
+
+This is really testing a formatting function. Extract it:
+
+```ts
+// PriceDisplay.utils.ts
+export function formatPrice(amount: number, currency: string): string { ... }
+
+// PriceDisplay.utils.test.ts
+test('formats USD cents to dollars', () => {
+ expect(formatPrice(1234, 'USD')).toBe('$12.34')
+})
+```
+
+**Correct (component test for real UI interaction logic):**
+
+```tsx
+// Testing popover open/close, filter application, keyboard dismiss
+describe('LogsFilterPopover', () => {
+ test('opens popover and shows filter options', async () => {
+ customRender()
+ await userEvent.click(screen.getByRole('button'))
+ expect(screen.getByText('Apply')).toBeVisible()
+ })
+
+ test('applies selected filters on submit', async () => {
+ const onChange = vi.fn()
+ customRender()
+ // ... interact with UI ...
+ await userEvent.click(screen.getByText('Apply'))
+ expect(onChange).toHaveBeenCalledWith(expectedFilters)
+ })
+
+ test('closes on Escape key', async () => {
+ customRender()
+ await userEvent.click(screen.getByRole('button'))
+ await userEvent.keyboard('{Escape}')
+ expect(screen.queryByText('Apply')).not.toBeInTheDocument()
+ })
+})
+```
+
+**Studio component test conventions:**
+
+```tsx
+// Always use customRender, not raw render
+import { fireEvent } from '@testing-library/react'
+// Use userEvent for popovers, fireEvent for dropdowns
+import userEvent from '@testing-library/user-event'
+import { customRender } from 'tests/lib/custom-render'
+// Use addAPIMock for API mocking in beforeEach
+import { addAPIMock } from 'tests/lib/msw'
+```
+
+See `tests/README.md` for full conventions on custom render, MSW mocking,
+and nuqs URL parameter testing.
diff --git a/.claude/skills/studio-testing/rules/testing-e2e-shared-features.md b/.claude/skills/studio-testing/rules/testing-e2e-shared-features.md
new file mode 100644
index 0000000000000..31945a4533f22
--- /dev/null
+++ b/.claude/skills/studio-testing/rules/testing-e2e-shared-features.md
@@ -0,0 +1,98 @@
+---
+title: E2E Tests for Self-Hosted and Platform Features
+impact: HIGH
+impactDescription: ensures critical shared features work across deployment targets
+tags: testing, e2e, playwright, self-hosted, platform
+---
+
+## E2E Tests for Self-Hosted and Platform Features
+
+If a feature exists in both self-hosted and the Supabase platform, create an
+E2E test to cover it. E2E tests live in `e2e/studio/features/*.spec.ts`.
+
+**What to cover in E2E tests:**
+
+- Mouse/click interactions AND keyboard shortcuts (Tab, Enter, Escape, Arrow keys)
+- Full user flows end-to-end
+- Both adding and removing/clearing state
+- Setup and teardown (create resources in `try`, clean up in `finally`)
+
+**Incorrect (only tests mouse clicks):**
+
+```ts
+test('can add a filter', async ({ page }) => {
+ await page.getByRole('button', { name: 'Add filter' }).click()
+ await page.getByRole('option', { name: 'id' }).click()
+ // ... only click-based interactions
+})
+```
+
+**Correct (covers clicks AND keyboard shortcuts):**
+
+```ts
+test.describe('Basic Filter Operations', () => {
+ test('can add a filter by clicking', async ({ page }) => {
+ await addFilter(page, ref, 'id', 'equals', '1')
+ await expect(page.getByTestId('filter-condition')).toBeVisible()
+ })
+})
+
+test.describe('Keyboard Navigation - Freeform Input', () => {
+ test('Enter selects column from suggestions', async ({ page }) => {
+ await getFilterBarInput(page).press('Enter')
+ await expect(page.getByTestId('operator-input')).toBeFocused()
+ })
+
+ test('Backspace on empty input highlights last condition', async ({ page }) => {
+ await addFilter(page, ref, 'id', 'equals', '1')
+ await getFilterBarInput(page).press('Backspace')
+ await expect(page.getByTestId('filter-condition')).toHaveAttribute('data-highlighted', 'true')
+ })
+
+ test('Escape clears highlight', async ({ page }) => {
+ // ...
+ await getFilterBarInput(page).press('Escape')
+ await expect(page.getByTestId('filter-condition')).toHaveAttribute('data-highlighted', 'false')
+ })
+})
+```
+
+**E2E helper pattern:** Extract reusable interactions into helper files at
+`e2e/studio/utils/*-helpers.ts`:
+
+```ts
+// e2e/studio/utils/filter-bar-helpers.ts
+export async function addFilter(page, ref, column, operator, value) {
+ await selectColumnFilter(page, column)
+ await selectOperator(page, column, operator)
+ // ... fill value, wait for API response
+}
+
+export async function setupFilterBarPage(page, ref, editorUrl) {
+ await page.goto(editorUrl)
+ await enableFilterBar(page)
+ await page.reload()
+}
+```
+
+This keeps spec files focused on assertions while helpers handle the
+interaction mechanics.
+
+**Always use try/finally for resource cleanup:**
+
+```ts
+test('filters the table', async ({ page, ref }) => {
+ const tableName = await createTable(page, ref)
+ try {
+ await setupFilterBarPage(page, ref, editorUrl)
+ await navigateToTable(page, ref, tableName)
+ await addFilter(page, ref, 'id', 'equals', '1')
+ // assertions...
+ } finally {
+ await dropTable(page, ref, tableName)
+ }
+})
+```
+
+For E2E execution details (running tests, selectors, debugging), use the
+`e2e-studio-tests` skill.
diff --git a/.claude/skills/studio-testing/rules/testing-exhaustive-permutations.md b/.claude/skills/studio-testing/rules/testing-exhaustive-permutations.md
new file mode 100644
index 0000000000000..afa808d7ad7c6
--- /dev/null
+++ b/.claude/skills/studio-testing/rules/testing-exhaustive-permutations.md
@@ -0,0 +1,84 @@
+---
+title: Test Every Permutation of Utility Functions
+impact: CRITICAL
+impactDescription: catches edge cases and regressions in business logic
+tags: testing, utils, coverage, permutations
+---
+
+## Test Every Permutation of Utility Functions
+
+Once logic is extracted into a pure function, test it exhaustively. Every code
+path should have a test. Don't just test the happy path.
+
+**What to cover:**
+
+- Valid inputs (happy path for each branch)
+- Invalid / malformed inputs
+- Empty values, null values, missing fields
+- Edge cases (timestamps with colons, special characters, boundary values)
+- Security-sensitive inputs (XSS payloads, external URLs) where relevant
+
+**Incorrect (only tests the happy path):**
+
+```ts
+describe('formatFilterURLParams', () => {
+ test('parses a filter', () => {
+ const result = formatFilterURLParams('id:gte:20')
+ expect(result).toStrictEqual({ column: 'id', operator: 'gte', value: '20' })
+ })
+})
+```
+
+**Correct (tests every permutation):**
+
+```ts
+describe('formatFilterURLParams', () => {
+ test('parses valid filter', () => {
+ const result = formatFilterURLParams('id:gte:20')
+ expect(result).toStrictEqual({ column: 'id', operator: 'gte', value: '20' })
+ })
+
+ test('handles timestamp with colons in value', () => {
+ const result = formatFilterURLParams('created:gte:2024-01-01T00:00:00')
+ expect(result).toStrictEqual({
+ column: 'created',
+ operator: 'gte',
+ value: '2024-01-01T00:00:00',
+ })
+ })
+
+ test('rejects malformed filter with missing parts', () => {
+ const result = formatFilterURLParams('id')
+ expect(result).toBeUndefined()
+ })
+
+ test('rejects unrecognized operator', () => {
+ const result = formatFilterURLParams('id:nope:20')
+ expect(result).toBeUndefined()
+ })
+
+ test('allows empty filter value', () => {
+ const result = formatFilterURLParams('name:eq:')
+ expect(result).toStrictEqual({ column: 'name', operator: 'eq', value: '' })
+ })
+})
+```
+
+**Another real example -- `inferColumnType` tests every data type:**
+
+```ts
+describe('inferColumnType', () => {
+ test('defaults to text for empty data', () => { ... })
+ test('defaults to text for missing column', () => { ... })
+ test('defaults to text for null values', () => { ... })
+ test('detects integer', () => { ... }) // "42" -> int8
+ test('detects float', () => { ... }) // "161.72" -> float8
+ test('detects boolean', () => { ... }) // "true"/"false" -> bool
+ test('detects boolean with nulls', () => { ... })
+ test('detects JSON object', () => { ... }) // "{}" -> jsonb
+ test('detects timestamp', () => { ... }) // multiple formats -> timestamptz
+})
+```
+
+The goal: if someone changes the function, at least one test should break for
+any behavioral change.
diff --git a/.claude/skills/studio-testing/rules/testing-extract-logic.md b/.claude/skills/studio-testing/rules/testing-extract-logic.md
new file mode 100644
index 0000000000000..6c7d087fb2b90
--- /dev/null
+++ b/.claude/skills/studio-testing/rules/testing-extract-logic.md
@@ -0,0 +1,94 @@
+---
+title: Extract Logic Into Utility Files
+impact: CRITICAL
+impactDescription: makes business logic trivially testable without rendering components
+tags: testing, utils, extraction, pure-functions
+---
+
+## Extract Logic Into Utility Files
+
+Remove as much logic from components as possible. Put it in co-located
+`.utils.ts` files as pure functions: arguments in, return value out. No React
+hooks, no context, no side effects.
+
+**File naming convention:**
+
+- Utility file: `ComponentName.utils.ts` next to the component
+- Test file: `tests/components/.../ComponentName.utils.test.ts` mirroring the source path
+- Or under `tests/unit/` for non-component utilities
+
+**Incorrect (logic buried inside a component):**
+
+```tsx
+// components/Billing/TaxIdForm.tsx
+function TaxIdForm({ taxIdValue, taxIdName }: Props) {
+ const handleSubmit = () => {
+ // Logic buried in the component -- hard to test without rendering
+ const taxId = TAX_IDS.find((t) => t.name === taxIdName)
+ let sanitized = taxIdValue
+ if (taxId?.vatPrefix && !taxIdValue.startsWith(taxId.vatPrefix)) {
+ sanitized = taxId.vatPrefix + taxIdValue
+ }
+ submitToApi(sanitized)
+ }
+
+ return
+}
+```
+
+**Correct (logic extracted to a utility file):**
+
+```ts
+// components/Billing/TaxID.utils.ts
+import { TAX_IDS } from './TaxID.constants'
+
+// Pure function: args in, return out
+export function sanitizeTaxIdValue({ value, name }: { value: string; name: string }): string {
+ const taxId = TAX_IDS.find((t) => t.name === name)
+ if (taxId?.vatPrefix && !value.startsWith(taxId.vatPrefix)) {
+ return taxId.vatPrefix + value
+ }
+ return value
+}
+```
+
+```tsx
+// components/Billing/TaxIdForm.tsx
+import { sanitizeTaxIdValue } from './TaxID.utils'
+
+function TaxIdForm({ taxIdValue, taxIdName }: Props) {
+ const handleSubmit = () => {
+ const sanitized = sanitizeTaxIdValue({ value: taxIdValue, name: taxIdName })
+ submitToApi(sanitized)
+ }
+ return
+}
+```
+
+```ts
+// tests/components/Billing/TaxID.utils.test.ts
+import { sanitizeTaxIdValue } from 'components/.../TaxID.utils'
+
+describe('sanitizeTaxIdValue', () => {
+ test('prefixes unprefixed EU tax ID', () => {
+ expect(sanitizeTaxIdValue({ value: '12345678', name: 'AT VAT' })).toBe('ATU12345678')
+ })
+
+ test('passes through already-prefixed EU tax ID', () => {
+ expect(sanitizeTaxIdValue({ value: 'ATU12345678', name: 'AT VAT' })).toBe('ATU12345678')
+ })
+
+ test('passes through non-EU tax ID unchanged', () => {
+ expect(sanitizeTaxIdValue({ value: '12-3456789', name: 'US EIN' })).toBe('12-3456789')
+ })
+})
+```
+
+The component becomes a thin shell that calls the utility. All business logic
+is testable without rendering anything.
+
+**Real codebase examples:**
+
+- `components/grid/SupabaseGrid.utils.ts` -- URL param parsing, used by 15+ components
+- `components/.../SpreadsheetImport/SpreadsheetImport.utils.tsx` -- CSV parsing, column type inference
+- `components/.../BillingCustomerData/TaxID.utils.ts` -- tax ID sanitization and comparison
diff --git a/.claude/skills/vercel-composition-patterns/AGENTS.md b/.claude/skills/vercel-composition-patterns/AGENTS.md
new file mode 100644
index 0000000000000..558bf9aa1e36d
--- /dev/null
+++ b/.claude/skills/vercel-composition-patterns/AGENTS.md
@@ -0,0 +1,946 @@
+# React Composition Patterns
+
+**Version 1.0.0**
+Engineering
+January 2026
+
+> **Note:**
+> This document is mainly for agents and LLMs to follow when maintaining,
+> generating, or refactoring React codebases using composition. Humans
+> may also find it useful, but guidance here is optimized for automation
+> and consistency by AI-assisted workflows.
+
+---
+
+## Abstract
+
+Composition patterns for building flexible, maintainable React components. Avoid boolean prop proliferation by using compound components, lifting state, and composing internals. These patterns make codebases easier for both humans and AI agents to work with as they scale.
+
+---
+
+## Table of Contents
+
+1. [Component Architecture](#1-component-architecture) — **HIGH**
+ - 1.1 [Avoid Boolean Prop Proliferation](#11-avoid-boolean-prop-proliferation)
+ - 1.2 [Use Compound Components](#12-use-compound-components)
+2. [State Management](#2-state-management) — **MEDIUM**
+ - 2.1 [Decouple State Management from UI](#21-decouple-state-management-from-ui)
+ - 2.2 [Define Generic Context Interfaces for Dependency Injection](#22-define-generic-context-interfaces-for-dependency-injection)
+ - 2.3 [Lift State into Provider Components](#23-lift-state-into-provider-components)
+3. [Implementation Patterns](#3-implementation-patterns) — **MEDIUM**
+ - 3.1 [Create Explicit Component Variants](#31-create-explicit-component-variants)
+ - 3.2 [Prefer Composing Children Over Render Props](#32-prefer-composing-children-over-render-props)
+4. [React 19 APIs](#4-react-19-apis) — **MEDIUM**
+ - 4.1 [React 19 API Changes](#41-react-19-api-changes)
+
+---
+
+## 1. Component Architecture
+
+**Impact: HIGH**
+
+Fundamental patterns for structuring components to avoid prop
+proliferation and enable flexible composition.
+
+### 1.1 Avoid Boolean Prop Proliferation
+
+**Impact: CRITICAL (prevents unmaintainable component variants)**
+
+Don't add boolean props like `isThread`, `isEditing`, `isDMThread` to customize
+
+component behavior. Each boolean doubles possible states and creates
+
+unmaintainable conditional logic. Use composition instead.
+
+**Incorrect: boolean props create exponential complexity**
+
+```tsx
+function Composer({
+ onSubmit,
+ isThread,
+ channelId,
+ isDMThread,
+ dmId,
+ isEditing,
+ isForwarding,
+}: Props) {
+ return (
+
+ )
+}
+```
+
+**Correct: composition eliminates conditionals**
+
+```tsx
+// Channel composer
+function ChannelComposer() {
+ return (
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+// Thread composer - adds "also send to channel" field
+function ThreadComposer({ channelId }: { channelId: string }) {
+ return (
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+// Edit composer - different footer actions
+function EditComposer() {
+ return (
+
+
+
+
+
+
+
+
+
+ )
+}
+```
+
+Each variant is explicit about what it renders. We can share internals without
+
+sharing a single monolithic parent.
+
+### 1.2 Use Compound Components
+
+**Impact: HIGH (enables flexible composition without prop drilling)**
+
+Structure complex components as compound components with a shared context. Each
+
+subcomponent accesses shared state via context, not props. Consumers compose the
+
+pieces they need.
+
+**Incorrect: monolithic component with render props**
+
+```tsx
+function Composer({
+ renderHeader,
+ renderFooter,
+ renderActions,
+ showAttachments,
+ showFormatting,
+ showEmojis,
+}: Props) {
+ return (
+
+ )
+}
+```
+
+**Correct: compound components with shared context**
+
+```tsx
+const ComposerContext = createContext(null)
+
+function ComposerProvider({ children, state, actions, meta }: ProviderProps) {
+ return (
+
+ {children}
+
+ )
+}
+
+function ComposerFrame({ children }: { children: React.ReactNode }) {
+ return
+}
+
+function ComposerInput() {
+ const {
+ state,
+ actions: { update },
+ meta: { inputRef },
+ } = use(ComposerContext)
+ return (
+ update((s) => ({ ...s, input: text }))}
+ />
+ )
+}
+
+function ComposerSubmit() {
+ const {
+ actions: { submit },
+ } = use(ComposerContext)
+ return
+}
+
+// Export as compound component
+const Composer = {
+ Provider: ComposerProvider,
+ Frame: ComposerFrame,
+ Input: ComposerInput,
+ Submit: ComposerSubmit,
+ Header: ComposerHeader,
+ Footer: ComposerFooter,
+ Attachments: ComposerAttachments,
+ Formatting: ComposerFormatting,
+ Emojis: ComposerEmojis,
+}
+```
+
+**Usage:**
+
+```tsx
+
+
+
+
+
+
+
+
+
+
+```
+
+Consumers explicitly compose exactly what they need. No hidden conditionals. And the state, actions and meta are dependency-injected by a parent provider, allowing multiple usages of the same component structure.
+
+---
+
+## 2. State Management
+
+**Impact: MEDIUM**
+
+Patterns for lifting state and managing shared context across
+composed components.
+
+### 2.1 Decouple State Management from UI
+
+**Impact: MEDIUM (enables swapping state implementations without changing UI)**
+
+The provider component should be the only place that knows how state is managed.
+
+UI components consume the context interface—they don't know if state comes from
+
+useState, Zustand, or a server sync.
+
+**Incorrect: UI coupled to state implementation**
+
+```tsx
+function ChannelComposer({ channelId }: { channelId: string }) {
+ // UI component knows about global state implementation
+ const state = useGlobalChannelState(channelId)
+ const { submit, updateInput } = useChannelSync(channelId)
+
+ return (
+
+ sync.updateInput(text)}
+ />
+ sync.submit()} />
+
+ )
+}
+```
+
+**Correct: state management isolated in provider**
+
+```tsx
+// Provider handles all state management details
+function ChannelProvider({
+ channelId,
+ children,
+}: {
+ channelId: string
+ children: React.ReactNode
+}) {
+ const { state, update, submit } = useGlobalChannel(channelId)
+ const inputRef = useRef(null)
+
+ return (
+
+ {children}
+
+ )
+}
+
+// UI component only knows about the context interface
+function ChannelComposer() {
+ return (
+
+
+
+
+
+
+
+ )
+}
+
+// Usage
+function Channel({ channelId }: { channelId: string }) {
+ return (
+
+
+
+ )
+}
+```
+
+**Different providers, same UI:**
+
+```tsx
+// Local state for ephemeral forms
+function ForwardMessageProvider({ children }) {
+ const [state, setState] = useState(initialState)
+ const forwardMessage = useForwardMessage()
+
+ return (
+
+ {children}
+
+ )
+}
+
+// Global synced state for channels
+function ChannelProvider({ channelId, children }) {
+ const { state, update, submit } = useGlobalChannel(channelId)
+
+ return (
+
+ {children}
+
+ )
+}
+```
+
+The same `Composer.Input` component works with both providers because it only
+
+depends on the context interface, not the implementation.
+
+### 2.2 Define Generic Context Interfaces for Dependency Injection
+
+**Impact: HIGH (enables dependency-injectable state across use-cases)**
+
+Define a **generic interface** for your component context with three parts:
+
+`state`, `actions`, and `meta`. This interface is a contract that any provider
+
+can implement—enabling the same UI components to work with completely different
+
+state implementations.
+
+**Core principle:** Lift state, compose internals, make state
+
+dependency-injectable.
+
+**Incorrect: UI coupled to specific state implementation**
+
+```tsx
+function ComposerInput() {
+ // Tightly coupled to a specific hook
+ const { input, setInput } = useChannelComposerState()
+ return
+}
+```
+
+**Correct: generic interface enables dependency injection**
+
+```tsx
+// Define a GENERIC interface that any provider can implement
+interface ComposerState {
+ input: string
+ attachments: Attachment[]
+ isSubmitting: boolean
+}
+
+interface ComposerActions {
+ update: (updater: (state: ComposerState) => ComposerState) => void
+ submit: () => void
+}
+
+interface ComposerMeta {
+ inputRef: React.RefObject
+}
+
+interface ComposerContextValue {
+ state: ComposerState
+ actions: ComposerActions
+ meta: ComposerMeta
+}
+
+const ComposerContext = createContext(null)
+```
+
+**UI components consume the interface, not the implementation:**
+
+```tsx
+function ComposerInput() {
+ const {
+ state,
+ actions: { update },
+ meta,
+ } = use(ComposerContext)
+
+ // This component works with ANY provider that implements the interface
+ return (
+ update((s) => ({ ...s, input: text }))}
+ />
+ )
+}
+```
+
+**Different providers implement the same interface:**
+
+```tsx
+// Provider A: Local state for ephemeral forms
+function ForwardMessageProvider({ children }: { children: React.ReactNode }) {
+ const [state, setState] = useState(initialState)
+ const inputRef = useRef(null)
+ const submit = useForwardMessage()
+
+ return (
+
+ {children}
+
+ )
+}
+
+// Provider B: Global synced state for channels
+function ChannelProvider({ channelId, children }: Props) {
+ const { state, update, submit } = useGlobalChannel(channelId)
+ const inputRef = useRef(null)
+
+ return (
+
+ {children}
+
+ )
+}
+```
+
+**The same composed UI works with both:**
+
+```tsx
+// Works with ForwardMessageProvider (local state)
+
+
+
+
+
+
+
+// Works with ChannelProvider (global synced state)
+
+
+
+
+
+
+```
+
+**Custom UI outside the component can access state and actions:**
+
+```tsx
+function ForwardMessageDialog() {
+ return (
+
+
+
+ )
+}
+
+// This button lives OUTSIDE Composer.Frame but can still submit based on its context!
+function ForwardButton() {
+ const {
+ actions: { submit },
+ } = use(ComposerContext)
+ return
+}
+
+// This preview lives OUTSIDE Composer.Frame but can read composer's state!
+function MessagePreview() {
+ const { state } = use(ComposerContext)
+ return
+}
+```
+
+The provider boundary is what matters—not the visual nesting. Components that
+
+need shared state don't have to be inside the `Composer.Frame`. They just need
+
+to be within the provider.
+
+The `ForwardButton` and `MessagePreview` are not visually inside the composer
+
+box, but they can still access its state and actions. This is the power of
+
+lifting state into providers.
+
+The UI is reusable bits you compose together. The state is dependency-injected
+
+by the provider. Swap the provider, keep the UI.
+
+### 2.3 Lift State into Provider Components
+
+**Impact: HIGH (enables state sharing outside component boundaries)**
+
+Move state management into dedicated provider components. This allows sibling
+
+components outside the main UI to access and modify state without prop drilling
+
+or awkward refs.
+
+**Incorrect: state trapped inside component**
+
+```tsx
+function ForwardMessageComposer() {
+ const [state, setState] = useState(initialState)
+ const forwardMessage = useForwardMessage()
+
+ return (
+
+
+
+
+ )
+}
+
+// Problem: How does this button access composer state?
+function ForwardMessageDialog() {
+ return (
+
+ )
+}
+```
+
+**Incorrect: useEffect to sync state up**
+
+```tsx
+function ForwardMessageDialog() {
+ const [input, setInput] = useState('')
+ return (
+
+ )
+}
+
+function ForwardMessageComposer({ onInputChange }) {
+ const [state, setState] = useState(initialState)
+ useEffect(() => {
+ onInputChange(state.input) // Sync on every change 😬
+ }, [state.input])
+}
+```
+
+**Incorrect: reading state from ref on submit**
+
+```tsx
+function ForwardMessageDialog() {
+ const stateRef = useRef(null)
+ return (
+
+ )
+}
+```
+
+**Correct: state lifted to provider**
+
+```tsx
+function ForwardMessageProvider({ children }: { children: React.ReactNode }) {
+ const [state, setState] = useState(initialState)
+ const forwardMessage = useForwardMessage()
+ const inputRef = useRef(null)
+
+ return (
+
+ {children}
+
+ )
+}
+
+function ForwardMessageDialog() {
+ return (
+
+
+
+ )
+}
+
+function ForwardButton() {
+ const { actions } = use(Composer.Context)
+ return
+}
+```
+
+The ForwardButton lives outside the Composer.Frame but still has access to the
+
+submit action because it's within the provider. Even though it's a one-off
+
+component, it can still access the composer's state and actions from outside the
+
+UI itself.
+
+**Key insight:** Components that need shared state don't have to be visually
+
+nested inside each other—they just need to be within the same provider.
+
+---
+
+## 3. Implementation Patterns
+
+**Impact: MEDIUM**
+
+Specific techniques for implementing compound components and
+context providers.
+
+### 3.1 Create Explicit Component Variants
+
+**Impact: MEDIUM (self-documenting code, no hidden conditionals)**
+
+Instead of one component with many boolean props, create explicit variant
+
+components. Each variant composes the pieces it needs. The code documents
+
+itself.
+
+**Incorrect: one component, many modes**
+
+```tsx
+// What does this component actually render?
+
+```
+
+**Correct: explicit variants**
+
+```tsx
+// Immediately clear what this renders
+
+
+// Or
+
+
+// Or
+
+```
+
+Each implementation is unique, explicit and self-contained. Yet they can each
+
+use shared parts.
+
+**Implementation:**
+
+```tsx
+function ThreadComposer({ channelId }: { channelId: string }) {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+function EditMessageComposer({ messageId }: { messageId: string }) {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+function ForwardMessageComposer({ messageId }: { messageId: string }) {
+ return (
+
+
+
+
+
+
+
+
+
+
+ )
+}
+```
+
+Each variant is explicit about:
+
+- What provider/state it uses
+
+- What UI elements it includes
+
+- What actions are available
+
+No boolean prop combinations to reason about. No impossible states.
+
+### 3.2 Prefer Composing Children Over Render Props
+
+**Impact: MEDIUM (cleaner composition, better readability)**
+
+Use `children` for composition instead of `renderX` props. Children are more
+
+readable, compose naturally, and don't require understanding callback
+
+signatures.
+
+**Incorrect: render props**
+
+```tsx
+function Composer({
+ renderHeader,
+ renderFooter,
+ renderActions,
+}: {
+ renderHeader?: () => React.ReactNode
+ renderFooter?: () => React.ReactNode
+ renderActions?: () => React.ReactNode
+}) {
+ return (
+
+ )
+}
+
+// Usage is awkward and inflexible
+return (
+ }
+ renderFooter={() => (
+ <>
+
+
+ >
+ )}
+ renderActions={() => }
+ />
+)
+```
+
+**Correct: compound components with children**
+
+```tsx
+function ComposerFrame({ children }: { children: React.ReactNode }) {
+ return
+}
+
+function ComposerFooter({ children }: { children: React.ReactNode }) {
+ return
+}
+
+// Usage is flexible
+return (
+
+
+
+
+
+
+
+
+
+)
+```
+
+**When render props are appropriate:**
+
+```tsx
+// Render props work well when you need to pass data back
+ }
+/>
+```
+
+Use render props when the parent needs to provide data or state to the child.
+
+Use children when composing static structure.
+
+---
+
+## 4. React 19 APIs
+
+**Impact: MEDIUM**
+
+React 19+ only. Don't use `forwardRef`; use `use()` instead of `useContext()`.
+
+### 4.1 React 19 API Changes
+
+**Impact: MEDIUM (cleaner component definitions and context usage)**
+
+> **⚠️ React 19+ only.** Skip this if you're on React 18 or earlier.
+
+In React 19, `ref` is now a regular prop (no `forwardRef` wrapper needed), and `use()` replaces `useContext()`.
+
+**Incorrect: forwardRef in React 19**
+
+```tsx
+const ComposerInput = forwardRef((props, ref) => {
+ return
+})
+```
+
+**Correct: ref as a regular prop**
+
+```tsx
+function ComposerInput({ ref, ...props }: Props & { ref?: React.Ref }) {
+ return
+}
+```
+
+**Incorrect: useContext in React 19**
+
+```tsx
+const value = useContext(MyContext)
+```
+
+**Correct: use instead of useContext**
+
+```tsx
+const value = use(MyContext)
+```
+
+`use()` can also be called conditionally, unlike `useContext()`.
+
+---
+
+## References
+
+1. [https://react.dev](https://react.dev)
+2. [https://react.dev/learn/passing-data-deeply-with-context](https://react.dev/learn/passing-data-deeply-with-context)
+3. [https://react.dev/reference/react/use](https://react.dev/reference/react/use)
diff --git a/.claude/skills/vercel-composition-patterns/SKILL.md b/.claude/skills/vercel-composition-patterns/SKILL.md
new file mode 100644
index 0000000000000..d07025bf94334
--- /dev/null
+++ b/.claude/skills/vercel-composition-patterns/SKILL.md
@@ -0,0 +1,89 @@
+---
+name: vercel-composition-patterns
+description:
+ React composition patterns that scale. Use when refactoring components with
+ boolean prop proliferation, building flexible component libraries, or
+ designing reusable APIs. Triggers on tasks involving compound components,
+ render props, context providers, or component architecture. Includes React 19
+ API changes.
+license: MIT
+metadata:
+ author: vercel
+ version: '1.0.0'
+---
+
+# React Composition Patterns
+
+Composition patterns for building flexible, maintainable React components. Avoid
+boolean prop proliferation by using compound components, lifting state, and
+composing internals. These patterns make codebases easier for both humans and AI
+agents to work with as they scale.
+
+## When to Apply
+
+Reference these guidelines when:
+
+- Refactoring components with many boolean props
+- Building reusable component libraries
+- Designing flexible component APIs
+- Reviewing component architecture
+- Working with compound components or context providers
+
+## Rule Categories by Priority
+
+| Priority | Category | Impact | Prefix |
+| -------- | ----------------------- | ------ | --------------- |
+| 1 | Component Architecture | HIGH | `architecture-` |
+| 2 | State Management | MEDIUM | `state-` |
+| 3 | Implementation Patterns | MEDIUM | `patterns-` |
+| 4 | React 19 APIs | MEDIUM | `react19-` |
+
+## Quick Reference
+
+### 1. Component Architecture (HIGH)
+
+- `architecture-avoid-boolean-props` - Don't add boolean props to customize
+ behavior; use composition
+- `architecture-compound-components` - Structure complex components with shared
+ context
+
+### 2. State Management (MEDIUM)
+
+- `state-decouple-implementation` - Provider is the only place that knows how
+ state is managed
+- `state-context-interface` - Define generic interface with state, actions, meta
+ for dependency injection
+- `state-lift-state` - Move state into provider components for sibling access
+
+### 3. Implementation Patterns (MEDIUM)
+
+- `patterns-explicit-variants` - Create explicit variant components instead of
+ boolean modes
+- `patterns-children-over-render-props` - Use children for composition instead
+ of renderX props
+
+### 4. React 19 APIs (MEDIUM)
+
+> **⚠️ React 19+ only.** Skip this section if using React 18 or earlier.
+
+- `react19-no-forwardref` - Don't use `forwardRef`; use `use()` instead of `useContext()`
+
+## How to Use
+
+Read individual rule files for detailed explanations and code examples:
+
+```
+rules/architecture-avoid-boolean-props.md
+rules/state-context-interface.md
+```
+
+Each rule file contains:
+
+- Brief explanation of why it matters
+- Incorrect code example with explanation
+- Correct code example with explanation
+- Additional context and references
+
+## Full Compiled Document
+
+For the complete guide with all rules expanded: `AGENTS.md`
diff --git a/.claude/skills/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md b/.claude/skills/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md
new file mode 100644
index 0000000000000..ccee19ce495b9
--- /dev/null
+++ b/.claude/skills/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md
@@ -0,0 +1,100 @@
+---
+title: Avoid Boolean Prop Proliferation
+impact: CRITICAL
+impactDescription: prevents unmaintainable component variants
+tags: composition, props, architecture
+---
+
+## Avoid Boolean Prop Proliferation
+
+Don't add boolean props like `isThread`, `isEditing`, `isDMThread` to customize
+component behavior. Each boolean doubles possible states and creates
+unmaintainable conditional logic. Use composition instead.
+
+**Incorrect (boolean props create exponential complexity):**
+
+```tsx
+function Composer({
+ onSubmit,
+ isThread,
+ channelId,
+ isDMThread,
+ dmId,
+ isEditing,
+ isForwarding,
+}: Props) {
+ return (
+
+ )
+}
+```
+
+**Correct (composition eliminates conditionals):**
+
+```tsx
+// Channel composer
+function ChannelComposer() {
+ return (
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+// Thread composer - adds "also send to channel" field
+function ThreadComposer({ channelId }: { channelId: string }) {
+ return (
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+// Edit composer - different footer actions
+function EditComposer() {
+ return (
+
+
+
+
+
+
+
+
+
+ )
+}
+```
+
+Each variant is explicit about what it renders. We can share internals without
+sharing a single monolithic parent.
diff --git a/.claude/skills/vercel-composition-patterns/rules/architecture-compound-components.md b/.claude/skills/vercel-composition-patterns/rules/architecture-compound-components.md
new file mode 100644
index 0000000000000..e5e3043cb5a81
--- /dev/null
+++ b/.claude/skills/vercel-composition-patterns/rules/architecture-compound-components.md
@@ -0,0 +1,112 @@
+---
+title: Use Compound Components
+impact: HIGH
+impactDescription: enables flexible composition without prop drilling
+tags: composition, compound-components, architecture
+---
+
+## Use Compound Components
+
+Structure complex components as compound components with a shared context. Each
+subcomponent accesses shared state via context, not props. Consumers compose the
+pieces they need.
+
+**Incorrect (monolithic component with render props):**
+
+```tsx
+function Composer({
+ renderHeader,
+ renderFooter,
+ renderActions,
+ showAttachments,
+ showFormatting,
+ showEmojis,
+}: Props) {
+ return (
+
+ )
+}
+```
+
+**Correct (compound components with shared context):**
+
+```tsx
+const ComposerContext = createContext(null)
+
+function ComposerProvider({ children, state, actions, meta }: ProviderProps) {
+ return (
+
+ {children}
+
+ )
+}
+
+function ComposerFrame({ children }: { children: React.ReactNode }) {
+ return
+}
+
+function ComposerInput() {
+ const {
+ state,
+ actions: { update },
+ meta: { inputRef },
+ } = use(ComposerContext)
+ return (
+ update((s) => ({ ...s, input: text }))}
+ />
+ )
+}
+
+function ComposerSubmit() {
+ const {
+ actions: { submit },
+ } = use(ComposerContext)
+ return
+}
+
+// Export as compound component
+const Composer = {
+ Provider: ComposerProvider,
+ Frame: ComposerFrame,
+ Input: ComposerInput,
+ Submit: ComposerSubmit,
+ Header: ComposerHeader,
+ Footer: ComposerFooter,
+ Attachments: ComposerAttachments,
+ Formatting: ComposerFormatting,
+ Emojis: ComposerEmojis,
+}
+```
+
+**Usage:**
+
+```tsx
+
+
+
+
+
+
+
+
+
+
+```
+
+Consumers explicitly compose exactly what they need. No hidden conditionals. And the state, actions and meta are dependency-injected by a parent provider, allowing multiple usages of the same component structure.
diff --git a/.claude/skills/vercel-composition-patterns/rules/patterns-children-over-render-props.md b/.claude/skills/vercel-composition-patterns/rules/patterns-children-over-render-props.md
new file mode 100644
index 0000000000000..d4345ee30aea5
--- /dev/null
+++ b/.claude/skills/vercel-composition-patterns/rules/patterns-children-over-render-props.md
@@ -0,0 +1,87 @@
+---
+title: Prefer Composing Children Over Render Props
+impact: MEDIUM
+impactDescription: cleaner composition, better readability
+tags: composition, children, render-props
+---
+
+## Prefer Children Over Render Props
+
+Use `children` for composition instead of `renderX` props. Children are more
+readable, compose naturally, and don't require understanding callback
+signatures.
+
+**Incorrect (render props):**
+
+```tsx
+function Composer({
+ renderHeader,
+ renderFooter,
+ renderActions,
+}: {
+ renderHeader?: () => React.ReactNode
+ renderFooter?: () => React.ReactNode
+ renderActions?: () => React.ReactNode
+}) {
+ return (
+
+ )
+}
+
+// Usage is awkward and inflexible
+return (
+ }
+ renderFooter={() => (
+ <>
+
+
+ >
+ )}
+ renderActions={() => }
+ />
+)
+```
+
+**Correct (compound components with children):**
+
+```tsx
+function ComposerFrame({ children }: { children: React.ReactNode }) {
+ return
+}
+
+function ComposerFooter({ children }: { children: React.ReactNode }) {
+ return
+}
+
+// Usage is flexible
+return (
+
+
+
+
+
+
+
+
+
+)
+```
+
+**When render props are appropriate:**
+
+```tsx
+// Render props work well when you need to pass data back
+ }
+/>
+```
+
+Use render props when the parent needs to provide data or state to the child.
+Use children when composing static structure.
diff --git a/.claude/skills/vercel-composition-patterns/rules/patterns-explicit-variants.md b/.claude/skills/vercel-composition-patterns/rules/patterns-explicit-variants.md
new file mode 100644
index 0000000000000..56e32e8bee5e5
--- /dev/null
+++ b/.claude/skills/vercel-composition-patterns/rules/patterns-explicit-variants.md
@@ -0,0 +1,100 @@
+---
+title: Create Explicit Component Variants
+impact: MEDIUM
+impactDescription: self-documenting code, no hidden conditionals
+tags: composition, variants, architecture
+---
+
+## Create Explicit Component Variants
+
+Instead of one component with many boolean props, create explicit variant
+components. Each variant composes the pieces it needs. The code documents
+itself.
+
+**Incorrect (one component, many modes):**
+
+```tsx
+// What does this component actually render?
+
+```
+
+**Correct (explicit variants):**
+
+```tsx
+// Immediately clear what this renders
+
+
+// Or
+
+
+// Or
+
+```
+
+Each implementation is unique, explicit and self-contained. Yet they can each
+use shared parts.
+
+**Implementation:**
+
+```tsx
+function ThreadComposer({ channelId }: { channelId: string }) {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+function EditMessageComposer({ messageId }: { messageId: string }) {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+function ForwardMessageComposer({ messageId }: { messageId: string }) {
+ return (
+
+
+
+
+
+
+
+
+
+
+ )
+}
+```
+
+Each variant is explicit about:
+
+- What provider/state it uses
+- What UI elements it includes
+- What actions are available
+
+No boolean prop combinations to reason about. No impossible states.
diff --git a/.claude/skills/vercel-composition-patterns/rules/react19-no-forwardref.md b/.claude/skills/vercel-composition-patterns/rules/react19-no-forwardref.md
new file mode 100644
index 0000000000000..e0d8f8a76f148
--- /dev/null
+++ b/.claude/skills/vercel-composition-patterns/rules/react19-no-forwardref.md
@@ -0,0 +1,42 @@
+---
+title: React 19 API Changes
+impact: MEDIUM
+impactDescription: cleaner component definitions and context usage
+tags: react19, refs, context, hooks
+---
+
+## React 19 API Changes
+
+> **⚠️ React 19+ only.** Skip this if you're on React 18 or earlier.
+
+In React 19, `ref` is now a regular prop (no `forwardRef` wrapper needed), and `use()` replaces `useContext()`.
+
+**Incorrect (forwardRef in React 19):**
+
+```tsx
+const ComposerInput = forwardRef((props, ref) => {
+ return
+})
+```
+
+**Correct (ref as a regular prop):**
+
+```tsx
+function ComposerInput({ ref, ...props }: Props & { ref?: React.Ref }) {
+ return
+}
+```
+
+**Incorrect (useContext in React 19):**
+
+```tsx
+const value = useContext(MyContext)
+```
+
+**Correct (use instead of useContext):**
+
+```tsx
+const value = use(MyContext)
+```
+
+`use()` can also be called conditionally, unlike `useContext()`.
diff --git a/.claude/skills/vercel-composition-patterns/rules/state-context-interface.md b/.claude/skills/vercel-composition-patterns/rules/state-context-interface.md
new file mode 100644
index 0000000000000..d961bede0c6c6
--- /dev/null
+++ b/.claude/skills/vercel-composition-patterns/rules/state-context-interface.md
@@ -0,0 +1,191 @@
+---
+title: Define Generic Context Interfaces for Dependency Injection
+impact: HIGH
+impactDescription: enables dependency-injectable state across use-cases
+tags: composition, context, state, typescript, dependency-injection
+---
+
+## Define Generic Context Interfaces for Dependency Injection
+
+Define a **generic interface** for your component context with three parts:
+`state`, `actions`, and `meta`. This interface is a contract that any provider
+can implement—enabling the same UI components to work with completely different
+state implementations.
+
+**Core principle:** Lift state, compose internals, make state
+dependency-injectable.
+
+**Incorrect (UI coupled to specific state implementation):**
+
+```tsx
+function ComposerInput() {
+ // Tightly coupled to a specific hook
+ const { input, setInput } = useChannelComposerState()
+ return
+}
+```
+
+**Correct (generic interface enables dependency injection):**
+
+```tsx
+// Define a GENERIC interface that any provider can implement
+interface ComposerState {
+ input: string
+ attachments: Attachment[]
+ isSubmitting: boolean
+}
+
+interface ComposerActions {
+ update: (updater: (state: ComposerState) => ComposerState) => void
+ submit: () => void
+}
+
+interface ComposerMeta {
+ inputRef: React.RefObject
+}
+
+interface ComposerContextValue {
+ state: ComposerState
+ actions: ComposerActions
+ meta: ComposerMeta
+}
+
+const ComposerContext = createContext(null)
+```
+
+**UI components consume the interface, not the implementation:**
+
+```tsx
+function ComposerInput() {
+ const {
+ state,
+ actions: { update },
+ meta,
+ } = use(ComposerContext)
+
+ // This component works with ANY provider that implements the interface
+ return (
+ update((s) => ({ ...s, input: text }))}
+ />
+ )
+}
+```
+
+**Different providers implement the same interface:**
+
+```tsx
+// Provider A: Local state for ephemeral forms
+function ForwardMessageProvider({ children }: { children: React.ReactNode }) {
+ const [state, setState] = useState(initialState)
+ const inputRef = useRef(null)
+ const submit = useForwardMessage()
+
+ return (
+
+ {children}
+
+ )
+}
+
+// Provider B: Global synced state for channels
+function ChannelProvider({ channelId, children }: Props) {
+ const { state, update, submit } = useGlobalChannel(channelId)
+ const inputRef = useRef(null)
+
+ return (
+
+ {children}
+
+ )
+}
+```
+
+**The same composed UI works with both:**
+
+```tsx
+// Works with ForwardMessageProvider (local state)
+
+
+
+
+
+
+
+// Works with ChannelProvider (global synced state)
+
+
+
+
+
+
+```
+
+**Custom UI outside the component can access state and actions:**
+
+The provider boundary is what matters—not the visual nesting. Components that
+need shared state don't have to be inside the `Composer.Frame`. They just need
+to be within the provider.
+
+```tsx
+function ForwardMessageDialog() {
+ return (
+
+
+
+ )
+}
+
+// This button lives OUTSIDE Composer.Frame but can still submit based on its context!
+function ForwardButton() {
+ const {
+ actions: { submit },
+ } = use(ComposerContext)
+ return
+}
+
+// This preview lives OUTSIDE Composer.Frame but can read composer's state!
+function MessagePreview() {
+ const { state } = use(ComposerContext)
+ return
+}
+```
+
+The `ForwardButton` and `MessagePreview` are not visually inside the composer
+box, but they can still access its state and actions. This is the power of
+lifting state into providers.
+
+The UI is reusable bits you compose together. The state is dependency-injected
+by the provider. Swap the provider, keep the UI.
diff --git a/.claude/skills/vercel-composition-patterns/rules/state-decouple-implementation.md b/.claude/skills/vercel-composition-patterns/rules/state-decouple-implementation.md
new file mode 100644
index 0000000000000..71a5afaa7d707
--- /dev/null
+++ b/.claude/skills/vercel-composition-patterns/rules/state-decouple-implementation.md
@@ -0,0 +1,113 @@
+---
+title: Decouple State Management from UI
+impact: MEDIUM
+impactDescription: enables swapping state implementations without changing UI
+tags: composition, state, architecture
+---
+
+## Decouple State Management from UI
+
+The provider component should be the only place that knows how state is managed.
+UI components consume the context interface—they don't know if state comes from
+useState, Zustand, or a server sync.
+
+**Incorrect (UI coupled to state implementation):**
+
+```tsx
+function ChannelComposer({ channelId }: { channelId: string }) {
+ // UI component knows about global state implementation
+ const state = useGlobalChannelState(channelId)
+ const { submit, updateInput } = useChannelSync(channelId)
+
+ return (
+
+ sync.updateInput(text)}
+ />
+ sync.submit()} />
+
+ )
+}
+```
+
+**Correct (state management isolated in provider):**
+
+```tsx
+// Provider handles all state management details
+function ChannelProvider({
+ channelId,
+ children,
+}: {
+ channelId: string
+ children: React.ReactNode
+}) {
+ const { state, update, submit } = useGlobalChannel(channelId)
+ const inputRef = useRef(null)
+
+ return (
+
+ {children}
+
+ )
+}
+
+// UI component only knows about the context interface
+function ChannelComposer() {
+ return (
+
+
+
+
+
+
+
+ )
+}
+
+// Usage
+function Channel({ channelId }: { channelId: string }) {
+ return (
+
+
+
+ )
+}
+```
+
+**Different providers, same UI:**
+
+```tsx
+// Local state for ephemeral forms
+function ForwardMessageProvider({ children }) {
+ const [state, setState] = useState(initialState)
+ const forwardMessage = useForwardMessage()
+
+ return (
+
+ {children}
+
+ )
+}
+
+// Global synced state for channels
+function ChannelProvider({ channelId, children }) {
+ const { state, update, submit } = useGlobalChannel(channelId)
+
+ return (
+
+ {children}
+
+ )
+}
+```
+
+The same `Composer.Input` component works with both providers because it only
+depends on the context interface, not the implementation.
diff --git a/.claude/skills/vercel-composition-patterns/rules/state-lift-state.md b/.claude/skills/vercel-composition-patterns/rules/state-lift-state.md
new file mode 100644
index 0000000000000..d7fe27b549331
--- /dev/null
+++ b/.claude/skills/vercel-composition-patterns/rules/state-lift-state.md
@@ -0,0 +1,125 @@
+---
+title: Lift State into Provider Components
+impact: HIGH
+impactDescription: enables state sharing outside component boundaries
+tags: composition, state, context, providers
+---
+
+## Lift State into Provider Components
+
+Move state management into dedicated provider components. This allows sibling
+components outside the main UI to access and modify state without prop drilling
+or awkward refs.
+
+**Incorrect (state trapped inside component):**
+
+```tsx
+function ForwardMessageComposer() {
+ const [state, setState] = useState(initialState)
+ const forwardMessage = useForwardMessage()
+
+ return (
+
+
+
+
+ )
+}
+
+// Problem: How does this button access composer state?
+function ForwardMessageDialog() {
+ return (
+
+ )
+}
+```
+
+**Incorrect (useEffect to sync state up):**
+
+```tsx
+function ForwardMessageDialog() {
+ const [input, setInput] = useState('')
+ return (
+
+ )
+}
+
+function ForwardMessageComposer({ onInputChange }) {
+ const [state, setState] = useState(initialState)
+ useEffect(() => {
+ onInputChange(state.input) // Sync on every change 😬
+ }, [state.input])
+}
+```
+
+**Incorrect (reading state from ref on submit):**
+
+```tsx
+function ForwardMessageDialog() {
+ const stateRef = useRef(null)
+ return (
+
+ )
+}
+```
+
+**Correct (state lifted to provider):**
+
+```tsx
+function ForwardMessageProvider({ children }: { children: React.ReactNode }) {
+ const [state, setState] = useState(initialState)
+ const forwardMessage = useForwardMessage()
+ const inputRef = useRef(null)
+
+ return (
+
+ {children}
+
+ )
+}
+
+function ForwardMessageDialog() {
+ return (
+
+
+
+ )
+}
+
+function ForwardButton() {
+ const { actions } = use(Composer.Context)
+ return
+}
+```
+
+The ForwardButton lives outside the Composer.Frame but still has access to the
+submit action because it's within the provider. Even though it's a one-off
+component, it can still access the composer's state and actions from outside the
+UI itself.
+
+**Key insight:** Components that need shared state don't have to be visually
+nested inside each other—they just need to be within the same provider.
diff --git a/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.tsx b/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.tsx
index 11c436585bcc7..dc3e95e8e2d1c 100644
--- a/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.tsx
+++ b/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.tsx
@@ -84,7 +84,7 @@ export const StorageSettings = () => {
const {
data: config,
error,
- isPending: isLoading,
+ isPending: isLoadingProjectStorageConfig,
isSuccess,
isError,
} = useProjectStorageConfigQuery({ projectRef })
@@ -104,17 +104,28 @@ export const StorageSettings = () => {
const shouldAutoValidateBucketLimits = sizeLimitCheckCondition === 'auto'
const { data: organization } = useSelectedOrganizationQuery()
- const { getEntitlementNumericValue, isEntitlementUnlimited } =
- useCheckEntitlements('storage.max_file_size')
- const isFreeTier = organization?.plan.id === 'free'
+ const {
+ getEntitlementNumericValue,
+ isEntitlementUnlimited,
+ isLoading: isLoadingMaxFileSizeEntitlement,
+ } = useCheckEntitlements('storage.max_file_size')
+ const { hasAccess: hasAccessToFileSizeConfiguration, isLoading: isLoadingFileSizeConfigurable } =
+ useCheckEntitlements('storage.max_file_size.configurable')
+ const {
+ hasAccess: hasAccessToImageTransformations,
+ isLoading: isLoadingImageTransformationEntitlement,
+ } = useCheckEntitlements('storage.image_transformations')
+
const isSpendCapOn =
organization?.plan.id === 'pro' && organization?.usage_billing_enabled === false
+ const hasLimitedStorageAccess =
+ !hasAccessToImageTransformations && !hasAccessToFileSizeConfiguration
const [isUpdating, setIsUpdating] = useState(false)
const [initialValues, setInitialValues] = useState({
fileSizeLimit: 0,
unit: StorageSizeUnits.MB,
- imageTransformationEnabled: !isFreeTier,
+ imageTransformationEnabled: false,
})
const maxBytes = useMemo(() => {
@@ -125,6 +136,12 @@ export const StorageSettings = () => {
}
}, [organization, isEntitlementUnlimited, getEntitlementNumericValue])
+ const isLoading =
+ isLoadingProjectStorageConfig ||
+ isLoadingPermissions ||
+ isLoadingMaxFileSizeEntitlement ||
+ isLoadingFileSizeConfigurable ||
+ isLoadingImageTransformationEntitlement
const FormSchema = z
.object({
fileSizeLimit: z.coerce.number(),
@@ -218,10 +235,11 @@ export const StorageSettings = () => {
}
useEffect(() => {
- if (isSuccess && config) {
+ if (isSuccess && config && !isLoading) {
const { fileSizeLimit, features } = config
const { value, unit } = convertFromBytes(fileSizeLimit ?? 0)
- const imageTransformationEnabled = features?.imageTransformation?.enabled ?? !isFreeTier
+ const imageTransformationEnabled =
+ features?.imageTransformation?.enabled ?? hasAccessToImageTransformations
setInitialValues({
fileSizeLimit: value,
@@ -237,7 +255,7 @@ export const StorageSettings = () => {
})
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [isSuccess, config])
+ }, [isSuccess, config, isLoading, hasAccessToImageTransformations])
return (
@@ -250,7 +268,7 @@ export const StorageSettings = () => {
title="Storage settings are not available for self-hosted projects"
description="Storage settings are only available for Supabase Platform projects."
/>
- ) : isLoading || isLoadingPermissions ? (
+ ) : isLoading ? (
) : (
<>
@@ -296,7 +314,9 @@ export const StorageSettings = () => {
@@ -344,7 +364,10 @@ export const StorageSettings = () => {
form.clearErrors('fileSizeLimit')
}}
className="w-32 rounded-r-none border-r-0"
- disabled={isFreeTier || !canUpdateStorageSettings}
+ disabled={
+ !hasAccessToFileSizeConfiguration ||
+ !canUpdateStorageSettings
+ }
/>
{
unitField.onChange(val)
form.clearErrors('fileSizeLimit')
}}
- disabled={isFreeTier || !canUpdateStorageSettings}
+ disabled={
+ !hasAccessToFileSizeConfiguration ||
+ !canUpdateStorageSettings
+ }
>
@@ -367,7 +393,7 @@ export const StorageSettings = () => {
{Object.values(StorageSizeUnits).map((unit: string) => (
{unit}
@@ -398,7 +424,7 @@ export const StorageSettings = () => {
)}
- {isFreeTier && (
+ {hasLimitedStorageAccess && (
{
)}