Skip to content

Commit 0e88451

Browse files
authored
Merge pull request Stack-Cairn#299 from Stack-Cairn/features
feat(gui): rich system tray menu with live state and actions
2 parents 2159c39 + af492a5 commit 0e88451

17 files changed

Lines changed: 1857 additions & 123 deletions

File tree

crates/agent-gateway/web/src/components/chat/NotifyToast.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { memo, useEffect, useRef } from "react";
2-
import { AlertTriangle, X, XCircle } from "../icons";
2+
import { AlertTriangle, CheckCircle2, X, XCircle } from "../icons";
33

44
export type NotifyItem = {
55
id: string;
6-
type: "warning" | "error";
6+
type: "warning" | "error" | "success";
77
message: string;
88
};
99

@@ -47,24 +47,33 @@ const ToastEntry = memo(function ToastEntry(props: {
4747
}, [item.id, onDismiss]);
4848

4949
const isWarning = item.type === "warning";
50+
const isSuccess = item.type === "success";
5051

5152
return (
5253
<div
5354
ref={elRef}
5455
className={`notify-toast-enter pointer-events-auto flex w-72 items-start gap-2.5 rounded-lg border px-3 py-2.5 text-sm shadow-lg backdrop-blur-xl ${
5556
isWarning
5657
? "border-amber-500/30 bg-amber-50/95 dark:bg-amber-950/80 dark:border-amber-500/25"
57-
: "border-red-500/30 bg-red-50/95 dark:bg-red-950/80 dark:border-red-500/25"
58+
: isSuccess
59+
? "border-emerald-500/30 bg-emerald-50/95 dark:bg-emerald-950/80 dark:border-emerald-500/25"
60+
: "border-red-500/30 bg-red-50/95 dark:bg-red-950/80 dark:border-red-500/25"
5861
}`}
5962
>
6063
{isWarning ? (
6164
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400" />
65+
) : isSuccess ? (
66+
<CheckCircle2 className="mt-0.5 h-4 w-4 shrink-0 text-emerald-600 dark:text-emerald-400" />
6267
) : (
6368
<XCircle className="mt-0.5 h-4 w-4 shrink-0 text-red-600 dark:text-red-400" />
6469
)}
6570
<p
6671
className={`min-w-0 flex-1 leading-relaxed ${
67-
isWarning ? "text-amber-800 dark:text-amber-200" : "text-red-800 dark:text-red-200"
72+
isWarning
73+
? "text-amber-800 dark:text-amber-200"
74+
: isSuccess
75+
? "text-emerald-800 dark:text-emerald-200"
76+
: "text-red-800 dark:text-red-200"
6877
}`}
6978
>
7079
{item.message}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub mod app;
22
pub mod custom_tools;
33
pub mod system;
4+
pub mod tray;
45
pub mod update;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use std::sync::Arc;
2+
3+
use crate::services::tray::{apply_tray_menu, TrayMenuHandles, TrayMenuModel};
4+
5+
/// 前端推送托盘菜单模型(已本地化文案 + 动态列表 + 状态)。
6+
/// 唯一的托盘内容写入口;apply 内部经菜单句柄代理到主线程执行。
7+
#[tauri::command(rename_all = "snake_case")]
8+
pub async fn app_tray_menu_sync(
9+
app: tauri::AppHandle,
10+
model: TrayMenuModel,
11+
handles: tauri::State<'_, Arc<TrayMenuHandles>>,
12+
) -> Result<(), String> {
13+
apply_tray_menu(&app, &handles, model)
14+
}

crates/agent-gui/src-tauri/src/commands/config/settings/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn now_ms() -> i64 {
55
duration.as_millis() as i64
66
}
77

8-
fn config_dir() -> Result<PathBuf, String> {
8+
pub(crate) fn config_dir() -> Result<PathBuf, String> {
99
let home = dirs::home_dir().ok_or_else(|| "无法定位用户目录".to_string())?;
1010
let dir = home.join(format!(".{}", env!("CARGO_PKG_NAME")));
1111
fs::create_dir_all(&dir).map_err(|e| format!("创建配置目录失败:{e}"))?;

crates/agent-gui/src-tauri/src/commands/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub mod workspace_commands;
1616
pub use app_commands::app;
1717
pub use app_commands::custom_tools;
1818
pub use app_commands::system;
19+
pub use app_commands::tray;
1920
pub use app_commands::update;
2021

2122
pub use automation_commands::cron;

0 commit comments

Comments
 (0)