Skip to content

User channel change issue#1541

Merged
kriswest merged 9 commits intomainfrom
userChannelChangeIssue
Apr 3, 2025
Merged

User channel change issue#1541
kriswest merged 9 commits intomainfrom
userChannelChangeIssue

Conversation

@robmoffat
Copy link
Copy Markdown
Member

@robmoffat robmoffat commented Mar 18, 2025

Describe your change

DA proxy code needs to listen for channelChanged events from the DA and action them (if necessary) in order to handle channel changes performed outside of the window (e.g. in DAs that load apps into iframes and display their own channel selector, rather than an injected one, outside of the window).

Related Issue

resolves #1540

Contributor License Agreement

  • I acknowledge that a contributor license agreement is required and that I have one in place or will seek to put one in place ASAP.

Review Checklist

  • Issue: If a change was made to the FDC3 Standard, was an issue linked above? When the User Channel Changes, DA Proxy ContextListeners fail to recognise the change #1540
  • CHANGELOG: Is a CHANGELOG.md entry included?
  • API changes: Does this PR include changes to any of the FDC3 APIs (DesktopAgent, Channel, PrivateChannel, Listener, Bridging)?
    • Docs & Sources: If yes, were both documentation (/docs) and sources updated?

      JSDoc comments on interfaces and types should be matched to the main documentation in /docs
    • Conformance tests: If yes, are conformance test definitions (/toolbox/fdc3-conformance) still correct and complete?

      Conformance test definitions should cover all required aspects of an FDC3 Desktop Agent implementation, which are usually marked with a MUST keyword, and optional features (SHOULD or MAY) where the format of those features is defined
    • Schemas: If yes, were changes applied to the Bridging and FDC3 for Web protocol schemas?

      The Web Connection protocol and Desktop Agent Communication Protocol schemas must be able to support all necessary aspects of the Desktop Agent API, while Bridging must support those aspects necessary for Desktop Agents to communicate with each other
      • If yes, was code generation (npm run build) run and the results checked in?

        Generated code will be found at /src/api/BrowserTypes.ts and/or /src/bridging/BridgingTypes.ts
  • Context types: Were new Context type schemas created or modified in this PR?
    • Were the field type conventions adhered to?
    • Was the BaseContext schema applied via allOf (as it is in existing types)?
    • Was a title and description provided for all properties defined in the schema?
    • Was at least one example provided?
    • Was code generation (npm run build) run and the results checked in?

      Generated code will be found at /src/context/ContextTypes.ts
  • Intents: Were new Intents created in this PR?

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 18, 2025

Deploy Preview for fdc3 ready!

Name Link
🔨 Latest commit 8290bf2
🔍 Latest deploy log https://app.netlify.com/sites/fdc3/deploys/67ee4385887cc8000882fe12
😎 Deploy Preview https://deploy-preview-1541--fdc3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@robmoffat
Copy link
Copy Markdown
Member Author

Actually a single commit - the rest is from the release branch which we need to merge first

@github-actions
Copy link
Copy Markdown

506 passed

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 18, 2025

Coverage Report

Commit: 8290bf2
Base: main@a594e51

Type Base This PR
Total Statements Coverage  97.41%  97.38% (-0.03%)
Total Branches Coverage  86.53%  86.71% (+0.18%)
Total Functions Coverage  96.85%  96.66% (-0.19%)
Total Lines Coverage  97.43%  97.45% (+0.02%)
Details (changed files)
FileStatementsBranchesFunctionsLines
packages/fdc3-agent-proxy/src/channels/DefaultChannelSupport.ts 98.71% 100% 94.44% 100%
Details (all files)
FileStatementsBranchesFunctionsLines
packages/fdc3-agent-proxy/src/DesktopAgentProxy.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/index.ts 100% 100% 62.5% 100%
packages/fdc3-agent-proxy/src/apps/DefaultAppSupport.ts 88% 50% 100% 88%
packages/fdc3-agent-proxy/src/channels/DefaultChannel.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/channels/DefaultChannelSupport.ts 98.71% 100% 94.44% 100%
packages/fdc3-agent-proxy/src/channels/DefaultPrivateChannel.ts 97.29% 66.66% 100% 97.29%
packages/fdc3-agent-proxy/src/heartbeat/DefaultHeartbeatSupport.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/intents/DefaultIntentResolution.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/intents/DefaultIntentSupport.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/listeners/AbstractListener.ts 100% 60% 100% 100%
packages/fdc3-agent-proxy/src/listeners/DefaultContextListener.ts 100% 90% 100% 100%
packages/fdc3-agent-proxy/src/listeners/DefaultIntentListener.ts 100% 77.77% 100% 100%
packages/fdc3-agent-proxy/src/listeners/EventListener.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/listeners/HeartbeatListener.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/listeners/PrivateChannelEventListener.ts 93.33% 72.72% 100% 93.33%
packages/fdc3-agent-proxy/src/messaging/AbstractMessaging.ts 94.59% 100% 80% 94.59%
packages/fdc3-agent-proxy/src/util/AbstractFDC3Logger.ts 100% 94.11% 100% 100%
packages/fdc3-agent-proxy/src/util/Logger.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/util/throwIfUndefined.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/index.ts 100% 100% 28.57% 100%
packages/fdc3-get-agent/src/messaging/MessagePortMessaging.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/messaging/message-port.ts 97.43% 86.66% 100% 97.43%
packages/fdc3-get-agent/src/sessionStorage/DesktopAgentDetails.ts 97.36% 89.47% 100% 97.36%
packages/fdc3-get-agent/src/strategies/DesktopAgentPreloadLoader.ts 100% 81.25% 100% 100%
packages/fdc3-get-agent/src/strategies/FailoverHandler.ts 100% 76.47% 100% 100%
packages/fdc3-get-agent/src/strategies/HelloHandler.ts 94% 81.25% 100% 94%
packages/fdc3-get-agent/src/strategies/IdentityValidationHandler.ts 95.65% 73.33% 100% 95.65%
packages/fdc3-get-agent/src/strategies/PostMessageLoader.ts 98.48% 86.95% 100% 98.46%
packages/fdc3-get-agent/src/strategies/Timeouts.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/strategies/getAgent.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/ui/AbstractUIComponent.ts 97.14% 71.42% 100% 97.01%
packages/fdc3-get-agent/src/ui/DefaultDesktopAgentChannelSelector.ts 100% 75% 100% 100%
packages/fdc3-get-agent/src/ui/DefaultDesktopAgentIntentResolver.ts 100% 90% 100% 100%
packages/fdc3-get-agent/src/ui/NullChannelSelector.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/ui/NullIntentResolver.ts 100% 100% 66.66% 100%
packages/fdc3-get-agent/src/util/Logger.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/util/Uuid.ts 100% 100% 100% 100%
packages/fdc3-standard/src/index.ts 100% 100% 0% 100%
packages/fdc3-standard/src/api/Errors.ts 100% 100% 100% 100%
packages/fdc3-standard/src/api/GetAgent.ts 100% 100% 100% 100%
packages/fdc3-standard/src/api/Methods.ts 94.04% 84.05% 96.29% 95%
packages/fdc3-standard/src/api/RecommendedChannels.ts 100% 100% 100% 100%
packages/fdc3-standard/src/context/ContextType.ts 100% 100% 100% 100%
packages/fdc3-standard/src/intents/Intents.ts 100% 100% 100% 100%
packages/fdc3-standard/src/internal/contextConfiguration.ts 100% 100% 100% 100%
packages/fdc3-standard/src/internal/intentConfiguration.ts 100% 100% 100% 100%
packages/fdc3-standard/src/internal/typeHelpers.ts 100% 100% 100% 100%
toolbox/fdc3-for-web/fdc3-web-impl/src/BasicFDC3Server.ts 100% 100% 100% 100%
toolbox/fdc3-for-web/fdc3-web-impl/src/ServerContext.ts 100% 100% 100% 100%
toolbox/fdc3-for-web/fdc3-web-impl/src/directory/BasicDirectory.ts 96.87% 84.21% 100% 96.55%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/BroadcastHandler.ts 96.38% 86.41% 100% 96.12%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/HeartbeatHandler.ts 88.23% 71.87% 86.66% 90%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/IntentHandler.ts 95.6% 86.56% 100% 95%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/OpenHandler.ts 97.14% 86.84% 100% 97.14%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/support.ts 100% 100% 100% 100%

@kriswest kriswest changed the base branch from main to release/v2.2.0-beta.2 March 18, 2025 12:41
Copy link
Copy Markdown
Contributor

@kriswest kriswest left a comment

Choose a reason for hiding this comment

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

I don't think we should be changing the message schema to resolve this issue - there is already state in this class containing the user channel defs that should be used, rather than re-transmitting it with every event.

I want to spend a bit more time with the client code to confirm that we're not listening to this event elsewhere - I could have sworn we had this handled already.

}
]
},
"userChannels": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this should be here - the event should not have to carry all the user channel definitions, which are supposed to remain constant (there are no event s for changes in the user channel definitions which are supposed to remain fixed). These should already have been retrieved by the client code and hence this duplication is inefficient.

At most the definition of the channel being selected could be included - but even that should not be necessary.

Also this change to the message schema will need to be approved by the SWG, where a change to the implementation only can be approved by the maintainers.

@kriswest
Copy link
Copy Markdown
Contributor

Actually a single commit - the rest is from the release branch which we need to merge first

Changed the base to point at that release branch (and filled in summary/issue) - if that base is merged first the base will automatically change itself to main.

@robmoffat
Copy link
Copy Markdown
Member Author

robmoffat commented Mar 19, 2025

Would you prefer if I

a) reverted the change to channelChangedEvent.schema.json and then

b) changed DefaultChannelSupport to ask for the list of channels to something like:

// DefaultChannelSupport.ts

  this.addChannelChangedEventHandler(async (e: ApiEvent) => {
      const cce = e.details as ChannelChangedEventPayload;
      Logger.debug('Desktop Agent reports channel changed: ', cce.newChannelId);
      const newChannel = (await this.getUserChannels()).find(uc => uc.id === cce.newChannelId) ?? null;
      this.userChannelListeners.forEach(l => l.changeChannel(newChannel));
      this.channelSelector.updateChannel(newChannel?.id ?? null, this.userChannels);
    });

The advantage of this is that we wouldn't need to change the event message, but I do want to query the user channels in case they have changed, hence (await this.getUserChannels()). The disadvantage of which is a roundtrip back to the da.

@github-actions
Copy link
Copy Markdown

506 passed

@kriswest
Copy link
Copy Markdown
Contributor

kriswest commented Mar 19, 2025

There is a local cache of the User Channels data this.userChannels that is updated every time this.getUserChannels is called, I think we should check that and then only query with this.getUserChannels if you don't find the one you need - that way we eliminate the roundtrip to the DA unless we need it.

User channels are not generally updated - there's no provision for it in either the API or the communication protocol (i.e. no events - you can only poll for the list) and no built-in way to update injected channel selectors in FDC3 for the web. But its not explicitly stated that they don't change, so someone could implement a feature in a DA that does it. Hence, we should (IMHO) support the edge-case, but not focus on it (by querying the channels every time).

I've had a go at implementing that and pushed to your branch. Note that the tests needed a slight tweak after switching to an async handler for the event - I added a 100ms wait for the known channel case (n.b 0-1ms would probably have done the job). I added more for the unknown case due to the extra round trip.

When testing I noted that:

  • Vite has developed a vulnerability - I've updated and tested none of the UIs broke
  • The default web fdc3 channel selector wasn't working for me from fdc3.finos.org as its pointing at a (now non-existent) netlify PR preview URL, I've fixed that.
  • FDC3 workbench still has to be started locally for the demo - I think that can now switch to the published version - I have NOT fixed that.

@github-actions
Copy link
Copy Markdown

506 passed

@github-actions
Copy link
Copy Markdown

506 passed

@kriswest kriswest self-requested a review March 19, 2025 13:08
kriswest
kriswest previously approved these changes Mar 19, 2025
Copy link
Copy Markdown
Contributor

@kriswest kriswest left a comment

Choose a reason for hiding this comment

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

LGTM, will need another approver (or for me to not be the last push + reapprove)

@robmoffat
Copy link
Copy Markdown
Member Author

robmoffat commented Mar 19, 2025

Hence, we should (IMHO) support the edge-case, but not focus on it (by querying the channels every time).

The problem with this is the channel selector: unless you call getUserChannels() or you are changing to a new channel, then it will be displaying the old user channels. Thus, if the desktop agent adds channel 5, but you're on channel 2, you won't know about it. You'll have to restart the app to see the correct channels again, which is a workaround but not ideal.

Although thinking about this it might be possible to do in the channel selector itself with a web socket, maybe.

The default web fdc3 channel selector wasn't working for me from fdc3.finos.org as its pointing at a (now non-existent) netlify PR preview URL, I've fixed that.

nice, thanks

FDC3 workbench still has to be started locally for the demo - I think that can now switch to the published version - I have NOT fixed that.

yes, great idea.

@kriswest
Copy link
Copy Markdown
Contributor

kriswest commented Mar 19, 2025

The problem with this is the channel selector: unless you call getUserChannels() or you are changing to a new channel, then it will be displaying the old user channels. Thus, if the desktop agent adds channel 5, but you're on channel 2, you won't know about it. You'll have to restart the app to see the correct channels again, which is a workaround but not ideal.

Just retrieving the channel data from the the DA doesn't push it into the injected channel selectors - something extra would be needed for that. Also the channel being set shouldn't be the thing triggering such an update as by that point a channel has already been selected in an external channel selector (which wouldn't normally be used alongside an injected one).

The user channel set changing has never been a thing in FDC3 which is why there are no events telling apps that the set of channels has changed. It is something we could do - but its really a new feature and we need to do more than we are here (e.g. an event from DA saying channels have changed). Hence, if we want to talk about doing it a different issue should be raised and discussed for 2.3 IMHO.

@robmoffat
Copy link
Copy Markdown
Member Author

robmoffat commented Mar 19, 2025

Just retrieving the channel data from the the DA doesn't push it into the injected channel selectors - something extra would be needed for that.

The reason I ended up with my original commit (with the change to the message etc.) was because of this line:

      this.channelSelector.updateChannel(newChannel?.id ?? null, this.userChannels);

... in which we are pushing potentially state data (this.userChannels) out to the injected channel selectors.

Now, as I said in the previous comment, I think I can work around this by ignoring the user channel information and passing it separately with web sockets, but it still seems like we missed a step by not adding this to the incoming message or making sure it's correct before we send this out.

Shall I raise another issue for this?

@kriswest
Copy link
Copy Markdown
Contributor

kriswest commented Mar 19, 2025

Shall I raise another issue for this?

I think you should. The description on the message schema for FDC3UserInterfaceChannels:

"description": "Setup message sent by the DA proxy code in getAgent() to a channel selector UI in an iframe with the channel definitions and current channel selection.",

Describes it as being used for initial set-up, not for handling changes to the set of channels. It's also being used to set the channel when the app calls joinUserChannel (i.e. channel wasn't set by the channel selector so it doesn't know about the change unless told) - which is how we got to here... if we'd thought about that case we probably would have allowed for Fdc3UserInterfaceChannelSelected to be sent in either direction and then it wouldn't have been including the set of channels.

As I said, the standard doesn't explicitly say that the set of User channels doesn't change, just that they "are created and named by the desktop agent". However, it also makes no provision for changes (I suspect because no one actually thought that they would get changed) and if we start doing that it should be done properly (i.e. discussed and approved by the SWG) and with a complete solution (e.g. include an event for app's to know that the set of channels has changed, create a message for the DA to notify the proxy - which would be shared with the aforementioned event, what's the behaviour if the selected channel ceases to exist etc.).

The issue that this PR addresses is related but different and, IMHO, is just an implementation issue we can resolve through the maintainers, as channels being changed by the DA (with an external channel selector or similar feature) is an existing use case and easily solvable with the proposed code tweaks - it can go out in a 2.2.x NPM release.

Hence, if raising an issue I'd call it something like "Support changes to the set of User Channels in the Desktop Agent API" and we can confirm (or refute) that it is thing you should be able to do as part of that.

@robmoffat
Copy link
Copy Markdown
Member Author

ok will do. I am baffled by the idea that no one has ever wanted to change the user channels.

@robmoffat robmoffat marked this pull request as ready for review March 19, 2025 16:59
@robmoffat robmoffat requested a review from a team as a code owner March 19, 2025 16:59
@robmoffat
Copy link
Copy Markdown
Member Author

Would like to merge this but I need to merge v2.2.0-beta.3 PR first.

@kriswest
Copy link
Copy Markdown
Contributor

ok will do. I am baffled by the idea that no one has ever wanted to change the user channels.

They're simply a set of predefined colour channels for a user to select from, the use case has always been changing the selected channel rather than the set you select from. I'm aware of multiple products that will accept a configuration for the set (and of course the standard recommends a particular, fixed set of channel defs), but to my knowledge no one has expressed a use case or need to change them at runtime.

Where you have the ability to save or share a workspace or layout of apps, with channel selections, a changeable set of channels presents a problem as the links between apps in the layout might be broken by a channel used in the layout not existing in a particular user's set-up. Hence, I've mostly seen people change the set via config applied to all users on start-up. I can envisage someone coming up with a use case for adding to the set of user channels for some specific purpose (although such use cases are often served by app channels - which are not administrated by the user but handled by the apps instead), but changing or removing channels I mostly see as creating challenges for little gain.

@kriswest kriswest changed the base branch from release/v2.2.0-beta.2 to main March 20, 2025 13:26
@kriswest kriswest dismissed their stale review March 20, 2025 13:26

The base branch was changed.

kriswest
kriswest previously approved these changes Mar 20, 2025
Copy link
Copy Markdown
Contributor

@kriswest kriswest left a comment

Choose a reason for hiding this comment

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

Still LGTM, @robmoffat does it test up ok on your end?

@kriswest kriswest requested a review from a team March 20, 2025 13:28
@robmoffat
Copy link
Copy Markdown
Member Author

Still LGTM, @robmoffat does it test up ok on your end?

I mean, looks ok but I'm going to need to do another beta release to really test this out.

@kriswest
Copy link
Copy Markdown
Contributor

Feel free to set another release branch up and I'll review for ya - perhaps we should change the package.yml workflow back to running on merge into main at the same time...

That said, don't forget that you could just npm pack --workspace and then npm install <package-name>.tar.gz in the project you need to test it in, for a local test. However, it would be good to have a beta out with this change.

@robmoffat
Copy link
Copy Markdown
Member Author

@novavi could you take a look and approve this please?

@robmoffat robmoffat requested a review from novavi March 21, 2025 11:46
@robmoffat
Copy link
Copy Markdown
Member Author

Can someone from the maintainer team review this please?

@kriswest
Copy link
Copy Markdown
Contributor

Can someone from the maintainer team review this please?

@julianna-ciq I know you guys will need this to work...

mistryvinay
mistryvinay previously approved these changes Mar 27, 2025
Copy link
Copy Markdown
Contributor

@mistryvinay mistryvinay left a comment

Choose a reason for hiding this comment

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

Approve these additions.

@kriswest kriswest dismissed stale reviews from mistryvinay and themself via 65c1279 April 3, 2025 07:42
@kriswest kriswest requested review from a team, kriswest and mistryvinay April 3, 2025 08:15
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 3, 2025

506 passed

Copy link
Copy Markdown
Contributor

@mistryvinay mistryvinay left a comment

Choose a reason for hiding this comment

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

LGTM

@kriswest kriswest merged commit 80ea886 into main Apr 3, 2025
8 checks passed
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.

When the User Channel Changes, DA Proxy ContextListeners fail to recognise the change

3 participants