Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unhealthy icon reminder #665

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions screenpipe-app-tauri/lib/hooks/use-health-check.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState, useEffect, useCallback, useRef } from "react";
import { invoke } from "@tauri-apps/api/core";

interface HealthCheckResponse {
status: string;
Expand Down Expand Up @@ -45,6 +46,18 @@ export function useHealthCheck() {
throw new Error(`http error! status: ${response.status}`);
}
const data: HealthCheckResponse = await response.json();
console.log(data);
if(data.status=="unhealthy"){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use linter

try {
await invoke("set_tray_unhealth_icon");
} catch (error) {
console.error("set unhealthy icon:", error);
};
}else{
await invoke("set_tray_health_icon");
console.log("set healthy icon:" );
}

if (isHealthChanged(healthRef.current, data)) {
setHealth(data);
healthRef.current = data;
Expand All @@ -54,6 +67,7 @@ export function useHealthCheck() {
console.error("health check error:", error);
if (!isServerDown) {
setIsServerDown(true);
await invoke("set_tray_unhealth_icon");
const errorHealth: HealthCheckResponse = {
last_frame_timestamp: null,
last_audio_timestamp: null,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions screenpipe-app-tauri/src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ use serde_json::Value;
use tauri::Manager;
use tracing::info;


#[tauri::command]
pub fn set_tray_unhealth_icon(app_handle: tauri::AppHandle<tauri::Wry>) {

if let Some(main_tray) = app_handle.tray_by_id("screenpipe_main") {
let _ =main_tray.set_icon(Some(tauri::image::Image::from_path("icons/screenpipe-logo-tray-failed.png").unwrap()));
}
}

#[tauri::command]
pub fn set_tray_health_icon(app_handle: tauri::AppHandle<tauri::Wry>) {

if let Some(main_tray) = app_handle.tray_by_id("screenpipe_main") {
let _ =main_tray.set_icon(Some(tauri::image::Image::from_path("icons/screenpipe-logo-tray-black.png").unwrap()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, use linter

}
}

#[cfg(target_os = "macos")]
use core_foundation::{base::TCFType, boolean::CFBoolean, string::CFString};

Expand Down
10 changes: 9 additions & 1 deletion screenpipe-app-tauri/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ mod sidecar;
mod updates;
pub use commands::open_screen_capture_preferences;
pub use commands::reset_all_pipes;
pub use commands::set_tray_unhealth_icon;
pub use commands::set_tray_health_icon;
pub use commands::reset_screen_permissions;
pub use server::spawn_server;
pub use sidecar::kill_all_sreenpipes;
pub use sidecar::spawn_screenpipe;
Expand Down Expand Up @@ -113,6 +116,8 @@ async fn main() {
load_pipe_config,
save_pipe_config,
reset_all_pipes,
set_tray_unhealth_icon,
set_tray_health_icon,
llm_sidecar::start_ollama_sidecar,
llm_sidecar::stop_ollama_sidecar,
commands::update_show_screenpipe_shortcut,
Expand Down Expand Up @@ -261,8 +266,10 @@ async fn main() {
}
_ => {}
});

}


// Store setup and analytics initialization
let store = StoreBuilder::new(app.handle(), path.clone()).build();

Expand Down Expand Up @@ -411,7 +418,8 @@ async fn main() {
})
.build(tauri::generate_context!())
.expect("error while building tauri application");


// set_tray_unhealth_icon(app.app_handle().clone());
app.run(|app_handle, event| match event {
tauri::RunEvent::Ready { .. } => {
debug!("Ready event");
Expand Down
3 changes: 2 additions & 1 deletion screenpipe-app-tauri/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"icons/512x512.png",
"icons/1024x1024.png",
"icons/icon.icns",
"icons/icon.ico"
"icons/icon.ico",
"icons/screenpipe-logo-tray-failed.png"
],
"longDescription": "",
"resources": [
Expand Down
Loading