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): follow session networking for backups (#755)
LuoQianhonga89df9253209
diff --git a/.github/workflows/desktop-backup-network.yml b/.github/workflows/desktop-backup-network.ymlnew file mode 100644index 00000000..ebb3c44d--- /dev/null+++ b/.github/workflows/desktop-backup-network.yml@@ -0,0 +1,90 @@+name: Test desktop backup network++on:+ pull_request:+ paths:+ - ".github/workflows/desktop-backup-network.yml"+ - "apps/desktop/src/backup/**"+ - "apps/desktop/src/main/backup*.mjs"+ - "apps/desktop/src/main/index.mjs"+ - "apps/desktop/scripts/build-backup-worker.mjs"+ - "apps/desktop/package.json"+ - "apps/api/src/backup*"+ - "apps/api/src/*storage*"+ - "packages/client/src/**"+ - "packages/shared/src/backup*"+ - "migrations/**"+ - "package.json"+ - "bun.lock"+ push:+ branches: [main]+ paths:+ - ".github/workflows/desktop-backup-network.yml"+ - "apps/desktop/src/backup/**"+ - "apps/desktop/src/main/backup*.mjs"+ - "apps/desktop/src/main/index.mjs"+ - "apps/desktop/scripts/build-backup-worker.mjs"+ - "apps/desktop/package.json"+ - "apps/api/src/backup*"+ - "apps/api/src/*storage*"+ - "packages/client/src/**"+ - "packages/shared/src/backup*"+ - "migrations/**"+ - "package.json"+ - "bun.lock"+ workflow_dispatch:++permissions:+ contents: read++concurrency:+ group: desktop-backup-network-${{ github.event.pull_request.number || github.ref }}+ cancel-in-progress: true++jobs:+ backup-network:+ if: github.repository == 'tianma-if/edgeever'+ name: Backup network (${{ matrix.os }})+ strategy:+ fail-fast: false+ matrix:+ os: [macos-latest, windows-latest, ubuntu-latest]+ runs-on: ${{ matrix.os }}+ timeout-minutes: 15+ steps:+ - uses: actions/checkout@v5+ - uses: oven-sh/setup-bun@v2+ with:+ bun-version-file: package.json+ - name: Install Electron display dependencies+ if: runner.os == 'Linux'+ run: |+ sudo apt-get update+ sudo apt-get install -y libasound2t64 libatk-bridge2.0-0 libdrm2 libgbm1 libgtk-3-0 libnss3 xvfb+ - name: Install dependencies+ run: bun install --frozen-lockfile+ - name: Configure Electron sandbox on the Linux runner+ if: runner.os == 'Linux'+ working-directory: apps/desktop+ run: |+ electron="$(bun -e 'console.log(require("electron"))' | tail -n 1)"+ sandbox="$(dirname "$electron")/chrome-sandbox"+ sudo chown root:root "$sandbox"+ sudo chmod 4755 "$sandbox"+ - name: Test proxy and direct backup/restore+ if: runner.os != 'Linux'+ env:+ EDGE_EVER_BACKUP_REPORT: ${{ runner.temp }}/backup-network+ run: bun run test:desktop:backup-network+ - name: Test proxy and direct backup/restore (Xvfb)+ if: runner.os == 'Linux'+ env:+ EDGE_EVER_BACKUP_REPORT: ${{ runner.temp }}/backup-network+ run: xvfb-run --auto-servernum bun run test:desktop:backup-network+ - name: Upload runtime reports+ if: always()+ uses: actions/upload-artifact@v4+ with:+ name: backup-network-${{ matrix.os }}+ path: ${{ runner.temp }}/backup-network-*.json+ if-no-files-found: ignorediff --git a/apps/desktop/scripts/build-backup-worker.mjs b/apps/desktop/scripts/build-backup-worker.mjsindex 02828950..28084220 100644--- a/apps/desktop/scripts/build-backup-worker.mjs+++ b/apps/desktop/scripts/build-backup-worker.mjs@@ -5,6 +5,6 @@ import { join } from "node:path";const root = fileURLToPath(new URL("../../../", import.meta.url));const directory = join(root, "apps/desktop/build");await mkdir(directory, { recursive: true });-const result = await Bun.build({ entrypoints: [join(root, "apps/desktop/src/backup/worker.ts")], target: "node", format: "esm", outdir: directory, naming: "backup-worker.mjs" });+const result = await Bun.build({ entrypoints: [join(root, "apps/desktop/src/backup/worker.ts")], target: "node", format: "esm", external: ["electron"], outdir: directory, naming: "backup-worker.mjs" });if (!result.success) throw new AggregateError(result.logs, "Could not build the desktop backup worker");await copyFile(join(root, "node_modules/@zip.js/zip.js/LICENSE"), join(directory, "zip.js.LICENSE"));diff --git a/apps/desktop/src/backup/tests/electron-network-runner.mjs b/apps/desktop/src/backup/tests/electron-network-runner.mjsnew file mode 100644index 00000000..c1a2db68--- /dev/null+++ b/apps/desktop/src/backup/tests/electron-network-runner.mjs@@ -0,0 +1,111 @@+import assert from "node:assert/strict";+import { readFile } from "node:fs/promises";+import { join } from "node:path";+import { app, net, session, utilityProcess } from "electron";+import { BackupManager } from "../../main/backup-manager.mjs";++const settings = JSON.parse(await readFile(process.argv.at(-1), "utf8"));+app.setPath("userData", join(settings.directory, "electron"));+app.whenReady().then(async () => {+ await session.defaultSession.setProxy(settings.proxy+ ? { mode: "fixed_servers", proxyRules: settings.proxy, proxyBypassRules: "<-loopback>" }+ : { mode: "direct" });+ await session.defaultSession.cookies.set({ url: settings.source, name: "must-not-send", value: "fixture-cookie" });++ const workers = [];+ const factory = settings.baseline ? undefined : (await import("../../main/backup-worker.mjs")).createBackupWorkerFactory({+ utilityProcess, session: session.defaultSession,+ });+ let peakWorkerKiB = 0;+ let peakMainKiB = 0;+ let maxTimerDelayMs = 0;+ let lastSample = performance.now();+ const timer = setInterval(() => {+ const now = performance.now();+ maxTimerDelayMs = Math.max(maxTimerDelayMs, now - lastSample - 25); lastSample = now;+ for (const metric of app.getAppMetrics()) {+ if (metric.pid === process.pid) peakMainKiB = Math.max(peakMainKiB, metric.memory.workingSetSize);+ if (workers.some(worker => worker.pid === metric.pid)) peakWorkerKiB = Math.max(peakWorkerKiB, metric.memory.workingSetSize);+ }+ }, 25);+ const manager = new BackupManager({+ userData: join(settings.directory, "state"), defaultDirectory: join(settings.directory, "backups"),+ secureStorage: { isEncryptionAvailable: () => false },+ ...(factory ? { workerFactory(data) {+ const worker = factory(data);+ const exited = new Promise(resolve => worker.once("exit", resolve));+ workers.push({ get pid() { return worker.pid; }, exited });+ return worker;+ } } : {}),+ version: { edgeeverVersion: "2.16.1", buildId: "network-acceptance" },+ onDiagnostic: (event, detail) => console.error(JSON.stringify({ event, ...detail })),+ });+ const context = baseUrl => ({ baseUrl, accountId: "local", token: "fixture-bearer" });+ const checked = () => assert.equal(manager.status().error, null, JSON.stringify(manager.status().error));+ const output = {};+ try {+ await manager.setContext(context(settings.source));+ await manager.save({ ...manager.status().config, enabled: true });+ await manager.tick(); await manager.waitForIdle(); checked();+ const first = manager.status();+ assert.equal(first.lastCheck.result, "success");+ assert.equal(first.config.enabled, true);+ assert.equal(first.config.interval, "weekly");+ assert.equal(first.config.retention, 1);+ output.archiveBytes = first.history[0].size;+ output.archive = join(first.actualDirectory, first.history[0].name);++ // The due check must stay a single state request, not another archive export.+ await manager.tick(Date.parse(first.nextDueAt) + 1); await manager.waitForIdle(); checked();+ assert.equal(manager.status().lastCheck.result, "unchanged");+ assert.equal(manager.status().history.length, 1);++ const replacement = await net.fetch(new URL("./replace-attachment", settings.control).href, {+ method: "POST", credentials: "omit", cache: "no-store",+ });+ assert.equal(replacement.status, 200);+ const replaced = await replacement.json();+ assert.equal(replaced.resourceUrl, settings.mutableResourceUrl);+ assert.notEqual(replaced.hash, replaced.previousHash);+ assert.ok(replaced.revisionAfter > replaced.revisionBefore);+ await manager.run(); await manager.waitForIdle(); checked();+ const second = manager.status();+ assert.equal(second.lastCheck.result, "success");+ assert.equal(second.history.length, 1);+ output.archiveBytes = second.history[0].size;+ output.archive = join(second.actualDirectory, second.history[0].name);+ output.repeatedExport = true;++ await manager.setContext(context(settings.target));+ const selection = await manager.selectImport(output.archive);+ const ready = new Promise(resolve => { manager.onChange = status => { if (status?.task?.phase === "ready") resolve(); }; });+ await manager.prepareImport(selection.id); await Promise.race([ready, manager.operation.done]);+ assert.equal(manager.status().importError, null);+ assert.equal(manager.status().task.phase, "ready");+ manager.confirmImport(); await manager.waitForIdle();+ assert.equal(manager.status().importError, null);++ await manager.setContext(context(`${settings.source}/failure`));+ await manager.run(); await manager.waitForIdle();+ assert.equal(manager.status().error.code, "fixture_unavailable");+ assert.equal(manager.status().error.status, 503);++ await manager.setContext(context(`${settings.source}/hang`));+ await manager.run();+ const deadline = Date.now() + 5000;+ while (!(await (await net.fetch(settings.control, { credentials: "omit" })).json()).hanging) {+ assert.ok(Date.now() < deadline, "worker did not begin its request");+ await new Promise(resolve => setTimeout(resolve, 25));+ }+ await manager.cancel();+ assert.equal(manager.status().task, null);+ assert.equal(manager.status().lastCheck.result, "cancelled");+ await manager.close();+ await Promise.all(workers.map(worker => worker.exited));+ console.log(JSON.stringify({ ...output, workersExited: workers.length, peakWorkerKiB, peakMainKiB, maxTimerDelayMs }));+ app.exit(0);+ } catch (error) {+ console.error(error);+ await manager.close(); app.exit(1);+ } finally { clearInterval(timer); }+}).catch(error => { console.error(error); app.exit(1); });diff --git a/apps/desktop/src/backup/tests/electron-network.integration.mjs b/apps/desktop/src/backup/tests/electron-network.integration.mjsnew file mode 100644index 00000000..a11b4e9e--- /dev/null+++ b/apps/desktop/src/backup/tests/electron-network.integration.mjs@@ -0,0 +1,131 @@+import { expect, test } from "bun:test";+import { Database } from "bun:sqlite";+import { spawn } from "node:child_process";+import { createRequire } from "node:module";+import { mkdtemp, mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { fileURLToPath } from "node:url";+import { createHash, randomBytes } from "node:crypto";+import { fetchEdgeEverApp } from "../../../../api/src/index.ts";+import { createSelfHostedStorageAdapter } from "../../../../api/src/self-hosted-storage-adapter.ts";+import { RESOURCE_UPLOAD_PART_BYTES } from "../../../../api/src/resource-upload-service.ts";+import { createEdgeEverClient } from "../../../../../packages/client/src/index.ts";++const require = createRequire(new URL("../../../package.json", import.meta.url));+const electron = require("electron");+const trace = (...values) => { if (process.env.EDGE_EVER_BACKUP_TRACE === "1") console.error(...values); };+for (const proxy of [true, false]) test(`Electron backups export and restore through ${proxy ? "the session proxy" : "a direct connection"}`, async () => {+ const directory = await mkdtemp(join(tmpdir(), "edgeever-electron-backup-"));+ const cleanup = [];+ const paths = [];+ const auth = [];+ const attachmentCacheHeaders = [];+ let hanging = false;+ let replaceAttachment;+ try {+ const instance = async name => {+ const folder = join(directory, name); await mkdir(folder);+ const database = new Database(join(folder, "database.sqlite"));+ for (const file of (await readdir("migrations")).filter(name => name.endsWith(".sql")).sort()) database.exec(await readFile(join("migrations", file), "utf8"));+ const environment = { storage: createSelfHostedStorageAdapter(database, join(folder, "resources")), EDGE_EVER_ALLOW_UNAUTHENTICATED: "true", EDGE_EVER_RUNTIME: "self-hosted-bun" };+ const server = Bun.serve({ hostname: "127.0.0.1", port: 0, fetch(request) {+ const path = new URL(request.url).pathname;+ if (path === "/__fixture/status") return Response.json({ hanging });+ if (name === "source" && path === "/__fixture/replace-attachment" && request.method === "POST") return replaceAttachment();+ if (path.startsWith("/hang/")) { hanging = true; return new Promise((resolve) => request.signal.addEventListener("abort", () => resolve(new Response(null, { status: 499 })), { once: true })); }+ if (path.startsWith("/failure/")) return Response.json({ error: { code: "fixture_unavailable", message: "Fixture unavailable" } }, { status: 503 });+ if (request.headers.get("authorization") === "Bearer fixture-bearer") { paths.push(`${name}:${request.method} ${path}${new URL(request.url).search}`); auth.push({ authorization: request.headers.get("authorization"), cookie: request.headers.get("cookie") }); }+ trace(name, request.method, path);+ return fetchEdgeEverApp(request, environment, { waitUntil() {}, passThroughOnException() {} }).then(response => {+ if (name === "source" && request.method === "GET" && /^\/api\/v1\/resources\/[^/]+\/blob$/.test(path)) attachmentCacheHeaders.push({ path, cacheControl: response.headers.get("cache-control") });+ trace(name, request.method, path, response.status); return response;+ });+ } });+ cleanup.push(async () => {+ await server.stop(true);+ // Bun 1.3.14 can leave uncached SQLite statements alive (oven-sh/bun#36572).+ // Release them and require a complete close before deleting fixture files.+ Bun.gc(true); database.close(true);+ });+ return { server, database, folder, url: `http://127.0.0.1:${server.port}`, client: createEdgeEverClient({ baseUrl: `http://127.0.0.1:${server.port}` }) };+ };+ const source = await instance("source"); const target = await instance("target");+ const { notebook } = await source.client.createNotebook({ name: "Network backup" });+ const { memo } = await source.client.createMemo({ notebookId: notebook.id, title: "Proxy round trip", contentMarkdown: "Streaming backup and restore" });+ const bytes = randomBytes(Number(process.env.EDGE_EVER_BACKUP_ATTACHMENT_MIB ?? 32) * 1024 * 1024 + 11);+ const { resource } = await source.client.uploadMemoResource(memo.id, new File([new Uint8Array([1])], "stream.bin", { type: "application/octet-stream" }));+ const row = source.database.query("SELECT object_key FROM resources WHERE id=?").get(resource.id);+ await writeFile(join(source.folder, "resources", row.object_key), bytes);+ source.database.query("UPDATE resources SET byte_size=?, sha256=NULL WHERE id=?").run(bytes.length, resource.id);++ // A small attachment is reliably cacheable even on runners with a small HTTP cache.+ // Keep the large attachment above for the streaming regression.+ const mutableBytes = randomBytes(64 * 1024);+ const { resource: mutableResource } = await source.client.uploadMemoResource(memo.id, new File([mutableBytes], "mutable.bin", { type: "application/octet-stream" }));+ const mutableRow = source.database.query("SELECT object_key FROM resources WHERE id=?").get(mutableResource.id);+ const previousHash = createHash("sha256").update(mutableBytes).digest("hex");+ source.database.query("UPDATE resources SET sha256=? WHERE id=?").run(previousHash, mutableResource.id);+ replaceAttachment = async () => {+ const revisionBefore = source.database.query("SELECT backup_revision FROM workspaces WHERE id='ws_default'").get().backup_revision;+ mutableBytes[0] ^= 0xff;+ await writeFile(join(source.folder, "resources", mutableRow.object_key), mutableBytes);+ const hash = createHash("sha256").update(mutableBytes).digest("hex");+ source.database.query("UPDATE resources SET sha256=? WHERE id=?").run(hash, mutableResource.id);+ const revisionAfter = source.database.query("SELECT backup_revision FROM workspaces WHERE id='ws_default'").get().backup_revision;+ return Response.json({ previousHash, hash, revisionBefore, revisionAfter, resourceUrl: mutableResource.url });+ };++ let proxyRequests = 0;+ const forwarder = Bun.serve({ hostname: "127.0.0.1", port: 0, fetch(request) {+ proxyRequests++;+ const url = new URL(request.url); url.hostname = "127.0.0.1";+ trace("proxy", request.method, url.pathname);+ return fetch(new Request(url, request), { proxy: null });+ } });+ cleanup.push(() => forwarder.stop(true));+ const settings = { directory, source: proxy ? source.url.replace("127.0.0.1", "backup-fixture.invalid") : source.url,+ target: proxy ? target.url.replace("127.0.0.1", "backup-fixture.invalid") : target.url,+ control: `${source.url}/__fixture/status`, proxy: proxy ? `http=127.0.0.1:${forwarder.port}` : null,+ mutableResourceUrl: mutableResource.url,+ baseline: process.env.EDGE_EVER_BACKUP_BASELINE === "1" };+ const settingsPath = join(directory, "settings.json"); await writeFile(settingsPath, JSON.stringify(settings));+ const env = { ...process.env }; delete env.ELECTRON_RUN_AS_NODE;+ const child = spawn(electron, [fileURLToPath(new URL("./electron-network-runner.mjs", import.meta.url)), settingsPath], { env, stdio: ["ignore", "pipe", "pipe"] });+ const exited = new Promise((resolve, reject) => { child.once("exit", resolve); child.once("error", reject); });+ cleanup.push(async () => { child.kill("SIGTERM"); await exited.catch(() => {}); });+ let stdout = ""; let stderr = "";+ child.stdout.on("data", value => { stdout += value; }); child.stderr.on("data", value => { stderr += value; process.stderr.write(value); });+ let timer;+ const deadline = new Promise((_, reject) => {+ timer = setTimeout(() => {+ child.kill("SIGTERM");+ reject(new Error(`Electron backup fixture timed out. Last API requests:\n${paths.slice(-10).join("\n")}\n${stderr}`));+ }, 40000);+ });+ const code = await Promise.race([exited, deadline]).finally(() => clearTimeout(timer));+ expect(code, stderr).toBe(0);+ const report = JSON.parse(stdout.trim().split("\n").findLast(line => line.startsWith("{")));+ if (process.env.EDGE_EVER_BACKUP_REPORT) await writeFile(`${process.env.EDGE_EVER_BACKUP_REPORT}-${proxy ? "proxy" : "direct"}.json`, JSON.stringify({ ...report, archive: undefined, paths, proxyRequests }, null, 2));+ expect(report.archiveBytes).toBeGreaterThan(bytes.length);+ expect(report.workersExited).toBe(settings.baseline ? 0 : 6);+ expect(report.repeatedExport).toBe(true);+ expect((await target.client.getMemo(memo.id)).memo.contentMarkdown).toBe("Streaming backup and restore");+ const restored = await target.client.getResourceResponse(`/api/v1/resources/${resource.id}/blob`);+ expect(new Uint8Array(await restored.arrayBuffer())).toEqual(new Uint8Array(bytes));+ const restoredMutable = await target.client.getResourceResponse(mutableResource.url);+ expect(new Uint8Array(await restoredMutable.arrayBuffer())).toEqual(new Uint8Array(mutableBytes));+ expect(auth.every(value => value.authorization === "Bearer fixture-bearer" && value.cookie === null)).toBe(true);+ expect(paths.filter(path => path === "source:GET /api/v1/backups/state")).toHaveLength(5);+ expect(paths.filter(path => path.startsWith("source:GET /api/v1/backups/data"))).toHaveLength(6);+ expect(paths.filter(path => path === `source:GET /api/v1/resources/${resource.id}/blob`)).toHaveLength(2);+ expect(paths.filter(path => path === `source:GET /api/v1/resources/${mutableResource.id}/blob`)).toHaveLength(2);+ const mutableCacheHeaders = attachmentCacheHeaders.filter(value => value.path === `/api/v1/resources/${mutableResource.id}/blob`);+ expect(mutableCacheHeaders).toHaveLength(2);+ expect(mutableCacheHeaders.every(({ cacheControl }) => cacheControl?.includes("private") && cacheControl.includes("max-age=3600"))).toBe(true);+ // Two exports, one unchanged-source check and one restore. Only the large+ // restore's part count grows with EDGE_EVER_BACKUP_ATTACHMENT_MIB.+ expect(paths, JSON.stringify(paths)).toHaveLength(61 + Math.ceil(bytes.length / RESOURCE_UPLOAD_PART_BYTES));+ expect(proxyRequests > 0).toBe(proxy);+ } finally { for (const close of cleanup.reverse()) await close(); await rm(directory, { recursive: true, force: true }); }+}, 45000);diff --git a/apps/desktop/src/backup/worker-runtime.ts b/apps/desktop/src/backup/worker-runtime.tsnew file mode 100644index 00000000..a62ff4a2--- /dev/null+++ b/apps/desktop/src/backup/worker-runtime.ts@@ -0,0 +1,34 @@+import { parentPort, workerData } from "node:worker_threads";++type ControlMessage = { type: string };+type Port = {+ on(event: "message", listener: (message: ControlMessage) => void): unknown;+ postMessage(message: unknown): void;+ close(): void;+};++export const backupWorkerRuntime = async (): Promise<{ data: unknown; port: Port; request: typeof fetch }> => {+ // Preserve the existing Node execution contract for non-Electron callers.+ if (parentPort) return { data: workerData, port: parentPort, request: fetch };++ const utilityPort = process.parentPort;+ const { net } = await import("electron");+ const sessionFetch = net.fetch as typeof fetch;+ const data = await new Promise<unknown>(resolve => utilityPort.once("message", event => resolve(event.data)));+ const listeners = new Set<(event: { data: ControlMessage }) => void>();+ return {+ data,+ // A resource can change without changing its download URL. Backups must+ // neither read nor populate the shared session's HTTP cache.+ request: ((input, init) => sessionFetch(input, { ...init, cache: "no-store" })) as typeof fetch,+ port: {+ on(_event, listener) {+ const receive = (event: { data: ControlMessage }) => listener(event.data);+ listeners.add(receive); utilityPort.on("message", receive);+ },+ postMessage: message => utilityPort.postMessage(message),+ // The parent reaps the utility process after receiving its terminal result.+ close() { for (const receive of listeners) utilityPort.removeListener("message", receive); },+ },+ };+};diff --git a/apps/desktop/src/backup/worker.ts b/apps/desktop/src/backup/worker.tsindex e01e5008..dec6ecf6 100644--- a/apps/desktop/src/backup/worker.ts+++ b/apps/desktop/src/backup/worker.ts@@ -1,4 +1,4 @@-import { parentPort, workerData } from "node:worker_threads";+import { backupWorkerRuntime } from "./worker-runtime";import { createHash } from "node:crypto";import { createReadStream, createWriteStream } from "node:fs";import { open, rm } from "node:fs/promises";@@ -15,7 +15,8 @@ type Context = { baseUrl: string; accountId: string | null; token: string; localtype Input = { operation: "export" | "import" | "verify"; context: Context; path: string; password?: string; stagingDirectory?: string; previousState?: SourceState; version?: { edgeeverVersion: string; buildId: string } };type State = { protocolVersion: number; userId: string | null; workspaceId: string; identity: string; backupRevision: string; counts: Required<JsonBackupManifest["counts"]> };type SourceState = Pick<State, "identity" | "workspaceId" | "backupRevision">;-const input = workerData as Input;+const { data, port: parentPort, request: networkFetch } = await backupWorkerRuntime();+const input = data as Input;const abort = new AbortController();const signal = abort.signal;let confirm: (() => void) | undefined;@@ -45,7 +46,7 @@ const fetchWithDiagnostics: typeof fetch = async (url, init) => {const startedAt = Date.now();let response: Response;try {- response = await fetch(url, init);+ response = await networkFetch(url, init);} catch (error) {if (!signal.aborted) send("request-error", {method: init?.method ?? "GET",diff --git a/apps/desktop/src/main/backup-worker.mjs b/apps/desktop/src/main/backup-worker.mjsnew file mode 100644index 00000000..90182b76--- /dev/null+++ b/apps/desktop/src/main/backup-worker.mjs@@ -0,0 +1,15 @@+import { fileURLToPath } from "node:url";++// Keep archive bytes and CPU work outside the main process while sharing the+// renderer's network session, including each user's system proxy configuration.+export const createBackupWorkerFactory = ({ utilityProcess, session }) => (data) => {+ const worker = utilityProcess.fork(fileURLToPath(new URL("../../build/backup-worker.mjs", import.meta.url)), [], {+ session, serviceName: "EdgeEver Backup", stdio: "ignore",+ });+ worker.terminate = () => worker.kill();+ worker.on("message", (message) => {+ if (message.type === "done" || message.type === "error") worker.kill();+ });+ worker.postMessage(data);+ return worker;+};diff --git a/apps/desktop/src/main/index.mjs b/apps/desktop/src/main/index.mjsindex 81765fa4..c6e85ca2 100644--- a/apps/desktop/src/main/index.mjs+++ b/apps/desktop/src/main/index.mjs@@ -1,4 +1,4 @@-import { app, Notification, BrowserWindow, Menu, Tray, globalShortcut, nativeImage, ipcMain, session, net, protocol, shell, dialog, safeStorage, clipboard, ClipboardItem, powerMonitor, desktopCapturer, screen } from "electron";+import { app, Notification, BrowserWindow, Menu, Tray, globalShortcut, nativeImage, ipcMain, session, net, protocol, shell, dialog, safeStorage, clipboard, ClipboardItem, powerMonitor, desktopCapturer, screen, utilityProcess } from "electron";import { createReadStream, existsSync } from "node:fs";import { appendFile, mkdir, open, readdir, readFile, rename, rm, stat, unlink, writeFile } from "node:fs/promises";import { basename, join } from "node:path";@@ -8,6 +8,7 @@ import { backgroundNodeExecutable } from "./background-node.mjs";import { fileURLToPath, pathToFileURL } from "node:url";import { release as operatingSystemRelease } from "node:os";import { BackupManager } from "./backup-manager.mjs";+import { createBackupWorkerFactory } from "./backup-worker.mjs";import { registerBackupIpc } from "./backup-ipc.mjs";import { SidecarRpcClient } from "./rpc.mjs";import { instanceOrigin, encodeSessionCredential, decodeSessionCredential, credentialForUrl } from "./session-credential.mjs";@@ -1933,6 +1934,7 @@ const startApplication = async () => {});backupManager = new BackupManager({userData: app.getPath("userData"), defaultDirectory: join(app.getPath("documents"), "EdgeEver Backups"), secureStorage: safeStorage,+ workerFactory: createBackupWorkerFactory({ utilityProcess, session: session.defaultSession }),version: { edgeeverVersion: app.getVersion(), buildId: app.getVersion() },onChange: (status) => { if (mainWindow && !mainWindow.isDestroyed()) mainWindow.webContents.send("desktop:backup-status", status); },onDiagnostic: (event, details) => writeDiagnostic(event, details),diff --git a/docs/changes/2026-11-01-desktop-backup-system-network.md b/docs/changes/2026-11-01-desktop-backup-system-network.mdnew file mode 100644index 00000000..dbf8c541--- /dev/null+++ b/docs/changes/2026-11-01-desktop-backup-system-network.md@@ -0,0 +1,50 @@+# Desktop backups follow the system network++[简体中文](2026-11-01-desktop-backup-system-network.zh-CN.md)++## Problem and outcome++Desktop synchronization uses Electron networking, but the backup worker uses Node's global `fetch`. On a network that requires the system proxy, synchronization succeeds while the first scheduled backup times out connecting to `/api/v1/backups/state`. Backups and restores should follow each user's system network settings, without hardcoded proxy addresses or changes to the operating system.++The shared session also enables HTTP caching. Attachment responses are cacheable for an hour while replacement preserves the download URL. A backup can therefore receive old bytes after its data pages report a new SHA-256, failing with `incompleteResources`. Backup transport must bypass this cache so each archive matches current metadata.++Product changes cover desktop backup/restore network execution only, without note-list ordering or sharing changes. Reuse upstream's general CI stabilization rather than retaining independent import or appearance changes in this PR.++## Allowed changes and acceptance++1. Run desktop backup network requests through Electron's Chromium network stack and the same default session used by synchronization. This covers backup state/pages/attachment downloads and restore requests/uploads. Keep explicit bearer authentication and `credentials: "omit"`; do not start sending cookies. Users without a proxy continue to connect directly.+2. Keep archive creation, validation, encryption and disk work off the main process. Prefer Electron's existing utility-process API, with a thin adapter retaining the manager's message, cancellation, failure and termination contract. Preserve streaming downloads and bounded multipart uploads rather than buffering entire attachments/archives or relaying their bytes through the main process. Retain Node-worker execution for existing non-Electron tests/callers, not as a network fallback.+3. Preserve scheduling, unchanged-source checks, retention, paths, archive format, restore confirmation, account isolation, error diagnostics and request counts. Add no retry, timeout, proxy setting, certificate exception, migration or dependency.+4. Exercise the actual Electron runtime against a proxy-only fixture and a direct fixture, including export, attachment integrity, restore, cancellation/failure and worker exit. Verify streaming resource use with a representative attachment, compare request paths/counts, and reuse the existing focused backup tests. Run the required Web/mobile type checks and Web build for this branch.+5. Verify the real Cloudflare desktop workflow with a local candidate: load the existing backup configuration, create an archive containing the synced test note, inspect cumulative D1 reads without production full scans/stress, and keep the application and backup settings usable. Distinguish candidate execution from installation/release; do not deploy this dirty source tree or publish a release.+6. Align the independent branch with the latest upstream `main` and verify backup behavior with the updated shared archive/client code. Add a directly runnable backup-network test command and a path-filtered CI workflow running the same real Electron proxy/direct scenarios on macOS, Windows and Linux, with Xvfb on Linux and an official-repository job gate before runner allocation. Use cross-platform fixture entrypoint paths and isolate fixture data from user configuration; add no product network retry, timeout or proxy setting. Distinguish CI runtime evidence from packaged-release acceptance.++ Fixture children have a 40-second deadline inside the 45-second test timeout; cleanup waits for servers and children to close. Beyond the SQLite query-cache capacity, Bun 1.3.14's ordinary `close()` can leave statements and Windows file locks alive ([Bun #36572](https://github.com/oven-sh/bun/issues/36572)). Collect temporary statements and require `close(true)` before removing fixture directories. This replaces deletion retries so database-handle release does not depend on retry timing. Linux CI configures the downloaded `chrome-sandbox` owner/mode as required by Electron rather than disabling its sandbox. These settings apply only to isolated fixtures.+7. Integrate upstream CI stabilization `1bdcdefc`: import fixtures use the real self-hosted server's WAL/NORMAL, foreign-key and busy-timeout settings, and the long appearance test is split into independent scenarios. Adopt this shared solution instead of this branch's earlier transactional fixture setup; final import/appearance test source must match upstream. Change no product import/appearance behavior, test timeout, retry or test selection. Verify the complete import file and existing Ubuntu `bun run test`/browser CI entrypoints alongside the backup runtime on current upstream.+8. Force `cache: "no-store"` after caller options for Electron backup/restore requests, neither reading nor populating the shared HTTP cache. Retain session/proxy selection, bearer authentication, cookie omission, streaming and cancellation; do not clear the user's global cache or change non-Electron callers. Keep fixture attachment responses cacheable: successfully export once, replace attachment bytes/SHA-256 and advance the backup revision without changing its URL or length, then export again in the same session. The second export must download current bytes from the server and restore them successfully through both proxy and direct connections. Retain large-attachment streaming and unchanged-source checks; download each attachment once per new archive without adding retries, polling or metadata scans.++## Boundaries, risk and recovery++The value is consistent connectivity without requiring users to configure two networking stacks. The main risks are worker lifecycle differences and loss of streaming/cancellation behavior; worst cases are a failed backup/restore request or a worker left running. Preserve manager publication/verification safeguards so a failed task is not recorded as a completed archive. Roll back the independent transport adapter and worker entrypoint; no stored format or configuration migration is involved.++Installation, automatic updates, data storage, authentication and server protocols are unchanged. Existing archives and backup configuration must remain readable. Keep actual installed application files and user data intact; use a separate candidate and retain the official installer. Windows/Linux runtime behavior and packaged signing remain unverified until those platforms/releases are exercised; macOS checks do not establish cross-platform acceptance.++## Implementation decision++Use Electron utility processes with the default session and `net.fetch`, keeping the existing backup algorithm and streaming pipeline in the background. This avoids introducing a proxy parser/agent, a per-machine configuration, or a custom main-process streaming bridge. Keep the Node worker port as an execution adapter for existing tests, not a fallback after failed requests.++Force `cache: "no-store"` only in the backup transport adapter, after caller options. Do not clear the shared session cache or change server attachment cache headers, preserving normal note-browsing caching. Each attachment is still downloaded once per new archive, and unchanged-source checks still skip archive generation.++Run real Electron regressions in a separate, path-filtered CI workflow rather than starting desktop processes during ordinary Bun unit tests or charging unrelated Web changes for three-platform runs. Each platform covers proxy/direct transport and worker exit because this change replaces the desktop worker runtime. Packaged signing, in-app updates and release acceptance remain with the existing release workflows.++Adopt upstream `1bdcdefc` for general CI instead of this branch's earlier transactional import fixture. Its SQLite settings match `scripts/self-hosted-server.mjs` and the real runtime more closely; appearance checks are split by independent behavior while retaining assertions and deadlines. Do not layer a second fixture-initialization mechanism or change product storage/UI behavior.++## Completion check++- Desktop entry now supplies a utility-process worker bound to `session.defaultSession`; the bundled worker selects `net.fetch` only in that runtime. Its Node thread entry and injected worker contract remain usable. The manager, archive/storage/authentication logic and server code are unchanged. The build keeps `electron` external, and fixture scripts live under the existing excluded `tests` directory.+- The proxy-only regression failed with the original Node worker before implementation. The real Electron proxy/direct scenarios pass: scheduled export, 32 MiB attachment round trip, unchanged-source due check, confirmed restore, HTTP 503, cancellation and all five worker exits. Both transports issued the same 47 fixture API requests; the due unchanged check did not create another archive. Bearer headers were retained and session cookies were omitted. Run `bun run test:desktop:backup-network`, which builds the worker first; set `EDGE_EVER_BACKUP_ATTACHMENT_MIB=128` for the larger fixture. The 57 existing backup manager/IPC/Node-worker tests also pass, as do both required type checks and the desktop Web build.+- The 128 MiB proxy fixture exported and restored successfully. Main-process working set stayed about 144 MiB for both 32 and 128 MiB attachments; utility-worker peaks were about 301 and 318 MiB. The original Node-thread 32 MiB case peaked at about 434 MiB in the main process, versus about 445 MiB for the sum of the new main/worker peaks. These local per-process peaks are not necessarily simultaneous and omit the network service; they show bounded growth rather than an archive-sized main-process buffer. Maximum 25 ms timer lateness in the measured candidate fixtures was below 9 ms. [Machine-readable evidence](evidence/2026-11-01-desktop-backup-system-network/results.json).+- A local candidate reused the real official v2.16.1 profile, its enabled weekly/one-copy settings, and the unchanged official renderer/native sidecar. A manual Cloudflare backup completed: 175,373 bytes, 41 ZIP entries, CRC verification passed, and the previously synced validation note's exact body was present. The next real scheduled run is not due; scheduled behavior was verified in the isolated Electron fixture. The D1 24-hour row chart moved approximately 19.08k → 19.81k during connection/backup validation, including ordinary usage and initialization; this is not a per-backup or large-library cost measurement. No production scan/stress was used.+- Scope reconciliation: actual product changes are the runtime/factory adapters, desktop wiring, the external Electron build import and backup-only cache bypass, corresponding to items 1–3 and 8. Tests, CI and evidence cover items 4–8. No proxy configuration, request retry, archive/state format, storage/authentication mechanism, dependency or server change was added. The official v2.16.1 client could still read the completed backup history and existing schedule written by the candidate; this compatibility check used a candidate runtime, not a packaged release installation. All three runtimes must pass backup-network CI; packaged artifacts, signing and cross-version release acceptance remain with the release stage.+- The independent PR branch integrates upstream `main` (`1bdcdefc`); import/appearance test source matches upstream, and all 71 import cases with 621 assertions pass. Existing evidence for the 57 related tests, Web/mobile type checks and Web build remains applicable to unchanged paths. The backup command builds the worker automatically. A path-filtered workflow gates runner allocation to the official repository, runs proxy/direct regressions on macOS/Windows/Linux and saves reports. Fixture children are terminated/waited for within test deadlines before cleanup; these limits do not alter product requests.+- The same-URL regression reproduced `incompleteResources` before the product fix. Both proxy/direct cases pass with `no-store`. Retain the 32 MiB streaming attachment and add a 64 KiB cacheable attachment so different runner cache sizes do not hide the regression. Before the second export, change one byte without changing length/URL, update its hash and advance the backup revision via the resource trigger. The second archive restores current bytes; each new archive downloads that attachment once while responses remain `private, max-age=3600`. Each expanded default scenario makes 66 API requests and reaps all six workers; larger attachments add only the existing 8 MiB upload parts. Earlier single-archive/47-request performance measurements still describe that original scenario. Type checking, worker build and changed-file lint pass.diff --git a/docs/changes/2026-11-01-desktop-backup-system-network.zh-CN.md b/docs/changes/2026-11-01-desktop-backup-system-network.zh-CN.mdnew file mode 100644index 00000000..30f0ae42--- /dev/null+++ b/docs/changes/2026-11-01-desktop-backup-system-network.zh-CN.md@@ -0,0 +1,50 @@+# 桌面备份遵循系统网络设置++[English](2026-11-01-desktop-backup-system-network.md)++## 问题与目标++桌面同步使用 Electron 网络栈,备份工作线程却使用 Node 的全局 `fetch`。在依赖系统代理的网络中,同步正常,首次自动备份连接 `/api/v1/backups/state` 超时。备份与恢复应遵循每位用户自己的系统网络设置,不硬编码代理地址,也不修改操作系统配置。++共享 session 还会启用 HTTP 缓存。附件响应允许缓存一小时,而替换附件内容保留下载 URL;如果备份复用旧缓存,即使数据页已经包含新 SHA-256,下载仍可能拿到旧字节并触发 `incompleteResources`。备份传输必须绕过该缓存,保持每份归档内容与当前元数据一致。++产品变更仅涉及桌面备份与恢复的网络执行方式,不包含笔记列表排序或分享功能。通用回归的稳定化复用上游统一修复,不在本 PR 中保留独立的导入或外观功能改动。++## 允许变更与验收++1. 桌面备份网络请求使用 Electron 的 Chromium 网络栈,以及同步使用的同一个默认 session;覆盖备份状态、分页、附件下载及恢复请求、上传。保留显式 bearer 认证与 `credentials: "omit"`,不开始发送 cookie。未配置代理的用户仍然直连。+2. 归档生成、校验、加密和磁盘操作仍在主进程外执行。优先使用 Electron 已有的 utility process,以薄适配保留管理器的消息、取消、失败和终止契约。下载保持流式、分片上传保持有界,不缓存整个附件或归档,也不经主进程中转文件字节。保留既有非 Electron 测试/调用方的 Node worker 执行方式,不作为网络失败后的 fallback。+3. 保留调度、源未变化检查、保留数量、路径、备份格式、恢复确认、账号隔离、错误诊断及请求次数。不新增重试、超时、代理设置、证书例外、迁移或依赖。+4. 使用真实 Electron 运行时验证仅代理可达的测试实例及直连实例,覆盖导出、附件完整性、恢复、取消/失败及工作进程退出。以代表性附件验证流式资源开销、比较请求路径和次数,并复用现有相关备份测试。对本分支执行必需的 Web/移动端类型检查及 Web 构建。+5. 用本地候选验证真实 Cloudflare 桌面流程:读取既有备份配置,生成包含已同步测试笔记的归档,查看累计 D1 读取量,不对生产库全量扫描或压测;应用及备份设置保持可用。区分候选运行、安装与发布,不从脏工作区部署服务端,也不发布 Release。+6. 独立分支对齐最新上游 `main`,验证共享归档/客户端变化后的备份路径。新增可直接执行的备份网络测试命令及按相关路径触发的 CI,在 macOS、Windows、Linux 运行相同的真实 Electron 代理/直连场景;Linux 使用 Xvfb,CI job 仅在官方仓库分配 Runner。测试入口使用跨平台文件路径;测试环境与用户配置隔离,不增加产品网络重试、超时或代理设置。区分 CI 运行时结果与正式安装包验收。++ fixture 的子进程期限为 40 秒,位于 45 秒用例期限内;清理等待服务器和子进程关闭。Bun 1.3.14 在超过 SQLite 查询缓存容量时,普通 `close()` 仍可能留下 statement 和 Windows 文件锁([Bun #36572](https://github.com/oven-sh/bun/issues/36572));fixture 回收临时 statement 后使用 `close(true)` 确认完整关闭,再删除目录。这替代了删除重试方案,避免依赖重试时机释放数据库句柄。Linux CI 按 Electron 要求设置下载的 `chrome-sandbox` 所有者与权限,不关闭沙箱。这些设置仅用于隔离测试环境。+7. 同步上游 CI 稳定化提交 `1bdcdefc`:导入夹具使用与真实自托管服务相同的 WAL/NORMAL、外键和 busy timeout 设置,外观长用例拆成独立场景。采用该统一方案,替代本分支此前的事务化建库修复;最终导入与外观测试源码和上游一致。不改产品导入/外观功能,不增加测试超时、重试或跳过用例。验证完整导入文件及原有 Ubuntu `bun run test`、浏览器 CI 入口;备份运行时与最新上游共同验收。+8. 备份与恢复的 Electron 请求在调用方选项之后强制 `cache: "no-store"`,既不读取也不写入共享 HTTP 缓存,保留 session/代理、bearer、cookie 省略、流式和取消行为;不清理用户全局缓存,非 Electron 调用方不变。真实 Electron 回归保留可缓存的附件响应,在相同 session 中先成功导出,再同 URL、同长度替换附件字节与 SHA-256 并推进备份 revision,第二次导出必须从服务端取得新字节并成功恢复。代理/直连均覆盖此场景,保留大附件流式及源未变化检查;每份新归档中每个附件只下载一次,不增加重试、轮询或额外元数据扫描。++## 保持不变的边界、风险与恢复++功能价值是连接行为一致,用户无需配置两套网络栈。主要风险是工作进程生命周期差异、流式与取消行为退化;最坏影响是备份/恢复请求失败或工作进程未退出。保留管理器的发布和校验保护,失败任务不得记为成功归档。回滚独立的网络适配与工作进程入口即可,无存储格式或配置迁移。++安装、自动升级、数据存储、认证及服务端协议不变。既有归档及备份配置必须仍可读取。保留实际安装应用和用户数据,使用独立候选并保留官方安装包。Windows/Linux 运行时行为及安装包签名须在对应平台/发布阶段验证;macOS 检查不代表跨平台验收。++## 实施决策++使用绑定默认 session 的 Electron utility process 与 `net.fetch`,既有备份算法和流式管线继续在后台执行。这样无需引入代理解析/代理 agent、个人配置或自行实现主进程流式中转。Node worker port 仅作为既有测试的运行适配,不在请求失败后回退。++仅在备份传输适配器强制 `cache: "no-store"`,覆盖调用方的 cache 选项。不清空共享 session 缓存,也不修改服务端附件缓存头,避免扰动普通笔记浏览的缓存。每个附件仍只在生成新归档时下载一次;源未变化检查仍不导出归档。++真实 Electron 回归放在独立、按路径触发的 CI 工作流中,避免默认 Bun 单测误启动桌面进程,也不让无关 Web 改动承担三平台运行成本。三个平台都覆盖代理/直连和进程退出,因为本次变更替换了桌面工作进程运行时;安装包签名、应用内升级和发布仍由既有发布流程验收。++通用 CI 采用上游 `1bdcdefc` 的统一稳定化方案,替代本分支先前的事务化导入夹具:SQLite 设置与 `scripts/self-hosted-server.mjs` 一致,更贴近真实运行条件;外观用例按独立行为拆分,保留原有断言和期限。不叠加第二套测试初始化机制,也不修改产品存储或界面行为。++## 完成核对++- 桌面入口注入绑定 `session.defaultSession` 的 utility process;打包工作程序仅在该运行时使用 `net.fetch`。原有 Node 线程入口与可注入 worker 契约仍可用。管理器、归档/存储/认证逻辑和服务端代码不变。构建将 `electron` 保留为外部导入,测试脚本放入原本排除打包的 `tests` 目录。+- 实现前,原 Node worker 在仅代理可达的回归实例上因 `backup_failed / fetch failed` 失败。真实 Electron 的代理/直连场景均通过:自动调度导出、32 MiB 附件往返、到期但源未变化检查、确认后恢复、HTTP 503、取消以及五个工作进程全部退出。两种网络均发送相同的 47 次测试 API 请求;到期未变化检查未再次生成归档。bearer 头保留,session cookie 未发送。执行 `bun run test:desktop:backup-network`,命令会先构建工作程序;设置 `EDGE_EVER_BACKUP_ATTACHMENT_MIB=128` 可使用更大附件。现有 57 项备份管理器/IPC/Node worker 测试、两项类型检查及桌面 Web 构建通过。+- 128 MiB 代理场景完整导出并恢复成功。32 与 128 MiB 附件的主进程工作集均约 144 MiB,utility worker 峰值约 301、318 MiB。原 Node 线程方案在 32 MiB 场景下主进程峰值约 434 MiB;新方案主进程与 worker 各自峰值之和约 445 MiB。这些本地分进程峰值不一定同时发生,且不含网络服务;结果体现有界增长,而非在主进程缓存整份归档。候选测量中的 25 ms 定时器最大额外延迟低于 9 ms。[机器可读证据](evidence/2026-11-01-desktop-backup-system-network/results.json)。+- 本地候选复用了真实官方 v2.16.1 的既有配置、已开启的每周/保留一份设置,以及未修改的官方渲染代码和原生 sidecar。真实 Cloudflare 手动备份成功:175,373 字节、41 个 ZIP 条目,CRC 检查通过,包含此前已同步验收笔记的完整正文。下一次真实自动备份尚未到期,调度行为由隔离的 Electron 场景验证。连接与备份验证期间,D1 24 小时读取行图表约由 19.08k 增至 19.81k,包含普通使用和初始化,不是单次备份或大库读取成本;未进行生产扫描或压测。+- 双向范围核对:产品实际改动为运行时/factory 适配、桌面接线、构建中的外部 Electron 导入,以及备份专用缓存绕过,均对应条目 1–3、8;测试、CI 与证据对应条目 4–8。未增加代理配置、请求重试、归档/状态格式、存储/认证机制、依赖或服务端变化。正式 v2.16.1 客户端可继续读取候选写入的成功备份记录与原有计划;这项兼容性验证使用候选运行,不是正式发布安装。三平台运行时须通过备份网络 CI,正式安装包、签名和跨版本发布验收仍属于发布阶段。+- 独立 PR 分支已同步上游 `main`(`1bdcdefc`),导入与外观测试源码和上游一致;完整导入回归 71 项、621 条断言通过。原有 57 项相关测试、Web/移动端类型检查和 Web 构建证据继续适用于未改变的路径。备份命令自动构建 worker;独立 CI 仅对相关路径触发并以官方仓库门禁保护 Runner,在 macOS/Windows/Linux 执行代理/直连回归并保存报告。fixture 在测试期限内终止并等待自己的 Electron 子进程后清理;这些限制不进入产品请求逻辑。+- 同 URL 附件回归在修改产品代码前真实复现 `incompleteResources`;强制 `no-store` 后,代理/直连两项场景均通过。保留 32 MiB 大附件,另用 64 KiB 可缓存附件排除不同 runner 缓存容量的影响;第二次导出前只改变其中一个字节、保持长度和 URL,更新 hash 触发备份 revision 推进。第二份归档恢复出当前字节,两份新归档各从服务端下载该附件一次,响应仍为 `private, max-age=3600`。扩展后的默认场景均为 66 次 API 请求、6 个工作进程全部退出;较大的附件只按既有 8 MiB 上传分片增加次数。此前单归档/47 次请求的性能测量仍对应原场景。类型检查、工作程序构建及变更文件 lint 通过。diff --git a/docs/changes/evidence/2026-11-01-desktop-backup-system-network/results.json b/docs/changes/evidence/2026-11-01-desktop-backup-system-network/results.jsonnew file mode 100644index 00000000..2fabd82b--- /dev/null+++ b/docs/changes/evidence/2026-11-01-desktop-backup-system-network/results.json@@ -0,0 +1,99 @@+{+ "runtime": "macOS arm64 / Electron 44.7.0 / Chromium 152",+ "regression": {+ "baselineNodeWorkerProxyOnlyFixture": "failed with backup_failed / fetch failed before the change",+ "electronProxyAndDirectScenarios": "passed",+ "focusedBackupContracts": 57,+ "failures": 0,+ "webTypecheck": "passed",+ "mobileTypecheck": "passed",+ "desktopWebBuild": "passed"+ },+ "transport": {+ "sourceStateRequestsAcrossExportAndUnchangedCheck": 3,+ "sourceDataPages": 3,+ "downloadPerAttachment": 1,+ "restoreBearerPreserved": true,+ "cookiesOmitted": true,+ "retryAdded": false,+ "workersExitedPerScenario": 5,+ "directAndProxyApiRequestCount": 47,+ "unchangedDueCheckCreatesArchive": false+ },+ "performance": {+ "metric": "Local Electron app.getAppMetrics working-set peaks in KiB; process peaks are not necessarily simultaneous. Network-service memory is not included. This is not production latency.",+ "nodeThread32MiB": {+ "archiveBytes": 33729791,+ "workersExited": 0,+ "peakWorkerKiB": 0,+ "peakMainKiB": 444512,+ "maxTimerDelayMs": 2.5726250000000164,+ "proxyRequests": 0+ },+ "utilityDirect32MiB": {+ "archiveBytes": 33729761,+ "workersExited": 5,+ "peakWorkerKiB": 301488,+ "peakMainKiB": 147072,+ "maxTimerDelayMs": 8.325874999999996,+ "proxyRequests": 0+ },+ "utilityProxy32MiB": {+ "archiveBytes": 33729790,+ "workersExited": 5,+ "peakWorkerKiB": 308592,+ "peakMainKiB": 147072,+ "maxTimerDelayMs": 6.260792000000038,+ "proxyRequests": 54+ },+ "utilityProxy128MiB": {+ "archiveBytes": 134393092,+ "workersExited": 5,+ "peakWorkerKiB": 325328,+ "peakMainKiB": 147248,+ "maxTimerDelayMs": 4.753042000000278,+ "proxyRequests": 66+ }+ },+ "cloudflare": {+ "serverVersion": "2.16.1",+ "serverMigration": "0084",+ "officialProfileConfigurationReused": true,+ "candidateManualBackupSucceeded": true,+ "archiveBytes": 175373,+ "archiveEntries": 41,+ "zipCrcErrors": null,+ "syncedValidationNoteBodyPresent": true,+ "automaticBackupEnabled": true,+ "interval": "weekly",+ "retention": 1,+ "realScheduledBackupWithCandidate": "not due; scheduled export and unchanged-source checks exercised in the isolated Electron fixture",+ "d1ReadRowChart24hApproxBefore": 19080,+ "d1ReadRowChart24hApproxAfter": 19810,+ "d1MetricScope": "Cumulative dashboard chart including initialization and ordinary usage; approximate/lagged, not the cost of one backup or a large-library acceptance."+ },+ "acceptanceLimitations": {+ "installedOfficialBundleContainsFix": false,+ "officialV2161ReadsCandidateBackupHistoryAndExistingSchedule": true,+ "windowsAndLinuxLocalRuntimeVerified": false,+ "packagedCandidateAndCrossVersionReleaseVerified": false+ },+ "submissionValidation": {+ "upstreamBase": "feff718afa08d8dfed5c05e85d6287d87f4e0a08",+ "focusedBackupContracts": 57,+ "electronNetworkScenarios": 2,+ "apiRequestsPerScenario": 47,+ "workersExitedPerScenario": 5,+ "webTypecheck": "passed",+ "mobileTypecheck": "passed",+ "desktopWebBuild": "passed",+ "fixtureEntryPoint": "bun run test:desktop:backup-network",+ "continuousIntegrationWorkflow": ".github/workflows/desktop-backup-network.yml",+ "continuousIntegrationPlatforms": [+ "macos-latest",+ "windows-latest",+ "ubuntu-latest"+ ],+ "continuousIntegrationRunnerGate": "github.repository == 'tianma-if/edgeever'"+ }+}diff --git a/package.json b/package.jsonindex 5db00662..42393e08 100644--- a/package.json+++ b/package.json@@ -68,6 +68,7 @@"publish:stores": "bun scripts/store-delivery.mjs","publish:extension": "bun scripts/publish-web-clipper.mjs","test:plugin-sync": "bun tests/plugin-structured-sync.integration.mjs",+ "test:desktop:backup-network": "bun apps/desktop/scripts/build-backup-worker.mjs && bun test ./apps/desktop/src/backup/tests/electron-network.integration.mjs","test:desktop:sidecar": "bun scripts/test-desktop-sidecar.mjs && bun run test:plugin-sync","test:desktop": "bun test apps/desktop/src/main --path-ignore-patterns='apps/desktop/src/main/{acp-cleanup,acp-adapter-manager,acp-host,workbuddy-auth,antigravity-proxy,acp-mcp-bridge}.test.mjs' apps/web/src/lib/api.test.mjs apps/web/src/lib/app-page-path.test.mjs apps/web/src/lib/clipboard.test.mjs apps/web/src/lib/desktop-renderer-ready.test.mjs apps/web/src/lib/desktop-workspace-restore.test.mjs apps/web/src/lib/desktop-repository.test.mjs apps/web/src/lib/desktop-resources.test.mjs apps/web/src/lib/desktop-acp.test.mjs apps/web/src/lib/desktop-sync.test.mjs apps/web/src/lib/local-mirror.test.mjs apps/web/src/lib/repository.test.mjs apps/web/src/lib/runtime.test.mjs apps/web/src/lib/picgo.test.mjs apps/web/src/lib/screenshot-import.test.mjs apps/web/src/lib/wechat-chat-import.test.mjs apps/web/src/lib/shared-file-import.test.mjs apps/web/src/lib/sync-queue.test.mjs && bun test --cwd apps/desktop src/main/acp-cleanup.test.mjs src/main/acp-adapter-manager.test.mjs src/main/acp-host.test.mjs src/main/workbuddy-auth.test.mjs src/main/antigravity-proxy.test.mjs src/main/acp-mcp-bridge.test.mjs && bun run test:desktop:sidecar","verify:desktop-renderer": "bun scripts/verify-desktop-renderer.mjs",