Skip to content

Commit

Permalink
release-app fix tray menu change for windows when unhealthy
Browse files Browse the repository at this point in the history
  • Loading branch information
louis030195 committed Jan 7, 2025
1 parent 6874e4c commit 973776d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
18 changes: 15 additions & 3 deletions screenpipe-app-tauri/components/pipe-store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ const PipeStore: React.FC = () => {
const { getDataDir } = useSettings();
const { user, refreshUser } = useUser();
const [showCreditDialog, setShowCreditDialog] = useState(false);
const [isEnabling, setIsEnabling] = useState(false);

useEffect(() => {
fetchInstalledPipes();
Expand Down Expand Up @@ -399,6 +400,11 @@ const PipeStore: React.FC = () => {

const handleToggleEnabled = async (pipe: Pipe) => {
try {
// Set loading state when enabling
if (!pipe.enabled) {
setIsEnabling(true);
}

const corePipe = corePipes.find((cp) => cp.id === pipe.id);
console.log("attempting to toggle pipe:", {
pipeId: pipe.id,
Expand Down Expand Up @@ -498,7 +504,8 @@ const PipeStore: React.FC = () => {
throw new Error(data.error);
}

await new Promise((resolve) => setTimeout(resolve, 1000));
// Wait for pipe to initialize
await new Promise((resolve) => setTimeout(resolve, 3000));
const freshPipes = await fetchInstalledPipes();
await new Promise((resolve) => setTimeout(resolve, 1000));

Expand All @@ -520,6 +527,9 @@ const PipeStore: React.FC = () => {
description: "please try again or check the logs for more information.",
variant: "destructive",
});
} finally {
// Reset loading state
setIsEnabling(false);
}
};

Expand Down Expand Up @@ -969,9 +979,10 @@ const PipeStore: React.FC = () => {
`http://localhost:${selectedPipe.config!.port}`
)
}
disabled={isEnabling}
>
<ExternalLink className="mr-2 h-3.5 w-3.5" />
open in browser
{isEnabling ? "initializing..." : "open in browser"}
</Button>
<Button
variant="default"
Expand All @@ -990,9 +1001,10 @@ const PipeStore: React.FC = () => {
});
}
}}
disabled={isEnabling}
>
<Puzzle className="mr-2 h-3.5 w-3.5" />
open as app
{isEnabling ? "initializing..." : "open as app"}
</Button>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions screenpipe-app-tauri/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion screenpipe-app-tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
version = "0.22.8"
version = "0.22.9"
description = ""
authors = ["you"]
license = ""
Expand Down
1 change: 1 addition & 0 deletions screenpipe-app-tauri/src-tauri/src/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ async fn check_health(client: &reqwest::Client) -> Result<HealthCheckResponse> {
.get("http://localhost:3030/health")
.header("Cache-Control", "no-cache")
.header("Pragma", "no-cache")
.timeout(Duration::from_secs(5)) // on windows it never times out
.send()
.await?;

Expand Down
17 changes: 7 additions & 10 deletions screenpipe-app-tauri/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,16 +881,13 @@ async fn main() {
let server_shutdown_tx = spawn_server(app.handle().clone(), 11435);
app.manage(server_shutdown_tx);

// Start health check service, only on macos since it's crashing on windows
#[cfg(target_os = "macos")]
{
let app_handle = app.handle().clone();
tauri::async_runtime::spawn(async move {
if let Err(e) = start_health_check(app_handle).await {
error!("Failed to start health check service: {}", e);
}
});
}
// Start health check service
let app_handle = app.handle().clone();
tauri::async_runtime::spawn(async move {
if let Err(e) = start_health_check(app_handle).await {
error!("Failed to start health check service: {}", e);
}
});

#[cfg(target_os = "macos")]
app.set_activation_policy(tauri::ActivationPolicy::Regular);
Expand Down

0 comments on commit 973776d

Please sign in to comment.