Skip to content

Update bettertouchtool extension - #17660

Closed
kmusick wants to merge 1 commit into
raycast:mainfrom
kmusick:ext/bettertouchtool
Closed

kmusick wants to merge 1 commit into
raycast:mainfrom
kmusick:ext/bettertouchtool

Conversation

@kmusick

@kmusick kmusick commented Mar 7, 2025 •

Copy link
Copy Markdown
Contributor

Description

Focused on AI and improving the named triggers experience.

  • Added Raycast AI Extension tools:
    • search-named-triggers
    • run-named-trigger
    • get-variable-value
    • set-variable-value
    • search-action
    • run-action
  • Rewrote named triggers page for better performance and usability
  • Added commands to get and set variables:
    • get-variable
    • set-string-variable
    • set-number-variable
  • Added new preferences:
    • Most Used Count
    • Default Action for Named Trigger
    • Default Action for Set Variable

Screencast

Checklist

@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: bettertouchtool Issues related to the bettertouchtool extension labels Mar 7, 2025
@raycastbot

raycastbot commented Mar 7, 2025 •

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! 🎉

🔔 @dnnsmnstrr 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.

@greptile-apps greptile-apps Bot 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.

PR Summary

This PR significantly enhances the BetterTouchTool extension with new AI tools, variable management commands, and improved trigger handling functionality.

Key changes:

The implementation is thorough and well-structured, though there are a few areas that could be improved for robustness and maintainability.

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

31 file(s) reviewed, 33 comment(s)
Edit PR Review Bot Settings | Greptile

Comment thread extensions/bettertouchtool/package.json Outdated
Comment on lines 21 to 24

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: Command name 'trigger' has changed from 'Run BTT Named Trigger' to 'Search Named Triggers'. Can we keep the old name? It is the unique ID where ranking, aliases, and hotkeys are saved.

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.

Willing to revert, but the updated names better follow Raycast conventions

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 think the new name makes sense, especially with the app name being displayed behind the command

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.

Yeah, it's confused here - as long as the name doesn't change

Comment thread extensions/bettertouchtool/package.json Outdated
Comment on lines 27 to 31

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: Command name 'action' has changed from 'Run BTT Action' to 'Search Actions'. Can we keep the old name? It is the unique ID where ranking, aliases, and hotkeys are saved.

Comment on lines 82 to 87

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: Silently falling back to string type when number parsing fails could lead to unexpected behavior. Consider throwing an error instead when variableType is 'number' but parsing fails.

Suggested change
if (isNaN(numValue)) {
// If number parsing fails, fall back to string type
return {
success: true,
value: { type: "string", value: variableValue },
};
if (isNaN(numValue)) {
return {
success: false,
error: `Failed to parse '${variableValue}' as a number`,
};
}

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.

Willing to change, but I believe this makes sense for AI tooling

Comment thread extensions/bettertouchtool/src/types.ts Resolved
@kmusick
kmusick marked this pull request as draft March 7, 2025 23:34
@kmusick
kmusick force-pushed the ext/bettertouchtool branch from cc1fd85 to c36688d Compare March 8, 2025 00:07
@kmusick
kmusick marked this pull request as ready for review March 8, 2025 03:06

@greptile-apps greptile-apps Bot 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.

PR Summary

(updates since last review)

Based on my review of the changes and the previous feedback, here are the key new points to highlight:

The PR adds significant functionality to the BetterTouchTool extension with a focus on AI integration and variable management.

  • The CHANGELOG.md entry for "AI Tools & Variable Commands" correctly uses {PR_MERGE_DATE} template string but previous entries use actual dates which should be updated
  • Command names in package.json have been changed (e.g., trigger, action) which could break existing user configurations - recommend keeping original command names
  • Lists and grids should implement isLoading state to avoid empty state flicker, particularly in trigger.tsx and other view components
  • getSelectedText() calls in the codebase should be wrapped in try/catch blocks for graceful error handling
  • Consider adding subtitles to commands in package.json to better identify the service (BetterTouchTool) for users with multiple similar commands

The implementation is solid overall but these adjustments would improve robustness and user experience.

31 file(s) reviewed, 19 comment(s)
Edit PR Review Bot Settings | Greptile

Comment thread extensions/bettertouchtool/.gitignore Outdated
Comment on lines 14 to 15

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 adding a comment above these lines to indicate they are for editor/tool specific files, similar to how other sections are labeled with comments

Comment thread extensions/bettertouchtool/README.md Outdated
Comment on lines 11 to 15

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: Command descriptions are inconsistent - some end with periods, others don't

Comment thread extensions/bettertouchtool/README.md Outdated
Comment on lines 21 to 26

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: AI tool descriptions are duplicates of command names without additional context or differentiation

Comment thread extensions/bettertouchtool/package.json Outdated
Comment on lines 95 to 98

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: variableValue for number variables should use type 'number' instead of 'text' to ensure proper validation

Comment on lines 88 to 89

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: console.error is unnecessary since error is already handled by showFailureToast

Suggested change
console.error(error);
showFailureToast(error);
await showFailureToast(error);
await showFailureToast(error);

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: Error handling is inconsistent - returning error string directly instead of maintaining Result<T> type pattern

Suggested change
return namedTriggersResult.error;
return { status: "error", error: namedTriggersResult.error };

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 trimming variableName and variableValue to handle leading/trailing whitespace consistently

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 escaping backticks in variableName and value to handle cases where they contain backticks

Comment thread extensions/bettertouchtool/src/types.ts Outdated

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 making Success type exported since it's used as part of the exported Result type. This would help with type inference in consuming code.

Comment thread extensions/bettertouchtool/src/types.ts Outdated

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 adding readonly modifiers to prevent accidental mutations of these value types

Suggested change
export type SetVariableValue = { type: "string"; value: string } | { type: "number"; value: number };
export type SetVariableValue = { readonly type: "string"; readonly value: string } | { readonly type: "number"; readonly value: number };

@dnnsmnstrr

Copy link
Copy Markdown
Contributor

@kmusick Wow, really cool 🤯 Was already thinking about how this extension has lots of potential for the new AI features, and you made it happen! Nice touch with the grouping of named triggers, too.

I tried testing your changes and unfortunately only had mixed success with letting the AI run named triggers. After moving the IMPORTANT comment from the Input type definition to above the tool function, it seemed to be a bit more reliable. I'll add some comments where I made the changes if you want to try it out.

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.

Adding this comment seemed to make the AI more reliably search for named triggers before running them:

/**
 * Run a named trigger in BetterTouchTool
 * 
 * IMPORTANT: You MUST use the search-named-triggers tool first to find the correct name of the trigger.
 * The name MUST MATCH EXACTLY what is returned by search-named-triggers - this includes:
 * - Exact capitalization (uppercase/lowercase)
 * - Exact spacing
 * - Exact punctuation
 * - Exact special characters
 *
 * DO NOT modify the name in any way from what search-named-triggers returns, regardless of what the user inputs.
 *
 * For example, if search-named-triggers returns "My-Trigger_Name!", you MUST use "My-Trigger_Name!"
 * (NOT "my-trigger_name!", "My Trigger Name", "mytriggername", etc.)
 *
 * Note: Do not make assumptions about whether a trigger is enabled or disabled.
 * Simply run the trigger by name without commenting on its enabled status.
 */

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 added a condensed version of that IMPORTANT message and updated Input type to contain the full SearchResult object. In my testing, these two changes have really increased run-named-trigger performance. If you are having issues, can you add an eval that demonstrates the issue? If you haven't used the eval functionality much, it seems to require significant adjustments after copying, especially with input that includes nested structures or arrays, in my experience.

Comment thread extensions/bettertouchtool/package.json Outdated
Comment on lines 21 to 24

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 think the new name makes sense, especially with the app name being displayed behind the command

Comment thread extensions/bettertouchtool/package.json Outdated

@dnnsmnstrr dnnsmnstrr Mar 8, 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 would personally want the instructions to more explicitly use the named trigger tool by default, unless asking for an 'action' to be run.
Many of the actions don't really work without additional input and I never found the time to go through and filter out the ones that can't simply be run, so that feature could use some more work if the AI should interact. The list came from here, but it's not really documented, so it would require some manual work / reverse engineering (maybe @fifafu could help)

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.

Removing this text and instead having examples above both run-named-trigger and run-action (where it is pointed out multiple times that the user must directly mention action) seems to have improved performance. npx run evals has three tests on run-named-trigger and one on run-action. I have not had issues after this latest commit, but I imagine any real AI Command usage would need to be decently specific to guarantee the correct behavior.

I am really not very knowledgeable about actions. I agree that the current situation is probably not ideal, but maybe occasionally useful? I imagine power users would always prefer named triggers, and normal users probably wouldn't use this at all, so I don't really think it will see much use. However, I also think it makes sense to ship AI tooling that matches the command functionality, especially since there are a reasonable number that seem to function correctly.

- refactor: Improve code formatting and comment clarity in run-named-trigger.ts
- feat(raycast-ai): Implement AI tools for triggers/actions/vars, improve named triggers, add set/get variable commands & prefs
- Initial commit

Update bettertouchtool extension

- feat(raycast-ai): Implement AI tools for triggers/actions/vars, improve named triggers, add set/get variable commands & prefs
- refactor: Improve code formatting and comment clarity in run-named-trigger.ts
- feat(raycast-ai): Implement AI tools for triggers/actions/vars, improve named triggers, add set/get variable commands & prefs

Delete extensions/bettertouchtool/.aider.input.history

Removed aider

Apply suggestions from code review

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

implemented code review suggestions

implementing review feedback

implementing review feedback

Implementing pr feedback and ai tooling changes. Changed format to encourage exact inputs, better handled invalid inputs, and better instructions to prefer named trigger vs action

fixed formatting
@kmusick
kmusick force-pushed the ext/bettertouchtool branch from bf8f1a3 to a833caf Compare May 19, 2025 21:13
@pernielsentikaer

Copy link
Copy Markdown
Contributor

Is this ready for another review @kmusick @dnnsmnstrr

@kmusick

kmusick commented May 20, 2025

Copy link
Copy Markdown
Contributor Author

Is this ready for another review @kmusick @dnnsmnstrr

Yes, it should be - I didn't realize that there was a conflict from the mass macOS platform push. The only change I made since my prior push was regenerating package-lock.json with updates from this branch as well as the macOS platform change.

@pernielsentikaer

Copy link
Copy Markdown
Contributor

Assigning this to you @andreaselia, can you help with this too?

@andreaselia

Copy link
Copy Markdown
Contributor

@kmusick could you go through and action/resolve any Greptile feedback please and let us know when ready for review again?

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

Labels

AI Extension extension: bettertouchtool Issues related to the bettertouchtool extension extension fix / improvement Label for PRs with extension's fix improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants