Skip to content

Commit 277f009

Browse files
authored
feat(linux): Quick Chat floating composer for the Tauri companion (#109947)
* feat(linux): add Quick Chat floating composer to the Tauri companion - frameless transparent always-on-top quickchat window (on-demand, canvas pattern), positioned top-third on the cursor monitor, CSS fade+zoom in/out - global shortcut Ctrl+Shift+Space on X11 (GNOME reserves Alt+Space); tray 'Quick Chat' item is the Wayland entry point; blur/Esc/close-request hide - sends via the CLI agent turn with --message-file staged 0600 (argv is world-readable procfs) and cleaned up after the turn; failures surface as desktop notifications; Ctrl+Enter also opens the dashboard - default-agent identity chip (emoji/monogram) from agents list --json, 60s cache - window-scoped capability + permission set; window-state denylist; docs * chore(linux): register quickchat.js as a knip native-asset entry
1 parent de03430 commit 277f009

11 files changed

Lines changed: 901 additions & 4 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[[permission]]
2+
identifier = "allow-quickchat"
3+
description = "Enables Quick Chat identity, send, hide, and dashboard commands."
4+
commands.allow = [
5+
"quickchat_hide",
6+
"quickchat_identity",
7+
"quickchat_ready",
8+
"quickchat_send",
9+
"quickchat_show_dashboard",
10+
]

‎apps/linux/src-tauri/src/main.rs‎

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod gateway;
66
mod installer;
77
mod notify;
88
mod pending_approvals;
9+
mod quickchat;
910
mod tray;
1011
mod updater;
1112

@@ -19,6 +20,7 @@ use std::thread;
1920
use std::time::Duration;
2021
use tauri::{AppHandle, Manager, State, Url, WebviewWindow};
2122
use tauri_plugin_deep_link::DeepLinkExt;
23+
use tauri_plugin_global_shortcut::{Code, Modifiers};
2224

2325
const CONNECTED_WATCH_INTERVAL: Duration = Duration::from_secs(15);
2426
const RECONNECT_INTERVAL: Duration = Duration::from_secs(3);
@@ -277,7 +279,7 @@ impl DesktopState {
277279
self.inner.quitting.load(Ordering::SeqCst)
278280
}
279281

280-
fn resolve_cli(&self) -> Result<OpenClawCli, CliError> {
282+
pub(crate) fn resolve_cli(&self) -> Result<OpenClawCli, CliError> {
281283
if let Some(cli) = self.inner.cli.lock().expect("CLI mutex poisoned").clone() {
282284
return Ok(cli);
283285
}
@@ -676,9 +678,15 @@ fn main() {
676678
let builder = if global_shortcuts_supported {
677679
builder.plugin(
678680
tauri_plugin_global_shortcut::Builder::new()
679-
.with_handler(|app, _shortcut, event| {
681+
.with_handler(|app, shortcut, event| {
680682
if event.state == tauri_plugin_global_shortcut::ShortcutState::Pressed {
681-
tray::show_window(app);
683+
if shortcut.matches(Modifiers::CONTROL | Modifiers::SHIFT, Code::Space) {
684+
quickchat::toggle_quickchat(app);
685+
} else if shortcut
686+
.matches(Modifiers::CONTROL | Modifiers::SHIFT, Code::KeyO)
687+
{
688+
tray::show_window(app);
689+
}
682690
}
683691
})
684692
.build(),
@@ -692,7 +700,7 @@ fn main() {
692700
.plugin(tauri_plugin_process::init())
693701
.plugin(
694702
tauri_plugin_window_state::Builder::default()
695-
.with_denylist(&["canvas"])
703+
.with_denylist(&["canvas", quickchat::QUICKCHAT_LABEL])
696704
.build(),
697705
);
698706
#[cfg(target_os = "linux")]
@@ -717,6 +725,7 @@ fn main() {
717725
}
718726

719727
app.manage(discovery::GatewayDiscovery::default());
728+
app.manage(quickchat::QuickChatState::default());
720729
app.manage(updater::UpdaterState::default());
721730
#[cfg(target_os = "linux")]
722731
match canvas::CanvasBridge::start(app.handle().clone()) {
@@ -738,6 +747,11 @@ fn main() {
738747
discovery::discover_gateways,
739748
install_cli,
740749
gateway_action,
750+
quickchat::quickchat_hide,
751+
quickchat::quickchat_identity,
752+
quickchat::quickchat_ready,
753+
quickchat::quickchat_send,
754+
quickchat::quickchat_show_dashboard,
741755
updater::open_release_page,
742756
updater::relaunch,
743757
updater::updater_ready
@@ -751,13 +765,32 @@ fn main() {
751765
discovery::discover_gateways,
752766
install_cli,
753767
gateway_action,
768+
quickchat::quickchat_hide,
769+
quickchat::quickchat_identity,
770+
quickchat::quickchat_ready,
771+
quickchat::quickchat_send,
772+
quickchat::quickchat_show_dashboard,
754773
updater::open_release_page,
755774
updater::relaunch,
756775
updater::updater_ready
757776
]);
758777

759778
let app = builder
760779
.on_window_event(|window, event| {
780+
if window.label() == quickchat::QUICKCHAT_LABEL {
781+
match event {
782+
tauri::WindowEvent::Focused(false) => {
783+
quickchat::request_hide(window.app_handle());
784+
return;
785+
}
786+
tauri::WindowEvent::CloseRequested { api, .. } => {
787+
api.prevent_close();
788+
quickchat::request_hide(window.app_handle());
789+
return;
790+
}
791+
_ => {}
792+
}
793+
}
761794
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
762795
let state = window.app_handle().state::<DesktopState>();
763796
if !state.is_quitting() {

0 commit comments

Comments
 (0)