Skip to content

feat: support lynx.reload()#2127

Merged
PupilTong merged 1 commit intolynx-family:mainfrom
PupilTong:p/hw/support-lynx-reload
Jan 22, 2026
Merged

feat: support lynx.reload()#2127
PupilTong merged 1 commit intolynx-family:mainfrom
PupilTong:p/hw/support-lynx-reload

Conversation

@PupilTong
Copy link
Collaborator

@PupilTong PupilTong commented Jan 22, 2026

Summary by CodeRabbit

  • New Features

    • Introduced lynx.reload() method enabling Lynx applications to programmatically trigger page reloads on demand, allowing applications to refresh displayed content without requiring manual page navigation
  • Tests

    • Added comprehensive end-to-end test coverage for reload functionality, verifying interactions with UI elements and visual state transitions across all test environments
  • Chores

    • Published patch version updates for web-worker-runtime, web-constants, and web-core packages

✏️ Tip: You can customize this high-level summary in your review settings.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@PupilTong PupilTong requested a review from Sherry-hue January 22, 2026 07:33
@PupilTong PupilTong self-assigned this Jan 22, 2026
@changeset-bot
Copy link

changeset-bot bot commented Jan 22, 2026

🦋 Changeset detected

Latest commit: ad061d2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@lynx-js/web-worker-runtime Patch
@lynx-js/web-constants Patch
@lynx-js/web-core Patch
@lynx-js/web-core-server Patch
@lynx-js/web-mainthread-apis Patch
upgrade-rspeedy Patch
@lynx-js/web-rsbuild-server-middleware Patch
@lynx-js/web-worker-rpc Patch
@lynx-js/rspeedy Patch
@lynx-js/web-core-wasm Patch
create-rspeedy Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

This PR introduces a lynx.reload() feature across the web platform. It adds RPC endpoints for reload functionality, registers handlers in the main thread and background thread, updates UI thread startup callbacks, includes supporting infrastructure in the worker runtime, and adds e2e tests with sample components demonstrating the reload capability.

Changes

Cohort / File(s) Summary
Changeset
.changeset/upset-bats-bathe.md
Declares patch bumps for web-worker-runtime, web-constants, and web-core packages to release the reload feature.
RPC Endpoint Definitions
packages/web-platform/web-constants/src/endpoints.ts, packages/web-platform/web-core-wasm/ts/client/endpoints.ts
Adds reloadEndpoint RPC endpoint definitions with no parameters and void return type in both endpoint files.
Background Thread APIs
packages/web-platform/web-core-wasm/ts/client/background/background-apis/createBackgroundLynx.ts, packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/createBackgroundLynx.ts
Exports new reload() method to background Lynx API surface; imports and invokes reloadEndpoint via thread RPC.
Cross-Thread Handler Registration
packages/web-platform/web-core-wasm/ts/client/mainthread/crossThreadHandlers/registerReloadHandler.ts, packages/web-platform/web-core/src/uiThread/crossThreadHandlers/registerReloadHandler.ts
Registers reload RPC handlers to wire reload requests to underlying reload implementations.
Main Thread Integration
packages/web-platform/web-core-wasm/ts/client/mainthread/Background.ts, packages/web-platform/web-core/src/uiThread/startBackground.ts, packages/web-platform/web-core/src/uiThread/startUIThread.ts
Imports and registers reload handler during background thread startup; adds reload: () => void callback to StartUIThreadCallbacks.
LynxView API
packages/web-platform/web-core/src/apis/LynxView.ts
Adds reload callback forwarding to LynxView instance reload method.
Test Specifications
packages/web-platform/web-core-wasm-e2e/tests/reactlynx.spec.ts, packages/web-platform/web-tests/tests/react.spec.ts
Adds "basic-lynx-reload" test cases that verify color toggle on target click and color reset on reload click.
Test Components
packages/web-platform/web-core-wasm-e2e/tests/reactlynx/basic-lynx-reload/index.jsx, packages/web-platform/web-tests/tests/react/basic-lynx-reload/index.jsx
Adds React-like Lynx components rendering color-toggling target and reload trigger views; demonstrates the reload feature.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

platform:Web

Suggested reviewers

  • Sherry-hue
  • colinaaa

Poem

A rabbit hops through threads with glee, ✨
New reload powers set code free,
Target taps and green takes flight,
Reload clicks restore to pink so bright,
Lynx now refreshes with grace—bounce bounce! 🐰

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: support lynx.reload()' directly and clearly describes the main feature added across the changeset, which is implementing support for the lynx.reload() API.
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 docstrings

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.

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

❌ Patch coverage is 68.00000% with 16 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...hread/crossThreadHandlers/registerReloadHandler.ts 18.18% 9 Missing ⚠️
...background/background-apis/createBackgroundLynx.ts 0.00% 3 Missing ⚠️
...oundThread/background-apis/createBackgroundLynx.ts 0.00% 3 Missing ⚠️
...m/web-core-wasm/ts/client/mainthread/Background.ts 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.changeset/upset-bats-bathe.md:
- Around line 1-7: The changeset currently bumps "@lynx-js/web-worker-runtime",
"@lynx-js/web-constants", and "@lynx-js/web-core" as patch while adding support
for the new API lynx.reload(); verify whether lynx.reload() introduces any
breaking or required API changes (new required callbacks or behavioral changes)
and if so update the changeset to a minor bump instead of patch for the affected
packages (e.g., change the version bump level for "@lynx-js/web-core" and any
other packages that expose the breaking surface) to follow the repo’s pre-1.0
versioning policy.
🧹 Nitpick comments (2)
packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/createBackgroundLynx.ts (1)

61-63: Consider returning/awaiting the reload RPC to surface failures.

If uiThreadRpc.invoke is async, the current fire‑and‑forget call can drop rejections and prevents callers from awaiting completion. Consider returning the promise (or making reload async) so callers can handle errors. As per coding guidelines, prefer async/await with proper error handling.

♻️ Suggested update
-    reload: () => {
-      uiThreadRpc.invoke(reloadEndpoint, []);
-    },
+    reload: () => uiThreadRpc.invoke(reloadEndpoint, []),
packages/web-platform/web-core-wasm/ts/client/endpoints.ts (1)

215-219: Duplicate endpoint definition with web-constants package.

This reloadEndpoint is also defined identically in packages/web-platform/web-constants/src/endpoints.ts (lines 263-266). Having the same endpoint defined in two separate packages creates a maintenance burden and risk of divergence. Consider importing from @lynx-js/web-constants instead, similar to how registerReloadHandler.ts in web-core imports it.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 22, 2026

Merging this PR will degrade performance by 6.29%

⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 60 untouched benchmarks
⏩ 3 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
transform 1000 view elements 45.8 ms 42.4 ms +8.03%
basic-performance-nest-level-100 7.7 ms 6.9 ms +11.11%
basic-performance-div-10000 454 ms 484.5 ms -6.29%

Comparing PupilTong:p/hw/support-lynx-reload (ad061d2) with main (9d8f262)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link

relativeci bot commented Jan 22, 2026

Web Explorer

#7291 Bundle Size — 383.78KiB (+0.04%).

ad061d2(current) vs 9d8f262 main#7277(baseline)

Bundle metrics  Change 4 changes Regression 1 regression
                 Current
#7291
     Baseline
#7277
Regression  Initial JS 154.12KiB(+0.06%) 154.03KiB
No change  Initial CSS 35.05KiB 35.05KiB
Change  Cache Invalidation 55.91% 0%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 239(+0.42%) 238
No change  Duplicate Modules 16 16
Change  Duplicate Code 3%(+0.33%) 2.99%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#7291
     Baseline
#7277
Regression  JS 251.71KiB (+0.06%) 251.56KiB
No change  Other 97.02KiB 97.02KiB
No change  CSS 35.05KiB 35.05KiB

Bundle analysis reportBranch PupilTong:p/hw/support-lynx-relo...Project dashboard


Generated by RelativeCIDocumentationReport issue

@PupilTong PupilTong merged commit 5b589ab into lynx-family:main Jan 22, 2026
76 of 79 checks passed
colinaaa pushed a commit that referenced this pull request Jan 25, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @lynx-js/react@0.116.0

### Minor Changes

- **BREAKING CHANGE**: Bump Preact from
[10.24.0](preactjs/preact@1807173)
to
[10.28.0](preactjs/preact@f7693b7),
see diffs at [hzy/preact#6](hzy/preact#6).
([#2042](#2042))

### Patch Changes

- Add safety checks for compilation macros to prevent runtime errors
when they are undefined.
([#2110](#2110))

Replaces direct usage of `__PROFILE__`, `__MAIN_THREAD__`,
`__BACKGROUND__` with `typeof` checks.

This improves robustness by checking variable existence before access,
preventing runtime errors in environments where compilation macros are
not defined.

## @lynx-js/lynx-bundle-rslib-config@0.2.0

### Minor Changes

- Use `LAYERS` exposed by DSL plugins
([#2114](#2114))

## @lynx-js/gesture-runtime@2.1.2

### Patch Changes

- Fix an issue that `NativeGesture` does not get correct types in
callback ([#2130](#2130))

## @lynx-js/rspeedy@0.13.1

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-rsbuild-server-middleware@0.19.6

## @lynx-js/react-rsbuild-plugin@0.12.6

### Patch Changes

- Support using `pluginReactLynx` in Rslib.
([#2114](#2114))

- Updated dependencies
\[[`4cd7182`](4cd7182)]:
    -   @lynx-js/template-webpack-plugin@0.10.2
    -   @lynx-js/react-alias-rsbuild-plugin@0.12.6
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.4
    -   @lynx-js/react-webpack-plugin@0.7.3
    -   @lynx-js/css-extract-webpack-plugin@0.7.0

## upgrade-rspeedy@0.13.1

### Patch Changes

- Fix the issue `rslib-runtime.js` was not published in dist folder.
([#2122](#2122))

## @lynx-js/testing-environment@0.1.10

### Patch Changes

- Fix the error "lynxTestingEnv is not defined"
([#2118](#2118))

## @lynx-js/web-constants@0.19.6

### Patch Changes

- feat: add main-thread API: \_\_QuerySelector
([#2115](#2115))

- fix: when a list-item is deleted from list, the deleted list-item is
still showed incorrectly.
([#1092](#1092))

This is because the `enqueueComponent` method does not delete the node
from the Element Tree. It is only to maintain the display node on RL,
and lynx web needs to delete the dom additionally.

- feat: support main thread invoke ui method
([#2104](#2104))

- feat: support lynx.reload()
([#2127](#2127))

- Updated dependencies
\[[`f7133c1`](f7133c1)]:
    -   @lynx-js/web-worker-rpc@0.19.6

## @lynx-js/web-core@0.19.6

### Patch Changes

- fix: avoid crash on CPUs that do not support SIMD
([#2133](#2133))

- feat: support lynx.reload()
([#2127](#2127))

- Updated dependencies
\[[`179f984`](179f984),
[`f7133c1`](f7133c1),
[`6c2b51a`](6c2b51a),
[`556fe9f`](556fe9f),
[`5b589ab`](5b589ab)]:
    -   @lynx-js/web-constants@0.19.6
    -   @lynx-js/web-mainthread-apis@0.19.6
    -   @lynx-js/web-worker-rpc@0.19.6
    -   @lynx-js/web-worker-runtime@0.19.6

## @lynx-js/web-core-wasm@0.0.1

### Patch Changes

- Updated dependencies
\[[`f7133c1`](f7133c1)]:
    -   @lynx-js/web-worker-rpc@0.19.6

## @lynx-js/web-mainthread-apis@0.19.6

### Patch Changes

- feat: add main-thread API: \_\_QuerySelector
([#2115](#2115))

- fix: when a list-item is deleted from list, the deleted list-item is
still showed incorrectly.
([#1092](#1092))

This is because the `enqueueComponent` method does not delete the node
from the Element Tree. It is only to maintain the display node on RL,
and lynx web needs to delete the dom additionally.

- feat: support main thread invoke ui method
([#2104](#2104))

- fix: mts && bts events can be binded both
([#2121](#2121))

- Updated dependencies
\[[`179f984`](179f984),
[`f7133c1`](f7133c1),
[`6c2b51a`](6c2b51a),
[`5b589ab`](5b589ab)]:
    -   @lynx-js/web-constants@0.19.6

## @lynx-js/web-worker-rpc@0.19.6

### Patch Changes

- fix: when a list-item is deleted from list, the deleted list-item is
still showed incorrectly.
([#1092](#1092))

This is because the `enqueueComponent` method does not delete the node
from the Element Tree. It is only to maintain the display node on RL,
and lynx web needs to delete the dom additionally.

## @lynx-js/web-worker-runtime@0.19.6

### Patch Changes

- feat: support lynx.reload()
([#2127](#2127))

- Updated dependencies
\[[`179f984`](179f984),
[`f7133c1`](f7133c1),
[`6c2b51a`](6c2b51a),
[`556fe9f`](556fe9f),
[`5b589ab`](5b589ab)]:
    -   @lynx-js/web-constants@0.19.6
    -   @lynx-js/web-mainthread-apis@0.19.6
    -   @lynx-js/web-worker-rpc@0.19.6

## @lynx-js/template-webpack-plugin@0.10.2

### Patch Changes

- Polyfill `lynx.requireModuleAsync` to allow cache same parallel
requests. ([#2108](#2108))

## create-rspeedy@0.13.1



## @lynx-js/react-alias-rsbuild-plugin@0.12.6



## @lynx-js/web-core-server@0.19.6



## @lynx-js/web-rsbuild-server-middleware@0.19.6

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants