Skip to content
Python

fix(desktop): keep an unknown startup failure code in the dialog

kristinhe111191250d7c8772
diff --git a/memhub/apps/desktop/src/main.ts b/memhub/apps/desktop/src/main.ts
index f8dc657..c38f775 100644
--- a/memhub/apps/desktop/src/main.ts
+++ b/memhub/apps/desktop/src/main.ts
@@ -113,7 +113,7 @@ import {
installServiceWithDisabledFallback,
isInstalledApplicationsApp,
stableRuntimeErrorCode,
- stableRuntimeUserMessage,
+ stableRuntimeFailureDetail,
startStableRuntimeRepair,
} from "./stable-runtime";
import { STARTUP_SCREEN_URL, startupScreenHtml } from "./startup-screen";
@@ -1672,7 +1672,7 @@ if (desktopVersion !== null) {
languagePreferences?.read().locale ?? "zh-CN",
"nativeErrorTitle",
),
- stableRuntimeUserMessage(error),
+ stableRuntimeFailureDetail(error),
);
},
});
diff --git a/memhub/apps/desktop/src/stable-runtime.test.ts b/memhub/apps/desktop/src/stable-runtime.test.ts
index cf277a7..25839e6 100644
--- a/memhub/apps/desktop/src/stable-runtime.test.ts
+++ b/memhub/apps/desktop/src/stable-runtime.test.ts
@@ -16,6 +16,7 @@ import {
isDisabledServiceInstallError,
isInstalledApplicationsApp,
stableRuntimeErrorCode,
+ stableRuntimeFailureDetail,
stableRuntimeUserMessage,
startStableRuntimeRepair,
} from "./stable-runtime";
@@ -298,3 +299,22 @@ describe("startup install errors", () => {
expect(coding).toContain("不会丢失");
});
});
+
+describe("startup dialog body", () => {
+ it("keeps a code we have no copy for, so support can see which failure fired", () => {
+ expect(stableRuntimeFailureDetail(new Error("page_load_failed"))).toBe(
+ "page_load_failed",
+ );
+ expect(
+ stableRuntimeFailureDetail(new Error("runtime_broker_unavailable")),
+ ).toBe("runtime_broker_unavailable");
+ });
+
+ it("shows the sentence we wrote for a migration failure", () => {
+ const detail = stableRuntimeFailureDetail(
+ new Error("sdk_migration_disk_space_insufficient"),
+ );
+ expect(detail).toContain("磁盘空间不足");
+ expect(detail).not.toContain("sdk_migration_disk_space_insufficient");
+ });
+});
diff --git a/memhub/apps/desktop/src/stable-runtime.ts b/memhub/apps/desktop/src/stable-runtime.ts
index 8e56454..8d44689 100644
--- a/memhub/apps/desktop/src/stable-runtime.ts
+++ b/memhub/apps/desktop/src/stable-runtime.ts
@@ -248,3 +248,16 @@ export function stableRuntimeUserMessage(error: unknown): string {
""
);
}
+
+/** What the startup dialog body says.
+ *
+ * A code we wrote copy for becomes a sentence. Every other code is shown as it
+ * is: this dialog is the last thing a person sees before the app closes, and an
+ * unexpected failure is more useful as the code support can look up than as a
+ * reassuring sentence that erases which failure actually fired. */
+export function stableRuntimeFailureDetail(error: unknown): string {
+ if (!(error instanceof Error)) {
+ return STABLE_RUNTIME_USER_MESSAGES.desktop_start_failed ?? "";
+ }
+ return STABLE_RUNTIME_USER_MESSAGES[error.message] ?? error.message;
+}