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

Global Hotkey Docs #1548

Merged
merged 7 commits into from
Dec 17, 2024
Merged

Global Hotkey Docs #1548

merged 7 commits into from
Dec 17, 2024

Conversation

oneirocosm
Copy link
Member

@oneirocosm oneirocosm commented Dec 17, 2024

Documents the allowed keys for globalhotkey. Also improves the algorithm for computing electron keybinds from wave keybindings.

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration key for setting a global hotkey to open the most recent Wave window.
    • Added documentation for customizable system-wide global hotkeys.
  • Documentation

    • Enhanced configuration documentation for clarity and usability.
    • New section added in keybindings documentation regarding customizable global hotkeys.
  • Chores

    • Updated type definitions to reflect new application-specific settings and removed old key-related settings.
    • Added new configuration constants related to application settings.

Copy link

coderabbitai bot commented Dec 17, 2024

Warning

Rate limit exceeded

@oneirocosm has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 47 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between e7dcb3c and f5bdb92.

📒 Files selected for processing (1)
  • emain/emain-util.ts (2 hunks)

Walkthrough

The pull request introduces a new system-wide global hotkey configuration for Wave, shifting from a "key:" prefix to an "app:" prefix in configuration settings. This change spans multiple files across documentation, frontend types, configuration constants, and utility functions. The modification allows users to set a custom keybinding to focus on the most recent Wave window from anywhere on their computer, with enhanced support for various key mappings and improved documentation.

Changes

File Change Summary
docs/docs/config.mdx Added documentation for new app:globalhotkey configuration key
docs/docs/keybindings.mdx Added section explaining customizable systemwide global hotkey
emain/emain-util.ts Extended waveKeyToElectronKey function with additional key mappings
emain/emain.ts Updated global hotkey configuration key retrieval
frontend/types/gotypes.d.ts Replaced key:* and key:globalhotkey with app:* and app:globalhotkey type definitions
pkg/wconfig/metaconsts.go Replaced key-related configuration constants with app-related constants
pkg/wconfig/settingsconfig.go Updated SettingsType struct with new app-related fields

Sequence Diagram

sequenceDiagram
    participant User
    participant App
    participant Settings
    participant ElectronKeyMapper

    User->>Settings: Set global hotkey
    Settings->>App: Configure app:globalhotkey
    App->>ElectronKeyMapper: Convert key mapping
    ElectronKeyMapper-->>App: Translated key code
    App->>User: Enable global hotkey functionality
Loading

Poem

🐰 A rabbit's tale of keys so bright,
From "key:" to "app:", a config delight!
Global hotkeys dance with glee,
Across the screen, now swift and free
Wave leaps forth at my command, 🚀
A techno-bunny's wonderland! 🌈


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@@ -170,6 +170,9 @@
export function waveKeyToElectronKey(waveKey: string): string {
const waveParts = waveKey.split(":");
const electronParts: Array<string> = waveParts.map((part: string) => {
const digitRegexpMatch = new RegExp("^c\{Digit(\d)\}$").exec(part);

Check failure

Code scanning / CodeQL

Useless regular-expression character escape High

The escape sequence '\{' is equivalent to just '{', so the sequence may still represent a meta-character when it is used in a regular expression.

Copilot Autofix AI 17 days ago

To fix the problem, we need to remove the unnecessary escape sequence \{ from the regular expression on line 173. This will make the regular expression clearer and easier to understand without changing its functionality.

  • In general terms, we should ensure that only necessary escape sequences are used in regular expressions.
  • Specifically, we will update the regular expression on line 173 to remove the unnecessary escape sequence \{.
  • No additional methods, imports, or definitions are needed to implement this change.
Suggested changeset 1
emain/emain-util.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/emain/emain-util.ts b/emain/emain-util.ts
--- a/emain/emain-util.ts
+++ b/emain/emain-util.ts
@@ -172,3 +172,3 @@
     const electronParts: Array<string> = waveParts.map((part: string) => {
-        const digitRegexpMatch = new RegExp("^c\{Digit(\d)\}$").exec(part);
+        const digitRegexpMatch = new RegExp("^c{Digit(\d)}$").exec(part);
         const numpadRegexpMatch = new RegExp("^c\{Numpad(\d)\}$").exec(part);
EOF
@@ -172,3 +172,3 @@
const electronParts: Array<string> = waveParts.map((part: string) => {
const digitRegexpMatch = new RegExp("^c\{Digit(\d)\}$").exec(part);
const digitRegexpMatch = new RegExp("^c{Digit(\d)}$").exec(part);
const numpadRegexpMatch = new RegExp("^c\{Numpad(\d)\}$").exec(part);
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Member Author

Choose a reason for hiding this comment

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

manually fixing this

@@ -170,6 +170,9 @@
export function waveKeyToElectronKey(waveKey: string): string {
const waveParts = waveKey.split(":");
const electronParts: Array<string> = waveParts.map((part: string) => {
const digitRegexpMatch = new RegExp("^c\{Digit(\d)\}$").exec(part);

Check failure

Code scanning / CodeQL

Useless regular-expression character escape High

The escape sequence '\d' is equivalent to just 'd', so the sequence is not a character class when it is used in a regular expression.

Copilot Autofix AI 17 days ago

To fix the problem, we need to ensure that the backslash is correctly interpreted as part of the regular expression. This can be achieved by using double backslashes (\\d) within the string literal to ensure that the regular expression correctly interprets it as a digit character class.

  • Update the regular expression string literals to use double backslashes for the digit character class.
  • Specifically, change the lines where the regular expressions are defined to use \\d instead of \d.
Suggested changeset 1
emain/emain-util.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/emain/emain-util.ts b/emain/emain-util.ts
--- a/emain/emain-util.ts
+++ b/emain/emain-util.ts
@@ -172,4 +172,4 @@
     const electronParts: Array<string> = waveParts.map((part: string) => {
-        const digitRegexpMatch = new RegExp("^c\{Digit(\d)\}$").exec(part);
-        const numpadRegexpMatch = new RegExp("^c\{Numpad(\d)\}$").exec(part);
+        const digitRegexpMatch = new RegExp("^c\\{Digit(\\d)\\}$").exec(part);
+        const numpadRegexpMatch = new RegExp("^c\\{Numpad(\\d)\\}$").exec(part);
         const lowercaseCharMatch = new RegExp("^([a-z])$").exec(part);
EOF
@@ -172,4 +172,4 @@
const electronParts: Array<string> = waveParts.map((part: string) => {
const digitRegexpMatch = new RegExp("^c\{Digit(\d)\}$").exec(part);
const numpadRegexpMatch = new RegExp("^c\{Numpad(\d)\}$").exec(part);
const digitRegexpMatch = new RegExp("^c\\{Digit(\\d)\\}$").exec(part);
const numpadRegexpMatch = new RegExp("^c\\{Numpad(\\d)\\}$").exec(part);
const lowercaseCharMatch = new RegExp("^([a-z])$").exec(part);
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Member Author

Choose a reason for hiding this comment

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

manually fixing this

@@ -170,6 +170,9 @@
export function waveKeyToElectronKey(waveKey: string): string {
const waveParts = waveKey.split(":");
const electronParts: Array<string> = waveParts.map((part: string) => {
const digitRegexpMatch = new RegExp("^c\{Digit(\d)\}$").exec(part);

Check failure

Code scanning / CodeQL

Useless regular-expression character escape High

The escape sequence '\}' is equivalent to just '}', so the sequence may still represent a meta-character when it is used in a regular expression.

Copilot Autofix AI 17 days ago

To fix the problem, we need to remove the unnecessary escape sequence \} from the regular expression on line 173. This will make the code more readable and maintainable without changing its functionality.

Suggested changeset 1
emain/emain-util.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/emain/emain-util.ts b/emain/emain-util.ts
--- a/emain/emain-util.ts
+++ b/emain/emain-util.ts
@@ -172,3 +172,3 @@
     const electronParts: Array<string> = waveParts.map((part: string) => {
-        const digitRegexpMatch = new RegExp("^c\{Digit(\d)\}$").exec(part);
+        const digitRegexpMatch = new RegExp("^c{Digit(\d)}$").exec(part);
         const numpadRegexpMatch = new RegExp("^c\{Numpad(\d)\}$").exec(part);
EOF
@@ -172,3 +172,3 @@
const electronParts: Array<string> = waveParts.map((part: string) => {
const digitRegexpMatch = new RegExp("^c\{Digit(\d)\}$").exec(part);
const digitRegexpMatch = new RegExp("^c{Digit(\d)}$").exec(part);
const numpadRegexpMatch = new RegExp("^c\{Numpad(\d)\}$").exec(part);
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Member Author

Choose a reason for hiding this comment

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

manually fixing this

emain/emain-util.ts Fixed Show resolved Hide resolved
emain/emain-util.ts Fixed Show fixed Hide fixed
emain/emain-util.ts Fixed Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (6)
pkg/wconfig/metaconsts.go (1)

9-10: LGTM! Consider documenting the prefix change.

The new constants follow the established naming convention and are properly grouped. The transition from "key:" to "app:" prefix is a logical change that better represents the configuration's purpose.

Consider adding a comment explaining the rationale behind the "app:" prefix transition for future maintainers.

docs/docs/keybindings.mdx (1)

74-77: Fix typo and consider enhancing the documentation.

  1. "Customizeable" should be "Customizable"
  2. Consider adding a basic example of setting a global hotkey to make the documentation more immediately useful.
-## Customizeable Systemwide Global Hotkey
+## Customizable Systemwide Global Hotkey
emain/emain-util.ts (1)

188-241: Consider refactoring key mappings for better maintainability.

The current implementation uses a long series of if statements. Consider using a mapping object for better maintainability and performance.

const KEY_MAPPINGS = {
  'Soft1': 'F21',
  'Soft2': 'F22',
  'Soft3': 'F23',
  'Soft4': 'F24',
  ' ': 'Space',
  'CapsLock': 'Capslock',
  'NumLock': 'Numlock',
  'ScrollLock': 'Scrolllock',
  'AudioVolumeUp': 'VolumeUp',
  'AudioVolumeDown': 'VolumeDown',
  'AudioVolumeMute': 'VolumeMute',
  'MediaTrackNext': 'MediaNextTrack',
  'MediaTrackPrevious': 'MediaPreviousTrack',
  'Decimal': 'numdec',
  'Add': 'numadd',
  'Subtract': 'numsub',
  'Multiply': 'nummult',
  'Divide': 'numdiv',
};

// Then in the code:
if (KEY_MAPPINGS[part]) {
  return KEY_MAPPINGS[part];
}
docs/docs/config.mdx (3)

208-208: Add missing comma for better readability.

-Soft keys `Soft1` through `Soft4`. These are essentially the same as `F21` through `F24`.
+Soft keys `Soft1` through `Soft4`. These are essentially the same as `F21` through `F24`,
🧰 Tools
🪛 LanguageTool

[uncategorized] ~208-~208: Possible missing comma found.
Context: ...ally the same as F21 through F24. - Space represented as a literal space  <c...

(AI_HYDRA_LEO_MISSING_COMMA)


197-231: Consider reorganizing the key list for better readability.

The key list is comprehensive but could be better organized into logical groups. Consider structuring it as follows:

-// Current flat list
+// Organized list
+#### Modifier Keys
+- `Ctrl`, `Cmd`, `Shift`, `Alt`, `Option`, `Meta`, `Super`
+
+#### Standard Keys
+- Letters: `a` through `z`
+- Digits: `c{Digit0}` through `c{Digit9}`
+- Function Keys: `F1` through `F20`
+- Soft Keys: `Soft1` through `Soft4` (same as `F21` through `F24`)
+
+#### Special Keys
+- Navigation: `ArrowUp`, `ArrowDown`, `ArrowLeft`, `ArrowRight`, `Home`, `End`, `PageUp`, `PageDown`
+- Control: `Enter`, `Tab`, `Backspace`, `Delete`, `Insert`, `Esc`, `Space`
+- Lock Keys: `CapsLock`, `NumLock`
+
+#### Media Keys
+- Volume: `AudioVolumeUp`, `AudioVolumeDown`, `AudioVolumeMute`
+- Playback: `MediaTrackNext`, `MediaTrackPrevious`, `MediaPlayPause`, `MediaStop`
+
+#### Numpad Keys
+- Numbers: `c{Numpad0}` through `c{Numpad9}`
+- Operators: `Add`, `Subtract`, `Multiply`, `Divide`, `Decimal`
🧰 Tools
🪛 LanguageTool

[uncategorized] ~208-~208: Possible missing comma found.
Context: ...ally the same as F21 through F24. - Space represented as a literal space  <c...

(AI_HYDRA_LEO_MISSING_COMMA)


232-232: Consider adding more examples for better clarity.

The current example is good but could be expanded to show more common use cases.

Add more examples:

Common examples:
- Windows/Linux: `"Ctrl:Alt:w"` for Ctrl+Alt+W
- macOS: `"Cmd:Shift:w"` for Command+Shift+W
- Function key: `"F12"`
- Multiple modifiers: `"Ctrl:Shift:Alt:t"`
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a06ba64 and b2b0986.

📒 Files selected for processing (7)
  • docs/docs/config.mdx (2 hunks)
  • docs/docs/keybindings.mdx (1 hunks)
  • emain/emain-util.ts (2 hunks)
  • emain/emain.ts (1 hunks)
  • frontend/types/gotypes.d.ts (1 hunks)
  • pkg/wconfig/metaconsts.go (1 hunks)
  • pkg/wconfig/settingsconfig.go (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/docs/config.mdx

[uncategorized] ~208-~208: Possible missing comma found.
Context: ...ally the same as F21 through F24. - Space represented as a literal space  <c...

(AI_HYDRA_LEO_MISSING_COMMA)

🪛 Biome (1.9.4)
emain/emain-util.ts

[error] 173-173: Use a regular expression literal instead of the RegExp constructor.

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

(lint/complexity/useRegexLiterals)


[error] 174-174: Use a regular expression literal instead of the RegExp constructor.

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

(lint/complexity/useRegexLiterals)


[error] 175-175: Use a regular expression literal instead of the RegExp constructor.

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

(lint/complexity/useRegexLiterals)

🔇 Additional comments (4)
pkg/wconfig/settingsconfig.go (1)

36-37: LGTM! Configuration structure changes look good.

The new fields AppClear and AppGlobalHotkey are properly defined with correct types and JSON tags, maintaining consistency with the configuration structure.

Let's verify that all references to the old configuration keys have been updated:

✅ Verification successful

Let me verify the remaining part about key:clear vs app:clear to ensure complete consistency.


Let me try a different approach to verify the clear configuration by searching for boolean fields in the configuration types.


Let me try one final verification to check for any Clear-related configuration in metaconsts.go since we found the other configuration key there.


Configuration changes are properly integrated across the codebase

The verification shows that:

  • The new app:globalhotkey is consistently used in the frontend (emain.ts), types (gotypes.d.ts), configuration (settingsconfig.go), constants (metaconsts.go), and is properly documented (config.mdx)
  • The AppClear field with app:* JSON tag follows the same pattern as other clear configurations in the codebase (like AiClear, TermClear, etc.)
  • No references to the old key: prefixed configurations remain
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to the old key:globalhotkey
rg "key:globalhotkey"

# Search for references to the new app:globalhotkey to ensure proper adoption
rg "app:globalhotkey"

Length of output: 1005


Script:

#!/bin/bash
# Search for any remaining references to the old key:clear
rg "key:clear"

# Search for references to the new app:clear to ensure proper adoption
rg "app:clear"

Length of output: 29


Script:

#!/bin/bash
# Search for AppClear usage in the codebase
ast-grep --pattern 'AppClear'

# Search for any Clear-related configuration in TypeScript types
rg "clear" frontend/types/gotypes.d.ts

# Search for Clear-related configuration in documentation
rg -i "clear" docs/docs/config.mdx

Length of output: 141


Script:

#!/bin/bash
# Check metaconsts.go for Clear-related configuration
rg "Clear" pkg/wconfig/metaconsts.go

# Also check for any other potential references to Clear in the Go files
rg "Clear" pkg/wconfig/

Length of output: 2287

emain/emain.ts (1)

614-614: LGTM! Configuration key update is correct.

The change from key:globalhotkey to app:globalhotkey aligns with the new configuration structure.

docs/docs/config.mdx (1)

28-28: LGTM! Configuration documentation is clear and well-placed.

The new configuration key is properly documented in the configuration table with a clear description and reference to the detailed section.

frontend/types/gotypes.d.ts (1)

609-610: LGTM! Consistent naming pattern for the new app namespace.

The new properties follow the established pattern for settings configuration and appropriately replace the old key:* and key:globalhotkey properties.

Let's verify that all usages of the old properties have been migrated:

✅ Verification successful

Migration to app:globalhotkey is complete and consistent

The new app:globalhotkey property is properly integrated across the codebase:

  • Defined in TypeScript types (frontend/types/gotypes.d.ts)
  • Implemented in Go settings config (pkg/wconfig/settingsconfig.go)
  • Constants defined in pkg/wconfig/metaconsts.go
  • Used in electron main process (emain/emain.ts)
  • Documented in config docs (docs/docs/config.mdx)

No references to the old key:globalhotkey property were found, confirming a complete migration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining usage of the old key:globalhotkey property
rg "key:globalhotkey" -l

# Search for any remaining usage of the old key:* property
rg "key:\\*" -l

# Search for usage of the new app:globalhotkey property to ensure it's being used
rg "app:globalhotkey" -l

Length of output: 186


Script:

#!/bin/bash
# Let's check the actual content of these files to understand the usage
echo "=== pkg/wconfig/settingsconfig.go ==="
rg -A 5 "app:globalhotkey" pkg/wconfig/settingsconfig.go

echo -e "\n=== pkg/wconfig/metaconsts.go ==="
rg -A 5 "app:globalhotkey" pkg/wconfig/metaconsts.go

echo -e "\n=== emain/emain.ts ==="
rg -A 5 "app:globalhotkey" emain/emain.ts

echo -e "\n=== docs/docs/config.mdx ==="
rg -A 5 "app:globalhotkey" docs/docs/config.mdx

# Also check if there are any remaining references to the old key:globalhotkey
echo -e "\n=== Checking for old key:globalhotkey references ==="
rg -A 5 "key:globalhotkey" 

Length of output: 3531

emain/emain-util.ts Outdated Show resolved Hide resolved
emain/emain-util.ts Outdated Show resolved Hide resolved
Requires matching on the range [0-9] instead of \d. Also grabs the match
instead of the entire expression.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
emain/emain-util.ts (2)

173-175: Use RegExp literals for better readability and maintainability.

Replace RegExp constructors with literal notation to improve code readability and reduce escaping complexity.

-const digitRegexpMatch = new RegExp("^c{Digit([0-9])}$").exec(part);
-const numpadRegexpMatch = new RegExp("^c{Numpad([0-9])}$").exec(part);
-const lowercaseCharMatch = new RegExp("^([a-z])$").exec(part);
+const digitRegexpMatch = /^c{Digit([0-9])}$/.exec(part);
+const numpadRegexpMatch = /^c{Numpad([0-9])}$/.exec(part);
+const lowercaseCharMatch = /^([a-z])$/.exec(part);
🧰 Tools
🪛 Biome (1.9.4)

[error] 173-173: Use a regular expression literal instead of the RegExp constructor.

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

(lint/complexity/useRegexLiterals)


[error] 174-174: Use a regular expression literal instead of the RegExp constructor.

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

(lint/complexity/useRegexLiterals)


[error] 175-175: Use a regular expression literal instead of the RegExp constructor.

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

(lint/complexity/useRegexLiterals)


242-244: Consider removing or guarding debug logging.

The console.log statement for digit matches might not be necessary in production code. Consider removing it or guarding it behind a debug flag.

 if (digitRegexpMatch && digitRegexpMatch.length > 1) {
-    console.log("digit match is ", digitRegexpMatch);
     return digitRegexpMatch[1];
 }
docs/docs/config.mdx (1)

195-234: Minor documentation improvements needed.

The documentation is comprehensive, but there are a few minor improvements to consider:

  1. Change "anywhere in your computer" to "anywhere on your computer"
  2. Add a comma after "F24" in the Soft keys description
  3. Consider adding more examples for common use cases
-Wave allows settings a custom global hotkey to open your most recent window from anywhere in your computer.
+Wave allows settings a custom global hotkey to open your most recent window from anywhere on your computer.

-Soft keys `Soft1` through `Soft4`. These are essentially the same as `F21` through `F24`.
+Soft keys `Soft1` through `Soft4`. These are essentially the same as `F21` through `F24`,
🧰 Tools
🪛 LanguageTool

[uncategorized] ~197-~197: The preposition “on” seems more likely in this position than the preposition “in”.
Context: ...n your most recent window from anywhere in your computer. This has the name `"app:...

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION_IN_ON)


[uncategorized] ~210-~210: Possible missing comma found.
Context: ...ally the same as F21 through F24. - Space represented as a literal space  <c...

(AI_HYDRA_LEO_MISSING_COMMA)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2b0986 and e7dcb3c.

📒 Files selected for processing (3)
  • docs/docs/config.mdx (2 hunks)
  • emain/emain-util.ts (2 hunks)
  • frontend/types/gotypes.d.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/types/gotypes.d.ts
🧰 Additional context used
🪛 Biome (1.9.4)
emain/emain-util.ts

[error] 173-173: Use a regular expression literal instead of the RegExp constructor.

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

(lint/complexity/useRegexLiterals)


[error] 174-174: Use a regular expression literal instead of the RegExp constructor.

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

(lint/complexity/useRegexLiterals)


[error] 175-175: Use a regular expression literal instead of the RegExp constructor.

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

(lint/complexity/useRegexLiterals)

🪛 LanguageTool
docs/docs/config.mdx

[uncategorized] ~197-~197: The preposition “on” seems more likely in this position than the preposition “in”.
Context: ...n your most recent window from anywhere in your computer. This has the name `"app:...

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION_IN_ON)


[uncategorized] ~210-~210: Possible missing comma found.
Context: ...ally the same as F21 through F24. - Space represented as a literal space  <c...

(AI_HYDRA_LEO_MISSING_COMMA)

🔇 Additional comments (3)
emain/emain-util.ts (2)

188-199: LGTM: Clear and consistent Soft keys mapping.

The mapping of Soft1-Soft4 to F21-F24 is implemented correctly and aligns with the documentation.


200-226: LGTM: Comprehensive special keys mapping.

The implementation correctly maps various special keys to their corresponding Electron accelerator key names, providing good coverage for media and system keys.

docs/docs/config.mdx (1)

28-28: LGTM: Well-documented configuration entry.

The app:globalhotkey configuration entry is clearly documented with appropriate cross-referencing to the detailed section.

@oneirocosm oneirocosm merged commit dbc2be1 into main Dec 17, 2024
10 checks passed
@oneirocosm oneirocosm deleted the sylvie/globalhotkey-docs branch December 17, 2024 23:25
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.

1 participant