Skip to content

feat(ios): add state restoration across app lifecycle#683

Merged
datlechin merged 1 commit intomainfrom
feat/ios-state-restoration
Apr 11, 2026
Merged

feat(ios): add state restoration across app lifecycle#683
datlechin merged 1 commit intomainfrom
feat/ios-state-restoration

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

Preserves and restores navigation context when iOS kills the app in the background. Uses Apple's @SceneStorage (per-scene UI state) and @AppStorage (user preferences).

What's restored on relaunch:

  • Last active connection (auto-reconnects)
  • Selected tab (Tables/Query)
  • Active database and schema
  • Query text in editor
  • Group-by-folder toggle
  • Filter tag selection

What's NOT restored (re-fetched from server):

  • Database session (reconnects automatically)
  • Table list, row data, query results
  • Search/filter/sort state

Architecture

@SceneStorage for per-scene state (connection ID, tab, database, schema, query text, filter). @AppStorage for user preferences (group-by-folder). No custom persistence — Apple handles save/restore automatically.

UUID values stored as String (SceneStorage doesn't support UUID). Enum values stored as raw String. Computed properties + Bindings provide type-safe access.

Files Changed (3 + CHANGELOG)

File Changes
ConnectionListView.swift selectedConnectionId@SceneStorage, groupByGroup@AppStorage, filterTagId@SceneStorage
ConnectedView.swift selectedTab@SceneStorage, activeDatabase@SceneStorage, activeSchema@SceneStorage
QueryEditorView.swift query@SceneStorage

Test plan

  • Connect → browse tables → background → kill from app switcher → relaunch → same connection shown
  • Switch to Query tab → relaunch → Query tab selected
  • Type SQL query → relaunch → query text preserved
  • Switch database → relaunch → same database active
  • Toggle group-by-folder → relaunch → grouping preserved
  • Delete connection while app killed → relaunch → shows empty state (no crash)
  • Server unreachable on restore → error view with Retry

@datlechin datlechin force-pushed the feat/ios-state-restoration branch 14 times, most recently from 3bd95cb to 14c5846 Compare April 11, 2026 14:51
@datlechin datlechin force-pushed the feat/ios-state-restoration branch from 14c5846 to 7a1aff6 Compare April 11, 2026 14:53
@datlechin datlechin merged commit 3744150 into main Apr 11, 2026
2 checks passed
@datlechin datlechin deleted the feat/ios-state-restoration branch April 11, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant