Skip to content

Update SwitchHosts extension - modernize + icons + markdown + add hook + remove setTimeout,node-fetch - #21017

Merged
raycastbot merged 3 commits into
raycast:mainfrom
xmok:ext/switchhosts
Aug 18, 2025
Merged

raycastbot merged 3 commits into
raycast:mainfrom
xmok:ext/switchhosts

Conversation

@xmok

@xmok xmok commented Aug 17, 2025

Copy link
Copy Markdown
Contributor

Description

  • show an Icon based on type
  • add README.md
  • add this CHANGELOG.md
  • add Icon to Action
  • add metadata image
  • categorize as "Developer Tools"
  • chore: update deps and scripts
  • modernize to use latest Raycast eslint.config.js

Screencast

switchosts.mp4

Checklist

@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: switchhosts Issues related to the switchhosts extension labels Aug 17, 2025
@raycastbot

ghost commented Aug 17, 2025 •

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! 🎉

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

Due to our current reduced availability during summer, the initial review may take up to 10-15 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 Summary

This PR comprehensively modernizes the SwitchHosts extension to align with current Raycast development standards. The changes include migrating from the deprecated .eslintrc.json to the modern eslint.config.js flat config format using @raycast/eslint-config. The codebase has been updated to use the useCachedPromise hook from @raycast/utils instead of manual state management with useState and useEffect, providing built-in caching, loading states, and better error handling.

The extension removes the node-fetch dependency in favor of native fetch, which is now available in modern Node.js versions. TypeScript configuration has been upgraded from ES2020 to ES2023, enabling access to newer JavaScript features and APIs. The UI has been enhanced with type-based icons for different host configurations (folder, group, remote, local) and improved accessories for better visual distinction.

Documentation improvements include adding a proper README.md file and CHANGELOG.md with historical entries dating back to 2021. The extension has been categorized as "Developer Tools" and includes metadata images for store submission. Package.json scripts have been standardized to include modern Raycast tooling commands like lint, fix-lint, and publish. The main functionality switches between different host configurations while preserving the URL path, now with optimistic updates for a more responsive user experience.

Important Files Changed

Filename Score Overview
extensions/switchhosts/src/switchhosts.tsx 3/5 Modernized with useCachedPromise hook and optimistic updates, but has potential UI state consistency issues
extensions/switchhosts/package.json 5/5 Updated dependencies, added categories, modernized scripts, and removed node-fetch dependency
extensions/switchhosts/eslint.config.js 4/5 Added modern ESLint flat config using @raycast/eslint-config
extensions/switchhosts/tsconfig.json 5/5 Upgraded to ES2023, added raycast-env.d.ts include, and enabled resolveJsonModule
extensions/switchhosts/README.md 4/5 Added proper documentation with installation requirements and feature listing
extensions/switchhosts/CHANGELOG.md 4/5 Added comprehensive changelog with proper formatting and {PR_MERGE_DATE} template
extensions/switchhosts/.eslintrc.json 5/5 Removed deprecated ESLint configuration file as part of modernization

Confidence score: 3/5

  • This PR requires careful review due to potential state consistency issues in the optimistic update logic
  • Score lowered due to a mismatch between optimistic update state and toast message logic that could confuse users
  • Pay close attention to extensions/switchhosts/src/switchhosts.tsx for the state management implementation

7 files reviewed, 4 comments

Edit Code Review Bot Settings | Greptile

Comment on lines +82 to +84
optimisticUpdate(data) {
return data.map((d) => (d.id === item.id ? { ...d, on: !d.on } : d));
},

ghost Aug 17, 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: Potential issue: optimistic update toggles on state, but success message on line 90 uses original item.on value. This creates incorrect toast messages - when turning ON a host, it shows 'Close Host Success'.

Comment thread extensions/switchhosts/README.md Resolved
Comment thread extensions/switchhosts/eslint.config.js Resolved
@pernielsentikaer pernielsentikaer self-assigned this Aug 18, 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.

Hi 👋

Looks good to me, approved 🔥

@raycastbot
raycastbot merged commit 76cc2c0 into raycast:main Aug 18, 2025
@github-actions

ghost commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

@raycastbot

ghost commented Aug 18, 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.

@xmok
xmok deleted the ext/switchhosts branch August 18, 2025 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants