Skip to content

feat: widget stack remembers its position across reboots - #1409

Merged
sameerasw merged 2 commits into
sameerasw:developfrom
jawzf:feat/001-widget-stack-position
Oct 18, 2026
Merged

sameerasw merged 2 commits into
sameerasw:developfrom
jawzf:feat/001-widget-stack-position

Conversation

@jawzf

@jawzf jawzf commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Description

Follow-up to #1328 (widget stack).

Before: each stack's current widget was only kept in memory, so after a reboot, an app update or the process being killed, every stack went back to its first widget.

After: a stack comes back showing the widget it was on.

How: positions are saved per stack in the existing widget_stack_prefs file (position_<stackWidgetId>), next to the stack configs, and restored when StackHost starts. A small StackPositions.restore clamps each saved position to the stack's current widgets and drops positions for stacks that no longer exist. Positions are saved:

  • right after an arrow or edge step,
  • when the screen turns off,
  • when the app is moved to the background (onTrimMemory), because a cached app gets frozen and doesn't receive SCREEN_OFF until it wakes.

They aren't saved on every timer tick, so a running stack doesn't write to disk every few seconds. Removing a stack also removes its saved position.

Type of change

  • Bug fix
  • New feature
  • UI / visual update
  • Performance improvement
  • Refactoring / cleanup
  • Translations
  • Build / CI tooling

UI changes

None.

Checklist

  • The base branch is set to develop (not main).
  • The app builds cleanly locally with ./gradlew assembleDebug.
  • Unit tests pass with ./gradlew testDebugUnitTest (new StackPositionsTest, 6 tests).
  • Tested on the Android 17 emulator: stepped a 3-widget stack to the 2nd widget, rebooted, same widget shown; removed a widget so the saved position was out of range, rebooted, last widget shown without errors; confirmed nothing is written on timer ticks.
  • Positions stay in WidgetStackRepository alongside the stack configs, as the widget stack already stores its data there; no new user-facing preference.
  • No new settings, so nothing to register in FeatureRegistry.kt.
  • No UI changes.
  • No new strings or drawables.

🤖 Generated with Claude Code

Each stack's current widget was only kept in memory, so a reboot, app
update or killed process sent every stack back to its first widget.
Positions are now saved per stack in widget_stack_prefs after an arrow
or edge step, when the screen turns off and when the app is moved to
the background, and restored (clamped to the hosted widgets) on start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sameerasw
sameerasw force-pushed the feat/001-widget-stack-position branch from 0bcbe2d to 20c9f02 Compare October 18, 2026 03:28
@sameerasw sameerasw added help wanted Extra attention is needed enhancement New feature or request and removed help wanted Extra attention is needed labels Oct 18, 2026
@sameerasw
sameerasw merged commit f778280 into sameerasw:develop Oct 18, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Essentials Progress Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants