Skip to content

feat(common): sync indicator#14945

Merged
deepyjr merged 2 commits intodevelopfrom
feat/LIVE-26133
Mar 11, 2026
Merged

feat(common): sync indicator#14945
deepyjr merged 2 commits intodevelopfrom
feat/LIVE-26133

Conversation

@LucasWerey
Copy link
Member

@LucasWerey LucasWerey commented Mar 2, 2026

✅ Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • Mobile: sync error indicator appears in the TopBar when account sync fails
    • Desktop: refactored to consume shared sync status hook from live-common
    • Shared: new useAccountsSyncStatus hook mutualized in live-common

📝 Description

Implements the sync indicator feature on mobile and mutualizes sync error detection logic between desktop and mobile.

Shared layer (live-common)

  • New useAccountsSyncStatus hook in bridge/react/ — takes an array of AccountWithUpToDateCheck and returns which accounts have sync errors or are outdated, using useBatchAccountsSyncState under the hood.
  • Both desktop and mobile selectors now delegate isUpToDate computation to the existing isUpToDateAccount utility from @ledgerhq/live-common/account, removing duplicated inline logic.

Mobile

  • New useSyncIndicator hook combining useAccountsSyncStatus, useCountervaluesPolling, and useGlobalSyncState to derive sync status (isError, isPending).
  • TopBarView displays a Warning icon when accounts exist and sync has errors, with optional loading state when sync is pending.
  • SyncErrorBottomSheet component shows affected account names when the sync icon is pressed.
  • Drawer state (isSyncDrawerOpen) managed in the ViewModel for MVVM compliance.
  • CustomTopBar's TopBarActionIcon now supports a loading prop.
  • Accessibility labels use i18n keys instead of hardcoded English strings.
  • New accountsWithUpToDateCheckSelector in mobile's accounts reducer.

Desktop

  • Refactored useAccountsSyncStatus to delegate to the shared hook from live-common, keeping desktop-specific analytics tracking (SyncError event) and ticker-based error formatting.
  • Removed unused getEnv import from accounts reducer.
  • Desktop's existing sync lifecycle FSM (useSyncLifecycle) is preserved — the shared hook only handles error detection, not UI state transitions.

Tests

  • Unit tests for the shared useAccountsSyncStatus hook (6 cases in live-common).
  • TopBarView.test.tsx — sync icon visibility tests (3 cases).
  • TopBar.integration.test.tsx — sync indicator integration tests (3 cases), useSyncIndicator is mocked to isolate TopBar component behavior.
  • Updated useSwapTopBarHeaderViewModel.test.ts mock to include new sync props.
image image

❓ Context


🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

@live-github-bot live-github-bot bot added desktop Has changes in LLD mobile Has changes in LLM common Has changes in live-common translations Translation files have been touched labels Mar 2, 2026
@deepyjr deepyjr force-pushed the feat/LIVE-26133 branch 5 times, most recently from dec9f2e to 7e05e39 Compare March 9, 2026 14:26
@deepyjr deepyjr requested a review from Copilot March 9, 2026 14:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a cross-app “sync error” indicator by centralizing account sync error/outdated detection in @ledgerhq/live-common, then consuming it from mobile (TopBar warning + bottom sheet) and desktop (refactor to shared hook while keeping analytics/FSM behavior).

Changes:

  • Added shared useAccountsSyncStatus hook (with unit tests) to compute sync-error / out-of-date accounts from batch sync state.
  • Mobile TopBar: new useSyncIndicator, sync warning icon + loading state, and a SyncErrorBottomSheet to show impacted accounts; updated tests and i18n strings.
  • Desktop: refactored sync status hook and up-to-date selector logic to reuse live-common utilities; updated unit tests accordingly.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
libs/ledger-live-common/src/bridge/react/useAccountsSyncStatus.ts New shared hook to compute accounts with sync errors/outdated state + last sync timestamp.
libs/ledger-live-common/src/bridge/react/useAccountsSyncStatus.test.ts Unit tests covering multiple sync/outdated/pending scenarios for the shared hook.
libs/ledger-live-common/src/bridge/react/index.ts Exposes the new shared hook via the bridge/react barrel export.
apps/ledger-live-mobile/src/reducers/accounts.ts Adds selector to provide { account, isUpToDate } objects for the shared hook.
apps/ledger-live-mobile/src/mvvm/components/TopBar/useTopBarViewModel.ts Wires sync indicator state + drawer state into the TopBar ViewModel (MVVM).
apps/ledger-live-mobile/src/mvvm/components/TopBar/index.tsx Passes new sync-related props from ViewModel to TopBarView.
apps/ledger-live-mobile/src/mvvm/components/TopBar/hooks/useSyncIndicator.ts New hook combining account sync status + polling/global sync to derive error/pending UI state.
apps/ledger-live-mobile/src/mvvm/components/TopBar/components/SyncErrorBottomSheet.tsx New bottom sheet UI showing impacted accounts when sync warning is pressed.
apps/ledger-live-mobile/src/mvvm/components/TopBar/TopBarView/index.tsx Renders the sync warning action icon (with loading) and displays the bottom sheet.
apps/ledger-live-mobile/src/mvvm/components/CustomTopBar/index.tsx Adds loading support to TopBar action icons.
apps/ledger-live-mobile/src/mvvm/components/TopBar/tests/TopBarView.test.tsx Extends unit tests for sync icon visibility and updates icon mocks.
apps/ledger-live-mobile/src/mvvm/components/TopBar/integrations/TopBar.integration.test.tsx Adds integration coverage for sync icon visibility in TopBar.
apps/ledger-live-mobile/src/screens/Swap/LiveApp/components/tests/useSwapTopBarHeaderViewModel.test.ts Updates mocked TopBar VM shape to include sync indicator props.
apps/ledger-live-mobile/src/locales/en/common.json Adds English strings for sync indicator accessibility labels and bottom sheet copy.
apps/ledger-live-desktop/src/renderer/reducers/accounts.ts Simplifies up-to-date computation by delegating to isUpToDateAccount.
apps/ledger-live-desktop/src/mvvm/components/TopBar/hooks/useAccountsSyncStatus.ts Refactors desktop hook to delegate detection to shared live-common hook, keeping analytics.
apps/ledger-live-desktop/src/mvvm/components/TopBar/hooks/tests/useAccountsSyncStatus.test.ts Updates tests to mock the new shared hook and validate deduped tracking behavior.
apps/ledger-live-desktop/src/mvvm/components/TopBar/hooks/useActivityIndicator.ts Removes outdated comment (no functional change).

@deepyjr deepyjr force-pushed the feat/LIVE-26133 branch 2 times, most recently from d2e1504 to 4359299 Compare March 10, 2026 07:45
@deepyjr deepyjr marked this pull request as ready for review March 10, 2026 08:17
@deepyjr deepyjr requested review from a team as code owners March 10, 2026 08:17
Copilot AI review requested due to automatic review settings March 10, 2026 08:17

This comment was marked as spam.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

⚠️ E2E tests are required

Changes detected require e2e testing before merge (even before asking for any review).

🖥️ Desktop

-> Run Desktop E2E

  • Select "Run workflow"
  • Branch: feat/LIVE-26133
  • Device: nanoSP or stax

📱 Mobile

-> Run Mobile E2E

  • Select "Run workflow"
  • Branch: feat/LIVE-26133
  • Device: nanoX

Copilot AI review requested due to automatic review settings March 10, 2026 10:41

This comment was marked as spam.

@deepyjr deepyjr force-pushed the feat/LIVE-26133 branch 2 times, most recently from 285b580 to c424d79 Compare March 10, 2026 13:21
);

const batchState = useBatchAccountsSyncState({ accounts: allAccounts });
const errorTickers: string[] = [];
Copy link
Contributor

@mcayuelas-ledger mcayuelas-ledger Mar 10, 2026

Choose a reason for hiding this comment

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

we should keep this because for example if we have ETH/BTC/ETH

2 ETH accounts we want to track it. We don't want to deduplicate the analytics

Copilot AI review requested due to automatic review settings March 10, 2026 14:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@deepyjr deepyjr merged commit 1f94381 into develop Mar 11, 2026
116 of 120 checks passed
@deepyjr deepyjr deleted the feat/LIVE-26133 branch March 11, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Has changes in live-common desktop Has changes in LLD mobile Has changes in LLM translations Translation files have been touched

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants