Skip to content

JetBrains/intellij-community / .claude/skills/compose-ui

compose-ui

Verified

Write or audit Compose Desktop UI state, effects, and boundaries.

FileKindSize
OWNERSHIPother20 B
SKILL.mdskill md637 B
architecture/GUIDE.mdmarkdown5.7 KB
architecture/evals/evals.jsonconfig6.5 KB
architecture/references/animation.mdmarkdown11.3 KB
architecture/references/component-api-lists-performance.mdmarkdown4.1 KB
architecture/references/desktop-seams-review-output.mdmarkdown1.5 KB
architecture/references/effects.mdmarkdown1.7 KB
architecture/references/state-boundaries.mdmarkdown5.4 KB
architecture/skill-source.jsonconfig2.0 KB
audit/GUIDE.mdmarkdown14.1 KB
audit/evals/evals.jsonconfig18.1 KB
audit/references/api-hygiene.mdmarkdown8.8 KB
audit/references/audit-search-patterns.mdmarkdown3.9 KB
audit/references/boundary-violations.mdmarkdown3.3 KB
audit/references/effects/derived-state-of-guide.mdmarkdown2.2 KB
audit/references/effects/effect-selection-guide.mdmarkdown2.7 KB
audit/references/effects/infinite-loop-patterns.mdmarkdown2.6 KB
audit/references/effects/overview.mdmarkdown7.7 KB
audit/references/lazy-layouts/animate-item.mdmarkdown2.0 KB
audit/references/lazy-layouts/cache-window-and-prefetch.mdmarkdown3.2 KB
audit/references/lazy-layouts/desktop-scroll-measurement.mdmarkdown2.0 KB
audit/references/lazy-layouts/keys-and-content-type.mdmarkdown2.2 KB
audit/references/lazy-layouts/nested-lazy-layouts.mdmarkdown1.6 KB
audit/references/lazy-layouts/overview.mdmarkdown7.5 KB
audit/references/measurement/benchmarking-methodology.mdmarkdown1.9 KB
audit/references/measurement/overview.mdmarkdown5.5 KB
audit/references/measurement/profiler-setup.mdmarkdown2.5 KB
audit/references/modifiers/custom-modifier-node.mdmarkdown3.4 KB
audit/references/modifiers/modifier-order.mdmarkdown2.1 KB
audit/references/modifiers/overview.mdmarkdown7.4 KB
audit/references/modifiers/phase-deferral.mdmarkdown2.6 KB
audit/references/reporting-guidance.mdmarkdown2.3 KB
audit/references/stability/ci-stability-gate.mdmarkdown2.0 KB
audit/references/stability/desktop-measurement.mdmarkdown2.2 KB
audit/references/stability/overview.mdmarkdown7.6 KB
audit/references/stability/reading-classes-txt.mdmarkdown2.1 KB
audit/references/stability/reading-composables-txt.mdmarkdown1.9 KB
audit/references/stability/stabilising-types.mdmarkdown3.1 KB
audit/references/stability/stability-config-syntax.mdmarkdown1.6 KB
audit/references/stability/stability-inference-algorithm.mdmarkdown3.4 KB
audit/references/stability/strong-skipping-escape-hatches.mdmarkdown2.6 KB
audit/references/subcomposition/desktop-subcomposition-measurement.mdmarkdown1.7 KB
audit/references/subcomposition/overview.mdmarkdown7.2 KB
audit/references/subcomposition/subcomposition-decision-tree.mdmarkdown1.8 KB
audit/references/subcomposition/swing-panel-subcomposition.mdmarkdown1.8 KB
audit/references/tracing-setup.mdmarkdown5.3 KB
audit/references/tracing-usage.mdmarkdown6.3 KB
audit/skill-source.jsonconfig2.5 KB

audit/references/lazy-layouts/cache-window-and-prefetch.md

View on GitHub
# Cache Window and Prefetch

## LazyLayoutCacheWindow

Available on Desktop in Compose Foundation 1.6.0+ (`@OptIn(ExperimentalFoundationApi::class)`).

`LazyLayoutCacheWindow` keeps a buffer of off-screen items composed so they are ready when the
user scrolls them into view. Without it, items are composed on demand as they enter the viewport,
which can cause jank for expensive items.

> **API note:** `LazyLayoutCacheWindow` is an interface. It is passed to `rememberLazyListState`
> — there is no modifier-based API. The API shape is experimental and may evolve between releases;
> verify against the Compose Foundation KDoc for the version in use.

### Dp-based factory (recommended)

```kotlin
@OptIn(ExperimentalFoundationApi::class)
val listState = rememberLazyListState(
    cacheWindow = LazyLayoutCacheWindow(
        ahead = 200.dp,  // compose ~200dp of content ahead of the viewport
        behind = 100.dp, // keep ~100dp of content behind the viewport
    )
)
LazyColumn(state = listState) {
    items(data, key = { it.id }) { item ->
        ExpensiveItem(item)
    }
}
```

### Fraction-based factory

```kotlin
@OptIn(ExperimentalFoundationApi::class)
val listState = rememberLazyListState(
    cacheWindow = LazyLayoutCacheWindow(
        aheadFraction = 0.5f,  // 50% of viewport height ahead
        behindFraction = 0.25f // 25% of viewport height behind
    )
)
```

### Parameters

| Parameter | Meaning | Guidance |
|-----------|---------|----------|
| `ahead` / `aheadFraction` | How far ahead of the viewport to keep items composed | Start with 200.dp or 0.5f. Increase if profiling shows compose-on-entry jank. |
| `behind` / `behindFraction` | How far behind the viewport to retain items | Start with 100.dp or 0.25f. Increase only if back-scroll is also janky. |

### Memory trade-off

Each cached item retains its full composition tree. If an item contains images or complex layouts,
larger cache windows increase memory linearly. Measure heap before and after with YourKit or JFR:

```bash
# With YourKit: capture heap after scrolling through the list
# Compare retained size of LazyListItemNode with and without the cache window
```

### When NOT to use

- If list items are trivial (such as a single `Text`), omit the cache window because it adds overhead with no benefit.
- If the list is short (<20 items), omit the cache window because all items are likely already composed.
- If memory is constrained, prefer smaller cache-window distances or omit the cache window entirely.

## NestedPrefetchScope

`NestedPrefetchScope` allows a parent lazy list to prefetch children of nested lazy lists (e.g.
a `LazyRow` inside a `LazyColumn` item). This is advanced and rarely needed on Desktop.

Use it only when:

- You have a `LazyRow` carousel inside every `LazyColumn` item.
- Profiling shows the carousel items cause jank on first visibility.

```kotlin
@OptIn(ExperimentalFoundationApi::class)
LazyColumn {
    items(data, key = { it.id }) { item ->
        NestedPrefetchScope { // experimental API shape may vary
            CarouselRow(item.images)
        }
    }
}
```

Note: the exact `NestedPrefetchScope` API is still experimental and may change between releases.
Verify against the Compose Foundation 1.10.x KDoc before using.
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall