Skip to content

Conversation

@malinajirka
Copy link
Contributor

@malinajirka malinajirka commented Dec 12, 2025

#WOOMOB-1867

Description

This PR introduces a new action and a feature flag. The code isn't used yet - this will be done in follow up PRs.

The action poll the server (/catalog) endpoint, until

  • the server returns status that the job is completed
    or
  • the maximum number of polling attempts is exceeded
    or
  • three consecutive requests return a failure (e.g. network down/server down/...)

Test Steps

Green CI should be enough since the code isn't used yet.

Images/gif

N/A

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

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

This PR introduces a new polling mechanism for catalog feed generation in WooCommerce POS. The implementation includes a new action that polls a server endpoint until catalog generation completes or reaches a maximum number of attempts. The code is behind a feature flag and not yet integrated into the main flow.

  • Added WooPosFileBasedSyncAction with exponential backoff polling logic for catalog generation
  • Converted catalog state from String to enum type (WooPosGenerateCatalogState) for better type safety
  • Added new failure type CatalogGenerationTimeout to handle polling timeout scenarios

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
WooPosFileBasedSyncAction.kt New action class implementing catalog generation with polling and exponential backoff
WooPosFileBasedSyncActionTest.kt Comprehensive test suite for the new polling action covering success, failure, and timeout scenarios
WooPosGenerateCatalogResult.kt Changed state field from nullable String to enum type and added WooPosGenerateCatalogState enum
WooPosLocalCatalogStore.kt Updated to convert response state string to enum using the new from() method
FeatureFlag.kt Added WOO_POS_LOCAL_CATALOG_FILE_APPROACH feature flag (currently disabled)
WooPosSyncResult.kt Added CatalogGenerationTimeout failure type for timeout scenarios
WooPosLocalCatalogSyncWorker.kt Added handling for the new CatalogGenerationTimeout failure case
WooPosLocalCatalogSyncRepository.kt Mapped CatalogGenerationTimeout to analytics error type
WooPosAnalyticsEventConstant.kt Added CATALOG_GENERATION_TIMEOUT analytics constant

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 12, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App NameWooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit966cbde
Direct Downloadwoocommerce-wear-prototype-build-pr15093-966cbde.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 12, 2025

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit966cbde
Direct Downloadwoocommerce-prototype-build-pr15093-966cbde.apk

@codecov-commenter
Copy link

codecov-commenter commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 85.33333% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.56%. Comparing base (b251959) to head (966cbde).

Files with missing lines Patch % Lines
...i/woopos/localcatalog/WooPosFileBasedSyncAction.kt 92.45% 1 Missing and 3 partials ⚠️
...re/pos/localcatalog/WooPosGenerateCatalogResult.kt 75.00% 2 Missing and 1 partial ⚠️
...s/localcatalog/WooPosLocalCatalogSyncRepository.kt 0.00% 1 Missing ⚠️
...oopos/localcatalog/WooPosLocalCatalogSyncWorker.kt 50.00% 0 Missing and 1 partial ⚠️
...android/ui/woopos/localcatalog/WooPosSyncResult.kt 0.00% 1 Missing ⚠️
...kotlin/com/woocommerce/android/util/FeatureFlag.kt 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #15093      +/-   ##
============================================
+ Coverage     38.53%   38.56%   +0.02%     
- Complexity    10397    10412      +15     
============================================
  Files          2173     2174       +1     
  Lines        123725   123795      +70     
  Branches      17050    17063      +13     
============================================
+ Hits          47676    47739      +63     
- Misses        71238    71240       +2     
- Partials       4811     4816       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samiuelson samiuelson self-assigned this Dec 16, 2025
@samiuelson samiuelson requested a review from Copilot December 16, 2025 14:55
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 10 out of 10 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@samiuelson samiuelson left a comment

Choose a reason for hiding this comment

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

LGTM!

"scheduled" -> SCHEDULED
"in_progress" -> IN_PROGRESS
"completed" -> COMPLETED
else -> UNKNOWN
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity: does the backend also return "error" for the catalog generation successful response, or rather an error response type?

private const val MAX_POLL_ATTEMPTS = 20
private const val MAX_CONSECUTIVE_FAILED_ATTEMPTS = 3

// Backoff settings
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Backoff settings

var attemptCount = 0
var failedConsecutiveAttempts = 0

while (attemptCount < MAX_POLL_ATTEMPTS) {
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 n.p.: repeat(MAX_POLL_ATTEMPTS) { attemptIndex -> ... } would be more idiomatic, a bit easier to understand, and maintain the code. However, keep in mind that this suggestion may just be my personal taste, and feel free to ignore it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants