Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

docs(agents): add frontend feature architecture skill (#14039)

Nikita Kabardinf89273cd8a4b
diff --git a/.agents/skills/frontend-large-feature-architecture/SKILL.md b/.agents/skills/frontend-large-feature-architecture/SKILL.md
new file mode 100644
index 0000000000..bf58aaab7f
--- /dev/null
+++ b/.agents/skills/frontend-large-feature-architecture/SKILL.md
@@ -0,0 +1,74 @@
+---
+name: frontend-large-feature-architecture
+description: |
+ Use when building, changing, or refactoring large Langfuse frontend features,
+ virtualized lists, large tables, controller components, local feature state,
+ Zustand stores, row selection, high-frequency UI state, or
+ rendering-performance issues.
+---
+
+# Frontend Large Feature Architecture
+
+Use this skill when building, changing, or refactoring a large frontend
+surface.
+
+In this skill, "controller" means a component or hook that owns feature logic:
+data fetching, view state, table/list state, effects, actions, and expensive
+rendering. The problem is not the name; it is one place owning too many
+changing responsibilities.
+
+## Big Feature Rules
+
+When a feature grows, split rendering from logic. Most components should be
+view-only. Data preparation should be pure. Complex user actions should live in
+external async functions or local-store actions. Effects are integration
+boundaries, not the normal way to derive state.
+
+For the full rules, read
+[`references/big-feature-rules.md`](references/big-feature-rules.md).
+
+## Required Model
+
+- The page/view owns lifecycle and creates feature-scoped dependencies.
+- Server/query state stays in tRPC/React Query; route state stays in the
+ router/filter hooks.
+- High-frequency feature UI state belongs in a per-mount local vanilla Zustand
+ store. Create it with lazy `useState`, not `useMemo`.
+- Global stores are only for truly cross-feature, cross-route product state.
+- React context may provide a stable store or action owner. Do not put
+ frequently changing state directly in provider values.
+- Rendered rows/cells/items should be view-only or narrow containers. Put
+ effects, subscriptions, data loading, and workflows outside expensive views.
+- Shared `src/components/*` exports should stay context-free or receive
+ explicit props. Put view-scoped Zustand consumers in `src/features/*`.
+- Large feature folders should have a concise `README.md` owner map.
+- Migrate real features through small PRs that improve one state boundary,
+ action workflow, data-preparation seam, or render boundary.
+
+## Local Store Default
+
+Prefer a local vanilla Zustand store for large or high-frequency feature state.
+The store is created by the page/view and destroyed on unmount.
+
+Use selectors that return primitives or stable references. If a component needs
+multiple values, use shallow selector helpers or split subscriptions so one
+changing field does not rerender unrelated UI.
+
+Complex user workflows should live in `actions/*.ts` files or store actions.
+The component wires hooks and passes dependencies; the action owns the workflow.
+
+## When To Read References
+
+- For the core big-feature rules and migration reality, read
+ [`references/big-feature-rules.md`](references/big-feature-rules.md).
+- For virtualized lists, translated DOM, row measurement, and scroll rerenders,
+ read [`references/virtualized-lists.md`](references/virtualized-lists.md).
+- For local feature stores and splitting large components, read
+ [`references/local-feature-state.md`](references/local-feature-state.md).
+- For feature `README.md` owner maps, read
+ [`references/feature-readmes.md`](references/feature-readmes.md).
+- For a step-by-step migration from a controller component to a managed feature
+ pattern, read
+ [`references/controller-migration.md`](references/controller-migration.md).
+ This is the default reference for traces/observations tables, sessions,
+ experiments, prompts, evals, datasets, and other controller-heavy surfaces.
diff --git a/.agents/skills/frontend-large-feature-architecture/agents/openai.yaml b/.agents/skills/frontend-large-feature-architecture/agents/openai.yaml
new file mode 100644
index 0000000000..2a1a8660fd
--- /dev/null
+++ b/.agents/skills/frontend-large-feature-architecture/agents/openai.yaml
@@ -0,0 +1,7 @@
+interface:
+ display_name: "Frontend Feature Architecture"
+ short_description: "Build, change, or refactor React features"
+ default_prompt: "Use $frontend-large-feature-architecture to build, change, or refactor this large frontend surface with clear state ownership, stable subscriptions, and view-only render boundaries."
+
+policy:
+ allow_implicit_invocation: true
diff --git a/.agents/skills/frontend-large-feature-architecture/references/big-feature-rules.md b/.agents/skills/frontend-large-feature-architecture/references/big-feature-rules.md
new file mode 100644
index 0000000000..eee7043d67
--- /dev/null
+++ b/.agents/skills/frontend-large-feature-architecture/references/big-feature-rules.md
@@ -0,0 +1,98 @@
+# Big Feature Rules
+
+Use these rules when a feature keeps growing and the instinct is to add one
+more state variable, prop, callback, or effect to the same component.
+
+Here, "controller" means a component or hook that owns feature logic: state,
+effects, data loading, subscriptions, actions, and derived data. Some
+controller code is necessary. The failure mode is one controller owning too many
+changing responsibilities and waking too much UI.
+
+## Ownership Baseline
+
+- The page/view owns lifecycle and creates feature-scoped dependencies.
+- Server/query state stays in tRPC/React Query.
+- Route state stays in router/filter hooks.
+- High-frequency local UI state belongs in a per-mount feature store.
+- Global stores are only for product state shared across routes or features.
+- Pure data preparation turns fetched data into UI data before rendering.
+- Complex workflows live in `actions/*.ts` or store actions.
+- Effects are integration boundaries, not ordinary state derivation.
+- Expensive rows/cells/items should be view-only behind narrow containers.
+
+## Hard Rules
+
+1. Growth usually means React rendering and feature logic need to be separated.
+ A bigger component is not an architecture.
+2. Most components should be view-only. They render what they are given, or
+ they read a small selected value from a context-available feature store.
+3. Complicated data preparation belongs in separate pure functions. Backend
+ data should flow one way: fetched data -> compiled UI data -> render.
+4. User actions that trigger complex logic should live outside render
+ components as named async functions or store actions. If the action needs a
+ lot of context, pass the feature store instance and let the action read what
+ it needs.
+5. A feature with both local store state and React Query data needs an explicit
+ bridge in a custom hook or named action.
+6. Prefer view-scoped local feature stores over global stores for page-instance
+ state. Filters, selected rows, expanded rows, lazy load state, drawers, and
+ local actions usually belong to one mounted page instance.
+7. Create local store instances with a lazy `useState` initializer, not
+ `useMemo`. The store is a per-mount instance, not a render-time derived
+ value.
+8. Effects should not be normal state mutators. Before adding an effect, try
+ pure data preparation, a store action, or an explicit event handler.
+9. Do not copy existing large Langfuse feature components as examples. Treat
+ them as legacy unless they follow this skill.
+10. Prefer small reliable PRs over a large rewrite. Each PR should improve one
+ state boundary, action workflow, data-preparation seam, or render boundary,
+ then update the feature README or migration note with the next slice.
+
+## Migration Reality
+
+Most large frontend features are not yet in the ideal shape. Traces,
+observations, experiments, prompts, evals, datasets, and session views all have
+some controller-heavy surfaces. Do not copy an existing large component just
+because it works today. Treat it as a migration candidate and move it one
+state/action/data-preparation boundary at a time.
+
+For the step-by-step path, read `controller-migration.md`.
+
+## Small PR Policy
+
+A good big-feature PR is intentionally incomplete. It should change one
+semantic interaction and keep behavior stable: one selection boundary, one
+action workflow, one pure data-preparation helper, or one render boundary.
+
+Do not bundle file reorganization, state extraction, visual changes, and
+behavior fixes in the same PR unless the user explicitly asks for that scope.
+When a reorganization is needed, prefer a rename-only PR first or a later
+follow-up PR.
+
+## Effects And Actions
+
+Effects are for subscriptions, observers, imperative third-party APIs,
+one-time initialization, and cleanup. Keep them in containers or feature hooks,
+not view components. If an effect writes state repeatedly, make the store action
+idempotent.
+
+Complex actions should be callable without rendering a component. Put workflows
+in `actions/*.ts` or named store actions. Components wire hooks and pass
+dependencies; actions own the workflow.
+
+```ts
+await applyBulkAction({
+ store,
+ queryClient,
+ projectId,
+});
+```
+
+Actions must not call React hooks. Pass hook results, query helpers, the local
+store instance, or narrow callback dependencies into the action. If an action
+needs substantial data preparation, export a pure helper next to it so the
+transformation can be tested independently.
+
+Do not pass twenty props through the tree so a button can do feature-level work,
+and do not leave complex workflows inline in a page controller because that
+controller happened to have all dependencies in scope.
diff --git a/.agents/skills/frontend-large-feature-architecture/references/controller-migration.md b/.agents/skills/frontend-large-feature-architecture/references/controller-migration.md
new file mode 100644
index 0000000000..685500119d
--- /dev/null
+++ b/.agents/skills/frontend-large-feature-architecture/references/controller-migration.md
@@ -0,0 +1,123 @@
+# Controller Migration Guide
+
+Use this when a frontend surface has grown into one component or hook that owns
+data fetching, route glue, filters, table/list state, selection, drawers,
+actions, and expensive rendering.
+
+The target is clear ownership, not "everything in a store." Start from the
+ownership baseline in `big-feature-rules.md`.
+
+Most existing features are not there yet. Migrate in narrow slices and keep
+behavior stable.
+
+## Realistic Migration Strategy
+
+Do not start by designing the perfect final feature. Start by making the next
+change safer than the previous one.
+
+For each migration PR, write down:
+
+- the current controller problem being targeted
+- the single state/action/data-preparation/render boundary being improved
+- what behavior must remain unchanged
+- what instrumentation or tests prove the slice worked
+- what still remains spread across the feature
+- the next recommended atomic slice
+
+This is how large features become managed features without review-hostile
+rewrites. The feature README is the living owner map; update it in place as the
+feature moves forward.
+
+## Step-by-Step Path
+
+1. **Map the controller.** List every state group, query, derived value, effect,
+ callback, action, and expensive child render owned by the component.
+2. **Classify state.** Separate server/query, route, persisted browser,
+ high-frequency local UI, derived view data, imperative integration, and
+ one-off modal/form state.
+3. **Instrument one symptom.** Pick a concrete interaction such as row
+ selection, scroll, filter change, drawer open, form step change, or
+ saved-view change. Measure what rerenders, remounts, refetches, or
+ recalculates.
+4. **Choose one boundary.** Start with the smallest high-value boundary:
+ selection, lazy-row state, batch action workflow, filter-target mapping,
+ column/view state, wizard step state, or pure data preparation. Do not
+ migrate everything at once.
+5. **Choose the lightest tool.** A pure helper or action extraction may be the
+ right first PR. Add a local store only when selective subscriptions or
+ per-mount persistence are needed.
+6. **Create a local store instance when needed.** Use lazy `useState` in the
+ page/view:
+
+ ```ts
+ const [store] = useState(() => createFeatureStore(initialState));
+ ```
+
+ Provide only this stable store instance through context.
+
+7. **Move mutations into named actions.** Put state-changing logic in store
+ actions or external action functions. Keep components responsible for user
+ events, not workflows.
+8. **Split containers from views.** Containers may subscribe, call hooks, or
+ fetch data. Views should render props or tiny selected values.
+9. **Move data preparation out of render.** Put expensive or complicated
+ transformations in pure functions. Backend data should flow into compiled UI
+ data, then into rendering.
+10. **Bridge query state explicitly.** If local store decisions depend on React
+ Query data, use a named feature hook or action to express that relationship.
+11. **Isolate imperative integration.** Virtualizers, observers, keyboard
+ listeners, third-party DOM mutation handling, and timers belong in narrow
+ integration hooks.
+12. **Update the feature README.** Record what this PR improved, desired
+ boundaries, known spread state, and the next extraction target.
+13. **Remove debug instrumentation.** Temporary logs are useful during
+ migration, but should not survive the slice.
+14. **Repeat.** Each slice should make one semantic interaction narrower and
+ easier to reason about.
+
+## Feature-Specific First Slices
+
+Use the feature's current shape to pick the first slice:
+
+- **Traces and observations tables**: start with row selection, select-all,
+ batch actions, or expensive cell wrappers.
+- **Session detail and session events**: isolate virtualization, lazy-row load
+ state, and dynamic measurement from rendered row content.
+- **Experiment result tables**: start with selected-row state, filter-target
+ mapping, run/evaluation batch actions, or pure helpers for comparison column
+ construction.
+- **Experiment creation wizards**: separate submitted form data from display
+ state such as active step, selected prompt labels, schema display names, and
+ evaluator selection.
+- **Prompt management**: split prompt detail route/query state, label/version
+ selection, prompt history data preparation, and mutation workflows.
+- **Eval template and evaluator forms**: extract form defaults, model/provider
+ preparation, validation helpers, and submit workflows before adding a store.
+- **Datasets and dataset runs**: isolate active-cell/compare-field state,
+ table selection, run comparison preparation, and upload/import workflows.
+
+If a feature already has hooks for part of this work, treat them as partial
+migration, not proof that the whole surface is healthy.
+
+## Acceptance Criteria
+
+- A local state change wakes only components that selected that state.
+- Page components no longer rebuild columns, filters, row wrappers, and action
+ callbacks for unrelated row-level changes.
+- Expensive rows/cells are view-only behind narrow containers.
+- Effects are integration boundaries or one-time initialization, not ordinary
+ data derivation.
+- Complex workflows can be called without rendering the page.
+- The feature README tells the next developer what has improved, what remains
+ spread, and what the next small PR should target.
+
+Avoid:
+
+- Replacing a giant component with a giant global store.
+- Moving all state at once without measured acceptance criteria.
+- Treating memoization as the architecture.
+- Putting provider-coupled store hooks into shared `src/components/*` exports.
+- Leaving a workflow inline in the page because the page had every dependency in
+ scope.
+- Using the README as a victory statement while hiding remaining controller
+ state. Be explicit about remaining debt.
diff --git a/.agents/skills/frontend-large-feature-architecture/references/feature-readmes.md b/.agents/skills/frontend-large-feature-architecture/references/feature-readmes.md
new file mode 100644
index 0000000000..95b4e2e912
--- /dev/null
+++ b/.agents/skills/frontend-large-feature-architecture/references/feature-readmes.md
@@ -0,0 +1,89 @@
+# Feature READMEs
+
+Large frontend feature folders should have a short `README.md` that acts as an
+owner map for humans and agents. Prefer `README.md` over `FEATURE.md` to match
+the existing `web/src/features/*` convention. Use `FEATURE.md` only if a folder
+already has a user-facing or generated README.
+
+The README is not a changelog. It should describe durable boundaries and point
+to deeper migration notes.
+
+## Required Sections
+
+- **Surface**: what product surface the folder owns.
+- **Entry Points**: route files or parent components that mount the feature,
+ and the page/view lifecycle owner files they call.
+- **Structure**: what each subfolder owns. Use root `components/` only for
+ components reused across surfaces inside the feature. Use surface folders such
+ as `detail/` for page controllers, local stores, `actions/`, integration
+ hooks, and surface-private containers.
+- **External Consumers**: other features that import these components. This
+ keeps shared exports context-free and prevents accidental provider coupling.
+- **State Ownership**: where server/query state, route state, local feature
+ state, global product state, DOM integration state, and view-only props live.
+- **Performance And Stability Boundaries**: which interactions are
+ high-frequency or externally unstable, and which components are allowed to
+ rerender or measure because of them.
+- **Migration State**: what has already been improved, what state/actions are
+ still spread, and the next one or two atomic slices.
+- **Development Context**: agent skills, migration notes, or issue docs to read
+ before extending the feature.
+
+## State Ownership Rules
+
+Use the ownership baseline in `big-feature-rules.md`. The README only needs to
+name where each state category lives in this feature and where known spread
+state remains.
+
+## Performance And Stability Map
+
+Every large feature README should name the high-frequency interactions that
+must stay narrow. Typical examples:
+
+- scroll and virtualization updates
+- row selection, hover, expansion, and lazy-loading
+- filter, saved-view, and column-state changes
+- drawers, peek navigation, and keyboard navigation
+- browser translation or other third-party DOM mutation
+- resize and dynamic row measurement
+
+For each interaction, state which boundary should update. The page component
+should not rerun expensive data preparation, recreate column/config objects, or
+rerender unchanged expensive cells for unrelated state changes.
+
+## Current-State Honesty
+
+If a feature is mid-migration, say so. The README should make the desired
+boundaries clear while naming known spread state as debt. Do not present a
+partially migrated feature as the final pattern.
+
+Use an update-in-place style rather than a changelog. For example:
+
+- **Improved in current shape**: local store owns row selection; export action
+ moved to `actions/exportFeatureData.ts`; row view no longer subscribes to
+ filter state.
+- **Still spread**: saved-view state remains in the page controller; filter
+ option preparation is still inline; mutation workflows still close over page
+ hooks.
+- **Next slice**: extract filter-option preparation into pure helpers; move
+ batch action workflow into an action file; split route/query glue from view
+ components.
+
+This makes small PRs reviewable while keeping the feature migration plan
+visible. Do not wait for a perfect reorganization before documenting the
+current state.
+
+## PR-Scale Guidance
+
+Feature README updates should match the PR size:
+
+- For a small state/action extraction, add or update only the relevant
+ migration-state bullets.
+- For a new feature folder structure, include the owner map and external
+ consumers before moving logic into the folder.
+- For a rename-only PR, document intended structure but avoid changing behavior.
+- For behavior PRs, avoid unrelated file moves unless they are required for the
+ boundary being improved.
+
+The README should help the next contributor avoid falling back into the same
+large component, not argue that the migration is complete.
diff --git a/.agents/skills/frontend-large-feature-architecture/references/local-feature-state.md b/.agents/skills/frontend-large-feature-architecture/references/local-feature-state.md
new file mode 100644
index 0000000000..8f86b737c8
--- /dev/null
+++ b/.agents/skills/frontend-large-feature-architecture/references/local-feature-state.md
@@ -0,0 +1,162 @@
+# Local Feature State
+
+Large frontend features should not let one component or hook own everything.
+That shape makes one checkbox, hover, or row-selection change rerun the code
+that also builds filters, columns, data wrappers, expensive cells, drawers,
+actions, and routing glue.
+
+The goal is to make each state change wake only the UI and actions that
+semantically depend on it.
+
+## Default Pattern
+
+Start from the ownership baseline in `big-feature-rules.md`, then add a local
+vanilla Zustand store only when state is high-frequency, shared across multiple
+subtrees in the mounted feature, or must survive row/item remounts.
+
+Use this shape:
+
+1. The page/view creates one store instance with lazy `useState`.
+2. Context provides only the stable store instance.
+3. Components subscribe to the smallest useful slice.
+4. Mutations live in named store actions.
+5. Complex user workflows live in `actions/*.ts` or store actions.
+6. Expensive cells/rows stay view-only behind narrow containers.
+7. Large feature roots have a short `README.md` owner map.
+
+## Feature README
+
+For a concrete owner-map template, read `feature-readmes.md`. Do not use the
+README as a changelog; record durable ownership facts and the next migration
+slice.
+
+## Why Local, Not Global
+
+Langfuse pages are often local-state heavy: filters, saved views, selected rows,
+expanded rows, drawers, peek navigation, lazy row load state, and view-local
+actions. Those states usually belong to one mounted page instance, not the whole
+application.
+
+Use local feature stores for this state. Create the store in the page/view and
+destroy it on unmount. This keeps multiple mounted instances independent, avoids
+cross-route state leaks, and makes ownership visible.
+
+Global state is reserved for product state that is genuinely shared across
+features or routes. Do not promote state globally to avoid prop drilling or to
+make a large component smaller.
+
+Do not add a store just to make a PR look architectural. If the immediate
+problem is an inline export workflow, duplicated filter option shaping, or a
+large column builder, first extract an action or pure helper. Use the store when
+state needs selective subscriptions or must survive row remounts within one
+mounted feature instance.
+
+## Creating The Store
+
+Prefer lazy `useState` for local store instances:
+
+```ts
+const [store] = useState(() =>
+ createFeatureStore({
+ initialProjectId: projectId,
+ }),
+);
+```
+
+This expresses the real lifecycle: one store instance for the committed mounted
+view. The unused setter is acceptable. `useMemo` is the wrong default because it
+is a render-time cache for derived values, not an ownership boundary for an
+external store instance. A local store is stateful infrastructure, so treat its
+identity as state.
+
+`useRef` can also hold a stable instance, but prefer `useState` unless a ref is
+needed for imperative setup. Keep store creation pure; sync changing route/query
+inputs into named store actions such as `resetForFeature(...)` or `init(...)`.
+
+## Independent Actions
+
+Complex workflows should be independent functions. Put surface-specific actions
+in `actions/*.ts`, or make them named store actions when they are tightly coupled
+to local feature state.
+
+The component wires hooks, route params, stores, analytics, and query helpers.
+The action owns the workflow: refetching through callbacks, reading the passed
+store if needed, calling pure helpers, performing browser side effects, and
+emitting analytics.
+
+Actions must not call React hooks. If a workflow needs a lot of context, pass
+the local store instance or a small dependency object rather than threading long
+prop chains through view components.
+
+Example:
+
+```ts
+await exportFeatureData({
+ capture,
+ fetchDetails,
+ projectId,
+ refetchSummary,
+ selectedIds,
+});
+```
+
+For substantial data shaping, export a pure helper next to the action so the
+transformation can be tested without rendering the page.
+
+## Store Shape
+
+Use immutable plain objects for keyed state that must be selector-friendly:
+
+```ts
+type FeatureStoreState = {
+ selectedIds: Record<string, true>;
+ activeId: string | null;
+ actions: {
+ toggleSelected: (id: string, selected: boolean) => void;
+ setActiveId: (id: string | null) => void;
+ };
+};
+```
+
+Avoid mutating `Set` or `Map` in place. If you use them, replace the whole
+instance when updating.
+
+## Anti-Patterns
+
+- A table/list component owns selection, filters, columns, routing, peek state,
+ batch actions, local dialogs, and expensive rendered cells.
+- Context provider `value` changes on row selection, hover, scroll, active row,
+ expanded row, or other high-frequency state.
+- Local feature state is promoted to a global store even though it only belongs
+ to one mounted page instance.
+- `useMemo` is used to own a local external store instance.
+- A shared `src/components/*` component calls a feature-scoped store hook. That
+ silently breaks other callers that do not mount the feature provider.
+- Memoization is the only fix. `memo` helps, but it does not fix a bad state
+ boundary.
+- A callback depends on an inline config object and changes identity on every
+ render.
+- Components subscribe to large objects when they only need a boolean.
+- `useEffect` derives ordinary UI state from fetched data.
+- A component passes a long chain of feature context through props just so a
+ button can perform an action.
+- A page component keeps a complex async workflow inline because all the hooks
+ happen to be in scope there.
+
+## Migration Steps
+
+1. Instrument first: identify which semantic state change causes broad renders.
+2. Choose the smallest useful boundary: store state, action workflow, pure data
+ preparation, or imperative integration hook.
+3. Extract that one state group into a local store only when selective
+ subscriptions are needed.
+4. Replace broad props with selector subscriptions at the smallest UI boundary.
+5. Move related mutations into named actions.
+6. Stabilize callbacks and data wrappers.
+7. Move expensive data preparation into pure functions.
+8. Move complex user actions into store actions or external functions under
+ `actions/*.ts`.
+9. Update the feature README with what improved, what remains spread, and the
+ next atomic slice.
+10. Remove debug instrumentation.
+11. Repeat for the next state group.
diff --git a/.agents/skills/frontend-large-feature-architecture/references/virtualized-lists.md b/.agents/skills/frontend-large-feature-architecture/references/virtualized-lists.md
new file mode 100644
index 0000000000..a2b72fb03c
--- /dev/null
+++ b/.agents/skills/frontend-large-feature-architecture/references/virtualized-lists.md
@@ -0,0 +1,81 @@
+# Virtualized Lists
+
+Virtualized lists are render-boundary infrastructure. They should calculate
+which item shells are visible and position those shells. They should not make
+each row own feature state, effects, subscriptions, data loading, and workflows.
+
+Langfuse uses `@tanstack/react-virtual` for virtualization. Find current
+callsites before changing a virtualized surface, then apply the same
+state-boundary rules as any large feature.
+
+## Smartness Trap
+
+The broken shape is:
+
+- virtualizer rerenders on scroll
+- parent recreates callbacks, config, row wrappers, or data objects
+- row components receive changed props even though the semantic row did not
+ change
+- row-local effects/load state reset or refire
+- dynamic measurement observes DOM changed by an external mutator such as Google
+ Translate
+- measurement updates virtualizer state, which rerenders the same rows again
+
+That is not a small memoization bug. It is leaked state ownership.
+
+The fix is to make scroll and measurement state update the smallest possible
+integration boundary. If scrolling changes a virtual item offset, unchanged row
+content should not receive new semantic props, refire effects, or recreate
+expensive derived data.
+
+## Google Translate DOM Behavior
+
+Google Translate mutates rendered DOM after React has committed it. It can wrap
+text nodes, replace text, and change element dimensions outside React's data
+flow. React and TanStack Virtual do not know whether the changed DOM represents
+stable translated content or a transient mutation.
+
+Do not opt product UI out of translation with `translate="no"` unless product
+explicitly chooses that. Langfuse must work under browser translation.
+
+## Measurement Rules
+
+- Always put the correct `data-index` on the row element TanStack treats as the
+ item.
+- Do not combine live `measureElement` with externally mutated translated DOM
+ in text-heavy rows.
+- Prefer fixed estimates plus overscan for simple rows.
+- For dynamic text-heavy rows, use controlled measurement:
+ - `ResizeObserver` reads the row shell.
+ - Debounce commits.
+ - Do not commit while actively scrolling.
+ - Round heights to avoid sub-pixel churn.
+ - Call `virtualizer.resizeItem(index, height)`.
+ - If a row alternates between two heights repeatedly, clamp to a minimum
+ height that still allows later legitimate growth.
+
+## Row Rules
+
+- The virtualizer owns positioning only.
+- State that must survive remounts lives outside the row instance.
+- Expensive row content should be a memoized view component.
+- Narrow row containers may subscribe to local store slices and queries.
+- View components should receive stable props and perform no effects.
+- Feature-scoped row containers belong under `src/features/*`; shared
+ `src/components/*` row exports should be context-free.
+- Scrolling may rerender the virtualizer. It should not rerender unchanged
+ expensive row content.
+- Do not use a global store to preserve row state across virtualization. Use a
+ view-scoped store owned by the mounted list/page instance.
+
+## Migration Steps
+
+1. Add temporary logs to identify whether scroll causes remounts, prop changes,
+ measurement loops, or query refetches.
+2. Remove logs before shipping.
+3. Move row-local state that must survive virtualization into a local store.
+4. Stabilize callbacks and config objects passed to rows.
+5. Replace live `measureElement` with fixed estimates or controlled measurement.
+6. Move row logic into pure helpers or feature-local containers.
+7. Verify with browser translation enabled, horizontal resize, and small
+ vertical scroll deltas.
diff --git a/web/AGENTS.md b/web/AGENTS.md
index 088b318c7a..0d1f3b0e36 100644
--- a/web/AGENTS.md
+++ b/web/AGENTS.md
@@ -62,6 +62,8 @@ Use root [AGENTS.md](../AGENTS.md) for monorepo-level rules.
- Shared browser-review workflow for user-visible frontend changes:
[`../.agents/skills/frontend-browser-review/SKILL.md`](../.agents/skills/frontend-browser-review/SKILL.md)
+- Large frontend feature, virtualized-list, and local state architecture:
+ [`../.agents/skills/frontend-large-feature-architecture/SKILL.md`](../.agents/skills/frontend-large-feature-architecture/SKILL.md)
- React composition and component API design:
[`web/.agents/skills/vercel-composition-patterns/SKILL.md`](.agents/skills/vercel-composition-patterns/SKILL.md)
- React/Next.js performance and rendering best practices:
@@ -69,8 +71,9 @@ Use root [AGENTS.md](../AGENTS.md) for monorepo-level rules.
Read these package-local skills before substantial frontend refactors when the
task involves component composition, reusable component APIs, rendering
-performance, bundle size, React/Next.js performance patterns, or browser-based
-signoff of user-visible changes.
+performance, virtualized lists, local feature stores, bundle size,
+React/Next.js performance patterns, or browser-based signoff of user-visible
+changes.
## Web Conventions
@@ -162,7 +165,7 @@ signoff of user-visible changes.
### Error handling (tRPC + REST)
-1. Throw `BaseError` subclasses (eg `LangfuseNotFoundError`) from handlers and services.
+1. Throw `BaseError` subclasses (eg `LangfuseNotFoundError`) from handlers and services.
2. Let `BaseError`s bubble up to the tRPC and REST middlewares (eg. don't `try/catch` and rethrow in to `TRPCError` the handler)
3. Extend the `BaseError` or its subclasses in [`packages/shared/src/errors/`](../packages/shared/src/errors/) as needed.