feat(app): app icon, close button to quit or hide to the tray, one Jarvis at a time

- New icon (voice bars in a ring on the accent gradient; three thicker
  bars at 32 px and below) for the program file, window, taskbar,
  installer and a tray icon of its own.
- 앱 settings screen with app.closeButton: "quit" (default, as before)
  or "tray", read each time X is pressed (no restart). Tray mode only
  hides the window; the bot and services keep running. The tray icon is
  always there: a left click shows the window, its menu has 열기 and
  완전 종료 (the same stop-then-exit as closing).
- tauri-plugin-single-instance: starting Jarvis again while it runs
  shows the running one's window instead of a second app driving the
  same services.
- Version 0.1.8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-16 09:37:08 +09:00
parent 53d522db69
commit 2a6b350079
14 changed files with 601 additions and 31 deletions

2
app/Cargo.lock generated
View File

@@ -1520,7 +1520,7 @@ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
[[package]]
name = "jarvis-app"
version = "0.1.7"
version = "0.1.8"
dependencies = [
"async-trait",
"base64 0.22.1",

View File

@@ -1,6 +1,6 @@
[package]
name = "jarvis-app"
version = "0.1.7"
version = "0.1.8"
edition = "2021"
rust-version = "1.85"
description = "Jarvis v2 Windows app core: Discord voice, voice worker supervisor, chat channels"

459
app/shell/Cargo.lock generated
View File

@@ -91,6 +91,126 @@ dependencies = [
"serde",
]
[[package]]
name = "async-broadcast"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532"
dependencies = [
"event-listener",
"event-listener-strategy",
"futures-core",
"pin-project-lite",
]
[[package]]
name = "async-channel"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2"
dependencies = [
"concurrent-queue",
"event-listener-strategy",
"futures-core",
"pin-project-lite",
]
[[package]]
name = "async-executor"
version = "1.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f426a31126c735126297bc5ea7a521263c9faff4f63ca415267ee625651c4f37"
dependencies = [
"async-task",
"concurrent-queue",
"fastrand",
"futures-lite",
"pin-project-lite",
"slab",
]
[[package]]
name = "async-io"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc"
dependencies = [
"autocfg",
"cfg-if",
"concurrent-queue",
"futures-io",
"futures-lite",
"parking",
"polling",
"rustix",
"slab",
"windows-sys 0.61.2",
]
[[package]]
name = "async-lock"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0876700b0d007ad25d5508865a4259c3af9af6d296bf663a0d586d0bc3369f6f"
dependencies = [
"event-listener",
"event-listener-strategy",
"pin-project-lite",
]
[[package]]
name = "async-process"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75"
dependencies = [
"async-channel",
"async-io",
"async-lock",
"async-signal",
"async-task",
"blocking",
"cfg-if",
"event-listener",
"futures-lite",
"rustix",
]
[[package]]
name = "async-recursion"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.10",
]
[[package]]
name = "async-signal"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52b5aaafa020cf5053a01f2a60e8ff5dccf550f0f77ec54a4e47285ac2bab485"
dependencies = [
"async-io",
"async-lock",
"atomic-waker",
"cfg-if",
"futures-core",
"futures-io",
"rustix",
"signal-hook-registry",
"slab",
"windows-sys 0.61.2",
]
[[package]]
name = "async-task"
version = "4.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de"
[[package]]
name = "async-trait"
version = "0.1.92"
@@ -230,6 +350,19 @@ dependencies = [
"objc2",
]
[[package]]
name = "blocking"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a70e4329df6cb94385eed412ec92375c3cdd8a6e502493d1229b6414e4036dfa"
dependencies = [
"async-channel",
"async-task",
"futures-io",
"futures-lite",
"piper",
]
[[package]]
name = "brotli"
version = "9.1.1"
@@ -278,6 +411,12 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "byteorder-lite"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
[[package]]
name = "bytes"
version = "1.12.1"
@@ -481,6 +620,15 @@ dependencies = [
"memchr",
]
[[package]]
name = "concurrent-queue"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "const-oid"
version = "0.9.6"
@@ -1217,6 +1365,12 @@ dependencies = [
"simdutf8",
]
[[package]]
name = "endi"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099"
[[package]]
name = "enum-map"
version = "2.7.3"
@@ -1237,6 +1391,27 @@ dependencies = [
"syn 2.0.119",
]
[[package]]
name = "enumflags2"
version = "0.7.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef"
dependencies = [
"enumflags2_derive",
"serde",
]
[[package]]
name = "enumflags2_derive"
version = "0.7.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "equivalent"
version = "1.0.3"
@@ -1264,6 +1439,26 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "event-listener"
version = "5.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2"
dependencies = [
"parking",
"pin-project-lite",
]
[[package]]
name = "event-listener-strategy"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93"
dependencies = [
"event-listener",
"pin-project-lite",
]
[[package]]
name = "extended"
version = "0.1.0"
@@ -1488,6 +1683,19 @@ version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"
[[package]]
name = "futures-lite"
version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad"
dependencies = [
"fastrand",
"futures-core",
"futures-io",
"parking",
"pin-project-lite",
]
[[package]]
name = "futures-macro"
version = "0.3.34"
@@ -2349,6 +2557,19 @@ dependencies = [
"icu_properties",
]
[[package]]
name = "image"
version = "0.25.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104"
dependencies = [
"bytemuck",
"byteorder-lite",
"moxcms",
"num-traits",
"png",
]
[[package]]
name = "indexmap"
version = "1.9.3"
@@ -2416,7 +2637,7 @@ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
[[package]]
name = "jarvis-app"
version = "0.1.7"
version = "0.1.8"
dependencies = [
"async-trait",
"base64 0.22.1",
@@ -2445,12 +2666,13 @@ dependencies = [
[[package]]
name = "jarvis-shell"
version = "0.1.7"
version = "0.1.8"
dependencies = [
"jarvis-app",
"serde_json",
"tauri",
"tauri-build",
"tauri-plugin-single-instance",
"tokio",
]
@@ -3075,6 +3297,16 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "moxcms"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b"
dependencies = [
"num-traits",
"pxfm",
]
[[package]]
name = "muda"
version = "0.20.0"
@@ -3590,6 +3822,16 @@ dependencies = [
"num-traits",
]
[[package]]
name = "ordered-stream"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50"
dependencies = [
"futures-core",
"pin-project-lite",
]
[[package]]
name = "p256"
version = "0.13.2"
@@ -3637,6 +3879,12 @@ dependencies = [
"system-deps",
]
[[package]]
name = "parking"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"
[[package]]
name = "parking_lot"
version = "0.11.2"
@@ -3863,6 +4111,17 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13bee6c73da26345c729282832b60b0363cf3dd9f4bfd81d8551b7a1c889a113"
[[package]]
name = "piper"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1"
dependencies = [
"atomic-waker",
"fastrand",
"futures-io",
]
[[package]]
name = "pkcs8"
version = "0.10.2"
@@ -3935,6 +4194,20 @@ dependencies = [
"miniz_oxide 0.8.9",
]
[[package]]
name = "polling"
version = "3.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218"
dependencies = [
"cfg-if",
"concurrent-queue",
"hermit-abi",
"pin-project-lite",
"rustix",
"windows-sys 0.61.2",
]
[[package]]
name = "poly1305"
version = "0.8.0"
@@ -4041,6 +4314,15 @@ dependencies = [
"toml_edit 0.20.2",
]
[[package]]
name = "proc-macro-crate"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f"
dependencies = [
"toml_edit 0.25.19+spec-1.1.0",
]
[[package]]
name = "proc-macro-error"
version = "1.0.4"
@@ -4096,6 +4378,12 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "pxfm"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0c5ccf5294c6ccd63a74f1565028353830a9c2f5eb0c682c355c471726a6e3f"
[[package]]
name = "quick-xml"
version = "0.42.0"
@@ -5719,6 +6007,7 @@ dependencies = [
"gtk",
"heck 0.5.0",
"http",
"image",
"jni",
"libc",
"log",
@@ -5817,6 +6106,22 @@ dependencies = [
"tauri-utils",
]
[[package]]
name = "tauri-plugin-single-instance"
version = "2.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "726b6da0dd5bd1344f84f4108a622c07d01923baacb5c803a605189672c5352f"
dependencies = [
"serde",
"serde_json",
"tauri",
"thiserror 2.0.21",
"tokio",
"tracing",
"windows-sys 0.61.2",
"zbus",
]
[[package]]
name = "tauri-runtime"
version = "2.12.2"
@@ -5916,6 +6221,19 @@ dependencies = [
"toml 1.2.1+spec-1.1.0",
]
[[package]]
name = "tempfile"
version = "3.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [
"fastrand",
"getrandom 0.4.3",
"once_cell",
"rustix",
"windows-sys 0.61.2",
]
[[package]]
name = "tendril"
version = "0.5.1"
@@ -6251,6 +6569,18 @@ dependencies = [
"winnow 0.5.40",
]
[[package]]
name = "toml_edit"
version = "0.25.19+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218"
dependencies = [
"indexmap 2.14.2",
"toml_datetime 1.1.3+spec-1.1.0",
"toml_parser",
"winnow 1.0.5",
]
[[package]]
name = "toml_parser"
version = "1.1.5+spec-1.1.0"
@@ -6528,6 +6858,17 @@ version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
[[package]]
name = "uds_windows"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"
dependencies = [
"memoffset",
"tempfile",
"windows-sys 0.61.2",
]
[[package]]
name = "unicase"
version = "2.10.0"
@@ -7322,6 +7663,9 @@ name = "winnow"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef"
dependencies = [
"memchr",
]
[[package]]
name = "winreg"
@@ -7444,6 +7788,76 @@ dependencies = [
"synstructure",
]
[[package]]
name = "zbus"
version = "5.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5db4be7c075cb421e4b7ee645541604239bd243ba7c357511f4ff3a74b555907"
dependencies = [
"async-broadcast",
"async-executor",
"async-io",
"async-lock",
"async-process",
"async-recursion",
"async-task",
"async-trait",
"blocking",
"enumflags2",
"event-listener",
"futures-core",
"futures-lite",
"hex",
"libc",
"ordered-stream",
"rustix",
"serde",
"serde_repr",
"tracing",
"uds_windows",
"uuid",
"windows-sys 0.61.2",
"winnow 1.0.5",
"zbus_macros",
"zbus_names",
"zvariant",
]
[[package]]
name = "zbus_macros"
version = "5.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40"
dependencies = [
"proc-macro-crate 3.5.0",
"proc-macro2",
"quote",
"syn 3.0.10",
"zbus_names",
"zvariant",
"zvariant_utils",
]
[[package]]
name = "zbus_names"
version = "4.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "812a12be4ead7a59e18ea8f047d08add0066b73bc62fc1467066a2472ae088dd"
dependencies = [
"serde",
"winnow 1.0.5",
"zvariant",
]
[[package]]
name = "zcheapstr"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "939f186d9ecebe044315a5cb6d6f78568bbc21152adc954d5a0c2f58bdbc9920"
dependencies = [
"serde",
]
[[package]]
name = "zerocopy"
version = "0.8.63"
@@ -7581,3 +7995,44 @@ dependencies = [
"log",
"simd-adler32",
]
[[package]]
name = "zvariant"
version = "5.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80bf6d6cd6a4b601acb64cfb8284cdc643fcfa75ef26ae3c46ec8aa4e8a1fbb7"
dependencies = [
"endi",
"enumflags2",
"serde",
"winnow 1.0.5",
"zcheapstr",
"zvariant_derive",
"zvariant_utils",
]
[[package]]
name = "zvariant_derive"
version = "5.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef2672456ba1cb54b5eaec136e63135b3c7495fb938e53b28a62e633496d486d"
dependencies = [
"proc-macro-crate 3.5.0",
"proc-macro2",
"quote",
"syn 3.0.10",
"zvariant_utils",
]
[[package]]
name = "zvariant_utils"
version = "4.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bad0294361a320b694a328460dc73add56c306150f5cb6bfafc44446120008a3"
dependencies = [
"proc-macro2",
"quote",
"serde",
"syn 3.0.10",
"winnow 1.0.5",
]

View File

@@ -1,6 +1,6 @@
[package]
name = "jarvis-shell"
version = "0.1.7"
version = "0.1.8"
edition = "2021"
rust-version = "1.85"
description = "Jarvis v2 management app window (Tauri 2 over the app core's AdminApi)"
@@ -16,7 +16,8 @@ tauri-build = { version = "2", features = [] }
[dependencies]
jarvis-app = { path = ".." }
tauri = { version = "2", features = [] }
tauri = { version = "2", features = ["tray-icon", "image-png"] }
tauri-plugin-single-instance = "2"
serde_json = "1"
tokio = { version = "1", features = ["full"] }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 53 KiB

BIN
app/shell/icons/tray.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -1,7 +1,9 @@
//! Jarvis management app: one Tauri 2 window over the app core (`app/src/admin.spec.md`, "Window
//! and Windows build"). The screens (`app/ui`) call `invoke("admin", {command, args})`, passed to the
//! same `AdminApi` the development server uses. Closing the window first stops what the app started;
//! if that cannot be confirmed the window stays open and says so, and closing it again quits.
//! same `AdminApi` the development server uses. Quitting first stops what the app started; if that
//! cannot be confirmed the window stays open and says so, and quitting again quits. The close button
//! quits, or hides the window to the tray when `app.closeButton` is "tray"; the tray icon opens it
//! again or quits. Starting Jarvis again while it runs shows the running one's window.
//!
//! jarvis [--location FILE]
//! jarvis --display-driver install|uninstall --result FILE (elevated, started by the app)
@@ -14,7 +16,9 @@ use std::sync::Arc;
use jarvis_app::admin_api::AdminApi;
use serde_json::Value;
use tauri::{Emitter, Manager, RunEvent, WebviewUrl, WebviewWindowBuilder, WindowEvent};
use tauri::menu::{Menu, MenuItem};
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
use tauri::{AppHandle, Emitter, Manager, RunEvent, WebviewUrl, WebviewWindowBuilder, WindowEvent};
/// Where closing stands: open, closing (stopping what runs), or the stop could not be confirmed.
const OPEN: u8 = 0;
@@ -37,6 +41,45 @@ async fn admin(app: tauri::AppHandle, state: tauri::State<'_, Api>, command: Str
Ok(out)
}
/// Bring the window back: from the tray, or when Jarvis is started again.
fn show_window(app: &AppHandle) {
if let Some(w) = app.get_webview_window("main") {
let _ = w.unminimize();
let _ = w.show();
let _ = w.set_focus();
}
}
/// Quit (the close button set to quit, or the tray's "완전 종료"): stop what the app started, then
/// exit; the window shows while that runs. If the stop fails the window stays with the reason, and
/// quitting again exits anyway.
fn quit(app: &AppHandle) {
let state = app.state::<Api>();
match state.phase.load(Ordering::SeqCst) {
CLOSE_FAILED => {
jarvis_app::warn_log!("app", "quitting again: quitting although the stop was not confirmed");
app.exit(0);
}
CLOSING => {}
_ => {
state.phase.store(CLOSING, Ordering::SeqCst);
show_window(app);
let _ = app.emit("closing", ());
let (handle, api) = (app.clone(), state.api.clone());
tauri::async_runtime::spawn(async move {
jarvis_app::info_log!("app", "quitting: stopping what the app started");
match api.shutdown().await {
Ok(()) => handle.exit(0),
Err(e) => {
handle.state::<Api>().phase.store(CLOSE_FAILED, Ordering::SeqCst);
let _ = handle.emit("close-failed", e);
}
}
});
}
}
}
fn arg(name: &str) -> Option<String> {
let args: Vec<String> = std::env::args().collect();
args.iter().position(|a| a == name).and_then(|i| args.get(i + 1).cloned())
@@ -66,6 +109,8 @@ fn main() {
let (webview_data, _) = jarvis_app::datadir::webview_data_dir(&location);
let app = tauri::Builder::default()
// First, so a second start only shows this one's window and exits.
.plugin(tauri_plugin_single_instance::init(|app, _, _| show_window(app)))
.manage(Api { api, phase: AtomicU8::new(OPEN) })
.invoke_handler(tauri::generate_handler![admin])
.setup({
@@ -76,6 +121,24 @@ fn main() {
.min_inner_size(900.0, 600.0)
.data_directory(webview_data)
.build()?;
let open = MenuItem::with_id(app, "open", "열기", true, None::<&str>)?;
let quit_item = MenuItem::with_id(app, "quit", "완전 종료", true, None::<&str>)?;
TrayIconBuilder::with_id("main")
.tooltip("Jarvis")
.menu(&Menu::with_items(app, &[&open, &quit_item])?)
.show_menu_on_left_click(false)
.on_menu_event(|app, e| match e.id.as_ref() {
"open" => show_window(app),
"quit" => quit(app),
_ => {}
})
.on_tray_icon_event(|tray, e| {
if let TrayIconEvent::Click { button: MouseButton::Left, button_state: MouseButtonState::Up, .. } = e {
show_window(tray.app_handle());
}
})
.icon(tauri::image::Image::from_bytes(include_bytes!("../icons/tray.png"))?)
.build(app)?;
Ok(())
}
})
@@ -83,25 +146,17 @@ fn main() {
let WindowEvent::CloseRequested { api: close, .. } = event else { return };
let state = window.state::<Api>();
match state.phase.load(Ordering::SeqCst) {
CLOSE_FAILED => {
jarvis_app::warn_log!("app", "window closed again: quitting although the stop was not confirmed");
}
// After a failed stop the window closes, and with it the app.
CLOSE_FAILED => jarvis_app::warn_log!("app", "window closed again: quitting although the stop was not confirmed"),
CLOSING => close.prevent_close(),
_ if state.api.close_to_tray() => {
close.prevent_close();
let _ = window.hide();
jarvis_app::info_log!("app", "window hidden to the tray");
}
_ => {
close.prevent_close();
state.phase.store(CLOSING, Ordering::SeqCst);
let _ = window.emit("closing", ());
let (handle, api) = (window.app_handle().clone(), state.api.clone());
tauri::async_runtime::spawn(async move {
jarvis_app::info_log!("app", "window closing: stopping what the app started");
match api.shutdown().await {
Ok(()) => handle.exit(0),
Err(e) => {
handle.state::<Api>().phase.store(CLOSE_FAILED, Ordering::SeqCst);
let _ = handle.emit("close-failed", e);
}
}
});
quit(window.app_handle());
}
}
})

View File

@@ -38,7 +38,7 @@ that is not absolute, or is a file, is refused with a message.
`config/settings.json` keeps the format of `discord_core.spec.md` and `conversation.spec.md`.
- `fields()` describes every key the screens edit: its dotted path (`call.mode`), screen
(`bot`, `channels`, `chat`, `memory`, `model`, `features`, `collect`), kind (bool, integer with a range, number with a
(`bot`, `channels`, `chat`, `memory`, `model`, `features`, `collect`, `schedule`, `pcControl`, `game`, `app`), kind (bool, integer with a range, number with a
range, text, text list, choice with its values, Discord ID, Discord ID list, ID to number map,
chat channel list, MCP server list, collection target list, free object), its default and a Korean label. The screens are built from this
list, so a key is added in one place.
@@ -718,7 +718,7 @@ Plain HTML, CSS and an ES module, no build step, dark theme after `DESIGN.md`. A
Strata's last line, and stop in the header; the header with start, restart and stop is rebuilt
only when the state changes, so a click is never lost to the refresh. Every screen change starts
a new generation: an answer that arrives after the user moved to another screen is dropped.
- **Settings screens** (봇, 채널·호출, 채팅 채널, 대화 기억, 모델, 기능, 백그라운드 수집, 예약, PC 제어, 게임 모드): built from `settings_fields`; only
- **Settings screens** (봇, 채널·호출, 채팅 채널, 대화 기억, 모델, 기능, 백그라운드 수집, 예약, PC 제어, 게임 모드, 앱): built from `settings_fields`; only
changed fields are sent; the server and voice channel are pickers (choosing another server clears
the voice channel and lists only that server's channels); the chat channels are a table
with their switches; the bot screen also changes the token; the 기능 screen has the feature
@@ -730,7 +730,8 @@ Plain HTML, CSS and an ES module, no build step, dark theme after `DESIGN.md`. A
newest 100, filtered by any target that has results, each with its time, title, link and the start of its text shown
as plain text). The 예약 screen has `schedule.chatChannel` and every person's schedules (next time
or "다시 울리지 않음", repeat, who and how they asked, kind and text as plain text, the last
outcome, delete).
outcome, delete). The 앱 screen has `app.closeButton` (완전 종료 or 트레이로 최소화) with a note
that the tray icon opens the window again and its menu quits; saving it needs no restart.
- **사람별 지침**: every person's notes (name and ID, the text in a box, save and delete).
- **대화**: what people said, Jarvis's answers and how each answer was made, in time order with a
date line between days; people's words on the left, Jarvis's on the right with whom it answered,
@@ -802,6 +803,16 @@ both to a release with that tag. The repository's other releases (v1's `v1.x`) a
left is cleared (`Controller::shutdown`: the LLM's server stopped and confirmed gone). While that
runs the window says so; if it fails the window stays open with the reason, and closing it again
quits anyway. Quitting another way (the system shutting down) runs the same shutdown.
- The close button (X) quits as above, or, when `app.closeButton` is `"tray"` (`"quit"` by default,
read each time it is pressed; no data folder or settings that do not parse: quit), only hides the
window: the bot and services keep running. A tray icon (`icons/tray.png`, tooltip "Jarvis") is
always there: a left click shows the window again, its menu has 열기 and 완전 종료 (the quit
above, with the window shown while it runs).
- One Jarvis at a time (`tauri-plugin-single-instance`): starting it again while it runs shows the
running one's window (hidden or minimised) and the new start exits.
- The icon (`icons/icon.ico` for the program file, window, taskbar and installer, 16-256 px;
`icons/icon.png` 512 px): voice bars in a ring on the accent colour's gradient; at 32 px and below
only three thicker bars, so it stays readable in the taskbar and tray.
- `app/shell/package.sh <folder>` builds it on Linux (`x86_64-pc-windows-gnu`, mingw-w64) and lays
out `Jarvis/`: `jarvis.exe`, `WebView2Loader.dll`, `python-src/` (the `voice_worker` and
`jarvis` packages, no caches or specs) and `display-driver/` (the virtual monitor's driver). The worker's sources are `python-src` next to the

View File

@@ -157,6 +157,14 @@ impl AdminApi {
Ok(c.get_or_insert_with(|| Controller::new(ServicesHost::new(dir.path().to_path_buf()))).clone())
}
/// Whether the window's close button hides it to the tray (`app.closeButton`) rather than
/// quitting. Without a data folder or with settings that do not parse, closing quits.
pub fn close_to_tray(&self) -> bool {
self.dir.lock().unwrap().as_ref()
.and_then(|d| crate::settings::load_settings(&d.settings_file()).ok())
.is_some_and(|s| s.close_to_tray)
}
/// The app is closing: cancel an install in progress and wait for it (its commands and their
/// children end), stop the services (a start in progress is cancelled and waited for) and clear
/// what a failed run may have left (the LLM's server). An error means something may still run;
@@ -317,7 +325,8 @@ impl AdminApi {
let speed = crate::settings::load_settings(&file).map_err(|e| e.0)?.voice.tts_speed;
self.controller()?.set_tts_speed(speed);
}
let restart = changes.keys().any(|k| k != "voice.tts.speed");
// The close button's choice is read when it is pressed.
let restart = changes.keys().any(|k| k != "voice.tts.speed" && k != "app.closeButton");
Ok(json!({"saved": changes.len(),
"restartNeeded": restart && self.controller()?.state() == crate::control::State::Running,
"sync": sync}))
@@ -550,6 +559,20 @@ mod tests {
assert!(a.call("nope", json!({})).await.is_err());
}
#[tokio::test]
async fn the_close_button_follows_the_saved_choice() {
let (a, base) = api("api-close");
assert!(!a.close_to_tray(), "no data folder yet: closing quits");
let data = base.join("d");
a.call("folder_choose", json!({"path": data.to_string_lossy()})).await.unwrap();
assert!(!a.close_to_tray());
a.call("settings_apply", json!({"changes": {"app.closeButton": "tray"}})).await.unwrap();
assert!(a.close_to_tray());
// A settings file that does not parse never leaves the window unable to close.
std::fs::write(data.join("config").join("settings.json"), "{").unwrap();
assert!(!a.close_to_tray());
}
#[tokio::test]
async fn the_notes_screen_lists_edits_and_deletes_anyones_notes() {
let (a, base) = api("api-notes");

View File

@@ -221,6 +221,9 @@ pub struct Settings {
/// Jarvis's voice channel (admin.spec.md, "Schedules"); None: not delivered then.
pub schedule_channel: Option<u64>,
pub pc_control: PcControlSettings,
/// The window's close button (X) hides it to the tray instead of quitting (`app.closeButton`:
/// "tray" or "quit", default "quit"; admin.spec.md, "Window and Windows build").
pub close_to_tray: bool,
}
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -272,6 +275,7 @@ impl Default for Settings {
pc_control: PcControlSettings { allowed_users: vec![], view: Level::Auto, click: Level::Ask,
type_text: Level::Ask, run: Level::Ask,
screen_exclude: ["1Password", "Bitwarden", "KeePass", "KeePassXC"].map(String::from).into() },
close_to_tray: false,
}
}
}
@@ -618,6 +622,11 @@ pub fn parse_settings(raw: &Value) -> Result<Settings, SettingsError> {
game: parse_game(raw, &d.game)?,
schedule_channel,
pc_control: parse_pc_control(raw, &d.pc_control)?,
close_to_tray: match get_str(section(raw, "app")?, "closeButton", "app", "quit")?.as_str() {
"tray" => true,
"quit" => false,
_ => return err("app.closeButton must be tray or quit"),
},
})
}
@@ -984,6 +993,16 @@ mod tests {
}
}
#[test]
fn the_close_button_choice_is_read_and_checked() {
assert!(!parse_settings(&json!({})).unwrap().close_to_tray, "closing quits by default");
assert!(parse_settings(&json!({"app": {"closeButton": "tray"}})).unwrap().close_to_tray);
assert!(!parse_settings(&json!({"app": {"closeButton": "quit"}})).unwrap().close_to_tray);
for bad in [json!({"app": {"closeButton": "hide"}}), json!({"app": {"closeButton": 1}}), json!({"app": 1})] {
assert!(parse_settings(&bad).unwrap_err().0.contains("app"), "{bad}");
}
}
#[test]
fn game_detection_settings_are_read_and_checked() {
assert_eq!(parse_settings(&json!({})).unwrap().game, GameSettings { detect: true, games: vec![], not_games: vec![], other_room_gb: 1.0, reserve_gb: 8.0, revert_seconds: 30, pause_in_game: false });

View File

@@ -24,6 +24,7 @@ pub enum Screen {
Game,
Schedule,
PcControl,
App,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize)]
@@ -159,6 +160,8 @@ pub fn fields() -> Vec<Field> {
f("game.revertSeconds", Game, Int { min: 0, max: 600 }, json!(30), "게임이 끝난 뒤 평소 배치로 돌아가기까지(초)"),
f("game.pauseInGame", Game, Bool, json!(false), "게임 중 일시정지(대답하지 않음)"),
f("game.notGames", Game, TextList { max_items: 100, nullable: false }, json!([]), "게임이 아닌 프로그램(파일 이름)"),
// The window (admin.spec.md, "Window and Windows build"): read when the close button is pressed.
f("app.closeButton", App, Choice { values: &["quit", "tray"] }, json!("quit"), "창 닫기(X) 버튼을 누르면"),
]
}

View File

@@ -42,6 +42,7 @@ const LEVEL = { auto: "자동", ask: "먼저 묻기", never: "안 함" };
const CHOICE = {
"pcControl.view": LEVEL, "pcControl.click": LEVEL, "pcControl.type": LEVEL, "pcControl.run": LEVEL,
"call.mode": { wakeWord: "호출어로 부를 때만", addressed: "자비스에게 하는 말로 보이면", everything: "모든 말" },
"app.closeButton": { quit: "완전 종료", tray: "트레이로 최소화" },
"response.policy": { first: "처음 대화만", inOrder: "순서대로", latest: "가장 최근 것", important: "중요한 것 먼저" },
};
const REASON = { busy: "다른 답을 하는 중", queue_full: "대기열이 가득 참", replaced: "더 새 요청이 대신함",
@@ -897,8 +898,9 @@ async function show(name) {
if (name === "notes") { screen.replaceChildren(notesScreen()); return; }
if (name === "update") { const u = updateScreen(); screen.replaceChildren(u.view); ticker = setInterval(u.tick, 1000); return; }
const titles = { bot: "봇", channels: "채널·호출", chat: "채팅 채널", memory: "대화 기억", model: "모델", features: "기능",
collect: "백그라운드 수집", game: "게임 모드", schedule: "예약", pcControl: "PC 제어" };
const extra = name === "bot" ? await tokenCard() : name === "features" ? await displayDriverCard() : null;
collect: "백그라운드 수집", game: "게임 모드", schedule: "예약", pcControl: "PC 제어", app: "앱" };
const extra = name === "bot" ? await tokenCard() : name === "features" ? await displayDriverCard()
: name === "app" ? h("div", { class: "hint", style: "margin-bottom:12px" }, "트레이로 최소화하면 창만 숨고 봇과 서비스는 계속 돕니다. 작업 표시줄 오른쪽의 Jarvis 아이콘을 누르면 창이 다시 열리고, 아이콘의 오른쪽 클릭 메뉴에서 완전 종료할 수 있습니다. 저장하면 바로 적용됩니다.") : null;
const view = await settingsScreen(name, titles[name], extra);
if (name === "collect") view.append(await collectResults());
if (name === "schedule") view.append(await scheduleList());

View File

@@ -25,6 +25,7 @@
<button data-screen="conversations" class="nav">대화</button>
<button data-screen="activity" class="nav">한 일</button>
<button data-screen="game" class="nav">게임 모드</button>
<button data-screen="app" class="nav">앱</button>
<button data-screen="logs" class="nav">로그</button>
<button data-screen="update" class="nav" id="nav-update">업데이트</button>
<div class="side-foot" id="version"></div>