Skip to content

[codex] Add storage sync settings UI#14

Merged
Eoic merged 1 commit into
masterfrom
codex/storage-sync-offline-ui
Jun 27, 2026
Merged

[codex] Add storage sync settings UI#14
Eoic merged 1 commit into
masterfrom
codex/storage-sync-offline-ui

Conversation

@Eoic

@Eoic Eoic commented Jun 27, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds runtime sync settings and storage/sync controller plumbing for the profile Storage & sync screen.
  • Replaces fake Storage & sync controls with implemented account sync status/actions and a simplified offline-mode UI focused on local storage, backup entry points, and clearing the local library.
  • Scopes account cache by sync server profile and keeps offline local data separate.
  • Adds widget/provider/service coverage for sync settings, database switching, cache clearing, and offline UI copy.

Notes

  • This branch is based on current origin/master after the feat/auth PRs were merged.
  • Offline backup/export and import are visible entry points but currently report that the feature is not available yet; no fake backup implementation is included.

Validation

  • dart format lib/pages/profile_page.dart test/pages/profile_storage_sync_test.dart
  • flutter test test/pages/profile_storage_sync_test.dart
  • flutter analyze
  • flutter test

@Eoic Eoic marked this pull request as ready for review June 27, 2026 14:17
Copilot AI review requested due to automatic review settings June 27, 2026 14:17
@Eoic Eoic merged commit 2f55641 into master Jun 27, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements the real “Storage & sync” settings surface by introducing persisted sync settings (official vs custom), scoping auth + local cache by sync profile, and wiring new UI actions for reconnecting sync and clearing local data.

Changes:

  • Adds SyncSettingsProvider and StorageSyncController to drive Storage & sync settings/UI state.
  • Updates PapyrusPowerSyncService to support profile-scoped authenticated database paths plus reconnect/clear-cache actions.
  • Replaces placeholder Storage & sync UI with implemented offline and authenticated experiences, with test coverage for providers, PowerSync service behavior, and UI.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
app/test/providers/sync_settings_provider_test.dart Adds unit tests for sync settings defaults, persistence, and media storage restrictions.
app/test/providers/auth_provider_test.dart Tests repository replacement behavior when switching servers.
app/test/powersync/powersync_service_test.dart Updates tests for profile-scoped DB paths and adds coverage for clear/reconnect behaviors.
app/test/pages/profile_storage_sync_test.dart Adds widget tests for offline/authenticated Storage & sync UI and actions.
app/lib/widgets/statistics/stat_card.dart Adjusts optional action rendering in a stats card header.
app/lib/widgets/shared/eink_page_header.dart Adjusts optional trailing widget rendering in header.
app/lib/widgets/library/selection_header.dart Adjusts optional actions rendering in selection header.
app/lib/widgets/library/bulk_status_sheet.dart Removes an unused colorScheme local.
app/lib/providers/sync_settings_provider.dart Introduces persisted sync server + media storage settings and profile key derivation.
app/lib/providers/auth_provider.dart Allows swapping auth repositories (used for profile/server switching).
app/lib/powersync/storage_sync_controller.dart Adds a UI/controller layer to compute labels, visibility, and allowed actions.
app/lib/powersync/powersync_service.dart Adds profile/user-scoped DB paths, reconnect, clear guest library, and clear authenticated cache.
app/lib/pages/profile_page.dart Replaces fake Storage & sync controls with the new implemented UI and actions.
app/lib/pages/developer_options_page.dart Removes unused settings UI imports and an unused helper widget.
app/lib/main.dart Wires sync settings provider; scopes token storage; switches active sync profile at runtime.
app/lib/auth/token_store.dart Scopes secure refresh token storage by profile key.
app/integration_test/powersync_books_integration_test.dart Updates integration test DB path resolver for new signature (profile/user scoping).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 202 to 207
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(title, style: textTheme.titleMedium),
if (action != null) action!,
?action,
],
Comment on lines 29 to 35
child: Row(
children: [
Text(title, style: Theme.of(context).textTheme.headlineMedium?.copyWith(fontWeight: FontWeight.bold)),
const Spacer(),
if (trailing != null) trailing!,
?trailing,
],
),
Comment on lines 41 to 46
onPressed: _allSelected ? onDeselectAll : onSelectAll,
child: Text(_allSelected ? 'Deselect all' : 'Select all'),
),
const Spacer(),
if (actions != null) actions!,
?actions,
],
Comment on lines +53 to +59
PapyrusApiConfig get activeApiConfig {
if (serverType == SyncServerType.official) {
return officialConfig;
}

return PapyrusApiConfig(serverBaseUri: Uri.parse(customApiUrl), powerSyncServiceUri: Uri.parse(customPowerSyncUrl));
}
Comment thread app/lib/main.dart
Comment on lines +115 to 135
void _handleSyncSettingsChanged() {
final nextProfileKey = _syncSettingsProvider.activeProfileKey;
if (nextProfileKey == _activeProfileKey) {
return;
}

_activeProfileKey = nextProfileKey;
unawaited(_switchActiveSyncProfile());
}

Future<void> _switchActiveSyncProfile() async {
_switchingSyncProfile = true;
try {
await _powerSyncService.deactivate(clearAuthenticated: false);
_authRepository = _buildAuthRepository(_syncSettingsProvider.activeApiConfig, _activeProfileKey);
await _authProvider.replaceRepository(_authRepository, bootstrapNewRepository: !_authProvider.isOfflineMode);
} finally {
_switchingSyncProfile = false;
_syncPowerSyncAuthState();
}
}
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.

2 participants