Fix Ctrl+Q to close embedded browser in Electron version #19

Merged
Copilot merged 3 commits from copilot/fix-control-q-close-issue into main 2025-11-17 16:34:38 -06:00
Copilot commented 2025-11-17 16:10:49 -06:00 (Migrated from github.com)

Ctrl+Q was not closing the embedded browser when a webpage was loaded. The handler only attempted to close external processes, which doesn't apply to URL-based services that open in BrowserView.

Changes

  • renderer.js: Modified Ctrl+Q handler to check if embedded browser is active before deciding action

    • If home-view is hidden: close browser and return to home screen
    • Otherwise: close last external app (original behavior)
  • test_electron.js: Added testKeyboardShortcuts() to verify handler logic

  • Documentation: Updated keyboard shortcut tables in README-ELECTRON.md and ARCHITECTURE.md

Implementation

// Ctrl+Q - Close embedded browser or last app
if (e.ctrlKey && e.key === 'q') {
  e.preventDefault();
  if (document.getElementById('home-view').style.display === 'none') {
    // Close embedded browser
    await window.castroix.closeBrowser();
    document.getElementById('home-view').style.display = 'flex';
    showNotification('Browser closed');
  } else {
    // Close last external app
    const result = await window.castroix.closeLastApp();
    // ... handle result
  }
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Control + Q seems to not close the browser</issue_title>
<issue_description>On the Electron version, I am able to click the icons, but when the webpage loads, I am unable to use Control + q to close it. </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Ctrl+Q was not closing the embedded browser when a webpage was loaded. The handler only attempted to close external processes, which doesn't apply to URL-based services that open in BrowserView. ### Changes - **renderer.js**: Modified Ctrl+Q handler to check if embedded browser is active before deciding action - If `home-view` is hidden: close browser and return to home screen - Otherwise: close last external app (original behavior) - **test_electron.js**: Added `testKeyboardShortcuts()` to verify handler logic - **Documentation**: Updated keyboard shortcut tables in README-ELECTRON.md and ARCHITECTURE.md ### Implementation ```javascript // Ctrl+Q - Close embedded browser or last app if (e.ctrlKey && e.key === 'q') { e.preventDefault(); if (document.getElementById('home-view').style.display === 'none') { // Close embedded browser await window.castroix.closeBrowser(); document.getElementById('home-view').style.display = 'flex'; showNotification('Browser closed'); } else { // Close last external app const result = await window.castroix.closeLastApp(); // ... handle result } } ``` <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Control + Q seems to not close the browser</issue_title> > <issue_description>On the Electron version, I am able to click the icons, but when the webpage loads, I am unable to use Control + q to close it. </issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> - Fixes SluberskiHomeLab/castroix#18 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
SluberskiHomeLab (Migrated from github.com) reviewed 2025-11-17 16:10:49 -06:00
Sign in to join this conversation.
No description provided.