Speed up devices list by using local cache for lastUsedTime#29277
Merged
chrisnojima merged 19 commits intoJun 3, 2026
Conversation
DeviceHistoryList was calling SyncSecretsForce on every load, triggering a blocking network request to key/fetch_private that took 0.8–4s. Now reads lastUsedTime from local LevelDB cache (sub-millisecond), with a background goroutine that force-syncs after the response is returned. When the background sync completes, a keyfamilyChanged notification fires so the devices screen auto-refreshes with fresh data — no user action needed.
- Fix comment in device_history.go: cache fallback is "out-of-date" not "expired" - Reset lastDeviceSync on background sync failure so next UI refresh retries immediately instead of waiting out the TTL
- device-page.tsx: show "Last used unknown" in timeline when lastUsed is missing (non-revoked device), matching list row behavior - device.go: call NotifyRouter.HandleKeyfamilyChanged directly instead of KeyfamilyChanged to avoid unnecessary BustLocalUserCache + HandleUserChanged on background sync completion
…rify comment - Filter keyfamilyChanged listener to current user's uid to avoid unnecessary DeviceHistoryList RPCs when other users' caches bust - Use mctx.ActiveDevice().UID() in backgroundSyncDevices instead of h.G().Env.GetUID() for correct/robust uid source - Fix misleading "empty or out-of-date" comment in getLastUsedTimes; forced sync only triggers on empty cache (zero devices)
zoom-ua
reviewed
Jun 3, 2026
zoom-ua
reviewed
Jun 3, 2026
zoom-ua
reviewed
Jun 3, 2026
Contributor
|
should get a green CI here |
zoom-ua
reviewed
Jun 3, 2026
zoom-ua
reviewed
Jun 3, 2026
zoom-ua
approved these changes
Jun 3, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…m cache During signup, SyncSecrets populates the LevelDB cache with only the desktop device before the paper key is provisioned. SyncSecretsFromCache then finds a valid cache (desktop has non-zero LastUsedTime), skips the network sync, and the paper device ends up absent from lastUsedTimes, leaving LastUsedTime = 0. Fix: after building lastUsedTimes from cache, scan non-revoked devices. If any is missing, call SyncSecretsForce once to get fresh data covering all provisioned devices.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DeviceHistoryList was calling SyncSecretsForce on every load, triggering a blocking network request to key/fetch_private that took 0.8–4s.
Now reads lastUsedTime from local LevelDB cache (sub-millisecond), with a background goroutine that force-syncs after the response is returned. When the background sync completes, a keyfamilyChanged notification fires so the devices screen auto-refreshes with fresh data — no user action needed.