Skip to content

Upgrade Matter.js to latest version#2501

Open
Pierre-Gilles wants to merge 17 commits intomasterfrom
upgrade-matter-latest
Open

Upgrade Matter.js to latest version#2501
Pierre-Gilles wants to merge 17 commits intomasterfrom
upgrade-matter-latest

Conversation

@Pierre-Gilles
Copy link
Copy Markdown
Contributor

@Pierre-Gilles Pierre-Gilles commented Mar 23, 2026

Pull Request check-list

To ensure your Pull Request can be accepted as fast as possible, make sure to review and check all of these items:

  • If your changes affect the code, did you write the tests?
  • Are tests passing? (npm test on both front/server)
  • Is the linter passing? (npm run eslint on both front/server)
  • Did you run prettier? (npm run prettier on both front/server)
  • If you are adding a new feature/service, did you run the integration comparator? (npm run compare-translations on front)
  • Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community (forum) for testing before merging.
  • If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
  • If you are adding a new features/services which needs explanation, did you modify the user documentation? See the GitHub repo and the website.
  • Did you add fake requests data for the demo mode (front/src/config/demo.js) so that the demo website is working without a backend? (if needed) See https://demo.gladysassistant.com.

NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.

Description of change

Upgrade Matter.js to latest version

Summary by CodeRabbit

  • Chores

    • Updated Matter-related development dependencies.
  • Bug Fixes

    • Stricter device filtering during startup to avoid incomplete device entries.
    • Initialization now refreshes devices in the background to prevent startup failures.
    • State events quietly skip processing when a target device/feature is missing instead of throwing.
  • Refactor

    • Aligned device endpoint and cluster client handling with updated Matter accessor APIs.
  • Tests

    • Updated test fixtures to match accessor-based device APIs.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 23, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Refactors Matter device access to use accessor methods (getAllClusterClients, getClusterClientById, getChildEndpoints), updates tests/mocks, bumps Matter dependencies, runs device refresh in background during init, and changes missing-state throws into logged no-ops.

Changes

Cohort / File(s) Summary
Package Dependencies
server/package.json, server/services/matter/package.json
Bumped Matter-related packages (@matter/main, @project-chip/matter.js) from ^0.13.0 to ^0.16.10.
Accessor API — Core logic
server/services/matter/lib/matter.getNodes.js, server/services/matter/lib/matter.handleNode.js, server/services/matter/lib/matter.listenToStateChange.js, server/services/matter/lib/matter.setValue.js, server/services/matter/utils/convertToGladysDevice.js
Replaced direct device.clusterClients / device.childEndpoints access with getAllClusterClients(), getClusterClientById(id), and getChildEndpoints(); added non-empty guards and tightened node filtering.
Initialization & Background Refresh
server/services/matter/lib/matter.init.js
CommissioningController options adjusted (removed storage, cleared autoConnect), and refreshDevices() is launched in background with its promise stored and .catch() logging instead of being awaited.
State Event Handling
server/lib/device/device.newStateEvent.js
When referenced device or feature is missing, log an info message and return early instead of throwing NotFoundError; removed the NotFoundError import.
Tests & Mocks Updated to Accessor API
server/test/services/matter/lib/convertToGladysDevice.test.js, server/test/services/matter/lib/listenToStateChange.test.js, server/test/services/matter/lib/matter.getNodes.test.js, server/test/services/matter/lib/matter.init.test.js, server/test/services/matter/lib/matter.pairDevice.test.js, server/test/services/matter/lib/matter.refreshDevices.test.js, server/test/services/matter/lib/matter.setValue.test.js, server/test/lib/device/device.newStateEvent.test.js
Refactored test fixtures/stubs from clusterClients Maps and childEndpoints arrays to use getAllClusterClients(), getClusterClientById(), and getChildEndpoints(); updated tests to accommodate background refresh and missing-state logging.
Minor Control-Flow Guards
server/services/matter/lib/matter.handleNode.js, server/services/matter/lib/matter.setValue.js, various tests
Added explicit existence/length checks before iterating child endpoints; replaced Map-based cluster lookups with accessor calls in multiple places.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped from Map to method door,
I peeked at clusters, counted more.
A background breeze now stirs the trees,
Missing leaves logged with gentle ease.
Happy hops — the garden hums with glee! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change—upgrading Matter.js to the latest version (from ^0.13.0 to ^0.16.10), which is reflected throughout the changeset's dependency updates and corresponding API adaptations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 upgrade-matter-latest

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.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 23, 2026

Deploying gladys-plus with  Cloudflare Pages  Cloudflare Pages

Latest commit: 90ed64f
Status: ✅  Deploy successful!
Preview URL: https://99a44bd2.gladys-plus.pages.dev
Branch Preview URL: https://upgrade-matter-latest.gladys-plus.pages.dev

View logs

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.81%. Comparing base (b32900c) to head (90ed64f).
⚠️ Report is 19 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2501      +/-   ##
==========================================
- Coverage   98.81%   98.81%   -0.01%     
==========================================
  Files        1007     1010       +3     
  Lines       17570    17694     +124     
==========================================
+ Hits        17362    17484     +122     
- Misses        208      210       +2     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@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

🧹 Nitpick comments (1)
server/test/services/matter/lib/matter.setValue.test.js (1)

465-497: Add test cases for missing cluster support on other device feature types.

The current test at lines 465-497 verifies error handling when the OnOff cluster is missing. However, the implementation only guards against null for OnOff—WindowCovering, LevelControl, ColorControl, and Thermostat clusters have no null-checks before method invocations. Add similar test cases for these feature types to ensure consistent error handling when cluster clients are unavailable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/test/services/matter/lib/matter.setValue.test.js` around lines 465 -
497, Add tests mirroring the OnOff missing-cluster case for the other feature
types: create gladysDevice/gladysFeature variants with types that map to
WindowCovering, LevelControl, ColorControl, and Thermostat and ensure
clusterClients Map returns undefined for their cluster IDs; call
matterHandler.setValue(...) for each and assert the promise is rejected with an
appropriate "Device does not support <ClusterName> cluster" error (or the exact
message your implementation uses). Use the same nodesMap setup, fake
connect/initialized/getDevices structure and reference matterHandler.setValue,
getClusterClientById, and the cluster client lookup logic so each cluster path
is exercised and null/undefined cluster clients are handled consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@server/services/matter/lib/matter.init.js`:
- Around line 48-50: Update the inline comment above the autoConnect option in
matter.init.js to remove the incorrect PR reference and instead reference the
correct Matter.js change; specifically, replace the bogus "PR `#3436`" link with
either the accurate PR/issue or the release note for Matter.js v0.12 (Jan 2025)
that introduced the autoConnect property, and clarify that autoConnect is set to
undefined as a workaround for compatibility with that version's PairedNode
connection options; keep the comment concise and mention the symbol autoConnect
and the Matter.js version or correct link so future maintainers understand why
autoConnect is being overridden.

---

Nitpick comments:
In `@server/test/services/matter/lib/matter.setValue.test.js`:
- Around line 465-497: Add tests mirroring the OnOff missing-cluster case for
the other feature types: create gladysDevice/gladysFeature variants with types
that map to WindowCovering, LevelControl, ColorControl, and Thermostat and
ensure clusterClients Map returns undefined for their cluster IDs; call
matterHandler.setValue(...) for each and assert the promise is rejected with an
appropriate "Device does not support <ClusterName> cluster" error (or the exact
message your implementation uses). Use the same nodesMap setup, fake
connect/initialized/getDevices structure and reference matterHandler.setValue,
getClusterClientById, and the cluster client lookup logic so each cluster path
is exercised and null/undefined cluster clients are handled consistently.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cb38406a-b9c3-49f4-8e23-ae5c34965003

📥 Commits

Reviewing files that changed from the base of the PR and between b32900c and 77373e2.

⛔ Files ignored due to path filters (2)
  • server/package-lock.json is excluded by !**/package-lock.json
  • server/services/matter/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (15)
  • server/package.json
  • server/services/matter/lib/matter.getNodes.js
  • server/services/matter/lib/matter.handleNode.js
  • server/services/matter/lib/matter.init.js
  • server/services/matter/lib/matter.listenToStateChange.js
  • server/services/matter/lib/matter.setValue.js
  • server/services/matter/package.json
  • server/services/matter/utils/convertToGladysDevice.js
  • server/test/services/matter/lib/convertToGladysDevice.test.js
  • server/test/services/matter/lib/listenToStateChange.test.js
  • server/test/services/matter/lib/matter.getNodes.test.js
  • server/test/services/matter/lib/matter.init.test.js
  • server/test/services/matter/lib/matter.pairDevice.test.js
  • server/test/services/matter/lib/matter.refreshDevices.test.js
  • server/test/services/matter/lib/matter.setValue.test.js

@relativeci
Copy link
Copy Markdown

relativeci bot commented Mar 23, 2026

#4149 Bundle Size — 11.44MiB (+0.05%).

90ed64f(current) vs c22a231 master#4138(baseline)

Warning

Bundle contains 2 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes Regression 1 regression
                 Current
#4149
     Baseline
#4138
Regression  Initial JS 6.42MiB(+0.09%) 6.42MiB
No change  Initial CSS 310.54KiB 310.54KiB
Change  Cache Invalidation 56% 0%
No change  Chunks 51 51
No change  Assets 179 179
No change  Modules 1643 1643
No change  Duplicate Modules 21 21
No change  Duplicate Code 0.94% 0.94%
No change  Packages 136 136
No change  Duplicate Packages 2 2
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#4149
     Baseline
#4138
Regression  JS 8.32MiB (+0.07%) 8.32MiB
No change  IMG 2.68MiB 2.68MiB
No change  CSS 328.39KiB 328.39KiB
No change  Fonts 93.55KiB 93.55KiB
No change  Other 18.82KiB 18.82KiB
No change  HTML 13.58KiB 13.58KiB

Bundle analysis reportBranch upgrade-matter-latestProject dashboard


Generated by RelativeCIDocumentationReport issue

@Pierre-Gilles Pierre-Gilles mentioned this pull request Mar 23, 2026
9 tasks
Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@server/test/services/matter/lib/matter.init.test.js`:
- Around line 900-908: The test contains a no-op Chai expression:
expect(matterHandler.refreshDevicesPromise).to.be.fulfilled which lints as an
unused expression; replace it with an executable assertion that actually awaits
the background promise (for example, use an awaited chai-as-promised check like
await expect(matterHandler.refreshDevicesPromise).to.be.fulfilled or simply
await matterHandler.refreshDevicesPromise and assert no error) so the test
verifies that matterHandler.refreshDevicesPromise resolves after calling
matterHandler.init().

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 53a75ce7-87b9-4b38-a44f-65af104d6122

📥 Commits

Reviewing files that changed from the base of the PR and between 6aba083 and d72b919.

📒 Files selected for processing (3)
  • server/services/matter/lib/matter.setValue.js
  • server/test/services/matter/lib/matter.init.test.js
  • server/test/services/matter/lib/matter.setValue.test.js

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