Skip to content
Open
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 src/components/views/AssistantView.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,16 @@ export class AssistantView extends LitElement {
this.handleNextResponse = () => this.navigateToNextResponse();
this.handleScrollUp = () => this.scrollResponseUp();
this.handleScrollDown = () => this.scrollResponseDown();
this.handleFocusInput = () => {
const textInput = this.shadowRoot.querySelector('#textInput');
if (textInput) textInput.focus();
};

ipcRenderer.on('navigate-previous-response', this.handlePreviousResponse);
ipcRenderer.on('navigate-next-response', this.handleNextResponse);
ipcRenderer.on('scroll-response-up', this.handleScrollUp);
ipcRenderer.on('scroll-response-down', this.handleScrollDown);
ipcRenderer.on('focus-input', this.handleFocusInput);
}
}

Expand All @@ -452,6 +457,7 @@ export class AssistantView extends LitElement {
if (this.handleNextResponse) ipcRenderer.removeListener('navigate-next-response', this.handleNextResponse);
if (this.handleScrollUp) ipcRenderer.removeListener('scroll-response-up', this.handleScrollUp);
if (this.handleScrollDown) ipcRenderer.removeListener('scroll-response-down', this.handleScrollDown);
if (this.handleFocusInput) ipcRenderer.removeListener('focus-input', this.handleFocusInput);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/components/views/CustomizeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ export class CustomizeView extends LitElement {
nextResponse: isMac ? 'Cmd+]' : 'Ctrl+]',
scrollUp: isMac ? 'Cmd+Shift+Up' : 'Ctrl+Shift+Up',
scrollDown: isMac ? 'Cmd+Shift+Down' : 'Ctrl+Shift+Down',
focusInput: isMac ? 'Cmd+L' : 'Ctrl+L',
};
}

Expand All @@ -319,6 +320,7 @@ export class CustomizeView extends LitElement {
{ key: 'nextResponse', name: 'Next Response', description: 'Move to next AI response' },
{ key: 'scrollUp', name: 'Scroll Response Up', description: 'Scroll response content upward' },
{ key: 'scrollDown', name: 'Scroll Response Down', description: 'Scroll response content downward' },
{ key: 'focusInput', name: 'Focus Input', description: 'Focus the text input box' },
];
}

Expand Down
20 changes: 20 additions & 0 deletions src/utils/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ function getDefaultKeybinds() {
nextResponse: isMac ? 'Cmd+]' : 'Ctrl+]',
scrollUp: isMac ? 'Cmd+Shift+Up' : 'Ctrl+Shift+Up',
scrollDown: isMac ? 'Cmd+Shift+Down' : 'Ctrl+Shift+Down',
focusInput: isMac ? 'Cmd+L' : 'Ctrl+L',
emergencyErase: isMac ? 'Cmd+Shift+E' : 'Ctrl+Shift+E',
};
}
Expand Down Expand Up @@ -270,6 +271,25 @@ function updateGlobalShortcuts(keybinds, mainWindow, sendToRenderer, geminiSessi
}
}

// Register focus input shortcut
if (keybinds.focusInput) {
try {
globalShortcut.register(keybinds.focusInput, () => {
console.log('Focus input shortcut triggered');
if (!mainWindow.isVisible()) {
mainWindow.show();
} else {
mainWindow.focus();
}
mainWindow.webContents.focus();
mainWindow.webContents.send('focus-input');
});
console.log(`Registered focusInput: ${keybinds.focusInput}`);
} catch (error) {
console.error(`Failed to register focusInput (${keybinds.focusInput}):`, error);
}
}
Comment on lines +274 to +291
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing isDestroyed() guard before accessing mainWindow.

The emergencyErase handler (line 298) checks mainWindow && !mainWindow.isDestroyed() before interacting with the window. This handler does not, which can throw if the window has been destroyed while shortcuts remain registered.

🛡️ Proposed fix
     if (keybinds.focusInput) {
         try {
             globalShortcut.register(keybinds.focusInput, () => {
                 console.log('Focus input shortcut triggered');
+                if (!mainWindow || mainWindow.isDestroyed()) return;
                 if (!mainWindow.isVisible()) {
                     mainWindow.show();
                 } else {
                     mainWindow.focus();
                 }
                 mainWindow.webContents.focus();
                 mainWindow.webContents.send('focus-input');
             });
🤖 Prompt for AI Agents
In `@src/utils/window.js` around lines 274 - 291, The focusInput shortcut callback
uses mainWindow without guarding against a destroyed window and can throw;
update the globalShortcut.register handler for keybinds.focusInput to first
check that mainWindow exists and is not destroyed (e.g., if (!mainWindow ||
mainWindow.isDestroyed()) return) before calling mainWindow.isVisible(),
.show(), .focus(), .webContents.focus(), or .webContents.send('focus-input');
optionally also ensure you unregister the shortcut or handle errors if the
window is gone.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intended; if window is closed and you focus textbox, it is good that it auto opens and focuses. much faster

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kyan-yang Got it! The auto-open behavior when the window is hidden works great with the current isVisible() check—that's already handling your use case.

My concern was specifically about the destroyed case: if mainWindow is destroyed (not just hidden), calling mainWindow.isVisible() would throw an error before the check executes. The isDestroyed() guard prevents that crash. It doesn't change your intended behavior—hidden windows would still auto-open—it just adds safety for the edge case where the window object is gone entirely.

That said, if you're confident this scenario won't occur in practice, feel free to keep it as-is!


✏️ Learnings added
Learnt from: kyan-yang
Repo: sohzm/cheating-daddy PR: 209
File: src/utils/window.js:274-291
Timestamp: 2026-02-09T14:57:59.175Z
Learning: In src/utils/window.js, the focusInput shortcut handler intentionally auto-opens the window when it's hidden (using isVisible() check) to provide faster access, as confirmed by kyan-yang.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh wait i confused the two states of visible and destroyed.

if window is destroyed though, app is like shut off and done so no need to check for that; just adds bloat.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kyan-yang Fair enough! You're right that in typical app lifecycle scenarios, if the window is destroyed, the app is shutting down and shortcuts won't be triggered anyway. I'll defer to your judgment on keeping it lean. 👍


🧠 Learnings used
Learnt from: kyan-yang
Repo: sohzm/cheating-daddy PR: 209
File: src/utils/window.js:274-291
Timestamp: 2026-02-09T14:57:59.175Z
Learning: In src/utils/window.js, the focusInput shortcut handler intentionally auto-opens the window when it's hidden (using isVisible() check) to provide faster access, as confirmed by kyan-yang.


// Register emergency erase shortcut
if (keybinds.emergencyErase) {
try {
Expand Down