preserving-state-across-reloads

Preserve Jetpack Compose UI state across HotSwan reloads using tier 1 retention.

472|16|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/skydoves/compose-performance-skills --skill preserving-state-across-reloads
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: preserving-state-across-reloads
Source: https://github.com/skydoves/compose-performance-skills/tree/main/hot-reload/preserving-state-across-reloads
Command: npx skills add https://github.com/skydoves/compose-performance-skills --skill preserving-state-across-reloads

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Use this skill to keep Jetpack Compose state alive across HotSwan hot reloads by understanding the three escalating tiers Compose HotSwan uses (tier 1 targeted recomposition, tier 2 composition reset, tier 3 Activity.recreate) and choosing edits and state holders that stay inside tier 1 where scroll position, lazy items, dialog state, and per-composable remember values all survive. Explains which edits force escalation, which state holders survive each tier, and how to hoist transient UI state when the iteration loop must escalate.

Core Features & Use Cases

When a hot reload escalates, this skill helps you diagnose exactly which state holders survive at each tier, how to prevent loss by preferring rememberSaveable and hoisting UI state into a ViewModel, and how to avoid root theme or CompositionLocal mutations that escalate tiers. It also covers patterns for preserving scroll position with rememberLazyListState and for keeping transient UI state across restarts.

  • Understand the three-tier model of HotSwan (tier 1 targeted recomposition, tier 2 composition reset, tier 3 Activity.recreate) and how they affect state retention.
  • Learn practical strategies to keep scroll position, dialog state, and per-composable remember values across reloads, including migrating local remember to rememberSaveable and hoisting to a ViewModel.
  • Use scenarios like scrolling, dialogs, tab selections, and lazy lists to decide when to hoist state and how to structure components for maximum tier-1 retention.

Quick Start

Identify edits that stay within tier 1 and hoist transient UI state into a ViewModel to maintain continuity during fast hot reload iterations.

Frequently Asked Questions about preserving-state-across-reloads

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I preserve Jetpack Compose state across hot reloads?

Jetpack Compose state survives hot reloads by staying within tier 1 targeted recomposition, using rememberSaveable for persistable values, and hoisting ephemeral UI state into a ViewModel to prevent loss when reloads escalate tiers.

Why does my Compose scroll position reset during hot reload?

Your Compose scroll position resets because the hot reload escalated beyond tier 1 targeted recomposition, causing a composition reset. Use rememberLazyListState or hoist scroll state into a ViewModel to retain it across higher-tier reloads.

What is the difference between HotSwan tier 1, tier 2, and tier 3 reloads?

HotSwan tier 1 performs targeted recomposition preserving all local state, tier 2 resets the composition dropping per-composable remember values, and tier 3 triggers Activity.recreate where only rememberSaveable or ViewModel-hoisted state survives.

When should I hoist Compose UI state to a ViewModel for hot reload?

Hoist Compose UI state to a ViewModel when hot reload iterations escalate to tier 2 composition resets or tier 3 Activity.recreate, ensuring transient state like dialog visibility and tab selections survives across escalating reload tiers.

Does mutating root theme CompositionLocals force a hot reload tier escalation?

Mutating root theme CompositionLocals forces a hot reload tier escalation because it triggers widespread composition invalidation, pushing the reload beyond tier 1 targeted recomposition and causing loss of per-composable remember state.

Can I use rememberSaveable to keep dialog state across Activity.recreate?

rememberSaveable keeps dialog state across Activity.recreate by persisting values through the saved state registry, making it the preferred approach for tier 3 hot reloads when hoisting transient UI state to a ViewModel is not necessary.