preserving-state-across-reloads

Preserves Jetpack Compose UI state across HotSwan hot reload tiers.

1|Updated Jul 6, 2026
One-click install
npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill preserving-state-across-reloads-citytexi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: preserving-state-across-reloads
Source: https://github.com/citytexi/team-yg-pesonal-agent/tree/main/.claude/skills/preserving-state-across-reloads
Command: npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill preserving-state-across-reloads-citytexi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Hot reloads in Jetpack Compose can silently escalate from targeted recomposition to a full composition reset or Activity recreation, wiping scroll position, dialog state, tab selection, and per-composable remember values. This Skill explains the three HotSwan reload tiers and shows how to keep edits inside tier 1 so iteration state survives. ## Core Features & Use Cases - Tier diagnosis: Read the tier reported in the HotSwan tool window after each reload to understand why state was lost and which scope an edit touched. - State holder guidance: Convert local remember to rememberSaveable, hoist transient UI state into a ViewModel, and rely on rememberLazyListState for scroll survival across tiers 2 and 3. - Escalation avoidance: Keep theme and staticCompositionLocalOf edits out of fast iteration loops since they 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; the Skill identifies the tier 2 escalation and recommends rememberSaveable and stable lazy list keys to keep the workbench state intact. ## Quick Start Ask the assistant why scroll position or dialog state was lost after a Compose 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 edits inside HotSwan tier 1 by changing only a single composable body, and back any state you want to survive escalation with rememberSaveable instead of remember. For long iteration sessions, hoist transient UI state into a ViewModel, which survives all three reload tiers.

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

Scroll resets when the reload escalates to tier 2 composition reset, which disposes per-composable remember values. 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 are lost when HotSwan escalates to tier 2 composition reset, while rememberSaveable values are retained through a Saveable and survive the reset. Convert any UI state you want to keep across reloads to rememberSaveable.

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

Editing a value used by MaterialTheme or any staticCompositionLocalOf invalidates the root CompositionLocalProvider content, 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.

Does ViewModel state survive Activity.recreate during hot reload?▼

Yes, ViewModel state survives all three HotSwan tiers including tier 3 Activity.recreate, as well as configuration changes generally. Hoisting selected tab, dialog open, and scroll state into a ViewModel keeps the iteration workbench intact.

When should I not use this state preservation approach?▼

Do not use it when the change was rejected as a schema violation and HotSwan fell back to a full build, when HotSwan is not installed or watching, or when the problem is overly wide recomposition unrelated to hot reload, which needs recomposition debugging instead.