Conversation
invokes are now batched (when device supports it and non-root-endopoint and not groups) within the same macro-task
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds automatic command batching to improve efficiency when multiple commands are invoked on a Matter device within the same timer tick. Commands sent to devices that support batching (maxPathsPerInvoke > 1) are now collected and sent as a single batched invoke request, reducing network overhead.
Changes:
- Introduced
CommandInvokerbase class andCommandBatcherextension for intelligent command batching - Refactored
ClientCommandMethodto use the new invoker infrastructure - Added batching support in
ClientNodeInteractionwhile maintaining non-batching behavior for groups viaClientGroupInteraction
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/node/src/node/client/commands/CommandInvoker.ts | New base class for command invocation with immediate execution logic |
| packages/node/src/node/client/commands/CommandBatcher.ts | Implements batching logic that collects commands within a timer tick and sends them as a single request |
| packages/node/src/node/client/commands/ClientCommandMethod.ts | Refactored to use the new invoker.invoke() API for batching support |
| packages/node/src/node/client/ClientNodeInteraction.ts | Integrated CommandBatcher and added cleanup in close() method |
| packages/node/src/node/client/ClientGroupInteraction.ts | Overrides to use plain CommandInvoker without batching for groups |
| packages/node/src/node/client/PeerBehavior.ts | Updated import path for moved ClientCommandMethod |
| packages/node/src/node/ClientNode.ts | Added prepareRuntimeShutdown() to close interaction and clean up batcher |
| packages/node/test/node/CommandBatcherTest.ts | Comprehensive test suite covering batching scenarios, cache clearing, and error handling |
| packages/node/test/node/ClientNodeTest.ts | Updated tests to use MockTime.resolve() for batched commands |
| packages/node/test/behaviors/scenes-management/ScenesManagementServerTest.ts | Updated tests to use MockTime.resolve() for batched commands |
| packages/node/test/behaviors/group-key-management/GroupKeyManagementServerTest.ts | Added comment explaining why root endpoint commands don't need MockTime.resolve() |
| CHANGELOG.md | Documented the enhancement |
lauckhart
reviewed
Jan 24, 2026
lauckhart
approved these changes
Feb 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
invokes are now batched (when device supports it and non-root-endopoint and not groups) within the same macro-task