Skip to content

fix(harmony): align isFirstTime and rollback mechanism with android/ios#585

Merged
sunnylqm merged 3 commits into
masterfrom
fix/harmony-first-time-rollback
Jun 29, 2026
Merged

fix(harmony): align isFirstTime and rollback mechanism with android/ios#585
sunnylqm merged 3 commits into
masterfrom
fix/harmony-first-time-rollback

Conversation

@sunnylqm

@sunnylqm sunnylqm commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved first-launch handling by atomically checking and consuming the stored “first load” marker, ensuring it’s cleared reliably.
    • Updated startup state resolution to better reflect rollback outcomes and preserve the correct launch state.
    • Fixed a scenario where rollback-related handling could remain enabled after successful version switches or state synchronization.
    • Refined how first-launch status is exposed during initialization so the framework receives the correct value.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c1a712f5-ec56-4a1a-9e57-2380d221a2eb

📥 Commits

Reviewing files that changed from the base of the PR and between b2a79e1 and d36a66b.

📒 Files selected for processing (1)
  • harmony/pushy/src/main/ets/UpdateContext.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • harmony/pushy/src/main/ets/UpdateContext.ts

📝 Walkthrough

Walkthrough

UpdateContext gains an ignoreRollback flag, new first-load marker persistence and consumption paths, and updated launch-state handling. PushyTurboModule.getConstants() now reads the first-load marker through consumeFirstLoadMarker().

Changes

First-load marker and rollback flag

Layer / File(s) Summary
ignoreRollback resets
harmony/pushy/src/main/ets/UpdateContext.ts
Introduces the static ignoreRollback flag and resets it in syncStateWithBinaryVersion and switchVersion.
first-load marker handling
harmony/pushy/src/main/ets/UpdateContext.ts
Extends persistState and runStateOperation to clear the first-load marker, and updates clearFirstTime() to remove that preference during the state operation.
launch-state marker flow
harmony/pushy/src/main/ets/UpdateContext.ts
Adds consumeFirstLoadMarker(), updates getBundleUrl() to pass ignoreRollback into launch resolution, persists launch state when first-time consumption or rollback occurs, and resets ignoreRollback after switchVersion().
PushyTurboModule first-load constant
harmony/pushy/src/main/ets/PushyTurboModule.ts
getConstants() now calls consumeFirstLoadMarker() instead of isFirstTime().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 The first-load flag went hop and hide,
Then ignoreRollback took the ride.
One tiny marker, read and cleared,
So state stayed tidy, well-prepared.
The bunny nods, with whiskers bright,
And lands the patch just right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: Harmony's first-time state and rollback handling are being aligned with Android/iOS.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/harmony-first-time-rollback

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

harmony/pushy/src/main/ets/UpdateContext.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: .eslintrc.js » @react-native/eslint-config#overrides[4]:
Environment key "jest/globals" is unknown

at /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2079:23
at Array.forEach (<anonymous>)
at ConfigValidator.validateEnvironment (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2073:34)
at ConfigValidator.validateConfigArray (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2223:18)
at CascadingConfigArrayFactory._finalizeConfigArray (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3985:23)
at CascadingConfigArrayFactory.getConfigArrayForFile (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3791:21)
at FileEnumerator._iterateFilesWithFile (/node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/file-enumerator.js:368:43)
at FileEnumerator._iterateFiles (/node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/file-enumerator.js:349:25)
at FileEnumerator.iterateFiles (/node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/file-enumerator.js:299:59)
at iterateFiles.next (<anonymous>)

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
harmony/pushy/src/main/ets/UpdateContext.ts (1)

245-249: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Reset ignoreRollback before the unchanged-state return.

Line 249 is unreachable when nextState.changed is false, so a static true value can leak across a normal same-binary sync. Move the reset before the early return.

Proposed fix
     const nextState = NativePatchCore.syncStateWithBinaryVersion(
       packageVersion,
       buildTime,
       currentState,
     );
+    UpdateContext.ignoreRollback = false;
     if (!nextState.changed) {
       return;
     }
 
-    UpdateContext.ignoreRollback = false;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@harmony/pushy/src/main/ets/UpdateContext.ts` around lines 245 - 249, In
UpdateContext, the ignoreRollback reset is placed after the early return in the
nextState.changed check, so it never runs for unchanged-state updates; move the
UpdateContext.ignoreRollback = false reset to before the if (!nextState.changed)
return path inside the relevant UpdateContext flow so same-binary sync always
clears the flag.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@harmony/pushy/src/main/ets/UpdateContext.ts`:
- Around line 390-394: The first-load marker is being written separately from
the launch state in UpdateContext, so a failure between the two writes can leave
first-time state consumed without the JS-visible marker. Update the persistence
flow around persistState(launchState) and firstLoadMarked so both values are
committed in the same preference flush, using the existing UpdateContext
launch-state persistence path and the firstLoadMarked key together.

---

Outside diff comments:
In `@harmony/pushy/src/main/ets/UpdateContext.ts`:
- Around line 245-249: In UpdateContext, the ignoreRollback reset is placed
after the early return in the nextState.changed check, so it never runs for
unchanged-state updates; move the UpdateContext.ignoreRollback = false reset to
before the if (!nextState.changed) return path inside the relevant UpdateContext
flow so same-binary sync always clears the flag.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 06da63f4-25bd-4303-9da9-53502645a1bd

📥 Commits

Reviewing files that changed from the base of the PR and between 38717fa and d6a460c.

📒 Files selected for processing (2)
  • harmony/pushy/src/main/ets/PushyTurboModule.ts
  • harmony/pushy/src/main/ets/UpdateContext.ts

Comment thread harmony/pushy/src/main/ets/UpdateContext.ts Outdated
@sunnylqm sunnylqm merged commit 2c864be into master Jun 29, 2026
4 checks passed
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