Skip to content

Call ClientBuilderEnterpriseHook whenever we create a client - #7590

Closed
richvdh wants to merge 3 commits into
developfrom
rav/fix_client_builder_enterprise_hook
Closed

Call ClientBuilderEnterpriseHook whenever we create a client#7590
richvdh wants to merge 3 commits into
developfrom
rav/fix_client_builder_enterprise_hook

Conversation

@richvdh

@richvdh richvdh commented Aug 28, 2026

Copy link
Copy Markdown
Member

Currently, the ClientBuilderEnterpriseHook is only called when we restore a previous session, rather than when performing a new login.

I'm putting this up for discussion rather than in the expectation it will land as-is. I don't really think it's the right solution, because it means that the session ID is not set for clients used for a login (and hence the functionality in the Enterprise hook which depends on that does not work correctly).

However, since we're trying to create the client before we know the user ID, it's hard to see what would be better.

Content

Motivation and context

Screenshots / GIFs

Tests

  • Step 1
  • Step 2
  • Step ...

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • I am aware of the etiquette.
  • This PR was made with the help of AI:
    • Yes. In this case, please request a review by Copilot.
    • No.
  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly defines what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

@richvdh
richvdh requested a review from a team as a code owner August 28, 2026 11:54
@richvdh
richvdh removed the request for review from a team August 28, 2026 11:54
@richvdh richvdh added the PR-Misc For other changes label Aug 28, 2026
@richvdh
richvdh requested a review from bmarty August 28, 2026 11:54
@richvdh richvdh added the PR-Misc For other changes label Aug 28, 2026
Make sure that the `ClientBuilderEnterpriseHook` is called on every
ClientBuilder we create, even if we don't yet have a user ID.
@richvdh
richvdh force-pushed the rav/fix_client_builder_enterprise_hook branch from a67c76c to 82d97f5 Compare August 28, 2026 11:55
* [io.element.android.libraries.matrix.impl.auth.RustMatrixAuthenticationService] after successful
* authentication.
*
* TODO: feels like this could do with a better name, since it doesn't actually create a client.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The create methods do not create a Client, but they create a RustMatrixClient. The methods could return MatrixClient though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It feels strange that we have two different methods called create with very different behaviours. I feel like it would be much clearer if this was called wrapClient or something of that nature.

@bmarty bmarty left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think that the changes make sense. It's quite complex code, since we are using the same method from the SDK to either create a client to authenticate, or create a client to restore an existing session.

Maybe we could revisit the code and let the client used to authenticate be destroyed, and always create a fresh once the user has just logged in, as if a session has been restored.

@bmarty bmarty mentioned this pull request Aug 28, 2026
12 tasks
@richvdh

richvdh commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

@bmarty has opened #7591 to explore the ideas he suggests above. I'm pretty happy with whatever solution we end up with here.

I'll keep this PR open for now as it may be helpful for the crypto team while we are working on a feature that needs this hook to work.

@bmarty
bmarty marked this pull request as draft September 3, 2026 08:26
@richvdh

richvdh commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

#7591 works for us.

@richvdh richvdh closed this Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Misc For other changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants