Skip to content

Conversation

@chris-bes
Copy link
Contributor

@chris-bes chris-bes commented Sep 12, 2025

Changes

  • Fixing found bugs when testing for datatrak offline

🥞 Stack

  1. feat(sync): RN-1545: Epic datatrak sync #6289
  2. feat(sync): RN-1717: Sync bugs #6446 👈

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @chris-bes, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a comprehensive overhaul of the client-side synchronization mechanism, focusing on providing users with real-time feedback on sync progress and status. It establishes a robust event-driven system for managing sync states, including distinct stages for pushing, pulling, and persisting data, and integrates this feedback directly into the user interface. Additionally, the changes enhance the application's progressive web app capabilities by implementing a user-friendly prompt for service worker updates, ensuring users are always on the latest version.

Highlights

  • Enhanced Sync Progress Tracking: Implemented a detailed, staged progress tracking system within the ClientSyncManager with distinct stages (Push, Pull, Persist) and percentage updates, providing granular feedback on synchronization status.
  • Real-time Sync UI Updates: The SyncPage now dynamically displays sync status, progress percentage, current stage, and messages using an event-driven architecture (mitt), offering a more interactive and informative user experience.
  • Improved Service Worker Handling: Added logic to main.tsx to detect new service worker versions and proactively prompt the user to update and reload the application, ensuring users are always on the latest version for Progressive Web App (PWA) deployments.
  • Refactored Sync Logic: The ClientSyncManager was significantly refactored to manage sync state, handle urgent synchronization requests, and emit events for UI consumption, making the overall sync process more observable and controllable.
  • New Sync UI Components: Introduced HeaderRight to house a mobile-specific sync button and LastSyncDetails to display counts of pushed and pulled records after a successful synchronization, enhancing the user interface's functionality.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant feature for data synchronization, including a new sync manager, UI pages for sync status, and service worker updates. The implementation is comprehensive, with detailed progress tracking and state management. My review focuses on improving robustness, fixing potential bugs, and enhancing code quality. Key feedback includes addressing a critical null-safety issue in the SyncContext, correcting event handling in the SyncPage component, and fixing a potential bug in the sync event type definitions. I've also included suggestions for better UX with service worker updates and general code cleanup.

});

// Check for updates
registration.update();
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Calling registration.update() inside the updatefound event listener is redundant. The updatefound event is fired after a check for updates (e.g., from navigator.serviceWorker.register()) has found a new service worker version. Calling update() again here immediately re-triggers a check. Periodic checks for updates should be handled separately, for example, on an interval or on subsequent page loads, not in response to finding an update.

@chris-bes chris-bes changed the base branch from rn-1717-task-details-offline to rn-1747-sync-progress-ui September 20, 2025 04:58
cursor[bot]

This comment was marked as outdated.

Base automatically changed from rn-1747-sync-progress-ui to rn-1545-epic-datatrak-offline October 1, 2025 22:29
@chris-bes chris-bes changed the base branch from rn-1545-epic-datatrak-offline to rn-1490-6 October 1, 2025 23:58
@jaskfla jaskfla force-pushed the rn-1490-6 branch 2 times, most recently from f2aa543 to cea6bc1 Compare October 2, 2025 22:23
@chris-bes chris-bes changed the base branch from rn-1490-6 to rn-1545-fix-bugs October 3, 2025 05:51
@chris-bes chris-bes changed the title feat(sync): RN-1717: Test feat(sync): RN-1717: Sync deployment Oct 16, 2025
cursor[bot]

This comment was marked as outdated.

Base automatically changed from rn-1545-fix-bugs to rn-1545-epic-datatrak-offline October 21, 2025 22:46
@chris-bes chris-bes changed the title feat(sync): RN-1717: Sync deployment feat(sync): RN-1717: Sync bugs Oct 22, 2025
cursor[bot]

This comment was marked as outdated.


const isRecoverableError = (response: Response) => {
return response.status < 500;
};
Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect Error Handling Masks Client Failures

The isRecoverableError function has inverted logic. It returns true for status codes less than 500, meaning 4xx errors (like 401, 403, 404) are considered "recoverable" and won't throw an error. The check !response.ok && !isRecoverableError(response) will only throw for 5xx errors, allowing 4xx client errors to proceed to stream processing, which will likely fail since the response body won't contain valid stream data.

Fix in Cursor Fix in Web

if (options.onConflictMerge) {
// onConflictMerge is an array of columns to merge conflicts for
query = query.onConflict(options.onConflictMerge).merge();
}
Copy link

Choose a reason for hiding this comment

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

Bug: Misplaced onConflictMerge Leads to SQL Failure.

The onConflictMerge option is applied after query.as() but must be applied immediately after the query method (INSERT) and before other query modifiers. In Knex, onConflict().merge() only works with INSERT queries and must be chained directly after the insert operation. Placing it after as(), offset(), and name aliasing will cause the conflict resolution to fail or produce incorrect SQL.

Fix in Cursor Fix in Web

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