diff --git a/src/App.tsx b/src/App.tsx index 3995b72..85cd47e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -54,6 +54,10 @@ async function runBackend(action: string, payload: Record): return (await invoke("run_python_action", { action, payload })) as T; } +async function openPath(path: string): Promise { + await invoke("open_path", { path }); +} + function formatTime(ts: number): string { if (!ts) return ""; const d = new Date(ts * 1000); @@ -465,8 +469,15 @@ export default function App() { include_map: includeMap, }); if (result.ok) { - setStatus("Preview PDF ready"); - window.alert(`Preview PDF saved to:\n${result.pdf_path}`); + setStatus("Opening preview PDF..."); + try { + await openPath(result.pdf_path); + setStatus("Preview PDF opened"); + } catch (openErr) { + setStatus("Preview PDF ready"); + console.error(openErr); + window.alert(`Preview PDF saved to:\n${result.pdf_path}\n\nCould not open it automatically.`); + } } else { setStatus("Preview failed"); window.alert(`Preview failed. Log: ${result.log_path}`);