preserving-state-across-reloads

Preserves Jetpack Compose UI state across HotSwan hot reload tiers.

Updated May 31, 2026
One-click install
npx skills add https://github.com/decoutkhanqindev/Lich-Viet-Loc-Phat --skill preserving-state-across-reloads-decoutkhanqindev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: preserving-state-across-reloads
Source: https://github.com/decoutkhanqindev/Lich-Viet-Loc-Phat/tree/main/.claude/skills/preserving-state-across-reloads
Command: npx skills add https://github.com/decoutkhanqindev/Lich-Viet-Loc-Phat --skill preserving-state-across-reloads-decoutkhanqindev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Hot reloads in Jetpack Compose can silently reset scroll positions, dialog state, tab selections, and lazy list contents when an edit escalates beyond targeted recomposition. This Skill explains HotSwan's three reload tiers and shows how to keep edits inside tier 1 so UI state survives every iteration. ## Core Features & Use Cases - Tier diagnosis: Read the tier (1, 2, or 3) reported in the HotSwan tool window after each reload to understand why state was lost. - State holder guidance: Learn which holders survive each tier, from remember and rememberSaveable to ViewModel and SavedInstanceState. - Escalation avoidance: Avoid theme edits and staticCompositionLocalOf mutations that force tier 2 composition resets. - Use Case: A developer notices the scroll position jumps to the top after every hot reload while tuning a feed screen; this Skill identifies the tier 2 escalation and converts the state to rememberSaveable or hoists it into a ViewModel. ## Quick Start Ask the assistant why my Compose screen lost its scroll position and dialog state after a HotSwan hot reload and how to keep the next edit inside tier 1.

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 keep Compose state after a hot reload?▼

Keep Compose state after a hot reload by staying inside HotSwan tier 1 targeted recomposition, which preserves remember values, scroll position, and dialog state. Convert local remember to rememberSaveable for any state that must survive a tier 2 composition reset.

Why does my scroll position reset after a Compose hot reload?▼

Scroll position resets when the reload escalates to tier 2 or tier 3 and the scroll state is not backed by a saveable holder. Use rememberLazyListState with stable item keys, since it is backed by a Saveable and survives composition reset and Activity recreation.

What is the difference between remember and rememberSaveable in hot reloads?▼

remember values survive tier 1 targeted recomposition but are disposed during a tier 2 composition reset. rememberSaveable persists through composition reset, making it the right choice for UI state that must survive reloads that may escalate.

Why does editing a MaterialTheme color force a full composition reset?▼

Editing a value used by MaterialTheme invalidates the root CompositionLocalProvider content lambda, which HotSwan cannot scope to a single recomposition target, so it escalates to tier 2. Move the value into a local override on the composable being tuned during iteration.

When should I hoist Compose UI state into a ViewModel?▼

Hoist transient UI state such as selected tab, expanded item, or dialog visibility into a ViewModel during long iteration sessions where edits keep escalating to tier 2 or tier 3. ViewModel survives all three HotSwan reload tiers and configuration changes.

Should I use staticCompositionLocalOf for values I edit frequently?▼

No, staticCompositionLocalOf invalidates the entire content of its provider on any change, forcing HotSwan to escalate to tier 2. Use compositionLocalOf instead, which tracks reads and only invalidates actual readers, keeping reloads inside tier 1.