Add Docker install helper for first-run setup
When Docker isn't detected on startup, surface a dialog offering a one-click install (pkexec + get.docker.com on Linux, brew cask on macOS, winget on Windows) with a graceful fallback to manual steps and a link to official documentation. Install output streams back to the UI via a tauri event. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
35
app/src/hooks/useInstallHelper.ts
Normal file
35
app/src/hooks/useInstallHelper.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { useCallback, useState } from "react";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import * as commands from "../lib/tauri-commands";
|
||||
import type { InstallOptions } from "../lib/types";
|
||||
|
||||
export function useInstallHelper() {
|
||||
const [options, setOptions] = useState<InstallOptions | null>(null);
|
||||
|
||||
const loadOptions = useCallback(async () => {
|
||||
try {
|
||||
const opts = await commands.detectInstallOptions();
|
||||
setOptions(opts);
|
||||
return opts;
|
||||
} catch {
|
||||
setOptions(null);
|
||||
return null;
|
||||
}
|
||||
}, []);
|
||||
|
||||
const runInstall = useCallback(
|
||||
async (onProgress?: (line: string) => void) => {
|
||||
const unlisten = onProgress
|
||||
? await listen<string>("docker-install-progress", (e) => onProgress(e.payload))
|
||||
: null;
|
||||
try {
|
||||
await commands.runDockerInstall();
|
||||
} finally {
|
||||
unlisten?.();
|
||||
}
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
return { options, loadOptions, runInstall };
|
||||
}
|
||||
Reference in New Issue
Block a user