Skip to content

Conversation

@toger5
Copy link
Contributor

@toger5 toger5 commented Nov 20, 2025

A test in the callViewModel uncovered that there is a much better way to split test for the call setup.
This splits the test into localTransport tests that check for the different error cases and a test for the local Membership that checks that on error we will end up in the correct state for the callViewModel. (based on this state we set fatalError$

@toger5 toger5 requested a review from a team as a code owner November 20, 2025 13:45
@toger5 toger5 requested a review from Half-Shot November 20, 2025 13:45
@toger5 toger5 added the PR-Developer-Experience Release note category. A PR that does not change EC but improves working with the repository. label Nov 20, 2025
Copy link
Member

@BillCarsonFr BillCarsonFr left a comment

Choose a reason for hiding this comment

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

Great refactor 👍
Just a few comments

>;

/**
*
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion?

Gets a bearer token from the homeserver and then use it to authenticate to the matrix RTC backend in order to get acces to the SFU.
It has built-in retry for calls to the homeserver with a backoff policy. Will bubble errors from the matrix RTC backend :(.

}: ErrorPageProps): ReactElement => {
const { t } = useTranslation();

logger.log("Error boundary caught:", error);
Copy link
Member

Choose a reason for hiding this comment

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

log.error?

livekit_service_url: "http://my-oldest-member-service-url.com",
livekit_alias: "my-oldest-member-service-alias",
};
// vi.mock("../../../widget", async (importOriginal) => ({
Copy link
Member

Choose a reason for hiding this comment

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

nit: delete?

/**
* Whether we are connected to the MatrixRTC session.
*/
export function createHomeserverConnected$(
Copy link
Member

Choose a reason for hiding this comment

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

I think we talked about extracting that to its own file? with some tests. Maybe next PR

* @prop useOldestMember Whether to use the same transport as the oldest member.
* This will only update once the first oldest member appears. Will not recompute if the oldest member leaves.
*
* @throws MatrixRTCTransportMissingError | FailToGetOpenIdToken
Copy link
Member

Choose a reason for hiding this comment

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

👍 I wonder if we can have a linter rule that uses that information to ensure the caller handle the errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I searched a bit. not possible.

transportFromStorage,
);
return transportFromStorage;
transport = transportFromStorage;
Copy link
Member

Choose a reason for hiding this comment

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

Can we have a test for that? (checking that is trying local storage)

};
logger.log("Using LiveKit transport from config: ", transportFromConf);
return transportFromConf;
transport = transportFromConf;
Copy link
Member

Choose a reason for hiding this comment

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

is it also returning transport?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this needed some update (the priority should have been the other way around) updated it.

connectOptions$.value,
);
},
createPublisherFactory: (connection: Connection) => {
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe we can extract it as a const just before instead of inlining? WDYT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was consciously done inline to make clear that this is "one Package" of input and not entangled with the rest of the call view model.
So that its easier to understand why callviewmodel test just mock the while createLocalMembership$ return value.

@Half-Shot Half-Shot changed the title Refactor local transport testing and local memberhsip initialization Refactor local transport testing and local membership initialization Nov 21, 2025
Copy link
Member

@BillCarsonFr BillCarsonFr left a comment

Choose a reason for hiding this comment

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

Ok for me 👍

localTransportCanThrow$.pipe(
catchError((e: unknown) => {
let error: ElementCallError;
if (e instanceof ElementCallError) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we have that at several place in the code, we might want some utility at some point

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

Labels

PR-Developer-Experience Release note category. A PR that does not change EC but improves working with the repository.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants