mirror of
https://github.com/aaddrick/claude-desktop-debian.git
synced 2026-05-17 00:26:21 +03:00
fix: address code review feedback for PR #232
- Drop isVisible() filter from getWindow() fallback so flashFrame() works on minimized windows, which is its primary use case - Add isDestroyed() guard to setTimeout resize callback to prevent errors if the window is closed within the 50ms delay Co-Authored-By: Claude <claude@anthropic.com>
This commit is contained in:
@@ -4,17 +4,19 @@ const KeyboardKey = { Backspace: 43, Tab: 280, Enter: 261, Shift: 272, Control:
|
||||
Object.freeze(KeyboardKey);
|
||||
|
||||
// Helper: get the focused BrowserWindow (lazy-loaded to avoid circular deps)
|
||||
// Filters destroyed/invisible windows from fallback to avoid errors like
|
||||
// flashFrame() on a destroyed window or getIsMaximized() on a popup
|
||||
// Filters destroyed windows from fallback to avoid errors like
|
||||
// flashFrame() on a destroyed window or getIsMaximized() on a popup.
|
||||
// Note: isVisible() is intentionally NOT checked — flashFrame() must work
|
||||
// on minimized (non-visible) windows, which is its primary use case.
|
||||
function getWindow() {
|
||||
try {
|
||||
const { BrowserWindow } = require('electron');
|
||||
const focused = BrowserWindow.getFocusedWindow();
|
||||
if (focused) return focused;
|
||||
const visible = BrowserWindow.getAllWindows().find(
|
||||
(w) => !w.isDestroyed() && w.isVisible()
|
||||
const win = BrowserWindow.getAllWindows().find(
|
||||
(w) => !w.isDestroyed()
|
||||
);
|
||||
return visible || null;
|
||||
return win || null;
|
||||
} catch (e) {
|
||||
console.warn('[Claude Native Stub] getWindow() failed:', e);
|
||||
return null;
|
||||
|
||||
@@ -96,7 +96,9 @@ Module.prototype.require = function(id) {
|
||||
// Only applies to main windows; popups don't need resize jiggle
|
||||
const [w, h] = this.getSize();
|
||||
this.setSize(w + 1, h + 1);
|
||||
setTimeout(() => this.setSize(w, h), 50);
|
||||
setTimeout(() => {
|
||||
if (!this.isDestroyed()) this.setSize(w, h);
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user