Skip to content

Sync update#74

Merged
keraliss merged 3 commits into
mainfrom
sync-update
Mar 23, 2026
Merged

Sync update#74
keraliss merged 3 commits into
mainfrom
sync-update

Conversation

@keraliss
Copy link
Copy Markdown
Collaborator

@keraliss keraliss commented Mar 23, 2026

updates the app with new sync apis

Summary by CodeRabbit

  • New Features
    • Offerbook syncing is now displayed as an explicit initialization step with dedicated visual progress feedback
    • Market data automatically refreshes every 15 minutes to keep current offers visible
    • Improved synchronization status handling with real-time feedback during offerbook updates
    • Enhanced error visibility and retry logic for sync operations

NeoZ666 and others added 2 commits March 20, 2026 05:56
Signed-off-by: NeoZ666 <neoz.blockchain@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 23, 2026

Warning

Rate limit exceeded

@keraliss has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 17 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bc4c527e-dee5-4331-ab57-c47481b285e4

📥 Commits

Reviewing files that changed from the base of the PR and between adffef5 and 4ab7c32.

📒 Files selected for processing (1)
  • .github/workflows/claude-code-review.yml
📝 Walkthrough

Walkthrough

This change refactors offerbook synchronization from main-thread polling to a worker-thread architecture. IPC handlers transition from taker:syncOfferbook and taker:isOfferbookSyncing to taker:syncOfferbookAndWait. Frontend components update to track sync progress via ID-based status polling instead of boolean state queries. A new UI step displays offerbook sync progress during initialization.

Changes

Cohort / File(s) Summary
Worker-Thread Sync Architecture
api1.js, offerbook-worker.js
Replaced main-thread sync polling (startOfferbookSync() with taker instance polling) with worker-spawning approach (startSyncWorker()). Worker thread constructs taker instance and invokes syncOfferbookAndWait(). Sync lifecycle tracked via activeSyncs map and state flags updated on worker message events (completed/error).
IPC API Surface
preload.js
Removed syncOfferbook() and isOfferbookSyncing() methods from window.api.taker. Added syncOfferbookAndWait() method that invokes taker:syncOfferbookAndWait IPC handler.
Market Component UI
src/components/market/Market.js
Refactored sync flow to call syncOfferbookAndWait() and poll getSyncStatus(syncId) until completion. Replaced isOfferbookSyncing() checks with getCurrentSyncState().isRunning. Added 15-minute periodic refresh interval and MutationObserver for cleanup.
Taker Initialization UI
src/components/taker/TakerInitialization.js
Added new step-offerbook UI step displaying sync progress. Changed initialization flow to call syncOfferbookAndWait() after wallet loads, poll getSyncStatus(syncId) for completion status, and display result (success/failure). Replaced exported syncOfferbook() helper with syncOfferbookAndWait().
Application Launch Flow
src/js/app.js
Added performLaunchSync(onComplete) helper that displays sync overlay, calls syncOfferbookAndWait(), and polls status before proceeding. Integrated into initialization success path and wallet unlock path with error handling.
CSS Cleanup
src/styles/output.css
Removed unused Tailwind utility classes (top-1, mt-0, flex-shrink, border-collapse, color utilities, etc.) and eliminated @property --tw-outline-style custom property declaration.

Sequence Diagram(s)

sequenceDiagram
    participant Renderer
    participant MainThread as Main Thread (api1.js)
    participant Worker as Worker Thread (offerbook-worker.js)
    participant Taker as Taker Instance
    
    Renderer->>MainThread: ipcRenderer.invoke('taker:syncOfferbookAndWait')
    MainThread->>MainThread: startSyncWorker(config)
    MainThread->>Worker: new Worker() with config in workerData
    Worker->>Worker: Load coinswap-napi & construct Taker instance
    MainThread->>Renderer: Return { success, syncId }
    Renderer->>Renderer: Poll getSyncStatus(syncId) every 1s
    
    par Worker Execution
        Worker->>Taker: taker.syncOfferbookAndWait()
        Taker->>Taker: Perform offerbook sync
        alt Sync Success
            Taker-->>Worker: Resolve
            Worker->>MainThread: postMessage({ type: 'completed' })
            MainThread->>MainThread: Update activeSyncs & syncState.isRunning = false
        else Sync Failure
            Taker-->>Worker: Error
            Worker->>MainThread: postMessage({ type: 'error', error })
            MainThread->>MainThread: Update syncState & log error
        end
    and Polling Loop
        loop Until completed or failed
            Renderer->>MainThread: ipcRenderer.invoke('taker:getSyncStatus', syncId)
            MainThread-->>Renderer: { status, ... }
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A worker hops and syncs with speed,
No more polling for our noble deed!
Threading through the offerbook maze,
Status checked in modern ways—
fffft! The market data's here to stay! 📚✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.10% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Sync update' is vague and generic, using non-descriptive terms that don't convey meaningful information about the specific changes in the changeset. Use a more descriptive title that clearly conveys the main change, such as 'Refactor offerbook sync to use worker threads' or 'Move offerbook sync from main thread to Worker'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync-update

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@keraliss keraliss merged commit 53f1c62 into main Mar 23, 2026
1 check failed
@coderabbitai coderabbitai Bot mentioned this pull request Mar 27, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Apr 18, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Apr 28, 2026
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