Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/desktop/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# CHANGELOG


## v0.30.6 (2026-11-19)

### Bug Fixes

- **desktop**: show the window again on a second launch



## v0.30.5 (2026-11-19)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/openadapt_desktop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
+-- backends/ Storage backend plugins
"""

__version__ = "0.30.5"
__version__ = "0.30.6"
4 changes: 2 additions & 2 deletions packages/desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openadapt-desktop",
"version": "0.30.5",
"version": "0.30.6",
"description": "Installed companion for OpenAdapt authoring, teaching, and local pairing",
"private": true,
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "openadapt-desktop"
version = "0.30.5"
version = "0.30.6"
description = "The OpenAdapt desktop app and local engine: record a data-entry task, run it on a list, and check each saved record"
readme = "README.md"
requires-python = ">=3.11"
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "openadapt-desktop"
version = "0.30.5"
version = "0.30.6"
description = "Installed companion for OpenAdapt authoring, teaching, and local pairing"
authors = ["OpenAdapt AI"]
license = "MIT"
Expand Down
18 changes: 12 additions & 6 deletions packages/desktop/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod ffmpeg;
mod pairing;
mod sidecar;
mod tray;
mod window;

use std::sync::Arc;

Expand Down Expand Up @@ -49,9 +50,8 @@ fn main() {
// Must be first: on Windows/Linux it forwards a second process's
// statically configured deep link into the deep-link plugin event.
.plugin(tauri_plugin_single_instance::init(|app, _argv, _cwd| {
if let Some(window) = app.get_webview_window("main") {
let _ = window.show();
}
// A second launch brings the running app's window to the front.
window::show_main(app);
}))
.plugin(tauri_plugin_deep_link::init())
.plugin(tauri_plugin_shell::init())
Expand All @@ -60,6 +60,8 @@ fn main() {
builder = builder.plugin(tauri_plugin_updater::Builder::new().build());
}
builder
// Closing the main window hides it; see window.rs.
.on_window_event(window::on_window_event)
.manage(SidecarHandle(engine.clone()))
.manage(commands::UpdaterAvailable(updater_configured))
.setup(move |app| {
Expand Down Expand Up @@ -124,9 +126,13 @@ fn main() {
])
.build(context)
.expect("error while building openadapt-desktop")
.run(move |_app, event| {
if let tauri::RunEvent::Exit = event {
sidecar::shutdown(&engine_for_exit);
.run(move |app, event| match event {
tauri::RunEvent::Exit => sidecar::shutdown(&engine_for_exit),
// A click on the Dock icon while the app is running.
#[cfg(target_os = "macos")]
tauri::RunEvent::Reopen { .. } => window::show_main(app),
_ => {
let _ = app;
}
});
}
5 changes: 1 addition & 4 deletions packages/desktop/src-tauri/src/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ pub fn setup_tray(app: &App) -> Result<(), Box<dyn std::error::Error>> {
}

fn show_main(app: &AppHandle) {
if let Some(window) = app.get_webview_window("main") {
let _ = window.show();
let _ = window.set_focus();
}
crate::window::show_main(app);
}

/// Reflect shadow mode's on/off state in the tray. Called by the window
Expand Down
67 changes: 67 additions & 0 deletions packages/desktop/src-tauri/src/window.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// The main window: closing it hides it, and every way back shows it again.
//
// The app keeps running after the main window is closed, because the tray icon
// and the hidden control overlay stay alive. Before 0.30.5 closing destroyed the
// window, so nothing could bring it back: a second launch from the Start menu,
// "Open OpenAdapt" in the tray menu and a click on the macOS Dock icon all
// looked for a window that no longer existed and did nothing.
//
// Closing now hides the window instead. `show_main` is the one way back, used
// by the single-instance handler (a second launch), the tray menu and the Dock.

use tauri::{AppHandle, Manager, Window, WindowEvent};

pub const MAIN_WINDOW: &str = "main";

/// What a close request does to a window.
#[derive(Debug, PartialEq, Eq)]
pub enum CloseAction {
/// Keep the window and hide it, so it can be shown again.
Hide,
/// Let the window close.
Close,
}

/// Only the main window is kept; any other window closes as usual.
pub fn close_action(label: &str) -> CloseAction {
if label == MAIN_WINDOW {
CloseAction::Hide
} else {
CloseAction::Close
}
}

/// Hide the main window when the person closes it.
pub fn on_window_event(window: &Window, event: &WindowEvent) {
if let WindowEvent::CloseRequested { api, .. } = event {
if close_action(window.label()) == CloseAction::Hide {
api.prevent_close();
let _ = window.hide();
}
}
}

/// Bring the main window back to the front.
pub fn show_main(app: &AppHandle) {
if let Some(window) = app.get_webview_window(MAIN_WINDOW) {
let _ = window.unminimize();
let _ = window.show();
let _ = window.set_focus();
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn closing_the_main_window_hides_it() {
assert_eq!(close_action("main"), CloseAction::Hide);
}

#[test]
fn other_windows_close_as_usual() {
assert_eq!(close_action("control-overlay"), CloseAction::Close);
assert_eq!(close_action(""), CloseAction::Close);
}
}
2 changes: 1 addition & 1 deletion packages/desktop/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/nicoverbruggen/tauri-v2-schema/main/schema.json",
"productName": "OpenAdapt Desktop",
"version": "0.30.5",
"version": "0.30.6",
"identifier": "ai.openadapt.desktop",
"build": {
"frontendDist": "../dist",
Expand Down
50 changes: 50 additions & 0 deletions packages/desktop/tests/test_main_window_reopens.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""Every way back to the app shows the main window.

The app keeps running after its window is closed. Before Desktop 0.30.5 closing
destroyed the window, so a second launch from the Start menu, "Open OpenAdapt"
in the tray menu and a click on the macOS Dock icon all did nothing.

``src-tauri/src/window.rs`` now hides the window on close and owns the one
function that shows it again. These checks hold the wiring in place; the
behaviour itself was verified on Windows 11 and macOS with a branch build.
"""

from __future__ import annotations

import re
from pathlib import Path

SHELL = Path(__file__).resolve().parents[1] / "src-tauri" / "src"


def _source(name: str) -> str:
return (SHELL / name).read_text(encoding="utf-8")


def test_closing_the_main_window_hides_it_instead_of_destroying_it() -> None:
window = _source("window.rs")
handler = window[window.index("pub fn on_window_event") : window.index("pub fn show_main")]
assert "WindowEvent::CloseRequested" in handler
assert "api.prevent_close()" in handler
assert "window.hide()" in handler
assert ".on_window_event(window::on_window_event)" in _source("main.rs")


def test_a_second_launch_shows_the_running_apps_window() -> None:
main = _source("main.rs")
start = main.index("tauri_plugin_single_instance::init(")
handler = main[start : main.index("}))", start)]
assert "window::show_main(app)" in handler


def test_the_tray_menu_and_the_dock_show_the_window_too() -> None:
assert "crate::window::show_main(app)" in _source("tray.rs")
main = _source("main.rs")
assert re.search(r"RunEvent::Reopen\s*\{\s*\.\.\s*\}\s*=>\s*window::show_main\(app\)", main)


def test_show_main_restores_shows_and_focuses() -> None:
window = _source("window.rs")
body = window[window.index("pub fn show_main") : window.index("#[cfg(test)]")]
for call in ("window.unminimize()", "window.show()", "window.set_focus()"):
assert call in body
2 changes: 1 addition & 1 deletion packages/desktop/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading