Skip to content

wip feat: Request checkpoint#153

Draft
stevensJourney wants to merge 9 commits into
mainfrom
request_checkpoint
Draft

wip feat: Request checkpoint#153
stevensJourney wants to merge 9 commits into
mainfrom
request_checkpoint

Conversation

@stevensJourney

Copy link
Copy Markdown
Contributor

Overview

This is the Swift SDK implementation of the Request Checkpoint proposal: https://github.com/orgs/powersync-ja/discussions/324

Related to:

This adds a new requestCheckpoint method which returns a CheckpointRequest. The CheckpointRequest instance exposes a waitForSync method which resolves once the request has been synced and applied to the client

    func refreshFromRemote(timeout: TimeInterval = 30) async throws {
        let checkpoint = try await powerSync.requestCheckpoint()
        try await checkpoint.waitForSync(timeout: timeout)
    }

The SDK is updated to cater for the Rust core and PowerSync service changes. The SyncStatus has been updated to expose the lastAppliedCheckpointRequestId - used to resolve checkpoint requests.

Demo

The PowerSyncExample has been updated to include a Pull to refresh action which will show a loading spinner until a checkpoint request has been resolved.

In order to showcase the functionality a bit better, a new Admin page has been added to the demo which conveys the SyncStatus. In the demo below, we go offline, create 50k todos which will be synced then connect and await a checkpoint request. We can see the download progress reach 100%, but the data is only available after the checkpoint has been applied locally - the checkpoint request correctly keeps the operation in a loading state until the data is actually available.

request-checkpoint.mp4

Todos

  • This implementation currently hardcodes a Checkpoint mode to the checkpoint-request feature. We should add compatibility checks for this
  • This PR contains potential workarounds for some observed weirdness in SyncStatus results - these might need to be separate fixes/PRs (needs further investigation)

AI disclosure: This work was assisted by Codex GPT 5.5. I manually guided and reviewed all the changes.

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