Skip to content

feat(web): support main thread invoke ui method#2104

Merged
Sherry-hue merged 1 commit intolynx-family:mainfrom
Sherry-hue:feat/main-ref-invoke
Jan 12, 2026
Merged

feat(web): support main thread invoke ui method#2104
Sherry-hue merged 1 commit intolynx-family:mainfrom
Sherry-hue:feat/main-ref-invoke

Conversation

@Sherry-hue
Copy link
Copy Markdown
Collaborator

@Sherry-hue Sherry-hue commented Jan 12, 2026

Summary by CodeRabbit

  • New Features

    • Introduced main thread API for remotely invoking UI element methods, enabling dynamic interaction with UI components from script with callback-based responses.
  • Tests

    • Added test coverage for the main thread UI method invocation feature, including scroll element manipulation validation.

✏️ 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).

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 12, 2026

🦋 Changeset detected

Latest commit: 21cc3b2

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

This PR includes changesets to release 10 packages
Name Type
@lynx-js/web-mainthread-apis Patch
@lynx-js/web-constants Patch
@lynx-js/web-core-server Patch
@lynx-js/web-core Patch
@lynx-js/web-worker-runtime Patch
upgrade-rspeedy Patch
@lynx-js/web-rsbuild-server-middleware Patch
@lynx-js/web-worker-rpc Patch
@lynx-js/rspeedy 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
Copy Markdown
Contributor

coderabbitai bot commented Jan 12, 2026

📝 Walkthrough

Walkthrough

A new feature enabling main thread invocation of UI element methods is introduced. Changes include type definitions for the __InvokeUIMethod API, implementation with error handling and callback patterns, test coverage, and example UI components demonstrating the functionality.

Changes

Cohort / File(s) Summary
Version and Feature Declaration
.changeset/empty-turkeys-strive.md
Patch version bump for @lynx-js/web-mainthread-apis and @lynx-js/web-constants; declares feature: "support main thread invoke ui method"
Type Definitions
packages/web-platform/web-constants/src/types/MainThreadGlobalThis.ts
Adds InvokeUIMethodPAPI type definition; imports InvokeCallbackRes from NativeApp; exposes __InvokeUIMethod in ElementPAPIs interface
Core Implementation
packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts
Implements __InvokeUIMethod with support for boundingClientRect retrieval, generic method invocation, error handling, and ErrorCode responses via callback; imports ErrorCode from @lynx-js/web-constants
Test Suite
packages/web-platform/web-tests/tests/react.spec.ts
Adds test case basic-ref-main-invoke-ui-method that validates scroll behavior triggered by UI method invocation
Test UI Components
packages/web-platform/web-tests/tests/react/basic-ref-main-invoke-ui-method/index.jsx
Introduces ScrollItem and App components; App uses useMainThreadRef and demonstrates tap handler triggering autoScroll on scroll-view via method invocation

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • PupilTong
  • hzy

Poem

🐰 A curious rabbit hops with glee,
New methods the UI can now be,
From main thread, we invoke with grace,
Callbacks dance across the space,
ScrollViews scroll at lightning speed! 🎉

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(web): support main thread invoke ui method' clearly and specifically summarizes the main change—adding a new feature for invoking UI methods from the main thread.

✏️ 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.

Copy link
Copy Markdown
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 @packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts:
- Around line 820-859: The __InvokeUIMethod handler must validate the element
before using it: at the start of the function (inside __InvokeUIMethod) check
that element is not null/undefined and is an HTMLElement (or at least a non-null
object) and if the check fails immediately call callback with
ErrorCode.PARAM_INVALID and return; only after that safe-check call
getBoundingClientRect or access (element as any)[method]; keep the existing
branching for 'boundingClientRect' and typeof (element as any)[method] ===
"function" but move/guard them behind this element validation to avoid runtime
errors.
🧹 Nitpick comments (4)
packages/web-platform/web-constants/src/types/MainThreadGlobalThis.ts (1)

321-326: Consider using a more specific type for the element parameter.

The element parameter is typed as unknown, but the implementation in createMainThreadGlobalThis.ts casts it to HTMLElement. Using HTMLElement here would provide better type safety and align with other PAPI types in this file that use HTMLElement.

💡 Suggested type improvement
 export type InvokeUIMethodPAPI = (
-  element: unknown,
+  element: HTMLElement,
   method: string,
   params: object,
   callback: (result: InvokeCallbackRes) => void,
 ) => void;
packages/web-platform/web-tests/tests/react.spec.ts (1)

451-465: Consider reducing the wait time for test stability.

The test uses a 3000ms wait, which is significantly longer than most other tests in this file (typically 100-500ms). While this may be intentional to allow the auto-scroll animation to complete, it could make the test slow and potentially flaky.

Consider either:

  1. Reducing the wait time if the scroll completes faster
  2. Using a polling approach with waitForFunction to wait until scrollTop > 100 rather than a fixed delay
💡 Alternative using waitForFunction
     test('basic-ref-main-invoke-ui-method', async ({ page }, { title }) => {
       await goto(page, title);
       await wait(100);
       const scrollView = page.locator('#scroll-view');
       const scrollTopBefore = await scrollView.evaluate((node) =>
         node.scrollTop
       );
       expect(scrollTopBefore).toBe(0);
       await page.locator('#target').click();
-      await wait(3000);
-      const scrollTopAfter = await scrollView.evaluate((node) =>
-        node.scrollTop
-      );
-      expect(scrollTopAfter).toBeGreaterThan(100);
+      await page.waitForFunction(
+        () => {
+          const el = document.querySelector('lynx-view')?.shadowRoot?.querySelector('#scroll-view');
+          return el && el.scrollTop > 100;
+        },
+        { timeout: 5000 }
+      );
     });
packages/web-platform/web-tests/tests/react/basic-ref-main-invoke-ui-method/index.jsx (1)

61-63: Missing key prop on list items.

When rendering a list of elements with .map(), each child should have a unique key prop to help React identify which items have changed, been added, or removed. While this is a test fixture, adding keys is a React best practice.

💡 Add key prop
         {Array.from({ length: 5 }).map((item, index) => (
-          <ScrollItem width='calc(100% - 10px)' height='100px' index={index} />
+          <ScrollItem key={index} width='calc(100% - 10px)' height='100px' index={index} />
         ))}
packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts (1)

822-837: Consider including x and y properties from DOMRect.

The boundingClientRect response includes most properties from DOMRect but omits x and y. While left and top are often equivalent, including x and y would provide complete parity with the native getBoundingClientRect() API.

💡 Include x and y properties
           callback({
             code: ErrorCode.SUCCESS,
             data: {
               id: (element as HTMLElement).id,
+              x: rect.x,
+              y: rect.y,
               width: rect.width,
               height: rect.height,
               left: rect.left,
               right: rect.right,
               top: rect.top,
               bottom: rect.bottom,
             },
           });
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23403f6 and 21cc3b2.

📒 Files selected for processing (5)
  • .changeset/empty-turkeys-strive.md
  • packages/web-platform/web-constants/src/types/MainThreadGlobalThis.ts
  • packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts
  • packages/web-platform/web-tests/tests/react.spec.ts
  • packages/web-platform/web-tests/tests/react/basic-ref-main-invoke-ui-method/index.jsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript in strict mode with the configuration specified in tsconfig.json

Files:

  • packages/web-platform/web-constants/src/types/MainThreadGlobalThis.ts
  • packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts
  • packages/web-platform/web-tests/tests/react.spec.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,tsx}: Follow eslint rules as configured in eslint.config.js including React and TypeScript specific rules
Follow code formatting rules specified in .dprint.jsonc and biome.jsonc

Files:

  • packages/web-platform/web-constants/src/types/MainThreadGlobalThis.ts
  • packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts
  • packages/web-platform/web-tests/tests/react.spec.ts
packages/web-platform/web-tests/**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (AGENTS.md)

Use Playwright for E2E tests in packages/web-platform/web-tests/

Files:

  • packages/web-platform/web-tests/tests/react.spec.ts
🧠 Learnings (26)
📓 Common learnings
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1770
File: packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts:316-318
Timestamp: 2025-09-18T08:12:56.802Z
Learning: In packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts, the current implementation uses cardStyleElement.textContent += for lazy component styles. While this could theoretically invalidate rule indices by reparsing the stylesheet, Sherry-hue indicated that UIDs don't repeat for the same element, making this approach acceptable for now. A future optimization to use separate style elements per entry was discussed but deferred to a separate PR to keep the current lazy bundle PR focused.
📚 Learning: 2025-10-11T06:16:12.517Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1820
File: packages/web-platform/web-tests/tests/react.spec.ts:834-856
Timestamp: 2025-10-11T06:16:12.517Z
Learning: In packages/web-platform/web-tests/tests/react.spec.ts, the tests `basic-bindmouse` and `basic-mts-bindtouchstart` are NOT duplicates despite having similar test structures. They test different event types: `basic-bindmouse` validates mouse events (mousedown, mouseup, mousemove) with mouse-specific properties (button, buttons, x, y, pageX, pageY, clientX, clientY), while `basic-mts-bindtouchstart` validates touch events (touchstart) with touch arrays (touches, targetTouches, changedTouches). The similar test structure is coincidental and follows testing conventions.

Applied to files:

  • packages/web-platform/web-tests/tests/react/basic-ref-main-invoke-ui-method/index.jsx
  • packages/web-platform/web-tests/tests/react.spec.ts
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: Applies to packages/web-platform/web-elements/src/elements/all.ts : Export new components in `src/elements/all.ts` and add export configuration to `package.json` under `exports` for both types and default

Applied to files:

  • packages/web-platform/web-tests/tests/react/basic-ref-main-invoke-ui-method/index.jsx
  • packages/web-platform/web-constants/src/types/MainThreadGlobalThis.ts
📚 Learning: 2025-11-11T08:05:14.163Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1932
File: packages/web-platform/web-tests/tests/react/basic-element-x-input-ng-bindinput/index.jsx:10-26
Timestamp: 2025-11-11T08:05:14.163Z
Learning: In packages/web-platform/web-tests/tests/react/basic-element-x-input-ng-bindinput/index.jsx, the test intentionally uses selectionStart twice in the result string (instead of selectionStart and selectionEnd) because it prioritizes testing whether x-input-ng works functionally, rather than validating the correctness of selection values.

Applied to files:

  • packages/web-platform/web-tests/tests/react/basic-ref-main-invoke-ui-method/index.jsx
  • packages/web-platform/web-tests/tests/react.spec.ts
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: Applies to packages/web-platform/web-elements/src/elements/**/index.ts : Ensure `index.ts` files and complex logic have clear, descriptive comments matching the implementation

Applied to files:

  • packages/web-platform/web-tests/tests/react/basic-ref-main-invoke-ui-method/index.jsx
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: Applies to packages/web-platform/web-elements/src/elements/**/*.ts : When creating new elements, inherit from `Element` via `Component` decorator and use reactive utilities provided by `element-reactive`

Applied to files:

  • packages/web-platform/web-tests/tests/react/basic-ref-main-invoke-ui-method/index.jsx
  • packages/web-platform/web-tests/tests/react.spec.ts
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: Applies to packages/web-platform/web-elements/tests/**/*.spec.ts : Create a separate spec file for new components (e.g., `tests/x-webview.spec.ts`) instead of adding to the monolithic `web-elements.spec.ts`

Applied to files:

  • packages/web-platform/web-tests/tests/react/basic-ref-main-invoke-ui-method/index.jsx
  • packages/web-platform/web-tests/tests/react.spec.ts
📚 Learning: 2025-09-12T09:43:04.847Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, empty changeset files (containing only `---\n\n---`) are used for internal changes that modify src/** files but don't require meaningful release notes, such as private package changes or testing-only modifications. This satisfies CI requirements without generating user-facing release notes.

Applied to files:

  • .changeset/empty-turkeys-strive.md
📚 Learning: 2025-09-12T09:43:04.847Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, private packages (marked with "private": true in package.json) like lynx-js/react-transform don't require meaningful changeset entries even when their public APIs change, since they are not published externally and only affect internal development.

Applied to files:

  • .changeset/empty-turkeys-strive.md
📚 Learning: 2025-07-22T09:23:07.797Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:23:07.797Z
Learning: In the lynx-family/lynx-stack repository, changesets are only required for meaningful changes to end-users such as bugfixes and features. Internal/development changes like chores, refactoring, or removing debug info do not need changeset entries.

Applied to files:

  • .changeset/empty-turkeys-strive.md
📚 Learning: 2025-07-22T09:26:16.722Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:26:16.722Z
Learning: In the lynx-family/lynx-stack repository, CI checks require changesets when files matching the pattern "src/**" are modified (as configured in .changeset/config.json). For internal changes that don't need meaningful changesets, an empty changeset file is used to satisfy the CI requirement while not generating any release notes.

Applied to files:

  • .changeset/empty-turkeys-strive.md
📚 Learning: 2025-12-26T05:10:01.608Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.608Z
Learning: Use changeset tool with `pnpm changeset` to document changes before contribution

Applied to files:

  • .changeset/empty-turkeys-strive.md
📚 Learning: 2025-10-10T08:22:12.051Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1837
File: packages/web-platform/web-mainthread-apis/src/prepareMainThreadAPIs.ts:266-266
Timestamp: 2025-10-10T08:22:12.051Z
Learning: In packages/web-platform/web-mainthread-apis, the handleUpdatedData function returned from prepareMainThreadAPIs is internal-only, used to serve web-core. It does not require public documentation, type exports, or SSR support.

Applied to files:

  • packages/web-platform/web-constants/src/types/MainThreadGlobalThis.ts
  • packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: Applies to packages/web-platform/web-elements/src/elements/**/*.ts : Minimize heavy computation in `attributeChangedCallback` as these elements run on the main thread

Applied to files:

  • packages/web-platform/web-constants/src/types/MainThreadGlobalThis.ts
  • packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts
📚 Learning: 2025-09-28T07:52:03.601Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1837
File: packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/createNativeApp.ts:151-154
Timestamp: 2025-09-28T07:52:03.601Z
Learning: There are two different registerUpdateDataHandler functions in the lynx-stack codebase:
1. Main thread version in packages/web-platform/web-worker-runtime/src/mainThread/crossThreadHandlers/registerUpdateDataHandler.ts takes (mainThreadRpc: Rpc, backgroundThreadRpc: Rpc, runtime: MainThreadGlobalThis)
2. Background thread version in packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/crossThreadHandlers/registerUpdateDataHandler.ts takes only (rpc: Rpc, tt: NativeTTObject)

Applied to files:

  • packages/web-platform/web-constants/src/types/MainThreadGlobalThis.ts
📚 Learning: 2025-12-30T10:02:35.055Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 2081
File: packages/react/runtime/src/alog/elementPAPICall.ts:109-112
Timestamp: 2025-12-30T10:02:35.055Z
Learning: In packages/react/runtime/src/alog/elementPAPICall.ts, the helper APIs `__GetTag` and `__GetElementUniqueID` should always exist when instrumenting FiberElement PAPIs, so defensive checks for their existence are unnecessary.

Applied to files:

  • packages/web-platform/web-constants/src/types/MainThreadGlobalThis.ts
📚 Learning: 2025-08-21T08:46:54.494Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/webpack/cache-events-webpack-plugin/src/LynxCacheEventsRuntimeModule.ts:23-27
Timestamp: 2025-08-21T08:46:54.494Z
Learning: In Lynx webpack runtime modules, the team prioritizes performance and simplicity over defensive runtime error handling. They prefer relying on compile-time type safety (TypeScript) rather than adding runtime checks like try-catch blocks or type validation, especially for performance-critical code like cache event setup/cleanup functions.

Applied to files:

  • packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts
📚 Learning: 2025-08-12T16:09:32.413Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1497
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_full_static.js:9-10
Timestamp: 2025-08-12T16:09:32.413Z
Learning: In the Lynx stack, functions prefixed with `__` that are called in transformed code may be injected globally by the Lynx Engine at runtime rather than exported from the React runtime package. For example, `__CreateFrame` is injected globally by the Lynx Engine, not exported from lynx-js/react.

Applied to files:

  • packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts
📚 Learning: 2025-08-27T12:42:01.095Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1616
File: packages/webpack/cache-events-webpack-plugin/test/cases/not-cache-events/lazy-bundle/index.js:3-3
Timestamp: 2025-08-27T12:42:01.095Z
Learning: In webpack, properties like __webpack_require__.lynx_ce are injected during compilation/build time when webpack processes modules and generates bundles, not at runtime when dynamic imports execute. Tests for such properties don't need to wait for dynamic imports to complete.

Applied to files:

  • packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: The `web-elements` package provides a Native UI implementation for the LynxJS Web Platform using Web Components built on the `element-reactive` reactive framework

Applied to files:

  • packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts
📚 Learning: 2025-09-25T14:03:25.576Z
Learnt from: PupilTong
Repo: lynx-family/lynx-stack PR: 1834
File: packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/createChunkLoading.ts:162-171
Timestamp: 2025-09-25T14:03:25.576Z
Learning: In the lynx-stack codebase, for loadScriptAsync implementations in createChunkLoading.ts, unhandled promise rejections from readScriptAsync are intentionally not caught - the caller is expected to handle errors rather than the loadScriptAsync method itself invoking the callback with error messages.

Applied to files:

  • packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: Applies to packages/web-platform/web-elements/tests/**/*.spec.ts : Use Playwright for all E2E and functional tests with standard assertions like `expect(locator).toBeVisible()`, `expect(locator).toHaveCSS()`, and `diffScreenShot` for screenshot comparisons

Applied to files:

  • packages/web-platform/web-tests/tests/react.spec.ts
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: Applies to packages/web-platform/web-elements/tests/**/*.spec.ts : When a component makes external requests (e.g., via `iframe` or `fetch`), mock them using `page.route` in Playwright tests to ensure tests are hermetic and fast

Applied to files:

  • packages/web-platform/web-tests/tests/react.spec.ts
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: Applies to packages/web-platform/web-elements/tests/**/*.spec.ts : In Playwright tests, access Shadow DOM explicitly using `.shadowRoot` when using `evaluate` or `waitForFunction`, as document.querySelector fails to directly access shadow DOM elements

Applied to files:

  • packages/web-platform/web-tests/tests/react.spec.ts
📚 Learning: 2026-01-04T11:17:24.013Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-core-wasm/AGENTS.md:0-0
Timestamp: 2026-01-04T11:17:24.013Z
Learning: When modifying Rust core logic in src/main_thread, ALWAYS add corresponding tests in tests/element-apis.spec.ts to verify the JS-side behavior

Applied to files:

  • packages/web-platform/web-tests/tests/react.spec.ts
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: Applies to packages/web-platform/web-elements/tests/fixtures/**/*.html : Use HTML files for test fixtures and define a helper function `goto(page, fixtureName)` to handle navigation and waiting for resources like `document.fonts.ready`

Applied to files:

  • packages/web-platform/web-tests/tests/react.spec.ts
🧬 Code graph analysis (1)
packages/web-platform/web-constants/src/types/MainThreadGlobalThis.ts (1)
packages/web-platform/web-constants/src/types/NativeApp.ts (1)
  • InvokeCallbackRes (100-103)
🔇 Additional comments (4)
.changeset/empty-turkeys-strive.md (1)

1-6: LGTM!

The changeset correctly declares patch bumps for both affected packages (@lynx-js/web-mainthread-apis and @lynx-js/web-constants) with a clear feature description.

packages/web-platform/web-constants/src/types/MainThreadGlobalThis.ts (1)

13-13: LGTM!

The import of InvokeCallbackRes and the addition of __InvokeUIMethod to the ElementPAPIs interface are correctly implemented and consistent with the existing patterns in this file.

Also applies to: 392-392

packages/web-platform/web-tests/tests/react/basic-ref-main-invoke-ui-method/index.jsx (1)

22-31: LGTM!

The App component correctly demonstrates the new __InvokeUIMethod API by using useMainThreadRef and invoking the autoScroll method on the scroll-view. The 'main thread' directive properly marks the handler for main thread execution.

packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts (1)

64-64: LGTM!

The ErrorCode import is correctly added to the existing import block from @lynx-js/web-constants.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 12, 2026

Codecov Report

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

Files with missing lines Patch % Lines
...b-mainthread-apis/ts/createMainThreadGlobalThis.ts 0.00% 40 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jan 12, 2026

CodSpeed Performance Report

Merging this PR will degrade performance by 8.02%

Comparing Sherry-hue:feat/main-ref-invoke (21cc3b2) with main (23403f6)

Summary

⚡ 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 43.2 ms 47 ms -8.02%
basic-performance-nest-level-100 7.7 ms 7.1 ms +7.48%
basic-performance-small-css 8.2 ms 7.6 ms +8.21%

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
Copy Markdown

relativeci bot commented Jan 12, 2026

Web Explorer

#7154 Bundle Size — 383.59KiB (+0.11%).

21cc3b2(current) vs 23403f6 main#7150(baseline)

Bundle metrics  Change 2 changes
                 Current
#7154
     Baseline
#7150
No change  Initial JS 154.03KiB 154.03KiB
No change  Initial CSS 35.05KiB 35.05KiB
Change  Cache Invalidation 7.28% 0%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 238(+0.42%) 237
No change  Duplicate Modules 16 16
No change  Duplicate Code 3% 3%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#7154
     Baseline
#7150
Regression  JS 251.56KiB (+0.17%) 251.13KiB
No change  Other 96.98KiB 96.98KiB
No change  CSS 35.05KiB 35.05KiB

Bundle analysis reportBranch Sherry-hue:feat/main-ref-invokeProject dashboard


Generated by RelativeCIDocumentationReport issue

@Sherry-hue Sherry-hue merged commit 6c2b51a into lynx-family:main Jan 12, 2026
98 of 105 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