Skip to content

Inspector: Move CLI bridge infrastructure to shared ModularTool framework#18332

Open
ryantrem wants to merge 8 commits intoBabylonJS:masterfrom
ryantrem:inspector-cli/make-modular-cli
Open

Inspector: Move CLI bridge infrastructure to shared ModularTool framework#18332
ryantrem wants to merge 8 commits intoBabylonJS:masterfrom
ryantrem:inspector-cli/make-modular-cli

Conversation

@ryantrem
Copy link
Copy Markdown
Member

🤖 This PR was created by the create-pr skill.

Extracts the CLI bridge infrastructure from inspector-v2 into the shared ModularTool framework in sharedUiComponents, making it reusable by any tool built with MakeModularTool.

Key Design Point

The MakeModularBridge service container is long-lived and survives across playground runs. Even though the scene is recreated on each run, the bridge stays the same and stays connected to the CLI. This ensures stable CLI connectivity without reconnection overhead.

Changes

  • New MakeModularBridge — a shared bridge entry point in sharedUiComponents/src/modularTool/modularBridge.ts that any modular tool can use for CLI connectivity.
  • Moved CLI services to sharedbridgeService, bridgeCommandRegistry, bridgeConnectionStatus, and protocol now live under sharedUiComponents/src/modularTool/services/cli/.
  • Refactored serviceContainer and serviceDefinition — updated service container and definition types to support the generalized bridge pattern.
  • Updated inspector-v2 — inspector's bridge, CLI commands, and inspectable module now consume the shared services instead of owning them.
  • Updated Playground — playground's renderer and command service updated to use the new shared bridge APIs.
  • Tests updated — bridge and service container tests moved/updated to match the new structure.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 16, 2026

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 16, 2026

Building or testing the playground has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18332/merge/testResults/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 16, 2026

Snapshot stored with reference name:
refs/pull/18332/merge

Test environment:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18332/merge/index.html

To test a playground add it to the URL, for example:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18332/merge/index.html#WGZLGJ#4600

Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves):

https://playground.babylonjs.com/?snapshot=refs/pull/18332/merge
https://sandbox.babylonjs.com/?snapshot=refs/pull/18332/merge
https://gui.babylonjs.com/?snapshot=refs/pull/18332/merge
https://nme.babylonjs.com/?snapshot=refs/pull/18332/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/18332/merge#BCU1XR#0

If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 16, 2026

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/18332/merge/

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ryantrem ryantrem marked this pull request as ready for review April 16, 2026 23:33
Copilot AI review requested due to automatic review settings April 16, 2026 23:33
@ryantrem
Copy link
Copy Markdown
Member Author

Self code review completed. Review fix: 47f50a82d3 — added \�oid\ operator to handle \Promise\ return from \disposeToken.dispose()\ in legacy inspector.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 16, 2026

Building or testing the playground has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18332/merge/testResults/

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Extracts the Inspector v2 CLI bridge infrastructure into the shared sharedUiComponents ModularTool framework so CLI connectivity (bridge, command registry, connection status, protocol) can be reused by multiple modular tools (including Playground).

Changes:

  • Introduces shared CLI bridge services/protocol under sharedUiComponents/src/modularTool/services/cli/ and adds a new shared MakeModularBridge entry point.
  • Refactors ServiceContainer / ServiceDefinition to a synchronous registration model and updates ModularTool + Inspector/Inspectable flows accordingly.
  • Updates Playground + Inspector v2 CLI/tests to consume the shared bridge APIs and adds additional bridge session robustness tests.

Reviewed changes

Copilot reviewed 28 out of 29 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/tools/playground/src/tools/playgroundCommandService.ts Switches Playground CLI command registration to the shared bridge command registry.
packages/tools/playground/src/components/rendererComponent.tsx Adds long-lived modular bridge token usage and wires inspectable sessions to reuse it.
packages/public/@babylonjs/inspector-v2/tsconfig.cli.json Adds path mapping so Inspector v2 CLI can import shared bridge protocol/types.
packages/dev/sharedUiComponents/test/unit/modularity/serviceContainer.test.ts Updates service container tests for the new synchronous API and adds cross-container dependency tests.
packages/dev/sharedUiComponents/test/unit/modularity/bridgeService.test.ts Updates bridge service tests to new shared service identities/names.
packages/dev/sharedUiComponents/src/modularTool/services/cli/protocol.ts Adds shared CLI↔bridge↔browser protocol types.
packages/dev/sharedUiComponents/src/modularTool/services/cli/bridgeService.ts Moves/renames the browser-side bridge service to shared UI components.
packages/dev/sharedUiComponents/src/modularTool/services/cli/bridgeConnectionStatus.ts Shared connection status contract/identity for CLI bridge.
packages/dev/sharedUiComponents/src/modularTool/services/cli/bridgeCommandRegistry.ts Shared command registry contract/identity for CLI bridge commands.
packages/dev/sharedUiComponents/src/modularTool/modularity/serviceDefinition.ts Updates service factory typing to the new synchronous model.
packages/dev/sharedUiComponents/src/modularTool/modularity/serviceContainer.ts Implements synchronous addService(s) registration and parent resolution behavior.
packages/dev/sharedUiComponents/src/modularTool/modularTool.tsx Updates ModularTool bootstrapping to use the synchronous service container and async disposal completion promise.
packages/dev/sharedUiComponents/src/modularTool/modularBridge.ts New shared MakeModularBridge helper to create a headless bridge container/token.
packages/dev/sharedUiComponents/src/modularTool/extensibility/extensionManager.ts Updates extension service registration to the synchronous service container API.
packages/dev/inspector-v2/test/unit/inspectable.test.ts Updates inspectable tests for synchronous initialization behavior.
packages/dev/inspector-v2/test/unit/cli/cli.test.ts Switches CLI tests to import the shared protocol types.
packages/dev/inspector-v2/test/unit/cli/bridge.test.ts Adds coverage for info-timeout session eviction and re-registration behavior; imports shared protocol types.
packages/dev/inspector-v2/src/services/cliConnectionStatusService.tsx Updates inspector UI service to consume shared bridge connection status identity/type.
packages/dev/inspector-v2/src/services/cli/*.ts Migrates inspector CLI command services to use shared bridge command registry identity/type.
packages/dev/inspector-v2/src/legacy/inspector.tsx Adjusts hide/disposal usage for async dispose tokens.
packages/dev/inspector-v2/src/inspector.tsx Makes inspector token disposal async and ensures disposal order via observable insertion.
packages/dev/inspector-v2/src/inspectable.ts Refactors inspectable to optionally reuse a long-lived modular bridge token; updates disposal ordering.
packages/dev/inspector-v2/src/index.ts Re-exports shared bridge types + MakeModularBridge for consumers (e.g., Playground).
packages/dev/inspector-v2/src/cli/cli.ts Switches CLI implementation to import shared protocol types.
packages/dev/inspector-v2/src/cli/bridge.ts Adds configurable info-timeout and removes dead sessions / prevents session leaks on re-register.

Comment thread packages/public/@babylonjs/inspector-v2/tsconfig.cli.json
Comment thread packages/tools/playground/src/components/rendererComponent.tsx Outdated
Comment thread packages/dev/sharedUiComponents/test/unit/modularity/serviceContainer.test.ts Outdated
Comment thread packages/dev/sharedUiComponents/test/unit/modularity/serviceContainer.test.ts Outdated
@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 16, 2026

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/18332/merge/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 16, 2026

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 17, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 17, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 17, 2026

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/18332/merge/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 17, 2026

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18332/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18332/merge/?snapshot=refs/pull/18332/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 17, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 17, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 17, 2026

@ryantrem ryantrem enabled auto-merge (squash) April 17, 2026 01:10
@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 17, 2026

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/18332/merge/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 17, 2026

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18332/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18332/merge/?snapshot=refs/pull/18332/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 17, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 17, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 17, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants