Skip to content

Commit 472a553

Browse files
committed
chore: better logging
1 parent b68bfac commit 472a553

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

src-electron/main-cred-ipc.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ function registerCredIpcHandlers() {
3636
}
3737

3838
windowTrustMap.set(webContentsId, { key, iv });
39-
console.log(`AES trust established for webContents: ${webContentsId}`);
39+
// Lazy require to avoid circular dependency
40+
const { getWindowLabel } = require('./main-window-ipc');
41+
console.log(`AES trust established for window: ${getWindowLabel(webContentsId)} (webContentsId: ${webContentsId})`);
4042
});
4143

4244
// Remove trust - requires matching key/iv
@@ -53,7 +55,8 @@ function registerCredIpcHandlers() {
5355
}
5456

5557
windowTrustMap.delete(webContentsId);
56-
console.log(`AES trust removed for webContents: ${webContentsId}`);
58+
const { getWindowLabel } = require('./main-window-ipc');
59+
console.log(`AES trust removed for window: ${getWindowLabel(webContentsId)} (webContentsId: ${webContentsId})`);
5760
});
5861

5962
// Store credential in system keychain
@@ -108,10 +111,10 @@ function registerCredIpcHandlers() {
108111
}
109112

110113
// Clean up trust when window closes
111-
function cleanupWindowTrust(webContentsId) {
114+
function cleanupWindowTrust(webContentsId, windowLabel) {
112115
if (windowTrustMap.has(webContentsId)) {
113116
windowTrustMap.delete(webContentsId);
114-
console.log(`AES trust auto-removed for closed webContents: ${webContentsId}`);
117+
console.log(`AES trust auto-removed for closed window: ${windowLabel} (webContentsId: ${webContentsId})`);
115118
}
116119
}
117120

src-electron/main-window-ipc.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function registerWindow(win, label) {
4848
webContentsToLabel.delete(webContentsId);
4949
windowCloseHandlers.delete(webContentsId);
5050
// Clean up AES trust for closing window (mirrors Tauri's on_window_event CloseRequested handler)
51-
cleanupWindowTrust(webContentsId);
51+
cleanupWindowTrust(webContentsId, label);
5252
// Clean up security trust
5353
cleanupTrust(webContentsId);
5454
});
@@ -285,4 +285,8 @@ function registerWindowIpcHandlers() {
285285
});
286286
}
287287

288-
module.exports = { registerWindowIpcHandlers, registerWindow, setupCloseHandler, windowRegistry };
288+
function getWindowLabel(webContentsId) {
289+
return webContentsToLabel.get(webContentsId) || 'unknown';
290+
}
291+
292+
module.exports = { registerWindowIpcHandlers, registerWindow, setupCloseHandler, windowRegistry, getWindowLabel };

0 commit comments

Comments
 (0)