From 03eef36f69575f83ff1c8df4e7624c22a9181584 Mon Sep 17 00:00:00 2001 From: Idris Gadi Date: Thu, 12 Mar 2026 23:24:47 +0530 Subject: [PATCH 1/4] fix: check not catching false value --- src/config/resolver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/resolver.ts b/src/config/resolver.ts index c909452..cb1a514 100644 --- a/src/config/resolver.ts +++ b/src/config/resolver.ts @@ -30,7 +30,7 @@ export function createResolvedConfig(config: Config): ResolvedConfig { ? (config[configKey] as EventConfig) : undefined; - if (eventConfig?.enabled) { + if (eventConfig?.enabled !== undefined) { return eventConfig.enabled; } From 4f9e240905bced361ae0b964c667db63ea033616 Mon Sep 17 00:00:00 2001 From: Idris Gadi Date: Thu, 12 Mar 2026 23:24:57 +0530 Subject: [PATCH 2/4] fix: project config detection --- index.ts | 4 ++-- src/config/loader.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index e1858c4..2f5caf0 100644 --- a/index.ts +++ b/index.ts @@ -4,8 +4,8 @@ import { createNotificationScheduler } from "@/notification-scheduler"; import { loadConfig, ConfigError } from "@/config/loader"; import { createResolvedConfig } from "@/config/resolver"; -export const SimpleNotificationPlugin: Plugin = async ({ client }) => { - const config = await loadConfig().catch(async (error) => { +export const SimpleNotificationPlugin: Plugin = async ({ client, directory }) => { + const config = await loadConfig(directory).catch(async (error) => { const message = error instanceof ConfigError ? `Notification plugin config error: ${error.message}` diff --git a/src/config/loader.ts b/src/config/loader.ts index d44062d..f8bc83d 100644 --- a/src/config/loader.ts +++ b/src/config/loader.ts @@ -95,7 +95,7 @@ export async function discoverConfigFiles(projectRoot?: string): Promise { +export async function loadConfig(projectRoot: string): Promise { const filePaths = await discoverConfigFiles(projectRoot); const configs: Record[] = []; From 56727dd56328af1cf4dfc2a7ac42ddbfe606eada Mon Sep 17 00:00:00 2001 From: Idris Gadi Date: Thu, 12 Mar 2026 23:27:50 +0530 Subject: [PATCH 3/4] feat: cache terminal info on module level --- src/notification.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/notification.ts b/src/notification.ts index 4bf141c..6c7d3a3 100644 --- a/src/notification.ts +++ b/src/notification.ts @@ -10,9 +10,10 @@ const terminalMap: Record = { konsole: { icon: "utilities-terminal", appName: "Konsole" }, }; -function getLinuxTerminalInfo(): { icon: string; appName: string } | null { - let cachedTerminal: { icon: string; appName: string } | null | undefined; +// Cache terminal info at module level to persist across calls +let cachedTerminal: { icon: string; appName: string } | null | undefined; +function getLinuxTerminalInfo(): { icon: string; appName: string } | null { if (process.platform !== "linux") return null; if (cachedTerminal !== undefined) return cachedTerminal; From d0193c317305ff93206fd05d9b48f96a61d39cc5 Mon Sep 17 00:00:00 2001 From: Idris Gadi Date: Thu, 12 Mar 2026 23:32:38 +0530 Subject: [PATCH 4/4] fix: silently swallow error that can be thrown by the system --- src/notification.ts | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/notification.ts b/src/notification.ts index 6c7d3a3..4568f55 100644 --- a/src/notification.ts +++ b/src/notification.ts @@ -25,20 +25,25 @@ function getLinuxTerminalInfo(): { icon: string; appName: string } | null { let currentPid = process.pid; for (let i = 0; i < 3 && currentPid > 1; i++) { - const status = readFileSync(`/proc/${currentPid}/status`, "utf-8"); - const ppidMatch = status.match(/PPid:\s*(\d+)/); - if (!ppidMatch || !ppidMatch[1]) break; - const ppid = parseInt(ppidMatch[1], 10); - if (ppid <= 1 || ppid === currentPid) break; - - const comm = readFileSync(`/proc/${ppid}/comm`, "utf-8").trim(); - const normalized = comm.replace(/-/g, "_"); - const result = terminalMap[comm] ?? terminalMap[normalized] ?? null; - if (result) { - cachedTerminal = result; - return result; + // /proc may be inaccessible in containers or restricted environments (EACCES/ENOENT) + try { + const status = readFileSync(`/proc/${currentPid}/status`, "utf-8"); + const ppidMatch = status.match(/PPid:\s*(\d+)/); + if (!ppidMatch || !ppidMatch[1]) break; + const ppid = parseInt(ppidMatch[1], 10); + if (ppid <= 1 || ppid === currentPid) break; + + const comm = readFileSync(`/proc/${ppid}/comm`, "utf-8").trim(); + const normalized = comm.replace(/-/g, "_"); + const result = terminalMap[comm] ?? terminalMap[normalized] ?? null; + if (result) { + cachedTerminal = result; + return result; + } + currentPid = ppid; + } catch { + break; } - currentPid = ppid; } cachedTerminal = null;