25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(agent-runtime): 启动恢复后同步运行时快照
Illuminated2020651806100889
diff --git a/src/App.vue b/src/App.vueindex d849be0458..4db8219410 100644--- a/src/App.vue+++ b/src/App.vue@@ -38,6 +38,7 @@ import { isCloseTabShortcut, isExecuteSqlShortcut } from "@/lib/keyboardShortcutimport { isPreviewTab } from "@/lib/tabPresentation";import { SQL_FILE_UNSUPPORTED_TYPES } from "@/lib/databaseCapabilities";import { classifyAiSqlExecution } from "@/lib/aiSqlExecutionPolicy";+import { restoreStartupAgentRuntime } from "@/lib/appStartup";import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";@@ -448,15 +449,14 @@ function onLoginSuccess() {}function initApp() {- savedSqlStore- .initFromStorage()- .then(() => connectionStore.initFromDisk())- .then(() => {- reconnectRestoredTabs();- })- .catch((e: any) => {- toast(t("connection.loadFailed", { message: e?.message || String(e) }), 5000);- });+ restoreStartupAgentRuntime({+ initSavedSql: () => savedSqlStore.initFromStorage(),+ initConnections: () => connectionStore.initFromDisk(),+ reconnectRestoredTabs,+ scheduleSync: () => agentRuntimeStore.scheduleSync(),+ }).catch((e: any) => {+ toast(t("connection.loadFailed", { message: e?.message || String(e) }), 5000);+ });settingsStore.initAiConfig();}diff --git a/src/lib/appStartup.ts b/src/lib/appStartup.tsnew file mode 100644index 0000000000..6545419cb4--- /dev/null+++ b/src/lib/appStartup.ts@@ -0,0 +1,13 @@+export interface RestoreStartupAgentRuntimeOptions {+ initSavedSql: () => Promise<unknown>;+ initConnections: () => Promise<unknown>;+ reconnectRestoredTabs: () => Promise<unknown> | unknown;+ scheduleSync: () => void;+}++export async function restoreStartupAgentRuntime(options: RestoreStartupAgentRuntimeOptions) {+ await options.initSavedSql();+ await options.initConnections();+ await options.reconnectRestoredTabs();+ options.scheduleSync();+}diff --git a/tests/agentRuntimeSnapshot.test.ts b/tests/agentRuntimeSnapshot.test.tsindex 3b02ddf167..4a99ababa8 100644--- a/tests/agentRuntimeSnapshot.test.ts+++ b/tests/agentRuntimeSnapshot.test.ts@@ -1,6 +1,7 @@import { strict as assert } from "node:assert";import test from "node:test";import { buildAgentRuntimeSnapshot } from "../src/lib/agentRuntimeSnapshot.ts";+import { restoreStartupAgentRuntime } from "../src/lib/appStartup.ts";test("builds runtime snapshot from active tab, selection, and limited result rows", () => {const snapshot = buildAgentRuntimeSnapshot({@@ -78,3 +79,24 @@ test("omits empty selected SQL and marks empty UI selection as none", () => {assert.deepEqual(snapshot.selection, { type: "none" });assert.equal(snapshot.result, undefined);});++test("schedules startup runtime sync only after connections and restored tabs are ready", async () => {+ const calls: string[] = [];++ await restoreStartupAgentRuntime({+ initSavedSql: async () => {+ calls.push("saved-sql");+ },+ initConnections: async () => {+ calls.push("connections");+ },+ reconnectRestoredTabs: async () => {+ calls.push("reconnect");+ },+ scheduleSync: () => {+ calls.push("schedule");+ },+ });++ assert.deepEqual(calls, ["saved-sql", "connections", "reconnect", "schedule"]);+});