Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript

feat: replace native app dialogs

nash_suab1a776d6366
diff --git a/src/App.tsx b/src/App.tsx
index bb020152..071e8dd9 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -19,12 +19,14 @@ import { AppLayout } from "@/components/layout/app-layout"
import { WelcomeScreen } from "@/components/project/welcome-screen"
import { CreateProjectDialog } from "@/components/project/create-project-dialog"
import type { WikiProject } from "@/types/wiki"
+import { useAppDialog } from "@/stores/app-dialog-store"
function applyDocumentZoom(level: number) {
document.documentElement.style.fontSize = `${BASE_FONT_SIZE_PX * level}px`
}
function App() {
+ const appDialog = useAppDialog()
const project = useWikiStore((s) => s.project)
const setProject = useWikiStore((s) => s.setProject)
const setFileTree = useWikiStore((s) => s.setFileTree)
@@ -566,7 +568,7 @@ function App() {
const validated = await openProject(proj.path)
await handleProjectOpened(validated)
} catch (err) {
- window.alert(`Failed to open project: ${err}`)
+ await appDialog.alert({ message: `Failed to open project: ${err}` })
}
}
@@ -581,7 +583,7 @@ function App() {
const proj = await openProject(selected)
await handleProjectOpened(proj)
} catch (err) {
- window.alert(`Failed to open project: ${err}`)
+ await appDialog.alert({ message: `Failed to open project: ${err}` })
}
}
diff --git a/src/components/app-dialog-host.tsx b/src/components/app-dialog-host.tsx
new file mode 100644
index 00000000..39976cec
--- /dev/null
+++ b/src/components/app-dialog-host.tsx
@@ -0,0 +1,55 @@
+import { useTranslation } from "react-i18next"
+import { Button } from "@/components/ui/button"
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/ui/dialog"
+import { useAppDialogStore } from "@/stores/app-dialog-store"
+
+export function AppDialogHost() {
+ const { t } = useTranslation()
+ const current = useAppDialogStore((state) => state.current)
+ const settle = useAppDialogStore((state) => state.settle)
+
+ if (!current) return null
+
+ const destructive = current.variant === "destructive"
+ return (
+ <Dialog
+ key={current.id}
+ open
+ onOpenChange={(open) => {
+ if (!open) settle(false)
+ }}
+ >
+ <DialogContent showCloseButton={false}>
+ <DialogHeader>
+ <DialogTitle>
+ {current.title ?? t(current.kind === "confirm" ? "common.confirm" : "common.notice")}
+ </DialogTitle>
+ <DialogDescription className="whitespace-pre-wrap break-words">
+ {current.message}
+ </DialogDescription>
+ </DialogHeader>
+ <DialogFooter>
+ {current.kind === "confirm" && (
+ <Button variant="outline" onClick={() => settle(false)}>
+ {current.cancelLabel ?? t("common.cancel")}
+ </Button>
+ )}
+ <Button
+ variant={destructive ? "destructive" : "default"}
+ onClick={() => settle(true)}
+ autoFocus
+ >
+ {current.confirmLabel ?? t("common.ok")}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/src/components/layout/activity-panel.tsx b/src/components/layout/activity-panel.tsx
index 44844fb5..f38fd951 100644
--- a/src/components/layout/activity-panel.tsx
+++ b/src/components/layout/activity-panel.tsx
@@ -6,6 +6,7 @@ import {
ArrowUp, ArrowDown,
} from "lucide-react"
import { useTranslation } from "react-i18next"
+import { useAppDialog } from "@/stores/app-dialog-store"
import { useActivityStore, type ActivityItem } from "@/stores/activity-store"
import { useWikiStore } from "@/stores/wiki-store"
import { useFileSyncStore } from "@/stores/file-sync-store"
@@ -78,6 +79,7 @@ function getFileTypeInfo(path: string): { icon: typeof FileText; typeKey: string
export function ActivityPanel() {
const { t } = useTranslation()
+ const appDialog = useAppDialog()
const items = useActivityStore((s) => s.items)
const clearDone = useActivityStore((s) => s.clearDone)
const project = useWikiStore((s) => s.project)
@@ -172,13 +174,16 @@ export function ActivityPanel() {
cancelTask(taskId)
}, [project])
- const handleCancelAll = useCallback(() => {
+ const handleCancelAll = useCallback(async () => {
if (!project) return
const activeCount = queueSummary.pending + queueSummary.processing
if (activeCount === 0) return
- if (!window.confirm(t("activity.cancelAllConfirm", { count: activeCount }))) return
+ if (!(await appDialog.confirm({
+ message: t("activity.cancelAllConfirm", { count: activeCount }),
+ variant: "destructive",
+ }))) return
cancelAllTasks()
- }, [project, queueSummary.pending, queueSummary.processing, t])
+ }, [appDialog, project, queueSummary.pending, queueSummary.processing, t])
const handleTogglePause = useCallback(() => {
if (!project) return
diff --git a/src/components/layout/knowledge-tree.tsx b/src/components/layout/knowledge-tree.tsx
index fd780b81..6b79f7d3 100644
--- a/src/components/layout/knowledge-tree.tsx
+++ b/src/components/layout/knowledge-tree.tsx
@@ -13,6 +13,7 @@ import { cascadeDeleteWikiPagesWithRefs } from "@/lib/wiki-page-delete"
import { inferWikiTypeFromPath, wikiTypeLabel } from "@/lib/wiki-page-types"
import { filterRawSourceTree } from "@/lib/source-filter"
import { useTranslation } from "react-i18next"
+import { useAppDialog } from "@/stores/app-dialog-store"
interface WikiPageInfo {
path: string
@@ -41,6 +42,7 @@ function typeConfig(type: string): { icon: typeof FileText; label: string; color
export function KnowledgeTree() {
const { t } = useTranslation()
+ const appDialog = useAppDialog()
const project = useWikiStore((s) => s.project)
const selectedFile = useWikiStore((s) => s.selectedFile)
const setSelectedFile = useWikiStore((s) => s.setSelectedFile)
@@ -117,12 +119,12 @@ export function KnowledgeTree() {
if (selectedFile === pagePath) setSelectedFile(null)
} catch (err) {
console.error("[KnowledgeTree] delete failed:", err)
- window.alert(`Failed to delete: ${err}`)
+ await appDialog.alert({ message: `Failed to delete: ${err}` })
} finally {
setDeletingPath(null)
}
},
- [project, armedPath, loadPages, selectedFile, setSelectedFile],
+ [appDialog, project, armedPath, loadPages, selectedFile, setSelectedFile],
)
if (!project) {
diff --git a/src/components/layout/research-panel.tsx b/src/components/layout/research-panel.tsx
index 5b15407a..be8b7435 100644
--- a/src/components/layout/research-panel.tsx
+++ b/src/components/layout/research-panel.tsx
@@ -20,9 +20,11 @@ import { detectLanguage } from "@/lib/detect-language"
import { getHtmlLang, getTextDirection } from "@/lib/language-metadata"
import { MermaidDiagram, unwrapMermaidPre } from "@/components/mermaid-diagram"
import { useTranslation } from "react-i18next"
+import { useAppDialog } from "@/stores/app-dialog-store"
export function ResearchPanel() {
const { t } = useTranslation()
+ const appDialog = useAppDialog()
const tasks = useResearchStore((s) => s.tasks)
const removeTask = useResearchStore((s) => s.removeTask)
const setPanelOpen = useResearchStore((s) => s.setPanelOpen)
@@ -35,21 +37,21 @@ export function ResearchPanel() {
const queued = tasks.filter((t) => t.status === "queued")
const done = tasks.filter((t) => t.status === "done" || t.status === "error")
- function handleStartResearch() {
+ async function handleStartResearch() {
const topic = inputValue.trim()
if (!topic || !project) return
if (!hasConfiguredDeepResearchSources(searchApiConfig)) {
- window.alert(t("research.notConfigured"))
+ await appDialog.alert({ message: t("research.notConfigured") })
return
}
queueResearch(normalizePath(project.path), topic, llmConfig, searchApiConfig)
setInputValue("")
}
- function handleRetryResearch(task: ResearchTask) {
+ async function handleRetryResearch(task: ResearchTask) {
if (!project) return
if (!hasConfiguredDeepResearchSources(searchApiConfig)) {
- window.alert(t("research.notConfigured"))
+ await appDialog.alert({ message: t("research.notConfigured") })
return
}
queueResearch(
diff --git a/src/components/lint/lint-view.tsx b/src/components/lint/lint-view.tsx
index 918656ff..a573cdbb 100644
--- a/src/components/lint/lint-view.tsx
+++ b/src/components/lint/lint-view.tsx
@@ -27,6 +27,7 @@ import {
rewriteWikilinkTarget,
} from "@/lib/lint-fixes"
import { useTranslation } from "react-i18next"
+import { useAppDialog } from "@/stores/app-dialog-store"
export function groupLintResultsForDisplay(results: readonly LintItem[]): {
warnings: LintItem[]
@@ -52,6 +53,7 @@ export function shouldShowLintResults(hasRun: boolean, itemCount: number): boole
export function LintView() {
const { t } = useTranslation()
+ const appDialog = useAppDialog()
const project = useWikiStore((s) => s.project)
const llmConfig = useWikiStore((s) => s.llmConfig)
const openFileInPreview = useWikiStore((s) => s.openFileInPreview)
@@ -255,7 +257,10 @@ export function LintView() {
if (!project) return
const pp = normalizePath(project.path)
const pagePath = `${pp}/wiki/${item.page}`
- const confirmed = window.confirm(t("lint.deleteOrphanConfirm", { page: item.page }))
+ const confirmed = await appDialog.confirm({
+ message: t("lint.deleteOrphanConfirm", { page: item.page }),
+ variant: "destructive",
+ })
if (!confirmed) return
try {
diff --git a/src/components/review/review-view.tsx b/src/components/review/review-view.tsx
index 93fd27a5..8a25ed44 100644
--- a/src/components/review/review-view.tsx
+++ b/src/components/review/review-view.tsx
@@ -23,6 +23,7 @@ import { makeQueryFileName } from "@/lib/wiki-filename"
import { createReviewPageDrafts } from "@/lib/review-create-page"
import { cleanAssistantContentForWikiSave, titleFromCleanAssistantContent } from "@/lib/chat-save-to-wiki"
import { useTranslation } from "react-i18next"
+import { useAppDialog } from "@/stores/app-dialog-store"
import { useResearchStore } from "@/stores/research-store"
const typeConfig: Record<ReviewItem["type"], { icon: typeof AlertTriangle; color: string }> = {
@@ -35,6 +36,7 @@ const typeConfig: Record<ReviewItem["type"], { icon: typeof AlertTriangle; color
export function ReviewView() {
const { t } = useTranslation()
+ const appDialog = useAppDialog()
const items = useReviewStore((s) => s.items)
const resolveItem = useReviewStore((s) => s.resolveItem)
const dismissItem = useReviewStore((s) => s.dismissItem)
@@ -70,7 +72,7 @@ export function ReviewView() {
if (action === "__deep_research__" && project) {
const searchConfig = useWikiStore.getState().searchApiConfig
if (!hasConfiguredDeepResearchSources(searchConfig)) {
- window.alert(t("research.notConfigured"))
+ await appDialog.alert({ message: t("research.notConfigured") })
return
}
if (item) {
@@ -260,7 +262,7 @@ export function ReviewView() {
} else {
resolveItem(id, action)
}
- }, [project, items, resolveItem])
+ }, [appDialog, project, items, resolveItem, t])
const pending = items.filter((i) => !i.resolved)
const resolved = items.filter((i) => i.resolved)
diff --git a/src/components/settings/sections/about-section.tsx b/src/components/settings/sections/about-section.tsx
index a93a30a7..eb43f903 100644
--- a/src/components/settings/sections/about-section.tsx
+++ b/src/components/settings/sections/about-section.tsx
@@ -8,6 +8,7 @@ import { API_SERVER_HEALTH_URL, API_SERVER_PORT } from "@/lib/api-server-constan
import { useUpdateStore, hasAvailableUpdate } from "@/stores/update-store"
import { checkForUpdates, toLatestReleaseUrl } from "@/lib/update-check"
import { saveUpdateCheckState } from "@/lib/project-store"
+import { useAppDialog } from "@/stores/app-dialog-store"
interface ApiHealth {
enabled?: boolean
@@ -251,6 +252,7 @@ function UpdateAvailableBanner({
onDismiss,
}: UpdateAvailableBannerProps) {
const { t } = useTranslation()
+ const appDialog = useAppDialog()
// Use `/releases/latest` (canonical GitHub redirect to the newest
// release) rather than the tag-specific URL from the release
// payload. Same rationale as in the top banner — see
@@ -273,11 +275,11 @@ function UpdateAvailableBanner({
console.error("[update-banner] openUrl failed:", err)
try {
await navigator.clipboard.writeText(targetUrl)
- // eslint-disable-next-line no-alert
- alert(`Could not open browser. URL copied to clipboard:\n${targetUrl}`)
+ await appDialog.alert({
+ message: `Could not open browser. URL copied to clipboard:\n${targetUrl}`,
+ })
} catch {
- // eslint-disable-next-line no-alert
- alert(`Could not open browser. Visit:\n${targetUrl}`)
+ await appDialog.alert({ message: `Could not open browser. Visit:\n${targetUrl}` })
}
}
}
diff --git a/src/components/settings/sections/maintenance-section.tsx b/src/components/settings/sections/maintenance-section.tsx
index 95c0935a..609d87d5 100644
--- a/src/components/settings/sections/maintenance-section.tsx
+++ b/src/components/settings/sections/maintenance-section.tsx
@@ -1,5 +1,6 @@
import { useCallback, useEffect, useMemo, useState } from "react"
import { useTranslation } from "react-i18next"
+import { useAppDialog } from "@/stores/app-dialog-store"
import { invoke } from "@tauri-apps/api/core"
import { open, save } from "@tauri-apps/plugin-dialog"
import {
@@ -62,6 +63,7 @@ function findTaskForGroup(
export function MaintenanceSection() {
const { t } = useTranslation()
+ const appDialog = useAppDialog()
const llmConfig = useWikiStore((s) => s.llmConfig)
const project = useWikiStore((s) => s.project)
@@ -143,7 +145,10 @@ export function MaintenanceSection() {
const commitHistoryRetention = useCallback(async (value: number) => {
if (!historySettings) return
- if (value === 0 && !window.confirm(t("settings.sections.maintenance.history.zeroConfirm"))) {
+ if (value === 0 && !(await appDialog.confirm({
+ message: t("settings.sections.maintenance.history.zeroConfirm"),
+ variant: "destructive",
+ }))) {
if (project) {
const projectPath = project.path
try {
@@ -164,10 +169,13 @@ export function MaintenanceSection() {
enabled: value === 0 ? false : historySettings.enabled,
maxVersionsPerFile: value,
})
- }, [historySettings, project, t, updateHistorySettings])
+ }, [appDialog, historySettings, project, t, updateHistorySettings])
const handleClearHistory = useCallback(async () => {
- if (!project || !window.confirm(t("settings.sections.maintenance.history.confirm"))) return
+ if (!project || !(await appDialog.confirm({
+ message: t("settings.sections.maintenance.history.confirm"),
+ variant: "destructive",
+ }))) return
const projectPath = project.path
setHistoryBusy(true)
try {
@@ -184,7 +192,7 @@ export function MaintenanceSection() {
setHistoryBusy(false)
}
}
- }, [project, t])
+ }, [appDialog, project, t])
const handleRebuildIndex = useCallback(async () => {
if (!project) return
diff --git a/src/components/sources/sources-view.tsx b/src/components/sources/sources-view.tsx
index 135a5134..60a4bb0d 100644
--- a/src/components/sources/sources-view.tsx
+++ b/src/components/sources/sources-view.tsx
@@ -9,6 +9,7 @@ import { useWikiStore } from "@/stores/wiki-store"
import { listDirectory, openPathInProject, readFile } from "@/commands/fs"
import type { FileNode } from "@/types/wiki"
import { useTranslation } from "react-i18next"
+import { useAppDialog } from "@/stores/app-dialog-store"
import { normalizePath } from "@/lib/path-utils"
import { decideDeleteClick } from "@/lib/sources-tree-delete"
import { rescanProjectFileSync } from "@/lib/project-file-sync"
@@ -33,6 +34,7 @@ type SourceIngestStatus = "not-ingested" | "ingested" | IngestTask["status"]
export function SourcesView() {
const { t } = useTranslation()
+ const appDialog = useAppDialog()
const project = useWikiStore((s) => s.project)
const selectedFile = useWikiStore((s) => s.selectedFile)
const setSelectedFile = useWikiStore((s) => s.setSelectedFile)
@@ -268,10 +270,10 @@ export function SourcesView() {
await openPathInProject(project.path, node.path)
} catch (err) {
console.error("Failed to open source externally:", err)
- window.alert(t("sources.openExternalFailed", {
+ await appDialog.alert({ message: t("sources.openExternalFailed", {
name: node.name,
error: String(err),
- }))
+ }) })
}
}
@@ -299,7 +301,7 @@ export function SourcesView() {
}
} catch (err) {
console.error("Failed to delete source:", err)
- window.alert(`Failed to delete: ${err}`)
+ await appDialog.alert({ message: `Failed to delete: ${err}` })
}
}
@@ -335,7 +337,7 @@ export function SourcesView() {
}
} catch (err) {
console.error("Failed to delete folder:", err)
- window.alert(`Failed to delete folder: ${err}`)
+ await appDialog.alert({ message: `Failed to delete folder: ${err}` })
}
}
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 04d3da5c..57fe1448 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -4,7 +4,7 @@
"subtitle": "Build and maintain your personal knowledge base with LLMs"
},
"common": {
- "retry": "Retry", "cancel": "Cancel", "ignore": "Ignore", "close": "Close",
+ "retry": "Retry", "cancel": "Cancel", "ignore": "Ignore", "close": "Close", "ok": "OK", "confirm": "Confirm", "notice": "Notice",
"dismiss": "Dismiss", "loading": "Loading...", "optional": "optional"
},
"layout": { "showSidebar": "Show sidebar", "hideSidebar": "Hide sidebar" },
diff --git a/src/i18n/it.json b/src/i18n/it.json
index 794a11e6..f9da4cef 100644
--- a/src/i18n/it.json
+++ b/src/i18n/it.json
@@ -4,7 +4,7 @@
"subtitle": "Costruisci e mantieni la tua knowledge base personale con gli LLM"
},
"common": {
- "retry": "Riprova", "cancel": "Annulla", "ignore": "Ignora", "close": "Chiudi",
+ "retry": "Riprova", "cancel": "Annulla", "ignore": "Ignora", "close": "Chiudi", "ok": "OK", "confirm": "Conferma", "notice": "Avviso",
"dismiss": "Nascondi", "loading": "Caricamento...", "optional": "opzionale"
},
"layout": { "showSidebar": "Mostra la barra laterale", "hideSidebar": "Nascondi la barra laterale" },
diff --git a/src/i18n/ru.json b/src/i18n/ru.json
index 47ec674e..915f41ce 100644
--- a/src/i18n/ru.json
+++ b/src/i18n/ru.json
@@ -4,7 +4,7 @@
"subtitle": "Создавайте и поддерживайте личную базу знаний с помощью LLM"
},
"common": {
- "retry": "Попробовать снова", "cancel": "Отмена", "ignore": "Игнорировать", "close": "Закрыть",
+ "retry": "Попробовать снова", "cancel": "Отмена", "ignore": "Игнорировать", "close": "Закрыть", "ok": "ОК", "confirm": "Подтверждение", "notice": "Уведомление",
"dismiss": "Скрыть", "loading": "Загрузка...", "optional": "необязательно"
},
"layout": { "showSidebar": "Показать боковую панель", "hideSidebar": "Скрыть боковую панель" },
diff --git a/src/i18n/zh.json b/src/i18n/zh.json
index 60aa858c..5cf2c0fd 100644
--- a/src/i18n/zh.json
+++ b/src/i18n/zh.json
@@ -4,7 +4,7 @@
"subtitle": "用 LLM 构建和维护你的个人知识库"
},
"common": {
- "retry": "重试", "cancel": "取消", "ignore": "忽略", "close": "关闭",
+ "retry": "重试", "cancel": "取消", "ignore": "忽略", "close": "关闭", "ok": "确定", "confirm": "确认", "notice": "提示",
"dismiss": "关闭", "loading": "加载中……", "optional": "可选"
},
"layout": { "showSidebar": "展开侧栏", "hideSidebar": "收起侧栏" },
diff --git a/src/main.tsx b/src/main.tsx
index 9425bcf6..96cd865b 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -4,6 +4,7 @@ import App from "./App";
import "./index.css";
import "@/i18n";
import { loadAndApplyTheme, watchSystemTheme } from "@/lib/theme";
+import { AppDialogHost } from "@/components/app-dialog-host";
function applyPlatformClass() {
const isTauri = "__TAURI_INTERNALS__" in window || "__TAURI__" in window;
@@ -22,6 +23,7 @@ async function initApp() {
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<App />
+ <AppDialogHost />
</React.StrictMode>
);
} catch (err) {
diff --git a/src/stores/app-dialog-store.test.ts b/src/stores/app-dialog-store.test.ts
new file mode 100644
index 00000000..08e381ee
--- /dev/null
+++ b/src/stores/app-dialog-store.test.ts
@@ -0,0 +1,32 @@
+import { beforeEach, describe, expect, it } from "vitest"
+import { useAppDialog, useAppDialogStore } from "./app-dialog-store"
+
+describe("app dialog store", () => {
+ beforeEach(() => {
+ useAppDialogStore.setState({ current: null, queue: [] })
+ })
+
+ it("queues dialogs and resolves them in order", async () => {
+ const dialogs = useAppDialog()
+ const first = dialogs.confirm({ message: "first" })
+ const second = dialogs.confirm({ message: "second" })
+
+ expect(useAppDialogStore.getState().current?.message).toBe("first")
+ expect(useAppDialogStore.getState().queue).toHaveLength(1)
+
+ useAppDialogStore.getState().settle(true)
+ await expect(first).resolves.toBe(true)
+ expect(useAppDialogStore.getState().current?.message).toBe("second")
+
+ useAppDialogStore.getState().settle(false)
+ await expect(second).resolves.toBe(false)
+ expect(useAppDialogStore.getState().current).toBeNull()
+ })
+
+ it("resolves alerts after dismissal", async () => {
+ const pending = useAppDialog().alert({ message: "notice" })
+ useAppDialogStore.getState().settle(false)
+ await expect(pending).resolves.toBeUndefined()
+ })
+})
+
diff --git a/src/stores/app-dialog-store.ts b/src/stores/app-dialog-store.ts
new file mode 100644
index 00000000..01fde187
--- /dev/null
+++ b/src/stores/app-dialog-store.ts
@@ -0,0 +1,71 @@
+import { create } from "zustand"
+
+export type AppDialogVariant = "default" | "destructive"
+
+export interface AppDialogOptions {
+ title?: string
+ message: string
+ confirmLabel?: string
+ cancelLabel?: string
+ variant?: AppDialogVariant
+}
+
+interface DialogRequest extends AppDialogOptions {
+ id: number
+ kind: "alert" | "confirm"
+ resolve: (value: boolean) => void
+}
+
+interface AppDialogState {
+ current: DialogRequest | null
+ queue: DialogRequest[]
+ enqueue: (request: DialogRequest) => void
+ settle: (value: boolean) => void
+}
+
+export const useAppDialogStore = create<AppDialogState>((set, get) => ({
+ current: null,
+ queue: [],
+ enqueue: (request) => {
+ if (!get().current) {
+ set({ current: request })
+ return
+ }
+ set((state) => ({ queue: [...state.queue, request] }))
+ },
+ settle: (value) => {
+ const { current, queue } = get()
+ if (!current) return
+ const [next, ...rest] = queue
+ set({ current: next ?? null, queue: rest })
+ current.resolve(value)
+ },
+}))
+
+let nextDialogId = 1
+
+function enqueueDialog(
+ kind: DialogRequest["kind"],
+ options: AppDialogOptions,
+): Promise<boolean> {
+ return new Promise((resolve) => {
+ useAppDialogStore.getState().enqueue({
+ ...options,
+ id: nextDialogId++,
+ kind,
+ resolve,
+ })
+ })
+}
+
+const appDialogApi = {
+ alert: async (options: AppDialogOptions): Promise<void> => {
+ await enqueueDialog("alert", options)
+ },
+ confirm: (options: AppDialogOptions): Promise<boolean> =>
+ enqueueDialog("confirm", options),
+}
+
+export function useAppDialog() {
+ return appDialogApi
+}