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

feat(apple): UI notification for reauth #3684

Merged
merged 14 commits into from
Mar 6, 2024
Merged

Conversation

roop
Copy link
Contributor

@roop roop commented Feb 19, 2024

This PR shows an alert (macOS) / local notification (iOS) when the user is signed out because of a tunnel error.

Fixes the apple part of #3329.

@roop roop requested a review from jamilbk February 19, 2024 09:06
Copy link

vercel bot commented Feb 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
firezone ⬜️ Ignored (Inspect) Visit Preview Mar 6, 2024 5:40am

Copy link

github-actions bot commented Feb 19, 2024

Performance Test Results

TCP

Test Name Received/s Sent/s Retransmits
direct-tcp-client2server 66.1 MiB (+1%) 66.7 MiB (+1%) 57 (+30%)
direct-tcp-server2client 54.6 MiB (-1%) 54.8 MiB (-1%) 34 (-19%)
relayed-tcp-client2server 29.6 MiB (+6%) 31.1 MiB (+1%) 113 (+565%)
relayed-tcp-server2client 28.5 MiB (-3%) 31.5 MiB (-2%) 481 (+3%)

UDP

Test Name Total/s Jitter Lost
direct-udp-client2server 50.0 MiB (-0%) 0.18ms (+1%) 0.00% (NaN%)
direct-udp-server2client 50.0 MiB (-0%) 0.24ms (+17%) 0.02% (-96%)
relayed-udp-client2server 50.0 MiB (+0%) 0.56ms (+21%) 19.70% (-6%)
relayed-udp-server2client 50.0 MiB (+0%) 0.50ms (-6%) 20.25% (-13%)

Copy link

github-actions bot commented Feb 19, 2024

Terraform Cloud Plan Output

Plan: 8 to add, 7 to change, 8 to destroy.

Terraform Cloud Plan

Copy link

Performance Test Results: direct-perf

TCP

Direction Received/s Sent/s Retransmits
Client to Server 142.1 MiB (+0%) 141.3 MiB (-0%) 147 (-7%)
Server to Client 90.1 MiB (+0%) 90.9 MiB (-0%) 143 (-19%)

UDP

Direction Total/s Jitter Lost
Client to Server 250.0 MiB (-0%) 0.03ms (-35%) 78.37% (+0%)
Server to Client 250.0 MiB (+0%) 0.69ms (+164%) 45.51% (+1%)

@roop
Copy link
Contributor Author

roop commented Feb 19, 2024

macOS:

Screenshot 2024-02-19 at 9 53 28 AM

iOS:


@roop
Copy link
Contributor Author

roop commented Feb 19, 2024

In iOS:

  • We ask for permissions at app launch, but whether the user allowed notifications or not, we'll allow the user to sign in
  • The notification disappears automatically after a few seconds. We're supposed to be able to make it persistent, but setting the style to "Persistent" (in iOS Settings > Notifications > Firezone > Banner Style) seems to have no effect for me, which is weird. I'll investigate further and report.
    • Update: A restart of the phone fixed that. The banner stays on screen till the user presses the home screen.

Copy link
Member

@jamilbk jamilbk left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple questions regarding the macOS notification!

alert.messageText = "Your Firezone session has ended"
alert.informativeText = "Please sign in again to reconnect"
NSApp.activate(ignoringOtherApps: true)
alert.runModal()
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 possible to change the buttons on this alert to:

Dismiss | Sign in so that the user can just click Sign in to fix it without having to click in the menubar?

Also, are the macOS notifications running in Notification center or are they separate? Do they auto-dismiss or stay visible until user action?

Copy link
Contributor Author

@roop roop Feb 21, 2024

Choose a reason for hiding this comment

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

Dismiss | Sign in so that the user can just click Sign in to fix it without having to click in the menubar?

Makes sense, will do that. Update: It's possible to add buttons to the notification in iOS, so will do it in iOS as well.

Also, are the macOS notifications running in Notification center or are they separate? Do they auto-dismiss or stay visible until user action?

iOS-like notifications are available in macOS as well, they behave similar to iOS (by default they auto-disappear but the user can make them stay in OS Settings). However, they are easy to miss (because they are small and in a corner), so we're using an in-app alert instead.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha. I'm wondering if it makes sense to use the Notification Center notification for macOS as well so that user's can turn it off if needed and so that it respects the Do Not Disturb settings by the user.

Otherwise it might be annoying to have that alert pop up in the middle of a presentation or something with no way to deactivate or see how much longer you have left in your session.

If they miss and notice the resources can't be accessed they'll probably figure out to click on the Firezone in menubar.

What do you think?

Copy link

Performance Test Results: direct-tcp-client2server

Received/s Sent/s Retransmits
60.0 MiB (+2%) 60.3 MiB (+2%) 0 (NaN%)

Copy link

Performance Test Results: relayed-tcp-server2client

Received/s Sent/s Retransmits
45.7 MiB (+6%) 45.9 MiB (+6%) 0 (NaN%)

Copy link

Performance Test Results: direct-udp-server2client

Total/s Jitter Lost
736.5 MiB (-10%) 0.31ms (-2%) 91.81% (-1%)

Copy link

Performance Test Results: relayed-udp-client2server

Total/s Jitter Lost
1.0 GiB (+1%) 0.33ms (+0%) 96.57% (-0%)

Copy link

Performance Test Results: relayed-tcp-client2server

Received/s Sent/s Retransmits
44.1 MiB (+12%) 44.2 MiB (+12%) 0 (NaN%)

Copy link

Performance Test Results: direct-tcp-server2client

Received/s Sent/s Retransmits
49.4 MiB (+1%) 49.5 MiB (+1%) 0 (NaN%)

Copy link

Performance Test Results: direct-udp-client2server

Total/s Jitter Lost
999.9 MiB (-0%) 0.88ms (+301%) 93.79% (-0%)

Copy link

Performance Test Results: relayed-udp-server2client

Total/s Jitter Lost
676.9 MiB (+16%) 0.45ms (-36%) 26.66% (-71%)

Copy link
Member

@jamilbk jamilbk left a comment

Choose a reason for hiding this comment

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

Requesting changes as discussed in today's call

@jamilbk
Copy link
Member

jamilbk commented Mar 4, 2024

@roop Is this still a WIP or should I close it?

@roop
Copy link
Contributor Author

roop commented Mar 4, 2024

The changes requested were:

  1. Adding 'Sign In' and 'Dismiss' buttons in the notification, so that the user can trigger the login from the notification itself.
  2. Use User Notifications in macOS as well (instead of an alert shown from the app)

The problem is that in macOS, for a user notification posted from the tunnel, the launching-the-app from the notification is not working correctly. The notification is shown, but on clicking on the notification, or on a button in the notification doesn't launch/activate the main app. (Found a relevant forum discussion on this too.) This works correctly in iOS.

@jamilbk So ,shall we stick to using user notifications in macOS, without the 'Sign In' button in the notifications? Or should we go back to alerts?

@roop
Copy link
Contributor Author

roop commented Mar 4, 2024

@roop Is this still a WIP or should I close it?

It's still a work-in-progress.

@jamilbk
Copy link
Member

jamilbk commented Mar 4, 2024

The problem is that in macOS, for a user notification posted from the tunnel, the launching-the-app from the notification is not working correctly.

Ah, I see, thanks for the clarification. Yeah, I thought we may run into issues with that.

Let's keep the existing alert style on macOS in that case then and just have the 'Sign in' and 'Dismiss' options if that's still feasible.

You'll need to rebase as I think there's been some CI changes since this was opened.

@roop roop force-pushed the roop/notify_for_reauth_2 branch from 2482897 to e6f9892 Compare March 5, 2024 14:12
@roop roop force-pushed the roop/notify_for_reauth_2 branch from e6f9892 to 1b2ffa4 Compare March 5, 2024 15:03
@roop
Copy link
Contributor Author

roop commented Mar 5, 2024

macOS alert with 'Sign In' button:

Screenshot 2024-03-05 at 7 48 22 PM

iOS notification after a long-press (which is how we access actions in a notification):

Screenshot 2024-03-05 at 8 33 39 PM

@roop roop requested a review from jamilbk March 5, 2024 15:06
Copy link
Member

@jamilbk jamilbk left a comment

Choose a reason for hiding this comment

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

LGTM, just some code organization / cleanup

Spacer()
.frame(maxHeight: 20)
Text(
"After tapping on the above button, tap on 'Allow' when prompted."
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"After tapping on the above button, tap on 'Allow' when prompted."
"After tapping the above button, tap 'Allow' when prompted."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e83bbab

@roop
Copy link
Contributor Author

roop commented Mar 6, 2024

@jamilbk:

Same here -- you could extract this into a single SessionNotification.showSignedOutNotification() function and in the SessionNotification class have the macOS / iOS conditional.

I couldn't fit both iOS and macOS code into a single function because they need different inputs, because they get called from different places (iOS: from the tunnel, macOS: from the app). They also do different things (iOS: notification, macOS: alert).

So, there are two different functions for iOS and macOS, and both are in SessionNotificationHelper:

  1. public static func showSignedOutNotificationiOS(logger: AppLogger)
  2. static func showSignedOutAlertmacOS(logger: AppLogger, authStore: AuthStore)

@roop roop requested a review from jamilbk March 6, 2024 05:13
Copy link
Member

Choose a reason for hiding this comment

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

This is much easier to understand, thanks!

@jamilbk jamilbk added this pull request to the merge queue Mar 6, 2024
Merged via the queue into main with commit 2003e3d Mar 6, 2024
66 checks passed
@jamilbk jamilbk deleted the roop/notify_for_reauth_2 branch March 6, 2024 06:29
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.

None yet

2 participants