Skip to content

Commit 6837286

Browse files
authored
feat: add manual check for updates (#701)
* feat: add check for update * feat: add Check for Updates * docs: update notes * build: build bundle test * docs: update notes * chore: recovering files
1 parent a431ead commit 6837286

20 files changed

Lines changed: 191 additions & 69 deletions

File tree

docs/content.en/docs/release-notes/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Information about release notes of Coco Server is provided here.
1414
### 🚀 Features
1515

1616
- feat: support `Tab` and `Enter` for delete dialog buttons #700
17+
- feat: add check for updates #701
1718

1819
### 🐛 Bug fix
1920

src-tauri/capabilities/default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "../gen/schemas/desktop-schema.json",
33
"identifier": "default",
44
"description": "Capability for the main window",
5-
"windows": ["main", "chat", "settings"],
5+
"windows": ["main", "chat", "settings", "check"],
66
"permissions": [
77
"core:default",
88
"core:event:allow-emit",

src-tauri/src/common/mod.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
pub mod health;
2-
pub mod profile;
3-
pub mod server;
1+
pub mod assistant;
42
pub mod auth;
5-
pub mod datasource;
63
pub mod connector;
7-
pub mod search;
4+
pub mod datasource;
85
pub mod document;
9-
pub mod traits;
10-
pub mod register;
11-
pub mod assistant;
12-
pub mod http;
136
pub mod error;
7+
pub mod health;
8+
pub mod http;
9+
pub mod profile;
10+
pub mod register;
11+
pub mod search;
12+
pub mod server;
13+
pub mod traits;
1414

1515
pub static MAIN_WINDOW_LABEL: &str = "main";
1616
pub static SETTINGS_WINDOW_LABEL: &str = "settings";
17+
pub static CHECK_WINDOW_LABEL: &str = "check";

src-tauri/src/lib.rs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ mod util;
1111

1212
use crate::common::register::SearchSourceRegistry;
1313
// use crate::common::traits::SearchSource;
14-
use crate::common::{MAIN_WINDOW_LABEL, SETTINGS_WINDOW_LABEL};
14+
use crate::common::{CHECK_WINDOW_LABEL, MAIN_WINDOW_LABEL, SETTINGS_WINDOW_LABEL};
1515
use crate::server::servers::{load_or_insert_default_server, load_servers_token};
1616
use autostart::{change_autostart, ensure_autostart_state_consistent};
1717
use lazy_static::lazy_static;
1818
use std::sync::Mutex;
1919
use std::sync::OnceLock;
2020
use tauri::async_runtime::block_on;
2121
use tauri::plugin::TauriPlugin;
22-
use tauri::{
23-
AppHandle, Emitter, Manager, PhysicalPosition, Runtime, WebviewWindow, WindowEvent,
24-
};
22+
use tauri::{AppHandle, Emitter, Manager, PhysicalPosition, Runtime, WebviewWindow, WindowEvent};
2523
use tauri_plugin_autostart::MacosLauncher;
2624

2725
/// Tauri store name
@@ -107,6 +105,8 @@ pub fn run() {
107105
show_coco,
108106
hide_coco,
109107
show_settings,
108+
show_check,
109+
hide_check,
110110
server::servers::get_server_token,
111111
server::servers::add_coco_server,
112112
server::servers::remove_coco_server,
@@ -211,7 +211,13 @@ pub fn run() {
211211

212212
let main_window = app.get_webview_window(MAIN_WINDOW_LABEL).unwrap();
213213
let settings_window = app.get_webview_window(SETTINGS_WINDOW_LABEL).unwrap();
214-
setup::default(app, main_window.clone(), settings_window.clone());
214+
let check_window = app.get_webview_window(CHECK_WINDOW_LABEL).unwrap();
215+
setup::default(
216+
app,
217+
main_window.clone(),
218+
settings_window.clone(),
219+
check_window.clone(),
220+
);
215221

216222
Ok(())
217223
})
@@ -413,6 +419,28 @@ async fn show_settings(app_handle: AppHandle) {
413419
window.set_focus().unwrap();
414420
}
415421

422+
#[tauri::command]
423+
async fn show_check(app_handle: AppHandle) {
424+
log::debug!("check menu item was clicked");
425+
let window = app_handle
426+
.get_webview_window(CHECK_WINDOW_LABEL)
427+
.expect("we have a check window");
428+
429+
window.show().unwrap();
430+
window.unminimize().unwrap();
431+
window.set_focus().unwrap();
432+
}
433+
434+
#[tauri::command]
435+
async fn hide_check(app_handle: AppHandle) {
436+
log::debug!("check window was closed");
437+
let window = &app_handle
438+
.get_webview_window(CHECK_WINDOW_LABEL)
439+
.expect("we have a check window");
440+
441+
window.hide().unwrap();
442+
}
443+
416444
#[tauri::command]
417445
async fn simulate_mouse_click<R: Runtime>(window: WebviewWindow<R>, is_chat_mode: bool) {
418446
#[cfg(target_os = "windows")]

src-tauri/src/setup/linux.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
use tauri::{App, WebviewWindow};
22

3-
pub fn platform(_app: &mut App, _main_window: WebviewWindow, _settings_window: WebviewWindow) {}
3+
pub fn platform(
4+
_app: &mut App,
5+
_main_window: WebviewWindow,
6+
_settings_window: WebviewWindow,
7+
_check_window: WebviewWindow,
8+
) {
9+
}

src-tauri/src/setup/mac.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ const WINDOW_BLUR_EVENT: &str = "tauri://blur";
1212
const WINDOW_MOVED_EVENT: &str = "tauri://move";
1313
const WINDOW_RESIZED_EVENT: &str = "tauri://resize";
1414

15-
pub fn platform(_app: &mut App, main_window: WebviewWindow, _settings_window: WebviewWindow) {
15+
pub fn platform(
16+
_app: &mut App,
17+
main_window: WebviewWindow,
18+
_settings_window: WebviewWindow,
19+
_check_window: WebviewWindow,
20+
) {
1621
// Convert ns_window to ns_panel
1722
let panel = main_window.to_panel().unwrap();
1823

src-tauri/src/setup/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,20 @@ pub use windows::*;
1818
#[cfg(target_os = "linux")]
1919
pub use linux::*;
2020

21-
pub fn default(app: &mut App, main_window: WebviewWindow, settings_window: WebviewWindow) {
21+
pub fn default(
22+
app: &mut App,
23+
main_window: WebviewWindow,
24+
settings_window: WebviewWindow,
25+
check_window: WebviewWindow,
26+
) {
2227
// Development mode automatically opens the console: https://tauri.app/develop/debug
2328
#[cfg(debug_assertions)]
2429
main_window.open_devtools();
2530

26-
platform(app, main_window.clone(), settings_window.clone());
31+
platform(
32+
app,
33+
main_window.clone(),
34+
settings_window.clone(),
35+
check_window.clone(),
36+
);
2737
}

src-tauri/src/setup/windows.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
use tauri::{App, WebviewWindow};
22

3-
pub fn platform(_app: &mut App, _main_window: WebviewWindow, _settings_window: WebviewWindow) {}
3+
pub fn platform(
4+
_app: &mut App,
5+
_main_window: WebviewWindow,
6+
_settings_window: WebviewWindow,
7+
_check_window: WebviewWindow,
8+
) {
9+
}

src-tauri/tauri.conf.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
"title": "Coco AI Settings",
4242
"url": "/ui/settings",
4343
"width": 1000,
44+
"minWidth": 1000,
4445
"height": 700,
4546
"minHeight": 700,
46-
"minWidth": 1000,
4747
"center": true,
4848
"transparent": true,
4949
"maximizable": false,
@@ -55,6 +55,26 @@
5555
"effects": ["sidebar"],
5656
"state": "active"
5757
}
58+
},
59+
{
60+
"label": "check",
61+
"title": "Coco AI Update",
62+
"url": "/ui/check",
63+
"width": 340,
64+
"minWidth": 340,
65+
"height": 260,
66+
"minHeight": 260,
67+
"center": false,
68+
"transparent": true,
69+
"maximizable": false,
70+
"skipTaskbar": false,
71+
"dragDropEnabled": false,
72+
"hiddenTitle": true,
73+
"visible": false,
74+
"windowEffects": {
75+
"effects": ["sidebar"],
76+
"state": "active"
77+
}
5878
}
5979
],
6080
"security": {
File renamed without changes.

0 commit comments

Comments
 (0)