Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ export default tseslint.config(
'error',
{ checksVoidReturn: { attributes: false } },
],
// Explicit: already error via strictTypeChecked. ignoreVoid keeps intentional fire-and-forget
// (call sites must still attach .catch when the promise can reject).
'@typescript-eslint/no-floating-promises': [
'error',
{ ignoreVoid: true, checkThenables: true },
],
// Off globally: defensive UI ?. / ?? churn. Re-enabled for shared + renderer/lib below.
'@typescript-eslint/no-unnecessary-condition': 'off',
// Autofix removes generics that TypeScript still needs for inference (tsc errors after
Expand Down
2 changes: 1 addition & 1 deletion reticulum-sidecar/patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ When [ratspeak/rsReticulum#14](https://github.com/ratspeak/rsReticulum/pull/14)

## Removed: rsReticulum-rnode-tcp-activity-keepalive.patch

Sunset when upstream landed `RNodeIdleProbe` (`88d3d38` — *rnode: restore TCP application idle probes*). [ratspeak/rsReticulum#15](https://github.com/ratspeak/rsReticulum/pull/15) was closed as superseded; mesh-client no longer carries that overlay (pin `9928abed269a83ec5a7ef165ff1142d938cad706` or later already includes idle probes). `RATSPEAK_PATCH_ENTRIES` in `scripts/update.sh` still tracks `#15` so `pnpm run update` warns on closed-without-merge until the entry is dropped after sunset is confirmed.
Sunset when upstream landed `RNodeIdleProbe` (`88d3d38` — *rnode: restore TCP application idle probes*). [ratspeak/rsReticulum#15](https://github.com/ratspeak/rsReticulum/pull/15) was closed as superseded; mesh-client no longer carries that overlay (pin `9928abed269a83ec5a7ef165ff1142d938cad706` or later already includes idle probes). Tracked entry removed from `RATSPEAK_PATCH_ENTRIES` in `scripts/update.sh` after sunset confirmation.

## rsReticulum-ble-rnode-pairing-transition-debounce.patch

Expand Down
3 changes: 1 addition & 2 deletions scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ check_ratspeak_patches() {
'rsReticulum-packet-tap.patch|ratspeak/rsReticulum|10|rsReticulum packet-tap|https://github.com/ratspeak/rsReticulum/pull/10'
'rsReticulum-auto-beacon-utun.patch|ratspeak/rsReticulum|11|rsReticulum auto-beacon utun|https://github.com/ratspeak/rsReticulum/pull/11'
'rsReticulum-link-client-nomad.patch|ratspeak/rsReticulum|14|rsReticulum LinkClient Nomad|https://github.com/ratspeak/rsReticulum/pull/14'
'rsReticulum-rnode-tcp-activity-keepalive.patch|ratspeak/rsReticulum|15|rsReticulum RNode TCP activity keepalive|https://github.com/ratspeak/rsReticulum/pull/15'
'rsReticulum-ble-rnode-pairing-transition-debounce.patch|ratspeak/rsReticulum|20|rsReticulum BLE RNode pairing-transition debounce|https://github.com/ratspeak/rsReticulum/pull/20'
'rsReticulum-discovery-announce-egress.patch|ratspeak/rsReticulum|19|rsReticulum discovery announce egress|https://github.com/ratspeak/rsReticulum/pull/19'
'rsLXMF-propagation-sync-peering.patch|ratspeak/rsLXMF|4|rsLXMF propagation sync peering|https://github.com/ratspeak/rsLXMF/pull/4'
Expand Down Expand Up @@ -297,7 +296,7 @@ check_ratspeak_patches() {
;;
closed)
# Still warn when the .patch is already gone so closed-without-merge stays visible
# (e.g. #15 superseded by upstream RNodeIdleProbe — confirm sunset, then drop entry).
# until sunset is confirmed and the entry is dropped from RATSPEAK_PATCH_ENTRIES.
warn_box "${label} (Ratspeak overlay)" "local patch" "PR closed (not merged?)" "${url}"
if [ "${patch_present}" -eq 1 ]; then
echo " Reason tracked: ${repo}#${pr} closed without merge — verify overlay still needed."
Expand Down
255 changes: 139 additions & 116 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2393,11 +2393,21 @@ ipcMain.handle('bluetooth-pair', async (event, macAddress: unknown, pin: unknown
stderr.includes('AuthenticationCanceled');
const pairingSucceededByOutput = stdout.includes('Pairing successful');
if (!pairingFailedByOutput && (pairingSucceededByOutput || code === 0)) {
void trustDeviceBestEffort().then(() => {
if (settled) return;
console.debug('[IPC] bluetooth-pair success');
finishResolve();
});
void trustDeviceBestEffort()
.then(() => {
if (settled) return;
console.debug('[IPC] bluetooth-pair success');
finishResolve();
})
.catch((e: unknown) => {
// trustDeviceBestEffort is best-effort and should not reject; finish pairing anyway.
console.debug(
'[IPC] bluetooth-pair trust settle:',
sanitizeLogMessage(e instanceof Error ? e.message : String(e)),
);
if (settled) return;
finishResolve();
});
} else {
console.warn(
'[IPC] bluetooth-pair failed:',
Expand Down Expand Up @@ -6405,134 +6415,147 @@ app.on('child-process-gone', (_event, details) => {
);
});

void app.whenReady().then(() => {
try {
initLogFile();
console.debug(`[Startup] runtime ${formatRuntimeLogTag()}`);
void app
.whenReady()
.then(() => {
try {
console.debug('[main] crashDumps path:', sanitizeLogMessage(app.getPath('crashDumps')));
} catch (e: unknown) {
console.warn(
'[main] crashDumps path unavailable:',
sanitizeLogMessage(e instanceof Error ? e.message : String(e)),
);
}
initLogFile();
console.debug(`[Startup] runtime ${formatRuntimeLogTag()}`);
try {
console.debug('[main] crashDumps path:', sanitizeLogMessage(app.getPath('crashDumps')));
} catch (e: unknown) {
console.warn(
'[main] crashDumps path unavailable:',
sanitizeLogMessage(e instanceof Error ? e.message : String(e)),
);
}

// Register lxm:// deep links (dev + packaged). OS-specific: argv in defaultApp.
if (process.defaultApp) {
if (process.argv.length >= 2) {
app.setAsDefaultProtocolClient('lxm', process.execPath, [path.resolve(process.argv[1])]);
// Register lxm:// deep links (dev + packaged). OS-specific: argv in defaultApp.
if (process.defaultApp) {
if (process.argv.length >= 2) {
app.setAsDefaultProtocolClient('lxm', process.execPath, [path.resolve(process.argv[1])]);
}
} else {
app.setAsDefaultProtocolClient('lxm');
}
} else {
app.setAsDefaultProtocolClient('lxm');
}
const coldStartUrl = findLxmUrlInArgv(process.argv);
if (coldStartUrl) pendingOpenUrl = coldStartUrl;
const coldStartUrl = findLxmUrlInArgv(process.argv);
if (coldStartUrl) pendingOpenUrl = coldStartUrl;

initDatabase();
initDatabase();

// Auto-restore TAK server if auto-start is enabled
const takSettingsPath = path.join(app.getPath('userData'), 'tak-settings.json');
try {
if (fs.existsSync(takSettingsPath)) {
const raw: unknown = JSON.parse(fs.readFileSync(takSettingsPath, 'utf-8'));
// Backfill autoStart for settings files saved before the field was added.
if (
raw != null &&
typeof raw === 'object' &&
typeof (raw as Record<string, unknown>).autoStart !== 'boolean'
) {
(raw as Record<string, unknown>).autoStart = false;
}
const saved = raw;
validateTakSettings(saved);
if (saved.autoStart) {
void ensureTakServerManager()
.then((m) => m.start(saved))
.catch((e: unknown) => {
console.error(
'[TAK] Auto-start failed:',
sanitizeLogMessage(e instanceof Error ? e.message : String(e)),
);
});
// Auto-restore TAK server if auto-start is enabled
const takSettingsPath = path.join(app.getPath('userData'), 'tak-settings.json');
try {
if (fs.existsSync(takSettingsPath)) {
const raw: unknown = JSON.parse(fs.readFileSync(takSettingsPath, 'utf-8'));
// Backfill autoStart for settings files saved before the field was added.
if (
raw != null &&
typeof raw === 'object' &&
typeof (raw as Record<string, unknown>).autoStart !== 'boolean'
) {
(raw as Record<string, unknown>).autoStart = false;
}
const saved = raw;
validateTakSettings(saved);
if (saved.autoStart) {
void ensureTakServerManager()
.then((m) => m.start(saved))
.catch((e: unknown) => {
console.error(
'[TAK] Auto-start failed:',
sanitizeLogMessage(e instanceof Error ? e.message : String(e)),
);
});
}
}
} catch (e: unknown) {
console.warn(
'[TAK] Settings restore failed:',
sanitizeLogMessage(e instanceof Error ? e.message : String(e)),
);
}
} catch (e: unknown) {
console.warn(
'[TAK] Settings restore failed:',
sanitizeLogMessage(e instanceof Error ? e.message : String(e)),
);
}

// Force the dock icon in development on macOS
if (!app.isPackaged && process.platform === 'darwin') {
const iconPath = path.join(
__dirname,
'../../resources/icons/mac/iconset/icon_256x256@1x.png',
// Force the dock icon in development on macOS
if (!app.isPackaged && process.platform === 'darwin') {
const iconPath = path.join(
__dirname,
'../../resources/icons/mac/iconset/icon_256x256@1x.png',
);
app.dock?.setIcon(iconPath);
}
createWindow();

const MAIN_PROCESS_HEALTH_LOG_INTERVAL_MS = 60 * 60 * 1000;
const MAIN_PROCESS_HEALTH_UPTIME_THRESHOLD_SEC = 24 * 60 * 60;
setInterval(() => {
if (process.uptime() < MAIN_PROCESS_HEALTH_UPTIME_THRESHOLD_SEC) return;
const uptimeSec = Math.floor(process.uptime());
const mem = process.memoryUsage();
const ble = nobleBleManager.getLongSessionHealthSnapshot();
console.debug(
`[main] long-session health uptimeSec=${uptimeSec} rss=${mem.rss} heapUsed=${mem.heapUsed} ble=${JSON.stringify(ble)}`,
);
}, MAIN_PROCESS_HEALTH_LOG_INTERVAL_MS).unref();

setupAppMenu();

// ─── Power monitor: notify renderer on suspend/resume ──────────
powerMonitor.on('suspend', () => {
console.debug('[main] System suspending');
rendererHeartbeatWatchdog.clearResumeWatchdog();
mqttManager.handlePowerSuspend();
meshcoreMqttAdapter.handlePowerSuspend();
mainWindow?.webContents.send('power:suspend');
});
powerMonitor.on('resume', () => {
console.debug('[main] System resumed');
rendererHeartbeatWatchdog.startResumeWatchdog();
mainWindow?.webContents.send('power:resume');
});
} catch (error) {
console.error(
'[main] Fatal startup error:',
sanitizeLogMessage(error instanceof Error ? (error.stack ?? error.message) : String(error)),
);
app.dock?.setIcon(iconPath);
const isNativeModuleError =
error instanceof Error && (error as NodeJS.ErrnoException).code === 'ERR_DLOPEN_FAILED';
const message = isDatabaseSchemaTooNewError(error)
? formatDatabaseSchemaTooNewMessage(error)
: isNativeModuleError
? `A native module failed to load. This usually means the app needs to be rebuilt for this version of Electron.\n\nFix: run "pnpm install" in the project directory, then restart.\n\nDetails: ${error.message}`
: `The application failed to start:\n\n${error instanceof Error ? error.message : String(error)}\n\nPlease report this issue.`;
showFatalStartupError('Mesh-Client — Startup Error', message);
app.quit();
return;
}
createWindow();

const MAIN_PROCESS_HEALTH_LOG_INTERVAL_MS = 60 * 60 * 1000;
const MAIN_PROCESS_HEALTH_UPTIME_THRESHOLD_SEC = 24 * 60 * 60;
setInterval(() => {
if (process.uptime() < MAIN_PROCESS_HEALTH_UPTIME_THRESHOLD_SEC) return;
const uptimeSec = Math.floor(process.uptime());
const mem = process.memoryUsage();
const ble = nobleBleManager.getLongSessionHealthSnapshot();
console.debug(
`[main] long-session health uptimeSec=${uptimeSec} rss=${mem.rss} heapUsed=${mem.heapUsed} ble=${JSON.stringify(ble)}`,
);
}, MAIN_PROCESS_HEALTH_LOG_INTERVAL_MS).unref();

setupAppMenu();

// ─── Power monitor: notify renderer on suspend/resume ──────────
powerMonitor.on('suspend', () => {
console.debug('[main] System suspending');
rendererHeartbeatWatchdog.clearResumeWatchdog();
mqttManager.handlePowerSuspend();
meshcoreMqttAdapter.handlePowerSuspend();
mainWindow?.webContents.send('power:suspend');
});
powerMonitor.on('resume', () => {
console.debug('[main] System resumed');
rendererHeartbeatWatchdog.startResumeWatchdog();
mainWindow?.webContents.send('power:resume');
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
try {
createWindow();
} catch (error) {
console.error(
'[main] Window creation error:',
sanitizeLogMessage(error instanceof Error ? error.message : String(error)),
);
}
} else {
mainWindow?.show(); // Restore hidden window on dock click
}
});
} catch (error) {
})
.catch((error: unknown) => {
console.error(
'[main] Fatal startup error:',
'[main] app.whenReady failed:',
sanitizeLogMessage(error instanceof Error ? (error.stack ?? error.message) : String(error)),
);
const isNativeModuleError =
error instanceof Error && (error as NodeJS.ErrnoException).code === 'ERR_DLOPEN_FAILED';
const message = isDatabaseSchemaTooNewError(error)
? formatDatabaseSchemaTooNewMessage(error)
: isNativeModuleError
? `A native module failed to load. This usually means the app needs to be rebuilt for this version of Electron.\n\nFix: run "pnpm install" in the project directory, then restart.\n\nDetails: ${error.message}`
: `The application failed to start:\n\n${error instanceof Error ? error.message : String(error)}\n\nPlease report this issue.`;
showFatalStartupError('Mesh-Client — Startup Error', message);
showFatalStartupError(
'Mesh-Client — Startup Error',
`The application failed to start:\n\n${error instanceof Error ? error.message : String(error)}\n\nPlease report this issue.`,
);
app.quit();
return;
}

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
try {
createWindow();
} catch (error) {
console.error(
'[main] Window creation error:',
sanitizeLogMessage(error instanceof Error ? error.message : String(error)),
);
}
} else {
mainWindow?.show(); // Restore hidden window on dock click
}
});
});

app.on('before-quit', (event) => {
// Clean up any pending Bluetooth device selection to prevent callback leak
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/components/ChatComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,9 @@ export function ChatComposer({
if (isLinux) {
setShowComposePicker((prev) => !prev);
} else {
void window.electronAPI.showEmojiPanel();
void window.electronAPI.showEmojiPanel().catch((e: unknown) => {
console.debug('[ChatComposer] showEmojiPanel failed ' + errLikeToLogString(e));
});
}
}}
disabled={disabled || !isConnected}
Expand Down
9 changes: 8 additions & 1 deletion src/renderer/components/ChatPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2852,7 +2852,14 @@ function ChatPanel({
} else {
reactionPickerTarget.current = { id, channel: msg.channel };
reactionCapturePendingRef.current = true;
void window.electronAPI.showEmojiPanel();
void window.electronAPI
.showEmojiPanel()
.catch((e: unknown) => {
console.debug(
'[ChatPanel] showEmojiPanel failed ' +
errLikeToLogString(e),
);
});
}
}}
{...{ [PARENT_HOVER_ATTR]: '' }}
Expand Down
8 changes: 6 additions & 2 deletions src/renderer/components/ConnectionPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,9 @@ export default function ConnectionPanel({
setWebBluetoothDevice(null);
}
} else {
void window.electronAPI.stopNobleBleScanning(protocol);
void window.electronAPI.stopNobleBleScanning(protocol).catch((e: unknown) => {
console.debug('[ConnectionPanel] stopNobleBleScanning failed ' + errLikeToLogString(e));
});
}
}
if (showSerialPicker) {
Expand Down Expand Up @@ -1319,7 +1321,9 @@ export default function ConnectionPanel({
// Don't call onConnect again - the original onConnect will continue from requestDevice()
// and proceed to connect(), which triggers the pairing handler.
} else {
void window.electronAPI.stopNobleBleScanning(protocol);
void window.electronAPI.stopNobleBleScanning(protocol).catch((e: unknown) => {
console.debug('[ConnectionPanel] stopNobleBleScanning failed ' + errLikeToLogString(e));
});
// Trigger the actual connection with the peripheral ID
onConnect('ble', undefined, deviceId).catch((err: unknown) => {
const errMsg = err instanceof Error ? err.message : String(err);
Expand Down
Loading