Skip to content

Update keyboard-shortcut-sequences extension - #22181

Merged
raycastbot merged 5 commits into
raycast:mainfrom
dw-herrmann:ext/keyboard-shortcut-sequences
Nov 5, 2025
Merged

raycastbot merged 5 commits into
raycast:mainfrom
dw-herrmann:ext/keyboard-shortcut-sequences

Conversation

@dw-herrmann

@dw-herrmann dw-herrmann commented Oct 14, 2025 •

Copy link
Copy Markdown
Contributor

Description

Screencast

Checklist

- update README clarity on shortcut sequence configuration
- chore: update changelog with new delay feature and UX improvements
- fix: simplify special keys handling in shortcut sequence
- fix: update shortcut delay handling and validation
- wording improvement
- fix: multiple special keys in one command
- add new features
@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: keyboard-shortcut-sequences Issues related to the keyboard-shortcut-sequences extension platform: macOS labels Oct 14, 2025
@raycastbot

ghost commented Oct 14, 2025 •

Copy link
Copy Markdown
Collaborator

Thank you for your first contribution! 🎉

🔔 @SKaplanOfficial you might want to have a look.

You can use this guide to learn how to check out the Pull Request locally in order to test it.

You can expect an initial review within five business days.

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Greptile Overview

Summary

This PR adds delay support and special key selection to keyboard shortcut sequences, improving UX by making shortcut management more dynamic.

Major changes:

  • Added delay field for each shortcut to compensate for loading times
  • Introduced special keys dropdown (function keys, arrows, volume, brightness) as alternative to manual key code entry
  • Replaced static "Number of Shortcuts" field with dynamic add/remove controls at end of form
  • Updated types to include specials array and delay field in Shortcut interface

Critical issues found:

  • utils.ts:8-10 - forEach with async callback won't execute shortcuts sequentially; delays won't work as intended
  • utils.ts:9 - Delay calculation accumulates all previous delays instead of using just the current shortcut's delay
  • SequenceForm.tsx:261 - shortcutDelays array not updated when removing shortcuts, causing state misalignment
  • types.ts:48,52-55 - Multiple duplicate key codes (Power/F5 both "96", brightness keys conflict with F-keys)

Confidence Score: 1/5

  • This PR has critical bugs that break core functionality - shortcuts won't execute sequentially and delays won't work correctly
  • Score reflects multiple critical logic errors: async forEach breaks sequential execution (the main feature), incorrect delay accumulation logic, missing state updates causing data misalignment, and duplicate key codes causing incorrect key mapping. These issues will cause the extension to malfunction.
  • Pay close attention to utils.ts (broken async logic) and types.ts (duplicate key codes)

Important Files Changed

File Analysis

Filename Score Overview
extensions/keyboard-shortcut-sequences/src/utils.ts 1/5 Critical logic errors: async forEach breaks sequential execution and delay calculation accumulates incorrectly
extensions/keyboard-shortcut-sequences/src/types.ts 2/5 Multiple duplicate key codes will cause incorrect key mapping (Power/F5, brightness/function keys, etc.)
extensions/keyboard-shortcut-sequences/src/components/SequenceForm.tsx 3/5 Missing state array update when removing shortcuts causes misalignment; otherwise good UX improvements

6 files reviewed, 5 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +8 to +10
sequence.shortcuts.forEach(async (shortcut, index) => {
const delay = sequence.shortcuts.slice(0, index + 1).reduce((acc, curr) => acc + (curr.delay || 0), 0);
await new Promise((resolve) => setTimeout(resolve, delay));

ghost Oct 14, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

logic: forEach doesn't wait for async callbacks - shortcuts will execute in parallel, not sequentially, breaking the delay logic.

Suggested change
sequence.shortcuts.forEach(async (shortcut, index) => {
const delay = sequence.shortcuts.slice(0, index + 1).reduce((acc, curr) => acc + (curr.delay || 0), 0);
await new Promise((resolve) => setTimeout(resolve, delay));
for (let index = 0; index < sequence.shortcuts.length; index++) {
const shortcut = sequence.shortcuts[index];
const delay = sequence.shortcuts.slice(0, index + 1).reduce((acc, curr) => acc + (curr.delay || 0), 0);
await new Promise((resolve) => setTimeout(resolve, delay));

const currentApplication = await getFrontmostApplication();
sequence.shortcuts.forEach(async (shortcut) => {
sequence.shortcuts.forEach(async (shortcut, index) => {
const delay = sequence.shortcuts.slice(0, index + 1).reduce((acc, curr) => acc + (curr.delay || 0), 0);

ghost Oct 14, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

logic: Delay calculation accumulates all previous delays, not just the current shortcut's delay. Each shortcut should only wait for its own delay value.

Suggested change
const delay = sequence.shortcuts.slice(0, index + 1).reduce((acc, curr) => acc + (curr.delay || 0), 0);
await new Promise((resolve) => setTimeout(resolve, shortcut.delay || 0));

setShortcutCount(shortcutCount + 1);
setShortcutKeys([...shortcutKeys, ""]);
setShortcutModifiers([...shortcutModifiers, []]);
setShortcutSpecials([...shortcutSpecials, []]);

ghost Oct 14, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

logic: When removing a shortcut, shortcutDelays is not updated. This causes misalignment between state arrays.

Suggested change
setShortcutSpecials([...shortcutSpecials, []]);
setShortcutDelays(shortcutDelays.slice(0, -1));

VolumeDown: "73",
Mute: "74",
Help: "114",
Power: "96",

ghost Oct 14, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

logic: Power and F5 both map to key code "96" - one is incorrect.

Comment on lines +52 to +55
BrightnessUp: "113",
BrightnessDown: "107",
PrintScreen: "105",
Insert: "114",

ghost Oct 14, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

logic: Duplicate key codes: BrightnessUp (113) conflicts with F15 (113), BrightnessDown (107) conflicts with F14 (107), PrintScreen (105) conflicts with F13 (105), and Insert (114) conflicts with Help (114).

- changelog
- bugfix broken behavior
- bugfix delay
- check and sort speical keys
- bugfix save delay on change
- hide hud and notify when sequence has finished
- add fn key functionality
- bugfix: dont delete empty shortcuts
- add fn key functionality

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks mostly good to me, just one small fix + something for a future version. Aside from the form dropdown, everything else seems to work as expected (delays, special keys such as arrow keys, and FN modifier).

sequence.shortcuts.forEach(async (shortcut) => {

// Hide Raycast overlay immediately
await showHUD(`Running: ${sequence.name}`);

ghost Oct 20, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we use showToast instead, we can have it show an animated state until the shortcut stops. Not sure that is better or worse though?

e.g. the code below will result in something like the image, but I'm not sure we actually want that. Could be annoying for longer delays. Perhaps it could be an option in a future version.

  // Hide Raycast overlay immediately
  // await showHUD(`Running: ${sequence.name}`); // Replaced
  await closeMainWindow();
  const toast = await showToast({
    title: `Running: ${sequence.name}`,
    style: Toast.Style.Animated
  });

  try {
    
    // ... shortcuts loop code
    
  } catch (error) {
    toast.title = `Failed to Run Sequence ${sequence.name}`;
    toast.style = Toast.Style.Failure;
    return;
  }

  // await showHUD(`Sequence ${sequence.name} finished`); // Replaced
  toast.title = `Sequence ${sequence.name} finished`;
  toast.style = Toast.Style.Success;
Screenshot 2025-10-20 at 1 37 14 PM

ghost Oct 30, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I like that Idea! Its in the next pullrequest

id="editShortcuts"
value="placeholder"
info="Use the selection to add or remove shortcuts from the sequence."
onChange={(value) => {

ghost Oct 20, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not able to add a 3rd sequence without manually resetting the dropdown to some other value (since it only checks if the value changed, this makes sense). There's a few ways around it, but imo an elegant way is the imperative API using useRef, e.g.:

  // ... state variables
  const dropdownRef = useRef<Form.ItemReference | null>(null);

    // ... form code

      <Form.Dropdown
        // ... props
        ref={dropdownRef}
        onChange={(value) => {
          if (value === "add") {
            // ... 
          } else if (value === "remove" && shortcutCount > 1) {
            // ...
          }

          // Reset to initial value
          dropdownRef.current?.reset();
        }}
      >
        // ...
      </Form.Dropdown>

@pernielsentikaer

ghost commented Oct 30, 2025

Copy link
Copy Markdown
Contributor

Hi @dw-herrmann👋

Thanks for your contribution 🔥

Did you see the comments from @SKaplanOfficial

I converted this PR into a draft until it's ready for the review, please press the button Ready for review when it's ready and we'll have a look 😊

@pernielsentikaer pernielsentikaer self-assigned this Oct 30, 2025
@pernielsentikaer
pernielsentikaer marked this pull request as draft October 30, 2025 09:02
@dw-herrmann

ghost commented Oct 30, 2025

Copy link
Copy Markdown
Contributor Author

@pernielsentikaer, thank you for the reminder. I'll take care of the fixes in the next few days :)

- updated images
- focus latest shortcut affter adding or removing one
- reset dropdown after adding field
- - show animated state while shortcut is running - wrap loop with try-catch
@dw-herrmann
dw-herrmann marked this pull request as ready for review October 30, 2025 15:58

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This review covers only the changes made since the last review, not the entire PR. The update addresses several critical fixes and UX improvements to the keyboard shortcut sequences extension. The changelog was updated to reflect the correct release date (October 14th) and document the new FN-key modifier support. The core execution logic was fixed by replacing forEach with a proper for-of loop to ensure sequential shortcut execution, and delay calculation was corrected to use individual shortcut delays rather than accumulating all previous delays. Function key support was added through proper AppleScript handling with key down/up events. The form component received UX enhancements including auto-focus for delay fields, dropdown reset functionality using the imperative API, and better error handling. The types were cleaned up by removing conflicting key codes and organizing them into logical sections. These changes address the fundamental async execution issues while expanding functionality and improving user experience.

Important Files Changed

Filename Score Overview
extensions/keyboard-shortcut-sequences/CHANGELOG.md 5/5 Updated release date and documented FN-key modifier feature addition
extensions/keyboard-shortcut-sequences/src/components/SequenceForm.tsx 4/5 Added auto-focus, dropdown reset functionality, and FN modifier support with some complexity concerns
extensions/keyboard-shortcut-sequences/src/utils.ts 4/5 Fixed critical async execution flow and added FN key support with proper error handling
extensions/keyboard-shortcut-sequences/src/types.ts 4/5 Removed conflicting key codes and added FN modifier support, improving reliability

Confidence score: 4/5

  • This PR addresses critical functional issues and is safe to merge with the improvements significantly outweighing any minor concerns
  • Score reflects successful resolution of major async execution bugs and timing issues, with well-implemented FN key support and UX enhancements, though some complexity was added to the form component
  • Pay close attention to the SequenceForm.tsx file for potential focus management edge cases in complex user interactions

4 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +292 to +293
// Set focus to the new delay field after state updates
setTimeout(() => setFocusDelayIndex(newIndex), 100);

ghost Oct 30, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

style: Consider using requestAnimationFrame instead of setTimeout for UI state changes to ensure proper timing with React's rendering cycle.

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@pernielsentikaer

ghost commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

@SKaplanOfficial can you give it another spin?

ghost Nov 5, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm fine with this image, but does it meet the store requirements @pernielsentikaer? In reference to the background not being one of the Raycast ones.

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All previous problems solved, and haven't encountered any new ones. Seems good to merge.

@raycast-extensions-bot raycast-extensions-bot Bot added the Approved Approved by a user label Nov 5, 2025

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me, approved 🔥

@raycastbot
raycastbot merged commit d9f76b0 into raycast:main Nov 5, 2025
@github-actions

ghost commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

@raycastbot

ghost commented Nov 5, 2025

Copy link
Copy Markdown
Collaborator

🎉 🎉 🎉

We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag.

@dw-herrmann

ghost commented Nov 5, 2025

Copy link
Copy Markdown
Contributor Author

Hey @pernielsentikaer, somehow the order of the screenshots got mixed up in the store and on the website. This makes the extension a little harder to understand.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved Approved by a user extension fix / improvement Label for PRs with extension's fix improvements extension: keyboard-shortcut-sequences Issues related to the keyboard-shortcut-sequences extension platform: macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants