Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Fix dev tools command invocation #544

Open
wants to merge 7 commits into
base: v1.0
Choose a base branch
from

Conversation

lily-de
Copy link
Collaborator

@lily-de lily-de commented Jan 6, 2025

Purpose of the Changes

The goal of this PR was to fix a bug where the Option+Cmd+I shortcut always triggered DevTools in the Electron app, even when the app was not in focus. This created conflicts when using the same shortcut in other applications (e.g., Chrome or iTerm).

The changes ensure:

  1. App-focused DevTools behavior in development mode—DevTools only open when the Electron app is focused.
  2. DevTools are disabled entirely in production mode to prevent accidental exposure of debugging tools.

Original Bug

  • Description: Pressing Option+Cmd+I opened DevTools in the Electron app even when other applications (e.g., Chrome or iTerm) were in focus.
  • Impact: This behavior was disruptive and unexpected when the Electron app intercepted the shortcut globally.
  • Root Cause: The app registered a global shortcut (globalShortcut.register) for Option+Cmd+I, which triggered DevTools regardless of the app's focus.

Summary of Code Changes

  1. Replaced Global Shortcut with App-Focused Logic:

    • Removed globalShortcut.register for Option+Cmd+I.
    • Added a before-input-event listener to open DevTools only when the Electron app is in focus.
  2. Environment-Specific Behavior:

    • Added logic to differentiate between development and production modes:
      • In development, Cmd+Option+I opens DevTools only when the Electron app is focused.
      • In production, Cmd+Option+I does nothing, and any attempt to open DevTools is immediately blocked.
  3. Updated package.json Scripts:

    • Added cross-env to manage NODE_ENV values for different environments.
    • start-gui now sets NODE_ENV=development.
    • make sets NODE_ENV=production for production builds.

How the Changes Were Tested

  1. Development Mode:

    • Ran the app using npm start:
      • Verified Option+Cmd+I opens DevTools only when the Electron app is focused.
      • Confirmed Option+Cmd+I works normally in other apps (e.g., Chrome, iTerm).
      • Logs confirm NODE_ENV=development and isDev=true.
  2. Simulated Production Mode:

    • Ran npm run make to test production behavior. This created a Goose binary in ui/desktop/out/Goose-Darwin-arm-64
      • Verified Option+Cmd+I does nothing.
      • Verified Option+Cmd+I continued to work in Chrome
      • Confirmed DevTools cannot be opened manually.

@lily-de lily-de marked this pull request as draft January 6, 2025 20:54
Copy link

github-actions bot commented Jan 6, 2025

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

Copy link

github-actions bot commented Jan 8, 2025

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

Copy link

github-actions bot commented Jan 8, 2025

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

@lily-de lily-de force-pushed the ldelalande/dev-tools-fix branch from a30a992 to d4c52c4 Compare January 8, 2025 19:29
Copy link

github-actions bot commented Jan 8, 2025

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

Copy link

github-actions bot commented Jan 8, 2025

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

@lily-de lily-de changed the title Fix dev tools command invocation [bug]: Fix dev tools command invocation Jan 8, 2025
@lily-de lily-de marked this pull request as ready for review January 8, 2025 23:55
@lily-de lily-de changed the title [bug]: Fix dev tools command invocation bug: Fix dev tools command invocation Jan 8, 2025
Copy link

github-actions bot commented Jan 8, 2025

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

ui/desktop/src/main.ts Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Jan 9, 2025

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

Copy link
Collaborator

@michaelneale michaelneale left a comment

Choose a reason for hiding this comment

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

if we can avoid the cross-env command would probably be for the best given its status

@@ -36,6 +36,7 @@
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-react": "^4.3.3",
"autoprefixer": "^10.4.20",
"cross-env": "^7.0.3",
Copy link
Collaborator

Choose a reason for hiding this comment

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

@lily-de do we need this - as the repo has been archived or is no longer maintained

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants