Skip to content
Python

fix(memhub): explain the wait and the failure on first launch

kristinheca4a66349b53
diff --git a/memhub/apps/desktop/src/main.ts b/memhub/apps/desktop/src/main.ts
index edb4aa5..f8dc657 100644
--- a/memhub/apps/desktop/src/main.ts
+++ b/memhub/apps/desktop/src/main.ts
@@ -113,6 +113,7 @@ import {
installServiceWithDisabledFallback,
isInstalledApplicationsApp,
stableRuntimeErrorCode,
+ stableRuntimeUserMessage,
startStableRuntimeRepair,
} from "./stable-runtime";
import { STARTUP_SCREEN_URL, startupScreenHtml } from "./startup-screen";
@@ -1671,7 +1672,7 @@ if (desktopVersion !== null) {
languagePreferences?.read().locale ?? "zh-CN",
"nativeErrorTitle",
),
- error instanceof Error ? error.message : "desktop_unavailable",
+ stableRuntimeUserMessage(error),
);
},
});
diff --git a/memhub/apps/desktop/src/stable-runtime.test.ts b/memhub/apps/desktop/src/stable-runtime.test.ts
index 206873f..cf277a7 100644
--- a/memhub/apps/desktop/src/stable-runtime.test.ts
+++ b/memhub/apps/desktop/src/stable-runtime.test.ts
@@ -274,4 +274,27 @@ describe("startup install errors", () => {
"MemHub 启动失败",
);
});
+
+ it("says why a data upgrade failed, and what the person can do", () => {
+ const noSpace = stableRuntimeUserMessage(
+ new Error("sdk_migration_disk_space_insufficient"),
+ );
+ // The only failure here the person fixes themselves: name the action.
+ expect(noSpace).toContain("磁盘空间不足");
+ expect(noSpace).toContain("重新启动");
+ expect(noSpace).toContain("不会丢失");
+ expect(noSpace).not.toContain("sdk_migration_disk_space_insufficient");
+
+ const noModel = stableRuntimeUserMessage(
+ new Error("model_profile_not_active"),
+ );
+ expect(noModel).toContain("模型");
+ expect(noModel).not.toContain("model_profile_not_active");
+
+ const coding = stableRuntimeUserMessage(
+ new Error("sdk_migration_working_fact_conflict"),
+ );
+ expect(coding).toContain("Coding");
+ expect(coding).toContain("不会丢失");
+ });
});
diff --git a/memhub/apps/desktop/src/stable-runtime.ts b/memhub/apps/desktop/src/stable-runtime.ts
index 1fedd10..89db81a 100644
--- a/memhub/apps/desktop/src/stable-runtime.ts
+++ b/memhub/apps/desktop/src/stable-runtime.ts
@@ -126,6 +126,21 @@ const SAFE_STABLE_RUNTIME_ERROR_CODES = new Set([
"installed_version_conflict",
"distribution_downgrade_refused",
"install_current_unmanaged",
+ // Migration runs before the app window exists, so these are the only names
+ // a first launch can be given. They stay codes here and become sentences in
+ // STABLE_RUNTIME_USER_MESSAGES: a person reading the dialog never sees them.
+ "model_profile_not_active",
+ "model_secret_unavailable",
+ "sdk_migration_preflight_failed",
+ "sdk_migration_disk_space_insufficient",
+ "sdk_migration_staging_failed",
+ "sdk_migration_backfill_failed",
+ "sdk_migration_working_fact_conflict",
+ "sdk_migration_coding_inventory_failed",
+ "sdk_migration_bundle_copy_failed",
+ "sdk_migration_response_invalid",
+ "sdk_migration_status_unavailable",
+ "sdk_migration_incomplete",
]);
export function stableRuntimeErrorCode(error: unknown): string {
@@ -191,6 +206,30 @@ export const STABLE_RUNTIME_USER_MESSAGES: Record<string, string> = {
"已安装的运行环境比这个安装包更新,无法用旧安装包启动。请安装最新版本的 MemHub;你的记忆数据不会受到影响。",
install_current_unmanaged:
"运行环境的安装目录被改动过,无法安全接管。请重新安装 MemHub,你的记忆数据不会受到影响。",
+ model_profile_not_active:
+ "还没有配置可用的模型,无法升级记忆数据格式。请在旧版本中完成模型配置后重启;你的记忆数据不会受到影响。",
+ model_secret_unavailable:
+ "模型密钥读不到(可能被系统钥匙串拒绝)。请允许 MemHub 访问钥匙串后重新启动;你的记忆数据不会受到影响。",
+ sdk_migration_disk_space_insufficient:
+ "磁盘空间不足,升级记忆数据格式时中断了。请至少腾出与记忆数据同等大小的可用空间(可在「关于本机 → 储存空间」查看),然后重新启动 MemHub;升级会自动继续,原有记忆数据不会丢失。",
+ sdk_migration_staging_failed:
+ "升级准备工作没有完成,通常是磁盘空间不足或文件被占用。请清理磁盘空间后重新启动;原有记忆数据不会丢失。",
+ sdk_migration_bundle_copy_failed:
+ "升级前备份没有写完,通常是磁盘空间不足。请清理磁盘空间后重新启动;原有记忆数据不会丢失。",
+ sdk_migration_working_fact_conflict:
+ "旧版数据里有一条 Coding 记忆的记录类型在升级中无法安全对应。为避免写错你的记忆,升级已停止。请把这个提示反馈给我们;原有记忆数据不会丢失。",
+ sdk_migration_coding_inventory_failed:
+ "读取旧版 Coding 记忆时发现无法识别的结构,升级已停止。请把这个提示反馈给我们;原有记忆数据不会丢失。",
+ sdk_migration_backfill_failed:
+ "升级记忆数据格式时失败,已停止且没有切换数据源。请重新启动重试;如果仍然失败,请把这个提示反馈给我们,原有记忆数据不会丢失。",
+ sdk_migration_preflight_failed:
+ "升级前的检查没有通过,升级已停止。请重新启动重试;如果仍然失败,请把这个提示反馈给我们,原有记忆数据不会丢失。",
+ sdk_migration_status_unavailable:
+ "读不到升级状态,无法判断是否需要升级。请重新启动 MemHub;如果仍然失败,请重新安装,你的记忆数据不会受到影响。",
+ sdk_migration_response_invalid:
+ "升级过程返回了无法识别的内容,已停止。原有记忆数据不会丢失;请重新启动重试,如果仍然失败,请把这个提示反馈给我们。",
+ sdk_migration_incomplete:
+ "记忆数据格式升级没有完成,MemHub 暂时无法打开。请重新启动重试;如果仍然失败,请把这个提示反馈给我们,原有记忆数据不会丢失。",
desktop_start_failed:
"MemHub 启动失败。请重新启动;如果仍然打不开,请重新安装,你的记忆数据不会受到影响。",
};
diff --git a/memhub/apps/desktop/src/startup-screen.test.ts b/memhub/apps/desktop/src/startup-screen.test.ts
index fe2c2b6..6114d05 100644
--- a/memhub/apps/desktop/src/startup-screen.test.ts
+++ b/memhub/apps/desktop/src/startup-screen.test.ts
@@ -21,6 +21,21 @@ describe("startup screen", () => {
);
expect(spanish).not.toMatch(/[一-鿿]/);
});
+ it("says an upgrade may take a while instead of leaving a silent wait", () => {
+ expect(startupScreenHtml()).toContain(
+ "首次启动或升级记忆数据可能需要几分钟,完成后会自动进入应用。",
+ );
+ expect(startupScreenHtml("en")).toContain(
+ "The first launch or a memory-data upgrade can take a few minutes.",
+ );
+ });
+ it("keeps a draggable strip so the waiting window can be moved", () => {
+ const html = startupScreenHtml();
+ // CSS alone does not move a frameless window: the region has to be a real
+ // element in the document, and it has to be the top strip.
+ expect(html).toContain('<div class="window-drag-region"');
+ expect(html).toContain("-webkit-app-region: drag");
+ });
it("is served from the app origin, not from the web bundle", () => {
expect(STARTUP_SCREEN_URL).toBe("one-memory://app/__startup");
});
diff --git a/memhub/apps/desktop/src/startup-screen.ts b/memhub/apps/desktop/src/startup-screen.ts
index 1b06000..c941376 100644
--- a/memhub/apps/desktop/src/startup-screen.ts
+++ b/memhub/apps/desktop/src/startup-screen.ts
@@ -37,6 +37,19 @@ export function startupScreenHtml(locale: GuiLocale = "zh-CN"): string {
"Helvetica Neue", Arial, sans-serif;
-webkit-font-smoothing: antialiased;
}
+ /* A frameless window still needs somewhere to grab; without this the
+ whole wait is undraggable. */
+ .window-drag-region {
+ position: absolute;
+ z-index: 1;
+ top: 0;
+ right: 0;
+ left: 0;
+ height: 58px;
+ -webkit-app-region: drag;
+ -webkit-user-select: none;
+ user-select: none;
+ }
@media (prefers-color-scheme: dark) {
body {
background: #15181d;
@@ -61,6 +74,13 @@ export function startupScreenHtml(locale: GuiLocale = "zh-CN"): string {
font-size: 13px;
opacity: 0.62;
}
+ p.hint {
+ max-width: 320px;
+ font-size: 12px;
+ line-height: 1.55;
+ text-align: center;
+ opacity: 0.45;
+ }
.bar {
position: relative;
width: 168px;
@@ -101,9 +121,11 @@ export function startupScreenHtml(locale: GuiLocale = "zh-CN"): string {
</style>
</head>
<body>
+ <div class="window-drag-region" aria-hidden="true"></div>
<main>
<h1>MemHub</h1>
<p>${translate(locale, "startupPreparing")}</p>
+ <p class="hint">${translate(locale, "startupUpgradeHint")}</p>
<div class="bar"><span></span></div>
</main>
</body>
diff --git a/memhub/package.json b/memhub/package.json
index 0fc8e9b..d8eeb54 100644
--- a/memhub/package.json
+++ b/memhub/package.json
@@ -2,7 +2,7 @@
"name": "one-memory",
"version": "1.0.5",
"release": {
- "build_number": 16,
+ "build_number": 17,
"macos_min_version": "13.0",
"app_update": "manual",
"runtime_manifest_schema": 1,
diff --git a/memhub/packages/i18n/src/gui-i18n-english.ts b/memhub/packages/i18n/src/gui-i18n-english.ts
index b20bf91..7e3a8a2 100644
--- a/memhub/packages/i18n/src/gui-i18n-english.ts
+++ b/memhub/packages/i18n/src/gui-i18n-english.ts
@@ -1933,6 +1933,8 @@ const baseEnglishMessages = {
languageLoadError: "Could not load the language setting. Please retry.",
nativeErrorTitle: "MemHub could not start",
startupPreparing: "Starting and preparing the memory service…",
+ startupUpgradeHint:
+ "The first launch or a memory-data upgrade can take a few minutes. MemHub opens automatically when it is done.",
} as const;
export const englishMessages = {
diff --git a/memhub/packages/i18n/src/gui-i18n-messages.ts b/memhub/packages/i18n/src/gui-i18n-messages.ts
index e21e422..b0f7ceb 100644
--- a/memhub/packages/i18n/src/gui-i18n-messages.ts
+++ b/memhub/packages/i18n/src/gui-i18n-messages.ts
@@ -52,6 +52,8 @@ const languageChineseMessages = {
languageLoadError: "无法加载语言设置,请重试。",
nativeErrorTitle: "MemHub 无法启动",
startupPreparing: "正在启动,正在准备记忆服务…",
+ startupUpgradeHint:
+ "首次启动或升级记忆数据可能需要几分钟,完成后会自动进入应用。",
} as const;
const languageSpanishMessages: Record<
@@ -71,6 +73,8 @@ const languageSpanishMessages: Record<
languageLoadError: "No se pudo cargar el idioma. Inténtalo de nuevo.",
nativeErrorTitle: "MemHub no pudo iniciarse",
startupPreparing: "Iniciando y preparando el servicio de memorias…",
+ startupUpgradeHint:
+ "El primer inicio o la actualización de tus memorias puede tardar unos minutos. La aplicación se abrirá automáticamente al terminar.",
};
type Catalog = {