fix: preserve custom desktop startup routing (#1958)

This commit is contained in:
whoisasx 2026-05-20 21:46:01 +05:30
parent 7f566a331b
commit 71e8151f6e
2 changed files with 37 additions and 1 deletions

View File

@ -124,6 +124,41 @@ describe("startup notifier defaults", () => {
});
});
it("preserves custom desktop routing when startup AO Notifier.app setup cannot complete", () => {
writeFileSync(
configPath,
[
"port: 3000",
"defaults:",
" notifiers: []",
"notifiers:",
" desktop:",
" plugin: desktop",
" backend: terminal-notifier",
" dashboardUrl: http://localhost:3000",
"notificationRouting:",
" urgent: [desktop]",
"projects: {}",
"",
].join("\n"),
);
expect(
ensureStartupNotifierDefaults({
configPath,
dashboardUrl: "http://localhost:3000",
desktopMode: "disable-default",
}),
).toBe(true);
const parsed = readConfig();
expect(parsed.notifiers?.["desktop"]).toMatchObject({
plugin: "desktop",
backend: "terminal-notifier",
});
expect(parsed.notificationRouting?.urgent).toEqual(["desktop", "dashboard"]);
});
it("preserves configured manual opt-in notifiers while removing only implicit manual defaults", () => {
writeFileSync(
configPath,

View File

@ -224,12 +224,13 @@ export function ensureStartupNotifierDefaults(options: StartupNotifierDefaultsOp
const dashboardConfigured = configuredPlugin(notifiers, "dashboard") === "dashboard";
const desktopConfigured = configuredPlugin(notifiers, "desktop") === "desktop";
const shouldRemoveDefaultDesktopRouting = desktopMode === "disable-default" && !desktopConfigured;
for (const priority of NOTIFICATION_PRIORITIES) {
const existingRoute = sanitizeNotifierReferences(notifiers, routing[priority]);
let nextRoute = existingRoute;
if (desktopMode === "disable-default") {
if (shouldRemoveDefaultDesktopRouting) {
nextRoute = nextRoute.filter((notifierName) => notifierName !== "desktop");
} else if (shouldManageDesktopRouting && desktopConfigured) {
nextRoute = nextRoute.filter((notifierName) => notifierName !== "desktop");