Skip to content

Add ping-menu extension - #22299

Merged
raycastbot merged 13 commits into
raycast:mainfrom
basilar:ext/ping-menu
Nov 7, 2025
Merged

raycastbot merged 13 commits into
raycast:mainfrom
basilar:ext/ping-menu

Conversation

@basilar

@basilar basilar commented Oct 20, 2025 •

Copy link
Copy Markdown
Contributor

Description

Screencast

Checklist

@raycastbot raycastbot added the new extension Label for PRs with new extensions label Oct 20, 2025
@raycastbot

ghost commented Oct 20, 2025

Copy link
Copy Markdown
Collaborator

Congratulations on your new Raycast extension! 🚀

You can expect an initial review within five business days.

Once the PR is approved and merged, the extension will be available on our Store.

@basilar
basilar marked this pull request as ready for review October 20, 2025 15:49
@pernielsentikaer

ghost commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

@greptileai can you do a fresh review here?

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.

I'll provide a fresh review of this ping-menu extension PR.

Overall Assessment

This is a well-structured menu bar extension that monitors ping latency to google.com. The implementation is clean and follows Raycast conventions. Here are my findings:

✅ Strengths

  1. Good documentation - README clearly explains features and limitations
  2. Proper caching - Uses LocalStorage to show last known values on startup
  3. Smart refresh logic - Different intervals for background vs. active states
  4. User feedback - Color-coded indicators and tooltips provide good UX
  5. Configuration - Standard Raycast config files are properly set up

🔍 Issues & Suggestions

Critical Issues

1. Hardcoded ping target
The extension only pings google.com with no configuration option. Consider adding a preference for the target host.

2. Type safety suppressions
There are multiple @ts-ignore comments in ping-monitor.tsx (lines 115, 117, 120, 124, 126). This suggests either:

  • Type definitions need updating
  • Components are being used incorrectly
  • There's a version mismatch in dependencies

Code Quality

3. Error handling in pingGoogle()

} catch (error) {
    console.error("Ping failed:", error);
    return null;
}

The error is logged but the actual error message isn't captured or displayed to users. The history just shows "Failed" without context.

4. Magic numbers

  • Line 16: -W 1000 (timeout)
  • Line 73: slice(0, 10) (history size)
  • Line 88: 1000 (interval)
  • Lines 102-104: Latency thresholds (60, 150)

These should be constants or preferences.

5. Potential memory leak in LocalStorage
Every ping saves to LocalStorage (line 73). While you're limiting to 10 items, this still happens every second when active. Consider debouncing or only saving periodically.

Documentation

6. Incomplete CHANGELOG
The date is 2025-10-20 which is in the future. Should this be 2024-10-20?

7. README oversells limitations
The note about "Background Execution Limitation" is extensive but the extension correctly uses interval: "10s" in package.json for background updates. The explanation might confuse users.

Configuration

8. Missing metadata
package.json is missing:

  • categories field (should include something like "Developer Tools" or "Productivity")
  • version field
  • keywords field for discoverability

9. Interval configuration
The interval: "10s" in package.json seems reasonable, but the code runs at 1-second intervals when open. Document this behavior difference more clearly.

Testing

10. No error state UI
If ping fails repeatedly, the menu just shows "..." or old data. Consider showing an error state or retry option.

11. Platform-specific ping command
/sbin/ping assumes macOS/Unix. While Raycast is macOS-only, the path might vary. Consider using just ping and letting PATH resolution handle it.

Recommendations

  1. Add user preferences for target host and update interval
  2. Fix TypeScript issues - remove @ts-ignore comments
  3. Extract magic numbers to named constants
  4. Add proper error state handling and display
  5. Fix the CHANGELOG date
  6. Add missing package.json metadata
  7. Consider rate-limiting LocalStorage writes
  8. Add more granular color indicators or make thresholds configurable

Minor Nits

  • mise.toml specifies node = "latest" but this might cause inconsistency across contributors
  • The icon.png file isn't visible in the diff - ensure it's high quality and follows Raycast guidelines
  • Consider adding a "Copy latency" action in the menu items

Would you like me to provide specific code suggestions for any of these issues?

… extension

- Deleted .eslintrc.json file.
- Updated package-lock.json and package.json to include new versions of dependencies, including @raycast/utils, @raycast/eslint-config, eslint, prettier, and typescript.
- Adjusted TypeScript configuration to target ES2023 and updated JSX handling.
- Refactored ping-monitor component to utilize useCachedPromise for improved data fetching and state management.
@pernielsentikaer

ghost commented Oct 30, 2025

Copy link
Copy Markdown
Contributor

Hi @basilar👋

Thanks for your contribution 🔥

I updated the code a bit; could you make sure I didn't break anything?

Ideas: let the user change the domain in preferences, maybe set the default to check every minute and let the user decide in preferences?

You could add a preference for that and check in the code if the time passed that amount to recheck 🙂

@pernielsentikaer
pernielsentikaer marked this pull request as draft October 30, 2025 11:34
@basilar
basilar marked this pull request as ready for review October 31, 2025 08:26

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. This PR adds a new ping-menu extension that provides continuous network latency monitoring through a menu bar command. The extension pings google.com every 10 seconds and displays the current latency with color-coded indicators (green for good, yellow for fair, red for poor). The implementation includes local storage of ping history (last 10 results) and proper error handling. Key technical changes include migrating from legacy .eslintrc.json to the newer eslint.config.js format, modernizing the TypeScript configuration to ES2023 with react-jsx transform, and refactoring the core ping logic from manual React hooks (useState/useEffect) to Raycast's useCachedPromise hook for simplified state management.

Important Files Changed

Filename Score Overview
extensions/ping-menu/eslint.config.js 5/5 Adds new ESLint configuration using Raycast's standard template
extensions/ping-menu/tsconfig.json 5/5 Modernizes TypeScript config with ES2023 and react-jsx transform
extensions/ping-menu/.eslintrc.json 2/5 Empties the old ESLint config file instead of removing it entirely
extensions/ping-menu/package.json 4/5 Defines new ping-menu extension with menu-bar command and dependencies
extensions/ping-menu/src/ping-monitor.tsx 3/5 Refactors ping monitor from manual hooks to useCachedPromise implementation

Confidence score: 3/5

  • This PR introduces a functional new extension but has some architectural concerns that may affect performance
  • Score lowered due to potential issues with useCachedPromise for continuous monitoring, empty .eslintrc.json file instead of proper cleanup, and missing PR description/screenshots required for new extensions
  • Pay close attention to ping-monitor.tsx implementation and ensure the empty .eslintrc.json file doesn't cause linting issues

Additional Comments (1)

  1. extensions/ping-menu/.eslintrc.json, line 1 (link)

    logic: Empty .eslintrc.json should be deleted if migrating to eslint.config.js. Having both files can cause conflicts. Are you migrating to the new flat config format? If so, this file should be deleted entirely.

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@basilar basilar closed this Oct 31, 2025
@basilar basilar reopened this Oct 31, 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.

Greptile Overview

Greptile Summary

This PR adds a new ping-menu extension that provides continuous network latency monitoring through Raycast's menu bar. The extension pings google.com at 10-second intervals and displays real-time latency information with color-coded status indicators (green for good, yellow for moderate, red for poor connection). It maintains a persistent history of the last 10 ping results using LocalStorage and caches results for improved performance. The extension integrates well with Raycast's menu bar system by using MenuBarExtra component and follows the platform's architectural patterns with proper TypeScript typing and React hooks like useCachedPromise.

Important Files Changed

Filename Score Overview
extensions/ping-menu/src/ping-monitor.tsx 3/5 Main extension logic with ping functionality, menu bar display, and status indicators - has hardcoded path and caching issues
extensions/ping-menu/CHANGELOG.md 4/5 Documents initial release features but uses hardcoded date instead of required {PR_MERGE_DATE} template
extensions/ping-menu/.prettierrc 2/5 Prettier configuration that doesn't follow Raycast's standard settings (should use printWidth: 120)
extensions/ping-menu/mise.toml 3/5 Node.js version configuration using "latest" instead of specific version number
extensions/ping-menu/package.json 5/5 Well-structured package configuration with proper dependencies and menu-bar command setup
extensions/ping-menu/eslint.config.js 5/5 Standard ESLint configuration following Raycast's template exactly
extensions/ping-menu/tsconfig.json 5/5 Standard TypeScript configuration with appropriate settings for Raycast extensions
extensions/ping-menu/.gitignore 5/5 Standard gitignore setup excluding appropriate files and folders

Confidence score: 3/5

  • This PR requires careful review due to several technical issues that could affect functionality and consistency
  • Score reflects hardcoded system paths, incorrect Prettier configuration, non-standard version specification, and missing changelog template format that deviate from Raycast guidelines
  • Pay close attention to ping-monitor.tsx for path compatibility, .prettierrc for formatting standards, and CHANGELOG.md for proper template usage

9 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment thread extensions/ping-menu/CHANGELOG.md Resolved
Comment thread extensions/ping-menu/.prettierrc Resolved
basilar and others added 5 commits November 1, 2025 07:58
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>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@pernielsentikaer

ghost commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

@greptileai could you do a fresh review of this PR?

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.

I'll review this PR for the new ping-menu extension. Let me analyze the code structure, implementation, and adherence to Raycast extension best practices.

Overall Assessment

This is a well-structured menu bar extension that monitors ping latency to google.com. The implementation is clean and follows Raycast conventions well.

✅ Strengths

  1. Clear Purpose: Simple, focused functionality - ping monitoring in the menu bar
  2. Good UX: Visual indicators (colored dots) and informative tooltips
  3. Proper Caching: Uses LocalStorage for persistence across sessions
  4. Error Handling: Gracefully handles ping failures
  5. TypeScript: Properly typed throughout
  6. Configuration: Follows Raycast extension structure correctly

🔍 Code Review Findings

Critical Issues

File: src/ping-monitor.tsx

  1. Performance Concern - Aggressive Polling (Lines 115-121)

    const intervalId = setInterval(() => {
      if (!cancelled) {
        fetchPing();
      }
    }, 1000);

    The extension pings every second regardless of whether the menu is open. This could be resource-intensive and potentially trigger rate limits. Consider using Raycast's built-in interval (currently set to 10s in package.json) for background updates and only poll frequently when the menu is actively being viewed.

Minor Issues

File: package.json

  1. Node Version Mismatch (Line in mise.toml)
    // mise.toml has node = "22.14.0" 
    // but package.json devDeps has "@types/node": "22.13.10"
    Consider aligning these versions for consistency.

File: src/ping-monitor.tsx

  1. Hardcoded Target (Line 16)

    const { stdout } = await execAsync("/sbin/ping -c 1 -W 1000 google.com");

    While google.com is a reasonable default, consider making this configurable via preferences for users who might want to ping different hosts.

  2. Magic Numbers (Lines 135-137)

    if (lat < 60) return Color.Green;
    if (lat < 150) return Color.Yellow;

    Consider extracting these thresholds as constants or making them configurable.

💡 Suggestions for Improvement

  1. Respect Menu State: Only poll aggressively (1s) when menu is open, use the 10s interval when closed
  2. Add Preferences: Allow users to configure ping target and latency thresholds
  3. Consider IPv6: The current ping command might not work consistently across all network configurations
  4. Add Error Details: Show more specific error information in the history when pings fail

📋 Compliance Check

  • ✅ Follows extension guidelines
  • ✅ Proper package.json structure
  • ✅ TypeScript configuration correct
  • ✅ Asset usage appropriate
  • ✅ README documentation present
  • ✅ Changelog included

Recommendation

Conditional Approval - This is a solid extension that provides useful functionality. The main concern is the aggressive 1-second polling which should be optimized. I'd recommend addressing the performance issue before merging, but the other suggestions are nice-to-haves for future iterations.

The extension demonstrates good understanding of Raycast APIs and follows best practices in most areas. Great work overall! 🎯

@pernielsentikaer

ghost commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

Could you look into above @basilar

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 😊

@basilar
basilar marked this pull request as draft November 7, 2025 11:04
@basilar
basilar marked this pull request as ready for review November 7, 2025 11:15
@basilar

ghost commented Nov 7, 2025

Copy link
Copy Markdown
Contributor Author

Hello @pernielsentikaer, I've introduced options to customise the site to ping and specify the "method" for running the process in the background. Personally, I require the 1-second refresh to bypass Raycast's own scheduler and avoid the 10-second limitation. However, I've also included the Raycast version (with a 10-second interval) as the default to ensure that only those who truly need my "override" will utilise it. I hope this meets your needs too. Cheers

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. The developer has enhanced the ping-menu extension by adding user configurability through preferences and implementing two distinct polling modes. The key changes include adding a preferences section to package.json with configurable site targeting and ping method selection (standard vs aggressive), refactoring the ping monitor to use these preferences, and updating the changelog with user-focused feature descriptions in an "Added" section.

Important Files Changed

Filename Score Overview
extensions/ping-menu/CHANGELOG.md 4/5 Restructured changelog from technical "Changed" to user-focused "Added" section with better formatting and British English consistency
extensions/ping-menu/package.json 4/5 Added preferences section with site selection and ping method configuration options
extensions/ping-menu/src/ping-monitor.tsx 4/5 Implemented configurable ping monitoring with dynamic polling intervals based on user preferences

Confidence score: 4/5

  • This PR is safe to merge with minimal risk of breaking existing functionality
  • Score reflects well-structured preferences implementation and proper state management, but dinged for lack of error handling in preference validation and potential confusion with polling method descriptions
  • Pay close attention to the preferences configuration in package.json to ensure the descriptions clearly communicate the trade-offs between methods

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

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 57cbf4b into raycast:main Nov 7, 2025
@github-actions

ghost commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

@raycastbot

ghost commented Nov 7, 2025

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 (@basilar).

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

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

Labels

new extension Label for PRs with new extensions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants