[feat] Add the BidiComponentContextProvider implementation#12754
[feat] Add the BidiComponentContextProvider implementation#12754sfc-gh-bnisco merged 1 commit intodevelopfrom
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
ee8592e to
732ea3e
Compare
d1b0bbb to
f9159b0
Compare
3fb6bd8 to
c5f3b2f
Compare
f9159b0 to
93613b5
Compare
c5f3b2f to
e575b5f
Compare
fdc0e6e to
85d8403
Compare
4fd4900 to
28e0810
Compare
85d8403 to
b59eb6e
Compare
28e0810 to
f9557e5
Compare
b59eb6e to
52e9727
Compare
f9557e5 to
3c1f5fd
Compare
52e9727 to
41020e5
Compare
3c1f5fd to
229751b
Compare
43e1228 to
f9cec43
Compare
c81bc3d to
f22703a
Compare
f9cec43 to
6062659
Compare
Merge activity
|
6062659 to
4618b9e
Compare
| return bytes ?? null | ||
| case "mixed": { | ||
| if (mixedJson && arrowBlobs) { | ||
| if (mixedJson) { |
Check warning
Code scanning / CodeQL
Useless conditional Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
The fix is straightforward: remove the useless conditional if (mixedJson) { ... } at line 59 and move its contents one level up, so that the block is only executed when the outer conditional (if (mixedJson && arrowBlobs)) is true. Specifically, replace lines 58–72 so that the parsing of mixedJson, construction of arrowBlobsMap, and call to reconstructMixedData occur directly within the block guarded by the outer conditional. No imports, method definitions, or additional variable definitions are needed.
| @@ -56,20 +56,16 @@ | ||
| return bytes ?? null | ||
| case "mixed": { | ||
| if (mixedJson && arrowBlobs) { | ||
| if (mixedJson) { | ||
| const jsonData = JSON.parse(mixedJson) | ||
| const jsonData = JSON.parse(mixedJson) | ||
|
|
||
| const arrowBlobsMap: Record<string, Uint8Array> = {} | ||
| if (arrowBlobs) { | ||
| Object.entries(arrowBlobs).forEach(([key, arrowProto]) => { | ||
| if (arrowProto?.data) { | ||
| arrowBlobsMap[key] = arrowProto.data | ||
| } | ||
| }) | ||
| const arrowBlobsMap: Record<string, Uint8Array> = {} | ||
| Object.entries(arrowBlobs).forEach(([key, arrowProto]) => { | ||
| if (arrowProto?.data) { | ||
| arrowBlobsMap[key] = arrowProto.data | ||
| } | ||
| }) | ||
|
|
||
| return reconstructMixedData(jsonData, arrowBlobsMap) | ||
| } | ||
| return reconstructMixedData(jsonData, arrowBlobsMap) | ||
| } | ||
| return null | ||
| } |
| const jsonData = JSON.parse(mixedJson) | ||
|
|
||
| const arrowBlobsMap: Record<string, Uint8Array> = {} | ||
| if (arrowBlobs) { |
Check warning
Code scanning / CodeQL
Useless conditional Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the problem, simply remove the conditional if (arrowBlobs) (lines 63-69). The forEach logic that populates arrowBlobsMap can be safely executed after the existing outer check (if (mixedJson && arrowBlobs)), as arrowBlobs is guaranteed to be non-null at that point. This will clean up the code without changing its behavior.
Specifically:
- In
frontend/lib/src/components/widgets/BidiComponent/utils/parseBidiComponentData.ts, lines 63-69 can be replaced by just the forEach loop (without the wrapping conditional) sincearrowBlobsis already verified. - No other imports or definitions are needed.
| @@ -60,13 +60,11 @@ | ||
| const jsonData = JSON.parse(mixedJson) | ||
|
|
||
| const arrowBlobsMap: Record<string, Uint8Array> = {} | ||
| if (arrowBlobs) { | ||
| Object.entries(arrowBlobs).forEach(([key, arrowProto]) => { | ||
| if (arrowProto?.data) { | ||
| arrowBlobsMap[key] = arrowProto.data | ||
| } | ||
| }) | ||
| } | ||
| Object.entries(arrowBlobs).forEach(([key, arrowProto]) => { | ||
| if (arrowProto?.data) { | ||
| arrowBlobsMap[key] = arrowProto.data | ||
| } | ||
| }) | ||
|
|
||
| return reconstructMixedData(jsonData, arrowBlobsMap) | ||
| } |

Describe your changes
Added a new BidiComponentContextProvider component and utility functions for parsing data. The provider creates a context with all necessary data and functions for CCv2 instances, including:
Also implemented a comprehensive data parser with tests that handles different data types:
GitHub Issue Link (if applicable)
Testing Plan
parseBidiComponentDatautility, covering all data types and edge casesContribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.