Commit Graph

14 Commits

Author SHA1 Message Date
Thomas Eizinger
1317bbb9e2 refactor(gui-client): replace tslink with tauri-specta (#10031)
Despite still being in development, the `tauri-specta` project already
proves to be quite useful. It allows us to generate TypeScript bindings
for our commands and events, creating a type-safe contract between the
frontend and the backend.

For example, this ensures that the TypeScript code calls a command
actually with the required parameters and thus avoids runtime failures.

Similarly, the frontend can listen on type-safe events without having to
use any magic strings.
2025-07-28 21:37:24 +00:00
Thomas Eizinger
fb7d780b6f refactor(gui-client): don't hardcode IDs (#9831)
A linter I am trying out locally suggested to not hardcode HTML IDs. TIL
about React's `useId`.
2025-07-11 13:47:15 +00:00
Thomas Eizinger
92f8c8820f chore(gui-client): configure eslint (#9550)
Resolves: #9546
2025-06-17 20:46:39 +00:00
Jamil
2a96102db4 refactor(gui-client): introduce custom ReactRouterSidebarItem (#9508)
This cleans up some changes left over from #9505 by using a custom
component.
2025-06-15 17:41:24 +00:00
Thomas Eizinger
3660f53150 fix(gui-client): remove bad hook dependencies (#9537)
The removed hook dependencies are invalid because the side-effect
specified in `useEffect` does in fact not depend on them. However, as a
result of these dependencies, the `useEffect` closure appears to run in
an end-less loop, constantly sending the `update_state` command to the
backend which in turn re-sends all state to the frontend, causing a
massive CPU and memory spike.

Resolves: #9519
2025-06-15 17:09:07 +00:00
Jamil
1295adc727 fix(gui-client): fix minor frontend issues in app window (#9505)
- removes `NavLink` in favor of using the `href` prop on `SidebarItem`.
This fixes vertical spacing between sidebar items (it was inconsistent)
and DOM structure issues caused by setting `NavLink` as a direct child
of `<SidebarItemGroup>`.
- adds `cursor-pointer` to all `<Button>`s
- adds `cursor-pointer` to the `<SidebarCollapse>`

### Before

<img width="1238" alt="Screenshot 2025-06-10 at 7 57 37 PM"
src="https://github.com/user-attachments/assets/2e5e66f2-d4c1-48b7-b81d-1803de2442fc"
/>


### After

<img width="1238" alt="Screenshot 2025-06-10 at 7 57 55 PM"
src="https://github.com/user-attachments/assets/aa676fc1-124a-4e33-859d-da8f3eaad211"
/>
2025-06-11 05:53:09 +00:00
Thomas Eizinger
9210ed2a97 fix(gui-client): don't say "signed in" without a connlib session (#9477)
With the introduction of the "connect on start" configuration option, we
introduced a bug where the GUI client said "Signed in as ..." even
though we did not have a `connlib` session. The tray-menu handles this
state correctly and clicking sign out and sign in restores Firezone to a
functional state.

This disparity happened because we assumed that having a token means we
must have a session.

To fix this, we introduce a new `SessionViewModel` that combines the
state of the auth session and the `connlib` state. Only if we have both
do we infer that we are "signed in". This also requires us to introduce
an intermediary state where we are "loading". This is represented as a
spinner in the UI.

Last but not least, this also removes the automated hiding of the client
window. In a prior design, the only job of this window was to show the
"Sign in" button so it wasn't useful beyond clicking that. Now that we
show more things in this window, automatically hiding it might confuse
the user.

Here is what this new design looks like:

[Login
flow](https://github.com/user-attachments/assets/276e390b-4837-48e2-aaf1-eea007472816)

As a result of other improvements around "zero-click sign-in", the user
often doesn't even have to switch to the browser window because sign-in
happens in the background. Unfortunately, the tab still remains open but
that is outside of our control (at least on Linux).
2025-06-09 09:41:18 +00:00
Jamil
c3eb880ee5 fix(ci): Keep indentation of TSLINK_BUILD output (#9407)
When building the gui client with `TSLINK_BUILD=true`, the library
outputs using 4 spaces for indent. These are however currently checked
into git with 2 spaces per indent, which causes the Tauri workflow to
fail because it checks for a pristine git directory after the build.

Unfortunately #9383 doesn't fix this issue because it has nothing to do
with prettier in CI.

Fixes
https://github.com/firezone/firezone/actions/runs/15457631114/job/43512703266
2025-06-04 21:07:11 -07:00
Jamil
339af8d7ab refactor(gui-client): embed fonts directly (#9398)
This will prevent the fonts from failing to load if the user has no
internet connection.

Tested.
2025-06-04 21:43:23 +00:00
Thomas Eizinger
d6ecda59a1 feat(gui-client): introduce "General" settings page (#9381)
This PR introduces "General" settings for the GUI client. The "Settings"
menu item in the GUI is split into two sub-sections. The menu item is
collapsible but open by default.

|General|Advanced|
|---|---|

|![](https://github.com/user-attachments/assets/190cd23a-7ff6-4097-9eb5-a4ccf4a9c4a0)|![](https://github.com/user-attachments/assets/d538b749-9fe0-4995-84fc-b5c88132ede6)|

"Connect on start" and "Account slug" can both be MDM managed. The
autostart functionality is implemented via the Windows Registry.

---------

Co-authored-by: Jamil Bou Kheir <jamilbk@users.noreply.github.com>
2025-06-04 15:50:18 +00:00
Thomas Eizinger
b7b296a102 ci: apply prettier to all files (#9356)
Resolves: #8940
2025-06-02 11:12:54 +00:00
Thomas Eizinger
3ad7848e8f feat(gui-client): add Sentry to the frontend (#9316)
With an increased amount of complexity in the frontend of the GUI
client, it pays off to initialise the Sentry React SDK to catch any
errors that might occur. In particular, any failing commands that we
issue to the backend will be caught that way as those rejected
`Promise`s will surface as uncaught exceptions.

Similar to the backend, Sentry in the frontend is only initialised for
known environments, i.e. our production and staging deployments of
Firezone. For on-premise installations, Sentry is disabled.

Related: #6138
2025-06-02 05:59:26 +00:00
Thomas Eizinger
499a67f44b chore(gui-client): generate TypeScript interfaces from Rust (#9353)
The frontend of the GUI client is written in TypeScript and communicates
with the backend via event listeners. Currently, we only have
type-safety within either of those parts of the codebase but not across
it. The payloads of these events are JSON-encoded. Any change to this
interface therefore needs to be applied on either end.

To avoid this, we add `tslink` to the GUI client which generates
TypeScript interfaces from Rust structs. We still check those into Git
into order to make local builds easy (otherwise every dev would have to
set `TSLINK_BUILD=true` on their machine). Our Tauri CI build already
has a check to ensure the Git workspace isn't modified after building so
any changes to these generated files will fail CI.

This adds a bit more type-safety to the codebase and makes refactorings
on the GUI client easier.
2025-06-02 01:56:06 +00:00
Thomas Eizinger
56ff469f03 refactor(gui-client): merge all windows into a single view (#9295)
This PR refactors the GUI clients frontend into a single window with a
sidebar. The functionality remains the same but we do make minor UI
improvements on the way. To pull the entire refactor off, we now use
`react` and `flowbite-react` for the GUI. All the communication with the
backend is moved towards one-way commands and events. That means, the
flow is always:

- Backend emits events to update frontend
- Frontend triggers actions in the backend that may or may not result in
further events

This allows us to decouple the GUI from knowing about which side-effects
change what parts of the state. Instead, it simply updates whenever it
receives an event.

- The previous "Advanced Settings" screen is now split into two parts:
Settings and Diagnostics. Later, we will add a "General settings" page
here.
- The tray menu remains identical to the current one. When the user
clicks "Settings" or "About", we open the window and navigate to the
corresponding page.
- The app and git version are now directly embedded in the frontend,
simplifying the interaction between the frontend and the backend
further.

|Before|After|
|---|---|

|![](https://github.com/user-attachments/assets/7e8039c8-d589-495e-92b4-1742f9eb01b2)|![](https://github.com/user-attachments/assets/363184b3-4fcf-45c2-82d2-c466902759ef)|

|![](https://github.com/user-attachments/assets/88163522-cafc-4ad4-90cd-be2e77073b7f)|![](https://github.com/user-attachments/assets/106ef921-38a7-4603-add9-8b0875064737)|

|![](https://github.com/user-attachments/assets/a4bef4b0-5b29-43dd-aea6-0babd3b4ec9e)|![](https://github.com/user-attachments/assets/b84f1b51-c35c-48cc-9335-c653eee597ff)

|![](https://github.com/user-attachments/assets/f0473a0a-cdba-4a15-af98-d97ef422dbc5)|![](https://github.com/user-attachments/assets/ddced01b-6f44-4241-80ea-038a4740915b)|
2025-05-31 01:57:40 +00:00