Skip to content

TW-2947: Handle invitation link web page and routing#2948

Merged
hoangdat merged 6 commits intomainfrom
TW-2947-handle-invitation-link-in-web
Mar 23, 2026
Merged

TW-2947: Handle invitation link web page and routing#2948
hoangdat merged 6 commits intomainfrom
TW-2947-handle-invitation-link-in-web

Conversation

@nqhhdev
Copy link
Member

@nqhhdev nqhhdev commented Mar 20, 2026

Ticket

Related issue

Resolved

Attach screenshots or videos demonstrating the changes

  • Web:
demo.mov

Summary by CodeRabbit

  • New Features

    • Support for invitation links that open chats directly from a shared URL.
    • Web invitation flow now shows a loading indicator while processing and will redirect to the rooms list if the link is invalid.
  • Bug Fixes

    • Improved handling when tapping invitation links to avoid dead-ends for self-chats.

@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

Warning

Rate limit exceeded

@nqhhdev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 45 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 569bdf21-2ce9-4692-9d6c-7e89a6bc1855

📥 Commits

Reviewing files that changed from the base of the PR and between ddfad5c and e92b513.

📒 Files selected for processing (2)
  • lib/presentation/mixins/go_to_direct_chat_mixin.dart
  • lib/utils/url_launcher.dart

Walkthrough

A new route handler and corresponding page component were introduced to support an invitation link feature. The route configuration maps the path /chat/:matrixId to a new InvitationLinkWeb page, extracting the matrixId parameter from the URL. The InvitationLinkWeb widget is a stateful component that accepts an optional matrixId, launches a URL after the first frame renders (or navigates to /rooms if matrixId is missing), and displays a centered loading indicator while launching.

Possibly related PRs

Suggested reviewers

  • dab246
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete, missing critical sections like Root cause, Solution, Impact description, Test recommendations, and Pre-merge checklist required by the template. Fill in all required template sections: add Root cause explanation, detailed Solution outline, Impact description, Test recommendations, and Pre-merge confirmation before merging.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately captures the main objective of the PR: implementing invitation link handling for web with appropriate routing setup.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch TW-2947-handle-invitation-link-in-web

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
lib/pages/invitation_link_web/invitation_link_web.dart (1)

28-29: Minor: animating: true is the default value.

This is redundant and can be removed for cleaner code.

Suggested fix
       child: CupertinoActivityIndicator(
-        animating: true,
         color: LinagoraSysColors.material().onSurfaceVariant,
       ),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/pages/invitation_link_web/invitation_link_web.dart` around lines 28 - 29,
The CupertinoActivityIndicator in invitation_link_web.dart explicitly sets
animating: true which is redundant because true is the default; remove the
animating parameter from the CupertinoActivityIndicator instantiation (locate
the CupertinoActivityIndicator widget in the InvitationLinkWeb widget / build
method) so the code relies on the default behavior and is cleaner.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/config/go_routes/go_router.dart`:
- Around line 123-132: The GoRoute for path '/chat/:matrixId' is missing an
authentication redirect guard causing unauthenticated users to reach
InvitationLinkWeb and UrlLauncher.openMatrixToUrl() which call matrix.client;
update the GoRoute definition (the GoRoute with path '/chat/:matrixId' that
builds InvitationLinkWeb) to include redirect: loggedOutRedirect so
unauthenticated users are redirected consistently like other routes.

In `@lib/pages/invitation_link_web/invitation_link_web.dart`:
- Around line 17-22: initState currently calls UrlLauncher(context, url:
widget.matrixId).launchUrl() without null-safety or awaiting its result, which
can throw (url! assertion) or leave the loading UI stuck; update initState to
null-check widget.matrixId and provide a fallback navigation (e.g.,
Navigator.pushReplacementNamed to '/rooms' or '/home') if null, and change the
call to await UrlLauncher(...).launchUrl() (or handle its Future with
then/catchError) so you can navigate away on both success and failure; ensure
you reference UrlLauncher and its launchUrl() completion to trigger a
Navigator.replace/pop to dismiss the loading screen in all early-return
branches.

---

Nitpick comments:
In `@lib/pages/invitation_link_web/invitation_link_web.dart`:
- Around line 28-29: The CupertinoActivityIndicator in invitation_link_web.dart
explicitly sets animating: true which is redundant because true is the default;
remove the animating parameter from the CupertinoActivityIndicator instantiation
(locate the CupertinoActivityIndicator widget in the InvitationLinkWeb widget /
build method) so the code relies on the default behavior and is cleaner.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 02ff494d-1309-4ec4-b9d5-66f3154a0d07

📥 Commits

Reviewing files that changed from the base of the PR and between 844b35b and 6a95e5f.

📒 Files selected for processing (2)
  • lib/config/go_routes/go_router.dart
  • lib/pages/invitation_link_web/invitation_link_web.dart

@github-actions
Copy link
Contributor

This PR has been deployed to https://linagora.github.io/twake-on-matrix/2948

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/utils/url_launcher.dart (1)

34-39: ⚠️ Potential issue | 🟡 Minor

Don't force invitation routing for every @user link.

launchUrl() drops the caller's isInvitationLink value in the early Matrix branch, and openMatrixToUrl() then hardcodes true for all @user links. Since GoToDraftChatMixin.goToDraftChat() uses that flag to redirect self-chats to /rooms, non-invitation self links will now take the invitation fallback too.

🧭 Proposed fix
   void launchUrl({bool isInvitationLink = false}) {
     if (url!.toLowerCase().startsWith(AppConfig.deepLinkPrefix) ||
         url!.toLowerCase().startsWith(AppConfig.inviteLinkPrefix) ||
         {'#', '@', '!', '+', '\$'}.contains(url![0]) ||
         url!.toLowerCase().startsWith(AppConfig.schemePrefix)) {
-      return openMatrixToUrl();
+      return openMatrixToUrl(isInvitationLink: isInvitationLink);
     }
@@
       onContactTap(
         context: context,
         path: 'rooms',
-        isInvitationLink: true,
+        isInvitationLink: isInvitationLink,
         contactPresentationSearch: ContactPresentationSearch(

Also applies to: 117-120, 224-227

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/utils/url_launcher.dart` around lines 34 - 39, The Matrix branch in
launchUrl() discards the caller's isInvitationLink and calls openMatrixToUrl()
which then hardcodes invitation=true for `@user` links; update openMatrixToUrl to
accept a bool isInvitationLink parameter and thread the original
isInvitationLink through each place that calls openMatrixToUrl (including the
other occurrences referenced) so the invite flag is preserved, and remove the
hardcoded true inside openMatrixToUrl/goToDraftChat paths so routing uses the
passed-in flag.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@lib/utils/url_launcher.dart`:
- Around line 34-39: The Matrix branch in launchUrl() discards the caller's
isInvitationLink and calls openMatrixToUrl() which then hardcodes
invitation=true for `@user` links; update openMatrixToUrl to accept a bool
isInvitationLink parameter and thread the original isInvitationLink through each
place that calls openMatrixToUrl (including the other occurrences referenced) so
the invite flag is preserved, and remove the hardcoded true inside
openMatrixToUrl/goToDraftChat paths so routing uses the passed-in flag.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 43c1d5e8-9031-444d-994e-f4b319298ae0

📥 Commits

Reviewing files that changed from the base of the PR and between 6a95e5f and ddfad5c.

📒 Files selected for processing (5)
  • lib/config/go_routes/app_route_paths.dart
  • lib/config/go_routes/go_router.dart
  • lib/pages/invitation_link_web/invitation_link_web.dart
  • lib/presentation/mixins/go_to_direct_chat_mixin.dart
  • lib/utils/url_launcher.dart
✅ Files skipped from review due to trivial changes (2)
  • lib/config/go_routes/app_route_paths.dart
  • lib/pages/invitation_link_web/invitation_link_web.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/config/go_routes/go_router.dart

@hoangdat hoangdat merged commit 3f8694c into main Mar 23, 2026
9 checks passed
@hoangdat hoangdat deleted the TW-2947-handle-invitation-link-in-web branch March 23, 2026 07:14
github-actions bot added a commit that referenced this pull request Mar 23, 2026
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