Skip to content

Update toothpick extension - #26147

Merged
raycastbot merged 9 commits into
raycast:mainfrom
merchako:ext/toothpick
May 5, 2026
Merged

raycastbot merged 9 commits into
raycast:mainfrom
merchako:ext/toothpick

Conversation

@merchako

@merchako merchako commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Motivation

  • Provide a single action to "refresh" Bluetooth when a device becomes unresponsive by briefly reconnecting a device or toggling Bluetooth power, as requested in issue [Toothpick] Refresh command #26144.

Implementation Details

  • Add a per-device "Refresh" action in the Manage Bluetooth Connections panel that runs connect → wait → disconnect by introducing src/core/devices/handlers/refresh-device.ts and wiring it into Device actions (src/core/devices/devices.model.tsx).
  • Add a refresh-device command and three favorite shortcuts (refresh-favorite-device-1/2/3) that reuse the existing fuzzy name/MAC lookup flow (src/refresh-device.ts, src/refresh-favorite-device-1.ts, src/refresh-favorite-device-2.ts, src/refresh-favorite-device-3.ts).
  • Add a refresh-all command to toggle Bluetooth power off/on via a new handler src/core/devices/handlers/refresh-bluetooth.ts and command src/refresh-all.ts.
  • Extend the devices service interface with refreshBluetooth() and implement it in blueutil only (blueutil -p 0 && blueutil -p 1 in src/core/devices/devices.service.blueutil.ts).
  • Register the new commands in package.json and add consistent user-facing messages via existing showAnimatedMessage / showSuccessMessage / showErrorMessage utilities.

Limitations

  • "Refresh All" requires blueutil

Testing

  • Passed npm run lint
  • Hand-tested on macOS

AI Disclosure

  • Used ~12-15 prompts to Codex and hand-modified the end result.

Screencast

CleanShot.2026-03-08.at.21.07.39.mp4

Checklist

- lint
- Fix CHANGELOG
- Removed a layer of abstraction from refresh-device.ts by calling services directly
- Merge pull request raycast#2 from merchako/codex/add-refresh-action-for-bluetooth-connections-1k5myo
- Finalize refresh changes and update manifest/changelog for Raycast contribution
- Initial commit
- Initial commit
- Initialize repository
@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: toothpick Issues related to the toothpick extension AI Extension platform: macOS labels Mar 9, 2026
@raycastbot

raycastbot commented Mar 9, 2026 •

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! 🎉

🔔 @VladCuciureanu @briankosw @sxn @rspeicher @AntonNiklasson @xmok 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.

📋 Quick checkout commands
BRANCH="ext/toothpick"
FORK_URL="https://github.com/merchako/raycast-extensions.git"
EXTENSION_NAME="toothpick"
REPO_NAME="raycast-extensions"

git clone -n --depth=1 --filter=tree:0 -b $BRANCH $FORK_URL
cd $REPO_NAME
git sparse-checkout set --no-cone "extensions/$EXTENSION_NAME"
git checkout
cd "extensions/$EXTENSION_NAME"
npm install && npm run dev

We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days.

@merchako
merchako marked this pull request as ready for review March 9, 2026 02:13
@greptile-apps

greptile-apps Bot commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a suite of "Refresh" commands to the Toothpick extension, covering per-device reconnect (disconnect → wait → reconnect), favorite-device shortcuts, and a Bluetooth power toggle (blueutil only). The implementation follows the existing connect/disconnect patterns closely and also fixes a pre-existing bug where connection failure showed a success toast.

  • New handler refresh-device.ts: chains disconnectDevice → 2 s delay → connectDevice, reusing the updated handlers that now return boolean.
  • New handler refresh-bluetooth.ts: calls blueutil -p 0 && sleep 1 && blueutil -p 1 synchronously via execSync; error path explicitly tells the user Bluetooth may need manual re-enabling.
  • Five new no-view commands registered in package.json (refresh-device, refresh-all, refresh-favorite-device-1/2/3), all disabledByDefault: true.

Confidence Score: 5/5

The changes are additive, all new commands are disabled by default, and the core logic closely mirrors existing connect/disconnect patterns.

All new handlers are isolated, error paths are properly guarded, and the only finding is a convention nit in the changelog date placeholder.

No files require special attention beyond the {PR_MERGE_DATE} placeholder fix in CHANGELOG.md.

Important Files Changed

Filename Overview
extensions/toothpick/CHANGELOG.md New changelog entry uses a hardcoded date instead of the required {PR_MERGE_DATE} placeholder.
extensions/toothpick/src/core/devices/handlers/refresh-device.ts New handler chains disconnect → wait → reconnect; both sub-handlers now return !!result so the boolean return type is clean.
extensions/toothpick/src/core/devices/handlers/refresh-bluetooth.ts Toggles Bluetooth off/on via blueutil; error message correctly warns user that Bluetooth may need manual re-enabling on failure.
extensions/toothpick/src/core/devices/devices.model.tsx Adds "Refresh" action appended after existing copy actions and before ...additionalActions, consistent with extension conventions.
extensions/toothpick/src/core/devices/devices.service.blueutil.ts Implements refreshBluetooth() with a synchronous execSync shell command; error propagation to caller is correct.
extensions/toothpick/package.json Registers five new no-view commands (refresh-device, refresh-all, refresh-favorite-device-1/2/3) and adds merchako as a contributor.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
extensions/toothpick/CHANGELOG.md:3
The changelog entry uses a hardcoded date instead of the `{PR_MERGE_DATE}` placeholder. Raycast's release tooling automatically populates the placeholder at merge time; a hardcoded date will not be updated and may diverge from the actual merge date.

```suggestion
## [Refresh Device and Refresh All Commands] - {PR_MERGE_DATE}
```

Reviews (5): Last reviewed commit: "Update CHANGELOG.md" | Re-trigger Greptile

Comment thread extensions/toothpick/src/utils.ts Resolved
merchako and others added 3 commits March 8, 2026 23:19
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
…th.ts

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

Copy link
Copy Markdown
Contributor

Thanks for the update @merchako

@VladCuciureanu can you give this a spin?

@pernielsentikaer pernielsentikaer self-assigned this Mar 16, 2026
@VladCuciureanu

Copy link
Copy Markdown

Thanks for the update @merchako

@VladCuciureanu can you give this a spin?

I'm afraid not. Schedule doesn't allow me to work on side-projects.

@pernielsentikaer pernielsentikaer 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.

Hi @merchako 👋

I have some feedback when I checked the code 🙂

  • Empty .gitkeep file added — extensions/toothpick/.gitkeep is a new empty file with no purpose. Should be removed 🙂

  • refresh-all is instant off→on with no delay — blueutil -p 0 && blueutil -p 1 turns BT off then immediately back on. For devices that are "stuck", this may not give enough time for the radio to fully power down. A small sleep 1 between the two commands would be more reliable: blueutil -p 0 && sleep 1 && blueutil -p 1.

  • Hardcoded 2-second delay in refresh-device.ts — setTimeout(resolve, 2000) is a magic number. Should at minimum be a named constant. Could also consider making it configurable or at least documenting why 2s was chosen.

  • refreshDevice duplicates connect/disconnect logic — refresh-device.ts calls devicesService.disconnectDevice() and devicesService.connectDevice() directly rather than reusing connectDevice() and disconnectDevice() from the existing handlers. This means it doesn't get the closeOnSuccessfulConnection behavior consistently and has its own message flow. It does handle closeOnSuccessfulConnection at the end, but the disconnect path doesn't respect it.

  • connect-device.ts side effect: now returns boolean — The existing connectDevice handler was changed to return !!result, and disconnectDevice similarly. These return values aren't used by existing callers. The change to showErrorMessage instead of showSuccessMessage on failure is a good bugfix, but the return value addition is dead code outside of the new refresh path (and refresh doesn't even use these handler functions).

  • Greptile flag is valid — The "Refresh" action in devices.model.tsx is inserted at index 1 (between Connect/Disconnect and Copy MAC Address). This extension's action list is ordered, and Refresh should probably go after Copy MAC Address, before ...additionalActions.

  • refresh-device.ts uses raw arrow function export — export default async (props) => {...} instead of a named function like the other command files (export default async function Command()). Minor consistency issue.

  • AppleScript backend refreshBluetooth() silently returns false — No user-facing message explains that Refresh All isn't supported on the AppleScript backend. The refresh-bluetooth.ts handler hardcodes getDevicesService("blueutil") which is good, but if someone calls refreshBluetooth() on the AppleScript service directly through the Manage panel, it silently fails. Not a real issue since refresh-all forces blueutil, but worth noting for interface completeness.


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 marked this pull request as draft March 19, 2026 13:53
@raycastbot

Copy link
Copy Markdown
Collaborator

This pull request has been automatically marked as stale because it did not have any recent activity.

It will be closed if no further activity occurs in the next 7 days to keep our backlog clean 😊

@raycastbot raycastbot added the status: stalled Stalled due inactivity label Apr 2, 2026
@raycastbot

Copy link
Copy Markdown
Collaborator

This pull request has been automatically closed due to inactivity.

Feel free to comment in the thread when you're ready to continue working on it 🙂

You can also catch us in Slack if you want to discuss this.

@raycastbot raycastbot closed this Apr 9, 2026
@merchako

merchako commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review! Here's what was addressed:

Resolved:

  • .gitkeep — Removed.

  • sleep 1 delay in refresh-all — Added. Used /bin/sleep 1 (full path) instead of sleep 1 — Raycast's subprocess runs with a restricted PATH that doesn't include /bin, so sleep wasn't found at runtime.

  • Hardcoded 2s delay — Extracted to const RECONNECT_DELAY_MS = 2000 in refresh-device.ts.

  • refreshDevice duplicates connect/disconnect logic — Refactored to call the connectDevice and disconnectDevice handler functions directly. As a side effect, closeMainWindow is now only called if the reconnect actually succeeds, since it's handled inside connectDevice rather than unconditionally at the end of refreshDevice.

  • Return values as dead code — Since refreshDevice now calls the handler functions, the boolean return values from connectDevice and disconnectDevice are actually used. No longer dead code.

  • Refresh action position — Moved after Copy MAC Address, before ...additionalActions.

  • Raw arrow function export — Changed to export default async function Command.

Not addressed:

  • AppleScript refreshBluetooth() silently returns false — Agreed it's not a real issue. For context: if blueutil isn't installed, Refresh All shows an error telling the user to install it via Homebrew. If blueutil is installed but AppleScript is set as the active backend in preferences, Refresh All still works — the handler hardcodes blueutil regardless of the preference setting.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@merchako

merchako commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Requesting a re-open @pernielsentikaer

@merchako

merchako commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor Author

@raycastbot raycastbot added OP is contributor The OP of the PR is a contributor of the extension and removed status: stalled Stalled due inactivity labels Apr 16, 2026
@pernielsentikaer
pernielsentikaer marked this pull request as ready for review April 16, 2026 08:20

@pernielsentikaer pernielsentikaer 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.

Hi @merchako 👋

Thanks for getting back to me, sorry I didn't catch it before now 🙂

Two small things:

  • refresh-favorite-device-1/2/3.ts use export default async () => instead of named function Command() like the other command files. Could you align these for consistency?
  • Minor: unused DevicesService type import in refresh-bluetooth.ts (only getDevicesService is needed)

Could you look into above?


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 marked this pull request as draft April 16, 2026 08:43
@raycastbot

Copy link
Copy Markdown
Collaborator

This pull request has been automatically marked as stale because it did not have any recent activity.

It will be closed if no further activity occurs in the next 7 days to keep our backlog clean 😊

@raycastbot raycastbot added the status: stalled Stalled due inactivity label Apr 30, 2026
…port

- Use named function Command() in refresh-favorite-device-1/2/3.ts for consistency with other command files
- Remove unused DevicesService type import from refresh-bluetooth.ts
@raycastbot raycastbot removed the status: stalled Stalled due inactivity label May 2, 2026
@merchako
merchako marked this pull request as ready for review May 2, 2026 02:21

@pernielsentikaer pernielsentikaer 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 7aa8832 into raycast:main May 5, 2026
3 checks passed
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

@raycastbot

Copy link
Copy Markdown
Collaborator

🎉 🎉 🎉

Such a great contribution deserves a reward, but unfortunately we couldn't find your Raycast account based on your GitHub username (@merchako).

Please link your GitHub account to your Raycast account to receive your credits and soon be able to exchange them for some swag.

@merchako

merchako commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@raycastbot Fixed. Try again. Can I tell you to try again? Probably not.

@merchako
merchako deleted the ext/toothpick branch May 7, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Extension extension fix / improvement Label for PRs with extension's fix improvements extension: toothpick Issues related to the toothpick extension OP is contributor The OP of the PR is a contributor of the extension platform: macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants