Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send a 'close' action when the widget is ready to close #3011

Open
wants to merge 2 commits into
base: livekit
Choose a base branch
from

Conversation

robintown
Copy link
Member

By keeping 'hangup' and 'close' as separate actions, we can allow Element Call widgets to stay on an error screen after the user has been disconnected without the widget completely disappearing from the host's UI. We don't have to request any additional capabilities to use a custom widget action like this one.

@robintown robintown requested a review from a team as a code owner February 17, 2025 12:50
@robintown robintown requested a review from AndrewFerr February 17, 2025 12:50
@robintown
Copy link
Member Author

I bumped the TypeScript module version here because I needed top-level await syntax to write the tests, which is only available on es2022 or later.

By keeping 'hangup' and 'close' as separate actions, we can allow Element Call widgets to stay on an error screen after the user has been disconnected without the widget completely disappearing from the host's UI. We don't have to request any additional capabilities to use a custom widget action like this one.
Comment on lines 147 to 153
await widget.api.transport.send(ElementWidgetActions.HangupCall, {});
// On a normal user hangup we can shut down and close the widget. But if an
// error occurs we should keep the widget open until the user reads it.
if (cause === "user") {
await widget.api.transport.send(ElementWidgetActions.Close, {});
widget.api.transport.stop();
PosthogAnalytics.instance.logout();
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned in the VoIP room I think that the general approach of two actions is correct. (It is the minimal set of information we need).

I do think we should not change the meaning of ElementWidgetActions.HangupCall however.
Changing it here is not an issue. But this change implies a change in EX and EW where we now do NOT close a widget anymore on receiving the hangup action. This make EC and EX incompatible with older EC versions which could be an issue on self hosted instances.
Also Jitsi might break.

I think the better would be to keep the action as they are and introduce the following:

  • a general purpose close action best with an MSC. org.matrix.mscXXXX.close action that any widget can use for requesting to get closed (This was sth that seemed like I wanted it for the matrixRTC demo also)
  • A dedicated element call hangup action io.element.hangup that is only used for element call hangups and does not imply any widget updating but only makes the call render as not connected. (Can you also update me again on the case in which this is different to the room state not including our own rtc memebrship anymore? I think that is not tracked yet in text)
  • replace HangupCall = "im.vector.hangup", from he ElementWidgetActions enum with io.element.hangup

Copy link
Member Author

Choose a reason for hiding this comment

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

I do think we should not change the meaning of ElementWidgetActions.HangupCall however. Changing it here is not an issue.

I'm still confused by this. This PR doesn't change the meaning of im.vector.hangup at all, it only adds more information.

But this change implies a change in EX and EW where we now do NOT close a widget anymore on receiving the hangup action. This make EC and EX incompatible with older EC versions which could be an issue on self hosted instances.

It's always been the case that we expect EC+EW deployments to be on the latest EC release at the time of the EW release, otherwise it becomes unnecessarily hard to make forward progress when it comes to URL parameters or widget communication. I agree that this isn't the best situation, as admins might forget about this hidden assumption, but I suggest we continue accepting this for now since the embedding work (#2994 / element-hq/element-web#23908) is going to make the dependency explicit, resolving it for good.

We do need to keep the EW/EX PRs blocked until we're confident that we can release a new EC version though, that's a good thing to remember here.

Also Jitsi might break.

Good thing to flag but it doesn't break, Jitsi video rooms are handled by a different class in Element Web and I've tested them.

I think the better would be to keep the action as they are and introduce the following:

  • a general purpose close action best with an MSC. org.matrix.mscXXXX.close action that any widget can use for requesting to get closed (This was sth that seemed like I wanted it for the matrixRTC demo also)

I have some thoughts about this:

  • Does this close action become part of the minimum implementation requirements of the widget API, or does it need to be requested as a capability?
  • The benefit, I guess, of standardizing a close action would be to allow arbitrary, untrusted widgets to request their own closure. It doesn't change anything for deep widget integrations like EW/EX + EC, which could just as easily use proprietary actions.
  • If you're a client, and you're presenting an untrusted widget, you have to either show your own close button in addition to the widget's, which could look awkward, or else risk that the widget won't offer any way of allowing the user to close it, permanently intruding the user's screen.

So generally it seems a bit hairy: see for example the restrictions that the Web platform places on window.close(). I think sticking to a proprietary action here may just be a good thing.

  • A dedicated element call hangup action io.element.hangup that is only used for element call hangups and does not imply any widget updating but only makes the call render as not connected. (Can you also update me again on the case in which this is different to the room state not including our own rtc memebrship anymore? I think that is not tracked yet in text)
  • replace HangupCall = "im.vector.hangup", from he ElementWidgetActions enum with io.element.hangup

How would such an action be any different from im.vector.hangup?

@@ -21,10 +21,11 @@ import { getUrlParams } from "./UrlParams";
import { Config } from "./config/Config";
import { ElementCallReactionEventType } from "./reactions";

// Subset of the actions in matrix-react-sdk
// Subset of the actions in element-web
export enum ElementWidgetActions {
JoinCall = "io.element.join",
HangupCall = "im.vector.hangup",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
HangupCall = "im.vector.hangup",
HangupCall = "io.element.hangup",

export enum ElementWidgetActions {
JoinCall = "io.element.join",
HangupCall = "im.vector.hangup",
Close = "io.element.close",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Close = "io.element.close",
Close = "org.matrix.mscXXXX.close",

// On a normal user hangup we can shut down and close the widget. But if an
// error occurs we should keep the widget open until the user reads it.
if (cause === "user") {
await widget.api.transport.send(ElementWidgetActions.Close, {});
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a way to also emit this with a button on the error screen?
This is unnecessary for EW since we have the close button there. But on EX this is a better UX since we then can close the widget by pressing sth like "Ok" or "Close" inside the IFrame.

(for now this screen would of course not be visible but once we update the rust sdk (if we go this route where a rust sdk udpate is required) we dont introduce the isse that the user cannot exit the error screen except when using the os activity manager)

Copy link
Member Author

Choose a reason for hiding this comment

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

I would love to do that, yeah, but in a separate PR.

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.

2 participants