Skip to content

feat(fdc3) - Modified Fdc3 native client to allow argumetns from ctor; improved documentation, added client factory to allow shell specific client creation#1253

Open
lilla28 wants to merge 2 commits intomorganstanley:mainfrom
lilla28:feat/fdc3-native-client-refactor
Open

feat(fdc3) - Modified Fdc3 native client to allow argumetns from ctor; improved documentation, added client factory to allow shell specific client creation#1253
lilla28 wants to merge 2 commits intomorganstanley:mainfrom
lilla28:feat/fdc3-native-client-refactor

Conversation

@lilla28
Copy link
Contributor

@lilla28 lilla28 commented Mar 17, 2026

Description:
The most recent updates simplify in-process app onboarding and make the Desktop Agent client easier to configure in host applications.

Key improvements:

  • Constructor arguments are now supported: DesktopAgentClient can now be instantiated with explicit values for AppId, InstanceId, initial user channel, and opened app context (with environment variable fallbacks).
  • New IDesktopAgentClientFactory abstraction: Allows the host (e.g., ComposeUI Shell) to create and wire IDesktopAgent instances in a shell-specific way while keeping the client implementation decoupled.
  • UsingFdc3StartupProperties model: Provides a structured way for in-process apps to register their FDC3 identity information so they can participate correctly in the FDC3 ecosystem.

Additional changes in the desktop agent service and startup modules (internal behavior updates). This commit focused primarily on the client-side and dependency injection story.

Usage

Registering the Desktop Agent client (default)

The simplest way to use the client is to register it via dependency injection:

services.AddFdc3DesktopAgentClient();

Explicit configuration (optional)

If an application does not set the following environment variables, we can now pass them directly into the DesktopAgentClient constructor:

  • AppIdentifier.AppId
  • AppIdentifier.InstanceId
  • Fdc3StartupParameters.Fdc3ChannelId (initial user channel to join)
  • Fdc3StartupParameters.OpenedAppContextId (context identifier to request from the FDC3 backend/middleware if the app was opened via the fdc3.open call)

Example manual registration (useful for native hosts):

//My logic to get the data for my instance
var identifier = GetAppIdentifier(myInstance);

return new DesktopAgentClient(
        messaging, // per each instance
        appId: identifier.AppId,
        instanceId: identifier.InstanceId,
        initialUserChannelId: identifier.InitialChannelId,
        initialOpenAppContextId: identifier.OpenedAppContextId,
        onReady: agent => { /* ready callback */ },
        loggerFactory: loggerFactory);

Using the shell-specific factory

To support shell-specific wiring and to allow multiple in-process apps to coexist, we must allow consumers implementing and registering IDesktopAgentClientFactory in their host.

services.AddSingleton<IDesktopAgentClientFactory, MyShellDesktopAgentClientFactory>();

The factory can be used by modules to obtain a ready-to-use IDesktopAgent. The factory should be able to match the Fdc3Properties set via RegisterInProcessAppPropertiesAsync while returning back the client to properly identify the instance which was started using the IModuleLoader. A callback will ensure that the IDesktopAgent is ready once the initialization step is finished on the client implementation and ready for use by the consumers:

await factory.GetDesktopAgentAsync("module-id", desktopAgent =>
{
    // Desktop agent is now ready for use
});

Registering in-process app properties

In-process apps can register their identity information via Fdc3Properties:

//NOTE: It's important , the AppID should be registered in the AppDirectory and the instance id (FDC3 specific) should be 
//created by the IModuleLoader interface (or should be used while triggering its methods) to properly register and allow the module in the FDC3 ecosystem
await factory.RegisterInProcessAppPropertiesAsync(new Fdc3StartupProperties
{
    AppId = "my-app",
    InstanceId = Guid.NewGuid().ToString(),
    ChannelId = "fdc3.channel.1",
    OpenedAppContextId = "context-123"
});

Snapshots:
image

image

@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 73.96450% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.1%. Comparing base (13726fb) to head (e5ca14a).

Files with missing lines Patch % Lines
...pAgent.Client/Infrastructure/DesktopAgentClient.cs 54.7% 12 Missing and 7 partials ⚠️
....ComposeUI.Fdc3.DesktopAgent/Fdc3ShutdownAction.cs 50.0% 6 Missing and 1 partial ⚠️
....Client/Infrastructure/Internal/ContextListener.cs 76.9% 3 Missing and 3 partials ⚠️
....Fdc3.DesktopAgent.Shared/ModuleChannelSelector.cs 81.2% 6 Missing ⚠️
...Infrastructure/Internal/Protocol/PrivateChannel.cs 25.0% 1 Missing and 2 partials ⚠️
...Fdc3.DesktopAgent.Shared/Exceptions/ThrowHelper.cs 0.0% 1 Missing ⚠️
...esktopAgent/Extensions/StartupContextExtensions.cs 96.2% 1 Missing ⚠️
...y.ComposeUI.Fdc3.DesktopAgent/Fdc3StartupAction.cs 83.3% 0 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (73.9%) is below the target coverage (100.0%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #1253     +/-   ##
=======================================
+ Coverage   65.9%   66.1%   +0.2%     
=======================================
  Files        335     336      +1     
  Lines       9821    9858     +37     
  Branches    1291    1294      +3     
=======================================
+ Hits        6476    6521     +45     
+ Misses      2971    2956     -15     
- Partials     374     381      +7     
Files with missing lines Coverage Δ
...t.Client/Infrastructure/Internal/ChannelHandler.cs 90.0% <100.0%> (-0.5%) ⬇️
....Fdc3.DesktopAgent.Shared/Fdc3StartupProperties.cs 100.0% <100.0%> (ø)
...oseUI.Fdc3.DesktopAgent/Fdc3DesktopAgentService.cs 70.9% <ø> (-0.1%) ⬇️
...rastructure/Internal/NativeStartupModuleHandler.cs 100.0% <100.0%> (ø)
...Infrastructure/Internal/WebStartupModuleHandler.cs 100.0% <100.0%> (ø)
...Fdc3.DesktopAgent.Shared/Exceptions/ThrowHelper.cs 60.5% <0.0%> (-1.7%) ⬇️
...esktopAgent/Extensions/StartupContextExtensions.cs 96.2% <96.2%> (ø)
...y.ComposeUI.Fdc3.DesktopAgent/Fdc3StartupAction.cs 80.7% <83.3%> (-7.1%) ⬇️
...Infrastructure/Internal/Protocol/PrivateChannel.cs 59.0% <25.0%> (+6.0%) ⬆️
....Client/Infrastructure/Internal/ContextListener.cs 76.4% <76.9%> (+1.5%) ⬆️
... and 3 more

... and 2 files with indirect coverage changes

🚀 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.

@lilla28 lilla28 marked this pull request as ready for review March 18, 2026 09:10
@lilla28 lilla28 requested a review from a team as a code owner March 18, 2026 09:10
@lilla28 lilla28 marked this pull request as draft March 19, 2026 15:20
improved documentation, added client factory to allow shell specific
client creation; Refactor FDC3 startup properties and channel selector; Introduce Fdc3StartupProperties class, replacing Fdc3Properties for startup configuration and updating all references. Refactor IDesktopAgentClientFactory and IStartupModuleHandler to use the new property structure, centralizing FDC3 startup logic. Move ModuleChannelSelector to Shared library for broader reuse. Expand and clarify README with detailed guidance on channel selector integration, UI responsibilities, and app channel usage. Improve ChannelHandler to trigger channel selector UI updates after channel joins. Refactor ContextListener unsubscribe logic for robust async error handling. Remove obsolete NativeInProcess module type and update project dependencies. Overall, enhance maintainability, clarity, and container UI integration.
@lilla28 lilla28 force-pushed the feat/fdc3-native-client-refactor branch from 5d795be to c703e97 Compare March 19, 2026 16:32
@lilla28 lilla28 marked this pull request as ready for review March 20, 2026 09:49
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