fix: prevent silent launch window flash#151
Conversation
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src-tauri/src/app_runtime.rs" line_range="12" />
<code_context>
DEFAULT_SHELL_LOCALE, DESKTOP_LOG_FILE, STARTUP_MODE_ENV,
};
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+enum StartupWindowAction {
+ KeepHidden,
</code_context>
<issue_to_address>
**issue (complexity):** Consider inlining the `silent_launch` branching logic or extracting a direct behavior function instead of routing through `StartupWindowAction` and `startup_window_action` to avoid unnecessary indirection.
You can keep the new behavior while removing the extra indirection from `StartupWindowAction` and `startup_window_action`, which currently just re-encode a boolean and add a test for that mapping.
Inline the decision on `silent_launch` and call the appropriate functions directly:
```rust
fn configure_setup(builder: Builder<tauri::Wry>) -> Builder<tauri::Wry> {
builder.setup(|app| {
let app_handle = app.handle().clone();
if let Err(error) = tray::setup::setup_tray(&app_handle) {
append_startup_log(&format!("failed to initialize tray: {error}"));
}
crate::windows_shutdown::install(&app_handle);
let desktop_settings = app_handle.state::<DesktopSettingsCache>().get();
if desktop_settings.silent_launch {
append_startup_log("silent launch enabled, keeping main window hidden");
tray::labels::update_tray_menu_labels_with_visibility(
&app_handle,
DEFAULT_SHELL_LOCALE,
Some(false),
append_desktop_log,
);
} else {
window::actions::show_main_window(
&app_handle,
DEFAULT_SHELL_LOCALE,
append_desktop_log,
);
}
startup_task::spawn_startup_task(app_handle.clone(), append_startup_log);
Ok(())
})
}
```
With this, you can remove:
```rust
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum StartupWindowAction {
KeepHidden,
Show,
}
fn startup_window_action(silent_launch: bool) -> StartupWindowAction {
if silent_launch {
StartupWindowAction::KeepHidden
} else {
StartupWindowAction::Show
}
}
#[test]
fn startup_window_action_keeps_window_hidden_for_silent_launch() {
assert_eq!(startup_window_action(true), StartupWindowAction::KeepHidden);
assert_eq!(startup_window_action(false), StartupWindowAction::Show);
}
```
If you want to keep the “startup behavior” idea explicit for future extension, you can still avoid the boolean-to-enum adapter and encode it where the behavior is executed:
```rust
fn apply_startup_window_behavior(
app_handle: &tauri::AppHandle,
silent_launch: bool,
) {
if silent_launch {
append_startup_log("silent launch enabled, keeping main window hidden");
tray::labels::update_tray_menu_labels_with_visibility(
app_handle,
DEFAULT_SHELL_LOCALE,
Some(false),
append_desktop_log,
);
} else {
window::actions::show_main_window(
app_handle,
DEFAULT_SHELL_LOCALE,
append_desktop_log,
);
}
}
// in configure_setup:
let desktop_settings = app_handle.state::<DesktopSettingsCache>().get();
apply_startup_window_behavior(&app_handle, desktop_settings.silent_launch);
```
This keeps the new behavior, reduces conceptual overhead, and removes the need for a dedicated test that only verifies a boolean-to-enum mapping.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request configures the main Tauri window to start hidden by default to prevent a visual flash during silent launches. In app_runtime.rs, a new StartupWindowAction enum is introduced to handle window visibility during startup based on the silent launch setting. If silent launch is enabled, the window remains hidden and tray menu labels are updated; otherwise, the window is shown. Relevant unit and integration tests have been added to verify this behavior. There are no review comments, and I have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src-tauri/src/app_runtime.rs" line_range="17-18" />
<code_context>
+#[cfg(target_os = "linux")]
const WAYLAND_DISPLAY_ENV: &str = "WAYLAND_DISPLAY";
+#[cfg(any(target_os = "linux", test))]
fn should_set_webkit_dmabuf_renderer_env(
existing_value: Option<&std::ffi::OsStr>,
wayland_display: Option<&std::ffi::OsStr>,
</code_context>
<issue_to_address>
**issue (bug_risk):** The `test` cfg on this function can cause non-Linux test builds to fail because the Linux-only env constants are not available there.
The function is compiled with `#[cfg(any(target_os = "linux", test))]`, but `WAYLAND_DISPLAY_ENV` (and `WEBKIT_DISABLE_DMABUF_RENDERER_ENV`) are only compiled on `target_os = "linux"`. On non-Linux test builds this function will still compile but reference constants that don’t exist, causing a compile error.
To fix, either:
- Restrict the function to Linux: `#[cfg(target_os = "linux")] fn should_set_webkit_dmabuf_renderer_env(...)` and keep its tests Linux-only, or
- Broaden the constants: `#[cfg(any(target_os = "linux", test))]` on both constants.
The key is to align the `cfg` on the function and its constants to avoid cross-platform test build failures.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
configure_setup, consider centralizing window visibility handling (show/hide plus tray label update) in a single helper so the silent and non-silent branches don’t drift in behavior over time. - The
#[cfg(target_os = "linux")]annotations for the WebKit-related constants and helper are now scattered; you might simplify maintenance by grouping this Linux-specific logic into a dedicated, cfg-gated module or section.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `configure_setup`, consider centralizing window visibility handling (show/hide plus tray label update) in a single helper so the silent and non-silent branches don’t drift in behavior over time.
- The `#[cfg(target_os = "linux")]` annotations for the WebKit-related constants and helper are now scattered; you might simplify maintenance by grouping this Linux-specific logic into a dedicated, cfg-gated module or section.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src-tauri/src/app_runtime.rs" line_range="67-69" />
<code_context>
})
}
+fn apply_startup_window_visibility(app_handle: &tauri::AppHandle, silent_launch: bool) {
+ if silent_launch {
+ append_startup_log("silent launch enabled, keeping main window hidden");
+ window::actions::hide_main_window(app_handle, DEFAULT_SHELL_LOCALE, append_desktop_log);
+ } else {
+ window::actions::show_main_window(app_handle, DEFAULT_SHELL_LOCALE, append_desktop_log);
+ }
+}
</code_context>
<issue_to_address>
**suggestion:** Consider logging the non-silent startup path as well for more consistent startup diagnostics.
Now that startup window visibility is centralized, it would be useful to add a log entry in the non-silent path as well (e.g., "silent launch disabled, showing main window") to make startup behavior and configuration-related issues easier to diagnose from logs.
```suggestion
fn configure_plugins(builder: Builder<tauri::Wry>) -> Builder<tauri::Wry> {
builder
.plugin(tauri_plugin_autostart::init(
})
}
fn apply_startup_window_visibility(app_handle: &tauri::AppHandle, silent_launch: bool) {
if silent_launch {
append_startup_log("silent launch enabled, keeping main window hidden");
window::actions::hide_main_window(app_handle, DEFAULT_SHELL_LOCALE, append_desktop_log);
} else {
append_startup_log("silent launch disabled, showing main window");
window::actions::show_main_window(app_handle, DEFAULT_SHELL_LOCALE, append_desktop_log);
}
}
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Summary
Why
When launch-at-login and silent launch are both enabled, the main window was created visible first and then hidden in setup, causing a brief app frame flash at login. Starting hidden and showing only for non-silent startup removes that flash.
Verification
Summary by Sourcery
Prevent the main Tauri window from briefly flashing on silent launch by starting it hidden and explicitly controlling its visibility based on startup settings.
Bug Fixes:
Enhancements:
Tests: