diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 346087c..a210472 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -58,7 +58,10 @@ fn open_status_bubble_window(app: AppHandle) -> Result<(), String> { } #[tauri::command] -fn open_quick_chat_window(app: AppHandle) -> Result<(), String> { +fn open_quick_chat_window( + app: AppHandle, + slot: Option, +) -> Result<(), String> { if let Some(window) = app.get_webview_window("quick-chat") { window.show().map_err(|error| error.to_string())?; window.set_focus().map_err(|error| error.to_string())?; @@ -67,7 +70,15 @@ fn open_quick_chat_window(app: AppHandle) -> Result<(), String> { WebviewWindowBuilder::new( &app, "quick-chat", - WebviewUrl::App("index.html?view=quick".into()), + WebviewUrl::App(match slot { + Some(desktop_protocol::ActiveSlotKind::Companion) => { + "index.html?view=quick&slot=companion".into() + } + Some(desktop_protocol::ActiveSlotKind::Operations) => { + "index.html?view=quick&slot=operations".into() + } + None => "index.html?view=quick".into(), + }), ) .title("AstrBot Quick Chat") .inner_size(420.0, 620.0) @@ -78,6 +89,15 @@ fn open_quick_chat_window(app: AppHandle) -> Result<(), String> { .map_err(|error| error.to_string()) } +#[tauri::command] +fn open_main_window(app: AppHandle) -> Result<(), String> { + let window = app + .get_webview_window("main") + .ok_or_else(|| "main window is unavailable".to_owned())?; + window.show().map_err(|error| error.to_string())?; + window.set_focus().map_err(|error| error.to_string()) +} + #[tauri::command] fn bootstrap_status( database: tauri::State<'_, ApplicationDatabase>, @@ -167,6 +187,7 @@ pub fn run() { .invoke_handler(tauri::generate_handler![ bootstrap_status, open_quick_chat_window, + open_main_window, open_status_bubble_window, connection_policy_status, profiles::list_connection_profiles, diff --git a/src/App.tsx b/src/App.tsx index bc3bd6e..74f8ff9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,4 @@ -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from "@tauri-apps/api/core"; import { useCallback, useEffect, useState } from "react"; import { ChatPanel } from "./features/chat/ChatPanel"; @@ -18,11 +18,21 @@ export function App() { const view = new URLSearchParams(window.location.search).get("view"); const isQuickView = view === "quick"; const isBubbleView = view === "bubble"; + const quickSlot = new URLSearchParams(window.location.search).get("slot"); const [status, setStatus] = useState(initialStatus); const [error, setError] = useState(null); const [chatLayout, setChatLayout] = useState< "single" | "focus-companion" | "focus-operations" >("single"); + const [quickTarget, setQuickTarget] = useState<"companion" | "operations">( + () => + localStorage.getItem("astrbot.quickTarget") === "operations" + ? "operations" + : "companion", + ); + const [bubbleTarget, setBubbleTarget] = useState<"main" | "quick">(() => + localStorage.getItem("astrbot.bubbleTarget") === "quick" ? "quick" : "main", + ); const refreshStatus = useCallback(async () => { try { @@ -42,7 +52,15 @@ export function App() { if (isQuickView) return (
- +
); @@ -82,11 +100,47 @@ export function App() {
+
+ + +
+
???? diff --git a/src/features/chat/StatusBubble.tsx b/src/features/chat/StatusBubble.tsx index 51cfa35..b94f5fa 100644 --- a/src/features/chat/StatusBubble.tsx +++ b/src/features/chat/StatusBubble.tsx @@ -31,7 +31,21 @@ export function StatusBubble() {