Skip to content

feat(gui-client): show "Welcome" screen on 2nd app launch#9136

Merged
thomaseizinger merged 5 commits into
mainfrom
feat/show-app-screen
May 15, 2025
Merged

feat(gui-client): show "Welcome" screen on 2nd app launch#9136
thomaseizinger merged 5 commits into
mainfrom
feat/show-app-screen

Conversation

@thomaseizinger

@thomaseizinger thomaseizinger commented May 14, 2025

Copy link
Copy Markdown
Member

Resolves: #8352.

@vercel

vercel Bot commented May 14, 2025

Copy link
Copy Markdown

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

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 14, 2025 9:18am

Comment on lines +33 to +48
listen<Session>('signed_in', (e) => {
let session = e.payload;

accountSlugSpan.textContent = session.account_slug;
actorNameSpan.textContent = session.actor_name;
signedOutDiv.style.display = "none";
signedInDiv.style.display = "block";
})

listen<void>('signed_out', (_e) => {
accountSlugSpan.textContent = "";
actorNameSpan.textContent = "";
signedOutDiv.style.display = "block";
signedInDiv.style.display = "none";
})

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.

I am using something new here. Tauri has the ability to send "events" to the frontend and we can listen on those events and update the GUI as a result. This allows us to nicely decouple things. If we get signed out for whatever reason and this window happens to be open, it will automatically update.

I am gonna do the same thing for the settings once I revamp those.

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.

This is how we do it on Apple and Android. The tunnel can run in whatever state it's in. When a GUI connects, it automatically gets updated with the proper state appropriately.

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.

Main difference that I want to point out here is that the communication is one-way. We never request data, it gets pushed via an event.

@thomaseizinger thomaseizinger May 15, 2025

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.

Also, this is between WebView and GUI client, the tunnel process is not at play here.

The GUI client is basically a backend to the WebView.

The equivalent on Apple is using an observable property in SwiftUI. I don't think we are doing that on Android?

Comment on lines +80 to +84
// Ensure state in frontend is up-to-date.
match current_session {
Some(session) => self.notify_signed_in(session)?,
None => self.notify_signed_out()?,
};

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.

In order to make sure the frontend is definitely up to date, we dispatch an event every time we show/hide it.

);
}
Req::SystemTrayMenu(system_tray::Event::SignOut) => {
SignOut | SystemTrayMenu(system_tray::Event::SignOut) => {

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.

Clicking SignOut just triggers the same codepath as clicking it in the tray menu.

Comment on lines +695 to +696
self.integration
.set_welcome_window_visible(true, self.auth.session())?;

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.

If a new instance gets launched, we now show the welcome window here.

}

if anyhow.root_cause().is::<gui::AlreadyRunning>() {
return Ok(());

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.

Detecting an already running instance is now no longer an error for the 2nd client.

return Ok(());
}

if anyhow.root_cause().is::<gui::NewInstanceHandshakeFailed>() {

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.

Failing to communicate with that 2nd instance is however.

@thomaseizinger thomaseizinger requested a review from jamilbk May 15, 2025 01:00
@thomaseizinger thomaseizinger marked this pull request as ready for review May 15, 2025 01:00

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.

👍

@jamilbk jamilbk 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.

Makes sense.

What happens if you launch Firezone a 3rd time with the Welcome window already open? Does it open another window or just bring the existing window to focus?

Comment thread rust/gui-client/src/welcome.ts Outdated
Comment on lines +33 to +48
listen<Session>('signed_in', (e) => {
let session = e.payload;

accountSlugSpan.textContent = session.account_slug;
actorNameSpan.textContent = session.actor_name;
signedOutDiv.style.display = "none";
signedInDiv.style.display = "block";
})

listen<void>('signed_out', (_e) => {
accountSlugSpan.textContent = "";
actorNameSpan.textContent = "";
signedOutDiv.style.display = "block";
signedInDiv.style.display = "none";
})

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.

This is how we do it on Apple and Android. The tunnel can run in whatever state it's in. When a GUI connects, it automatically gets updated with the proper state appropriately.

@thomaseizinger

Copy link
Copy Markdown
Member Author

Makes sense.

What happens if you launch Firezone a 3rd time with the Welcome window already open? Does it open another window or just bring the existing window to focus?

A 3rd time is no different to the 2nd time because the 2nd instance always exits right away. It will set the Welcome window to visible which is a no-op if it already is visible. I am not sure if that will focus it.

Base automatically changed from refactor/use-ipc-deeplink to main May 15, 2025 06:01
@thomaseizinger thomaseizinger force-pushed the feat/show-app-screen branch from 0971afc to bbd162b Compare May 15, 2025 07:10
@thomaseizinger

This comment was marked as outdated.


if visible {
win.show().context("Couldn't show Welcome window")?;
win.set_focus().context("Failed to focus window")?;

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.

@jamilbk This now does the focusing that you mentioned.

@thomaseizinger thomaseizinger enabled auto-merge May 15, 2025 08:06
@thomaseizinger thomaseizinger added this pull request to the merge queue May 15, 2025
Merged via the queue into main with commit 7f4b20a May 15, 2025
109 checks passed
@thomaseizinger thomaseizinger deleted the feat/show-app-screen branch May 15, 2025 08:35
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.

Optionally run in tray or as app

2 participants