AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
fix(desktop): start manual backups without confirmation dialog
tianma-if9cdfacc07025
diff --git a/apps/web/src/components/settings/DesktopBackupRunDialog.tsx b/apps/web/src/components/settings/DesktopBackupRunDialog.tsxindex 0ac8a531..5a4c5746 100644--- a/apps/web/src/components/settings/DesktopBackupRunDialog.tsx+++ b/apps/web/src/components/settings/DesktopBackupRunDialog.tsx@@ -3,16 +3,9 @@ import { useTranslation } from "react-i18next";import type { DesktopBackupActions, DesktopBackupStatus } from "@edgeever/shared";import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";-import { Switch } from "@/components/ui/switch";import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";import { describeDesktopBackupError } from "@/lib/desktop-backup";-const defaultName = () => {- const date = new Date();- const two = (value: number) => String(value).padStart(2, "0");- return `EdgeEver-${date.getFullYear()}-${two(date.getMonth() + 1)}-${two(date.getDate())}_${two(date.getHours())}${two(date.getMinutes())}${two(date.getSeconds())}`;-};-export const DesktopBackupRunDialog = ({ status, onRun, onClose }: {status: DesktopBackupStatus;onRun: (input: DesktopBackupActions["run"]["input"]) => Promise<unknown>;@@ -20,19 +13,16 @@ export const DesktopBackupRunDialog = ({ status, onRun, onClose }: {}) => {const { t } = useTranslation();const pending = status.pendingPublication;- const [name, setName] = useState(defaultName);- const [encrypted, setEncrypted] = useState(pending?.encrypted ?? status.config.encrypted);const [password, setPassword] = useState("");const [confirmation, setConfirmation] = useState("");const [working, setWorking] = useState(false);const [error, setError] = useState<string | null>(null);- const needsPassword = encrypted && (Boolean(pending) || !status.passwordSet || !status.secureStorageAvailable);- const valid = (pending || name.trim()) && (!needsPassword || password) && (pending || !encrypted || !password || password === confirmation);+ const valid = password.length > 0 && (Boolean(pending) || password === confirmation);const run = async () => {if (!valid || working) return;setWorking(true); setError(null);try {- await onRun({ backupSetId: status.backupSetId, ...(encrypted && password ? { password } : {}), ...(!pending ? { options: { name, encrypted } } : {}) });+ await onRun({ backupSetId: status.backupSetId, password });onClose();} catch (failure) { setError(describeDesktopBackupError(t, failure)); setWorking(false); }};@@ -42,16 +32,12 @@ export const DesktopBackupRunDialog = ({ status, onRun, onClose }: {<DialogTitle>{t(pending ? "desktopBackup.verifyPublication" : "desktopBackup.run")}</DialogTitle><DialogDescription className="break-all">{pending ? t("desktopBackup.verifyPassword", { name: pending.name }) : status.actualDirectory}</DialogDescription></DialogHeader>- {!pending ? <>- <label className="grid gap-2 text-sm font-medium"><span>{t("desktopBackup.fileName")}</span><div className="flex items-center gap-2"><Input autoFocus value={name} disabled={working} onChange={(event) => setName(event.target.value)} /><span className="shrink-0 text-muted-foreground">{encrypted ? ".edgeever.enc" : ".zip"}</span></div></label>- <label className="flex items-center justify-between gap-3 text-sm font-medium"><span>{t("desktopBackup.encryption")}</span><Switch checked={encrypted} disabled={working} onCheckedChange={(value) => { setEncrypted(value); setPassword(""); setConfirmation(""); }} /></label>- </> : null}- {encrypted ? <div className="grid gap-2">- <Input type="password" autoComplete="off" aria-label={t("desktopBackup.password")} placeholder={t(needsPassword ? "desktopBackup.password" : "desktopBackup.savedPasswordPlaceholder")} disabled={working} value={password} onChange={(event) => setPassword(event.target.value)} />- {!pending && (needsPassword || password) ? <Input type="password" autoComplete="off" aria-label={t("desktopBackup.confirmPassword")} placeholder={t("desktopBackup.confirmPassword")} disabled={working} value={confirmation} onChange={(event) => setConfirmation(event.target.value)} /> : null}+ <div className="grid gap-2">+ <Input autoFocus type="password" autoComplete="off" aria-label={t("desktopBackup.password")} placeholder={t("desktopBackup.password")} disabled={working} value={password} onChange={(event) => setPassword(event.target.value)} />+ {!pending ? <Input type="password" autoComplete="off" aria-label={t("desktopBackup.confirmPassword")} placeholder={t("desktopBackup.confirmPassword")} disabled={working} value={confirmation} onChange={(event) => setConfirmation(event.target.value)} /> : null}{!pending && confirmation && password !== confirmation ? <p className="text-sm text-destructive" role="alert">{t("desktopBackup.passwordMismatch")}</p> : null}{!pending ? <p className="text-sm text-muted-foreground">{t("desktopBackup.oncePassword")}</p> : null}- </div> : null}+ </div>{error ? <p className="text-sm text-destructive" role="alert">{error}</p> : null}<DialogFooter><Button type="button" variant="outline" disabled={working} onClick={onClose}>{t("common.cancel")}</Button><Button type="submit" className="bg-foreground text-background hover:bg-foreground/90" disabled={!valid || working}>{t(working ? "common.processing" : pending ? "desktopBackup.verifyPublication" : "desktopBackup.run")}</Button></DialogFooter></form>diff --git a/apps/web/src/components/settings/DesktopScheduledBackupCard.tsx b/apps/web/src/components/settings/DesktopScheduledBackupCard.tsxindex 9b26ed04..d7ba263f 100644--- a/apps/web/src/components/settings/DesktopScheduledBackupCard.tsx+++ b/apps/web/src/components/settings/DesktopScheduledBackupCard.tsx@@ -1,7 +1,7 @@import { useEffect, useRef, useState } from "react";import { ChevronRight, FolderOpen, HardDriveDownload, Loader2, Upload } from "lucide-react";import { useTranslation } from "react-i18next";-import type { DesktopBackupConfig } from "@edgeever/shared";+import type { DesktopBackupActions, DesktopBackupConfig } from "@edgeever/shared";import { Button } from "@/components/ui/button";import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";import { Input } from "@/components/ui/input";@@ -13,6 +13,12 @@ import { DesktopBackupImport } from "./DesktopBackupImport";import { DesktopBackupRunDialog } from "./DesktopBackupRunDialog";import { SETTINGS_CARD_DESCRIPTION_CLASSNAME, SETTINGS_CARD_HEADER_CLASSNAME, SETTINGS_CARD_ICON_CLASSNAME, SETTINGS_CARD_TITLE_CLASSNAME } from "./settings-ui";+const defaultBackupName = () => {+ const date = new Date();+ const two = (value: number) => String(value).padStart(2, "0");+ return `EdgeEver-${date.getFullYear()}-${two(date.getMonth() + 1)}-${two(date.getDate())}_${two(date.getHours())}${two(date.getMinutes())}${two(date.getSeconds())}`;+};+export const DesktopScheduledBackupCard = () => {const { t } = useTranslation();const { bridge, status } = useDesktopBackup();@@ -79,6 +85,15 @@ export const DesktopScheduledBackupCard = () => {try { await action(); } catch (failure) { if (scope.current === expected) setError(describeDesktopBackupError(t, failure)); }finally { if (scope.current === expected) setSaving(false); }};+ const runBackup = (input: DesktopBackupActions["run"]["input"]) => bridge.backup("run", {+ ...input,+ ...(!pending ? { options: { name: defaultBackupName(), encrypted: status.config.encrypted } } : {}),+ });+ const startBackup = () => {+ const needsPassword = pending ? pending.encrypted : status.config.encrypted && (!status.passwordSet || !status.secureStorageAvailable);+ if (needsPassword) setRunOpen(true);+ else void attempt(() => runBackup({ backupSetId: status.backupSetId }));+ };const date = (value: string | null) => value ? new Date(value).toLocaleString() : t("desktopBackup.never");const remove = async () => {if (!deleting || saving) return;@@ -96,7 +111,7 @@ export const DesktopScheduledBackupCard = () => {<CardContent className="grid gap-5 p-4 pt-0 sm:px-5"><DesktopBackupImport disabled={saving || runOpen || Boolean(deleting)}>{(restore, restoreDisabled) => <><div className="flex flex-wrap gap-2">- {busy ? <Button type="button" size="sm" variant="outline" disabled={saving} onClick={() => void attempt(() => bridge.backup("cancel", { backupSetId: status.backupSetId }))}>{t("common.cancel")}</Button> : <Button type="button" size="sm" className="bg-foreground text-background hover:bg-foreground/90" disabled={saving || (!pending && dirty)} onClick={() => { if (pending && !pending.encrypted) void attempt(() => bridge.backup("run", { backupSetId: status.backupSetId })); else setRunOpen(true); }}>{t(pending ? "desktopBackup.verifyPublication" : "desktopBackup.run")}</Button>}+ {busy ? <Button type="button" size="sm" variant="outline" disabled={saving} onClick={() => void attempt(() => bridge.backup("cancel", { backupSetId: status.backupSetId }))}>{t("common.cancel")}</Button> : <Button type="button" size="sm" className="bg-foreground text-background hover:bg-foreground/90" disabled={saving || (!pending && dirty)} onClick={startBackup}>{t(pending ? "desktopBackup.verifyPublication" : "desktopBackup.run")}</Button>}<Button type="button" size="sm" variant="outline" disabled={restoreDisabled} onClick={() => restore()}><Upload className="h-4 w-4" />{t("desktopBackup.importButton")}</Button><Button type="button" size="sm" variant="ghost" disabled={saving} onClick={() => void attempt(() => bridge.backup("open-folder", { backupSetId: status.backupSetId }))}><FolderOpen className="h-4 w-4" />{t("desktopBackup.openFolder")}</Button></div>@@ -164,7 +179,7 @@ export const DesktopScheduledBackupCard = () => {</section></>}</DesktopBackupImport></CardContent>- {runOpen ? <DesktopBackupRunDialog key={status.backupSetId} status={status} onRun={(input) => bridge.backup("run", input)} onClose={() => setRunOpen(false)} /> : null}+ {runOpen ? <DesktopBackupRunDialog key={status.backupSetId} status={status} onRun={runBackup} onClose={() => setRunOpen(false)} /> : null}{deleting ? <AppConfirmDialog title={t("desktopBackup.deleteTitle")} description={t("desktopBackup.deleteDescription", { name: deleting })} confirmLabel={t("desktopBackup.deleteConfirm")} error={deleteError} isWorking={saving} onCancel={() => setDeleting(null)} onConfirm={() => void remove()} /> : null}</Card>;};diff --git a/docs/desktop-scheduled-backup-design.md b/docs/desktop-scheduled-backup-design.mdindex c0388b64..ed89fa8c 100644--- a/docs/desktop-scheduled-backup-design.md+++ b/docs/desktop-scheduled-backup-design.md@@ -34,7 +34,7 @@ Desktop Settings → Data and backup uses one “Backup and restore” card inst| Keep recent | 1, 3, or 5 archives; 1 by default. Existing 10- and 20-archive settings remain valid and are displayed as a disabled option until changed || Backup encryption | Optional and initially off; enabling it requires entering and confirming a separate backup password |-The top actions are “Back up now,” “Restore from file,” and “Open folder.” Below them, show the last actual successful archive, latest check result, and next scheduled check or automatic-off state. Running tasks can be cancelled. Manual runs allow an editable filename and one-off plain/encrypted output, using the saved destination and retention without changing automatic settings; they remain available when scheduling is off.+The top actions are “Back up now,” “Restore from file,” and “Open folder.” Below them, show the last actual successful archive, latest check result, and next scheduled check or automatic-off state. Running tasks can be cancelled. Manual runs start immediately with an automatically generated local timestamp filename and the saved encryption, destination, and retention settings; they remain available when scheduling is off. Prompt for a password only when an encryption password is unavailable or an interrupted encrypted backup needs verification. Keep inline progress, success, and failure feedback.An encryption password must be nonempty and both entries must match exactly. Do not trim whitespace or normalize Unicode. After saving, show only “Password set,” never the saved value. When changing it, explain that the new password applies only to future archives.@@ -150,7 +150,7 @@ Changing the password affects future archives only; do not re-encrypt old files## 7. File publication and retention-Users select a destination root, and the app creates a `<backupSetId>` subdirectory for the current local backup set. Settings shows the effective destination, and “Open folder” opens it. Automatic filenames use UTC time and a random backup ID, such as `edgeever-backup-20261023T020000Z-<id>.zip`, with `.edgeever.enc` for encrypted files. Manual names default to an editable local timestamp without a random ID; append the selected format’s extension. Name conflicts fail without overwriting existing files.+Users select a destination root, and the app creates a `<backupSetId>` subdirectory for the current local backup set. Settings shows the effective destination, and “Open folder” opens it. Automatic filenames use UTC time and a random backup ID, such as `edgeever-backup-20261023T020000Z-<id>.zip`, with `.edgeever.enc` for encrypted files. Manual names use an automatically generated local timestamp without a random ID; append the saved format’s extension. Name conflicts fail without overwriting existing files.A task performs these steps in order:diff --git a/docs/desktop-scheduled-backup-design.zh-CN.md b/docs/desktop-scheduled-backup-design.zh-CN.mdindex d8e98ace..c6273768 100644--- a/docs/desktop-scheduled-backup-design.zh-CN.md+++ b/docs/desktop-scheduled-backup-design.zh-CN.md@@ -34,7 +34,7 @@| 保留最近 | 1、3、5;默认 1 份。已有的 10、20 份配置继续有效,修改前以不可选选项显示 || 备份加密 | 可选,首次关闭;开启时输入并确认独立的备份密码 |-顶部提供“立即备份”“从文件恢复”“打开文件夹”;其下显示上次实际成功备份、最近检查结果,以及下次计划检查或自动备份关闭状态。运行时可取消。手动备份可编辑文件名,并为本次选择明文或加密;沿用保存目录和保留规则,不修改自动备份配置,自动关闭时仍可使用。+顶部提供“立即备份”“从文件恢复”“打开文件夹”;其下显示上次实际成功备份、最近检查结果,以及下次计划检查或自动备份关闭状态。运行时可取消。手动备份点击后直接开始,自动生成本地时间戳文件名,沿用已保存的加密设置、保存目录和保留规则,自动关闭时仍可使用。仅加密密码不可用或核验中断的加密备份时提示输入密码;保留页面内进度、成功及失败反馈。开启加密时,密码必须非空且两次输入完全一致;不自动裁剪空格或修改 Unicode 内容。保存后只显示“已设置密码”,不回显密码。修改密码时说明“新密码仅用于之后生成的备份”。@@ -150,7 +150,7 @@ Linux 必须检查实际安全存储后端;`basic_text` 不能用于保存自## 7. 文件发布和保留规则-用户选择的是保存根目录,应用为当前本机备份集创建 `<backupSetId>` 子目录,设置页显示实际写入目录。“打开文件夹”打开该子目录。自动任务文件名采用 UTC 时间与随机备份 ID,例如 `edgeever-backup-20261023T020000Z-<id>.zip`;加密时后缀为 `.edgeever.enc`。手动文件名默认为本地时间戳,不带随机 ID,可编辑;按格式追加扩展名。同名拒绝,不覆盖已有文件。+用户选择的是保存根目录,应用为当前本机备份集创建 `<backupSetId>` 子目录,设置页显示实际写入目录。“打开文件夹”打开该子目录。自动任务文件名采用 UTC 时间与随机备份 ID,例如 `edgeever-backup-20261023T020000Z-<id>.zip`;加密时后缀为 `.edgeever.enc`。手动文件名自动采用本地时间戳,不带随机 ID;按已保存的格式追加扩展名。同名拒绝,不覆盖已有文件。一次任务依次完成以下操作:diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.tsindex bbd96e27..47aadfe6 100644--- a/packages/shared/src/i18n/en-US.ts+++ b/packages/shared/src/i18n/en-US.ts@@ -2173,7 +2173,7 @@ export const enUS = {},errors: {backup_name_invalid: "Enter a valid filename without paths, reserved names or special characters.",- backup_name_exists: "A file with this name already exists. Choose another name; the existing file is unchanged.",+ backup_name_exists: "A file with this name already exists. Try again in a moment; the existing file is unchanged.",backup_file_replaced: "The backup file was replaced. No action was taken.",backup_configuration_unavailable: "Could not read backup settings or clean private staging. Check the app data folder permissions and restart.",backup_too_large: "Encrypted backups are limited to 64 GiB minus 32 bytes. Choose an unencrypted backup for a larger archive.",diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.tsindex a5af0536..f9bf1fde 100644--- a/packages/shared/src/i18n/ja.ts+++ b/packages/shared/src/i18n/ja.ts@@ -2162,7 +2162,7 @@ export const ja = {},errors: {backup_name_invalid: "パス、予約名、特殊文字を含まない有効なファイル名を入力してください。",- backup_name_exists: "同名のファイルがあります。別の名前を選んでください。既存のファイルは変更されていません。",+ backup_name_exists: "同名のファイルがあります。少し待ってから再度バックアップしてください。既存のファイルは変更されていません。",backup_file_replaced: "バックアップファイルが置き換えられたため、操作を中止しました。",backup_configuration_unavailable: "バックアップ設定の読み取りか一時ファイルの削除に失敗しました。アプリのデータフォルダーの権限を確認し、再起動してください。",backup_too_large: "暗号化アーカイブの上限は 64 GiB から 32 バイトを引いたサイズです。より大きい場合は暗号化なしで保存してください。",diff --git a/packages/shared/src/i18n/pl.ts b/packages/shared/src/i18n/pl.tsindex fe07d6ff..1d97a5c2 100644--- a/packages/shared/src/i18n/pl.ts+++ b/packages/shared/src/i18n/pl.ts@@ -2162,7 +2162,7 @@ export const pl = {},errors: {backup_name_invalid: "Wpisz prawidłową nazwę pliku bez ścieżek, nazw zastrzeżonych i znaków specjalnych.",- backup_name_exists: "Plik o tej nazwie już istnieje. Wybierz inną nazwę; istniejący plik nie został zmieniony.",+ backup_name_exists: "Plik o tej nazwie już istnieje. Spróbuj ponownie za chwilę; istniejący plik nie został zmieniony.",backup_file_replaced: "Plik kopii został zastąpiony. Nie wykonano operacji.",backup_configuration_unavailable: "Nie można odczytać ustawień kopii lub usunąć plików tymczasowych. Sprawdź uprawnienia folderu danych aplikacji i uruchom ją ponownie.",backup_too_large: "Limit szyfrowanego archiwum wynosi 64 GiB minus 32 bajty. Dla większego pliku wybierz kopię bez szyfrowania.",diff --git a/packages/shared/src/i18n/ru.ts b/packages/shared/src/i18n/ru.tsindex bcbe1f1c..5b371397 100644--- a/packages/shared/src/i18n/ru.ts+++ b/packages/shared/src/i18n/ru.ts@@ -2173,7 +2173,7 @@ export const ru = {},errors: {backup_name_invalid: "Введите допустимое имя файла без пути, зарезервированных имён и специальных символов.",- backup_name_exists: "Файл с таким именем уже существует. Выберите другое имя; существующий файл не изменён.",+ backup_name_exists: "Файл с таким именем уже существует. Повторите резервное копирование чуть позже; существующий файл не изменён.",backup_file_replaced: "Файл резервной копии был заменён. Действие не выполнено.",backup_configuration_unavailable: "Не удалось прочитать настройки или очистить временные файлы. Проверьте права доступа к папке данных приложения и перезапустите его.",backup_too_large: "Размер зашифрованной копии ограничен 64 ГиБ минус 32 байта. Для большего архива отключите шифрование.",diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.tsindex e575da45..c263ff46 100644--- a/packages/shared/src/i18n/zh-CN.ts+++ b/packages/shared/src/i18n/zh-CN.ts@@ -2173,7 +2173,7 @@ export const zhCN = {},errors: {backup_name_invalid: "请输入有效文件名,不要包含路径、保留名称或特殊字符。",- backup_name_exists: "已存在同名文件,请修改名称。原文件未改动。",+ backup_name_exists: "已存在同名文件,请稍后重新备份。原文件未改动。",backup_file_replaced: "备份文件已被替换,未执行操作。",backup_configuration_unavailable: "无法读取备份设置或清理私有暂存。请检查应用数据目录权限并重启。",backup_too_large: "加密归档上限为 64 GiB 减 32 字节。更大的归档请选择不加密备份。",diff --git a/tests/browser/desktop-backup-import.browser.tsx b/tests/browser/desktop-backup-import.browser.tsxindex 2ee95442..9e76be35 100644--- a/tests/browser/desktop-backup-import.browser.tsx+++ b/tests/browser/desktop-backup-import.browser.tsx@@ -21,12 +21,15 @@ const status: DesktopBackupStatus = {{ name: "EdgeEver-2026-10-25_110000.edgeever.enc", directory: "/test/Backups", completedAt: "2026-10-25T03:00:00.000Z", size: 4910204, encrypted: true },],};+const params = new URLSearchParams(location.search);+if (params.has("encrypted")) { status.config.encrypted = true; status.passwordSet = true; }+if (params.has("no-secure-storage")) status.secureStorageAvailable = false;const calls: Array<{ action: string; input?: unknown }> = [];const listeners = new Set<(status: DesktopBackupStatus) => void>();const emit = () => { for (const listener of listeners) listener(structuredClone(status)); };let encrypted = true;let holdHandshake = false;-let runError = false;+let runError = params.has("run-error");let deleteError = false;const saveError = new URLSearchParams(location.search).has("save-error");let finish: (() => void) | undefined;@@ -38,6 +41,10 @@ Object.defineProperty(window, "edgeeverDesktop", {const value = input as { name?: string; config?: DesktopBackupStatus["config"]; password?: string; options?: { name: string; encrypted: boolean } } | undefined;if (action === "run") {if (runError) throw Object.assign(new Error("File exists"), { code: "backup_name_exists" });+ if (params.has("running")) {+ status.task = { kind: "export", phase: "exporting", completed: 2, total: 5 }; emit();+ return structuredClone(status);+ }const option = value!.options!; const at = new Date().toISOString();status.history.push({ name: option.name.replace(/(?:\.edgeever\.enc|\.zip)$/i, "") + (option.encrypted ? ".edgeever.enc" : ".zip"), directory: status.config.directory, completedAt: at, size: 149755, encrypted: option.encrypted });status.lastSuccessAt = at; status.lastCheck = { at, result: "success" }; emit();