Skip to content

Add restart-app extension - #18182

Closed
maxfahl wants to merge 2 commits into
raycast:mainfrom
maxfahl:ext/restart-app
Closed

maxfahl wants to merge 2 commits into
raycast:mainfrom
maxfahl:ext/restart-app

Conversation

@maxfahl

@maxfahl maxfahl commented Mar 27, 2025 •

Copy link
Copy Markdown
Contributor

Description

Screencast

Checklist

- Refactor app-picker, app-utils, and manage-configs components to improve code readability and maintainability. Consolidate action button rendering in app-picker, standardize string formatting in app-utils, and enhance UI elements in manage-configs for better user experience. Ensure consistent formatting and remove unnecessary whitespace across files.
- Update CHANGELOG for initial release details, modify package.json to change icon and category, remove deprecated icon file, and enhance ConfigForm with improved UI elements and placeholder text for better user guidance.
- Enhance ConfigForm in ManageConfigsViewComponent by introducing a data readiness state to manage UI rendering based on application loading status. Update app item rendering to display a loading message while applications are being fetched, improving user experience during data retrieval.
- Enhance ManageConfigsViewComponent by adding keyboard shortcuts for editing configurations and improving validation for configuration names. Introduce helper functions to display app names dynamically in the UI, ensuring better user experience and clarity in app selection.
- Enhance README.md to clarify multi-app restart functionality and startup arguments. Refactor app-utils to support restarting multiple applications with optional startup arguments. Update execute-app-restart and manage-configs-view-component to utilize new multi-app restart feature. Implement configuration migration for backward compatibility with previous app configurations.
- Update package.json to change icon and command titles for clarity. Enhance README.md with detailed usage instructions and features. Remove deprecated extension icon file. Refactor app-picker and manage-configs-view-component for improved functionality and user experience, including updates to quicklink creation instructions.
- Refactor ManageConfigsViewComponent to remove configId handling and streamline the component. Update package.json to simplify command descriptions and rename commands for clarity. Remove unused ManageConfigsView and adjust restart-app component for improved functionality.
- Add restart-app command to package.json and implement auto-navigation in restart-app component
- Refactor Manage Configurations view to streamline shortcut creation. Replaced the copy ID functionality with a command quick link creation feature, enhancing user interaction and simplifying the process of creating shortcuts. Updated related UI elements and toast notifications for improved feedback.
- Enhance Manage Configurations view with configuration ID handling and shortcut creation. Added support for passing a configId to restart specific applications. Implemented functionality to copy configuration IDs and create keyboard shortcuts via quicklink URLs. Improved user feedback with toast notifications for various actions.
- Refactor restart functionality to improve user experience and error handling. Removed the standalone restart-app command, integrated smart restart logic into the app-utils, and updated the Manage Configurations view to streamline configuration management. Enhanced toast notifications for better feedback during app restarts.
- Refactor app retrieval to use Raycast API and enhance error handling in ConfigForm. Updated getInstalledApps to leverage built-in API for fetching applications, improving performance and reliability. Added error states for loading applications and adjusted form handling for app selection.
- Initial commit
@raycastbot raycastbot added the new extension Label for PRs with new extensions label Mar 27, 2025
@raycastbot

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.

…he first app is restarted and improving error handling for missing apps. Modify UI to reflect the selected app\'s bundle ID or indicate if no apps are configured.
@maxfahl

maxfahl commented Apr 1, 2025

Copy link
Copy Markdown
Contributor Author

Is someone ever gonna take a look at this? :)

@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 15, 2025
@maxfahl

maxfahl commented Apr 16, 2025

Copy link
Copy Markdown
Contributor Author

Would anyone please review this?

@raycastbot raycastbot removed the status: stalled Stalled due inactivity label Apr 16, 2025
@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, 2025
@pernielsentikaer

Copy link
Copy Markdown
Contributor

This is still marked as a draft; you need to undraft it before we can take a look.

I'm sure we already have something like that in the store. Did you find any?

@pernielsentikaer pernielsentikaer self-assigned this May 7, 2025
@raycastbot raycastbot removed the status: stalled Stalled due inactivity label May 7, 2025
@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 May 21, 2025
@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 May 28, 2025
@maxfahl

maxfahl commented May 31, 2025

Copy link
Copy Markdown
Contributor Author

This is still marked as a draft; you need to undraft it before we can take a look.

I'm sure we already have something like that in the store. Did you find any?

I'm sorry, but I can't understand how to do this. I've looked everywhere on the page but don't find any buttons for this.

@pernielsentikaer
pernielsentikaer marked this pull request as ready for review June 3, 2025 04:37
@raycastbot raycastbot removed the status: stalled Stalled due inactivity label Jun 3, 2025

@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 👋

Thanks for your contribution 💪

I have now tested your extension, and I have some feedback ready for you:

Could you add the missing icon here

restart-app 2025-06-03 at 06 39 22

I'm looking forward to testing this extension again 🔥

Request a new review when you are ready. Feel free to contact me here or at Slack if you have any questions.

@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

New 'Restart App' extension allowing users to manage and execute application restart configurations on macOS with custom arguments and multi-app support.

  • CHANGELOG.md uses hardcoded date 2025-03-27 instead of required {PR_MERGE_DATE} template string
  • README.md contains duplicate metadata images in both assets and metadata folders which needs to be cleaned up
  • Metadata images are present for no-view command in package.json (execute-app-restart), these should be removed per documentation
  • Some error handling in app-utils.ts could be simplified using showFailureToast from @raycast/utils instead of manual error toast creation

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

15 file(s) reviewed, 14 comment(s)
Edit PR Review Bot Settings | Greptile

- **Configuration Management**: Create, edit, and delete restart configurations for your applications
- **Quick Restart**: Restart any configured app with a single click
- **Keyboard Shortcuts**: Create keyboard shortcuts for frequently restarted apps
- **Smart Exit Detection**: Automatically detect when an app has fully quit before starting it again1

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.

syntax: Typo '...again1' at the end of the line - remove the '1'

Suggested change
- **Smart Exit Detection**: Automatically detect when an app has fully quit before starting it again1
- **Smart Exit Detection**: Automatically detect when an app has fully quit before starting it again

4. Run the "Create Quicklink" command from Raycast
5. Paste the URL into the "Link" input field
6. Assign your preferred keyboard shortcut to the new quicklink
7. Now you can restart all app (or apps) in the configuration directly with your keyboard shortcut from anywhere No newline at end of file

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.

syntax: Grammar error: 'all app (or apps)' should be 'the app (or apps)'

Suggested change
7. Now you can restart all app (or apps) in the configuration directly with your keyboard shortcut from anywhere
7. Now you can restart the app (or apps) in the configuration directly with your keyboard shortcut from anywhere

"commands": [
{
"name": "restart-app",
"title": "Restart App",

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 title matches extension title. Consider adding subtitle to differentiate commands using the service name.

},
{
"name": "execute-app-restart",
"title": "Restart App by ID",

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 a more descriptive title like 'Quick Restart App' or 'Restart Configured App' since this is for predefined configurations.

"$schema": "https://www.raycast.com/schemas/extension.json",
"name": "restart-app",
"title": "Restart App",
"description": "Simply restart an app.",

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: Description is too brief. Add more detail about what the extension does (e.g., 'Quickly restart macOS applications using predefined configurations').

Comment on lines +13 to +72
useEffect(() => {
async function executeRestart() {
try {
// First, migrate configs if needed
await migrateConfigsIfNeeded();

if (!configId) {
await showToast({
style: Toast.Style.Failure,
title: "Missing configuration ID",
});
setTimeout(() => popToRoot(), 1500);
return;
}

// Get all configs
const configs = await getAppConfigs();

// Find the matching config
const configToRun = configs.find((config) => config.id === configId);

if (!configToRun) {
await showToast({
style: Toast.Style.Failure,
title: "Configuration not found",
message: `No configuration found with ID: ${configId}`,
});
setTimeout(() => popToRoot(), 1500);
return;
}

// Show the start toast
await showToast({
style: Toast.Style.Animated,
title: `Restarting apps in ${configToRun.name}`,
});

// Restart all apps in the configuration
await restartMultipleApps(configToRun.apps);

// Show success toast
await showToast({
style: Toast.Style.Success,
title: `Restarted all apps in ${configToRun.name}`,
});

// Return to Raycast root
setTimeout(() => popToRoot(), 1500);
} catch (error) {
await showToast({
style: Toast.Style.Failure,
title: "Failed to restart apps",
message: String(error),
});
setTimeout(() => popToRoot(), 1500);
}
}

executeRestart();
}, [configId]);

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: Effect runs on every configId change but doesn't clean up pending timeouts on unmount

Suggested change
useEffect(() => {
async function executeRestart() {
try {
// First, migrate configs if needed
await migrateConfigsIfNeeded();
if (!configId) {
await showToast({
style: Toast.Style.Failure,
title: "Missing configuration ID",
});
setTimeout(() => popToRoot(), 1500);
return;
}
// Get all configs
const configs = await getAppConfigs();
// Find the matching config
const configToRun = configs.find((config) => config.id === configId);
if (!configToRun) {
await showToast({
style: Toast.Style.Failure,
title: "Configuration not found",
message: `No configuration found with ID: ${configId}`,
});
setTimeout(() => popToRoot(), 1500);
return;
}
// Show the start toast
await showToast({
style: Toast.Style.Animated,
title: `Restarting apps in ${configToRun.name}`,
});
// Restart all apps in the configuration
await restartMultipleApps(configToRun.apps);
// Show success toast
await showToast({
style: Toast.Style.Success,
title: `Restarted all apps in ${configToRun.name}`,
});
// Return to Raycast root
setTimeout(() => popToRoot(), 1500);
} catch (error) {
await showToast({
style: Toast.Style.Failure,
title: "Failed to restart apps",
message: String(error),
});
setTimeout(() => popToRoot(), 1500);
}
}
executeRestart();
}, [configId]);
useEffect(() => {
let timeoutId: NodeJS.Timeout;
async function executeRestart() {
try {
// First, migrate configs if needed
await migrateConfigsIfNeeded();
if (!configId) {
await showToast({
style: Toast.Style.Failure,
title: "Missing configuration ID",
});
timeoutId = setTimeout(() => popToRoot(), 1500);
return;
}
// Get all configs
const configs = await getAppConfigs();
// Find the matching config
const configToRun = configs.find((config) => config.id === configId);
if (!configToRun) {
await showToast({
style: Toast.Style.Failure,
title: "Configuration not found",
message: `No configuration found with ID: ${configId}`,
});
timeoutId = setTimeout(() => popToRoot(), 1500);
return;
}
// Show the start toast
await showToast({
style: Toast.Style.Animated,
title: `Restarting apps in ${configToRun.name}`,
});
// Restart all apps in the configuration
await restartMultipleApps(configToRun.apps);
// Show success toast
await showToast({
style: Toast.Style.Success,
title: `Restarted all apps in ${configToRun.name}`,
});
// Return to Raycast root
timeoutId = setTimeout(() => popToRoot(), 1500);
} catch (error) {
await showToast({
style: Toast.Style.Failure,
title: "Failed to restart apps",
message: String(error),
});
timeoutId = setTimeout(() => popToRoot(), 1500);
}
}
executeRestart();
return () => {
if (timeoutId) {
clearTimeout(timeoutId);
}
};
}, [configId]);

Comment on lines +70 to +90
async function handleRestart(config: AppConfig) {
try {
await showToast({
style: Toast.Style.Animated,
title: `Restarting apps in ${config.name}`,
});

await restartMultipleApps(config.apps);

await showToast({
style: Toast.Style.Success,
title: `Restarted apps in ${config.name}`,
});
} catch (error) {
await showToast({
style: Toast.Style.Failure,
title: "Failed to restart apps",
message: String(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 using showFailureToast from @raycast/utils for error handling to keep the codebase consistent

Suggested change
async function handleRestart(config: AppConfig) {
try {
await showToast({
style: Toast.Style.Animated,
title: `Restarting apps in ${config.name}`,
});
await restartMultipleApps(config.apps);
await showToast({
style: Toast.Style.Success,
title: `Restarted apps in ${config.name}`,
});
} catch (error) {
await showToast({
style: Toast.Style.Failure,
title: "Failed to restart apps",
message: String(error),
});
}
}
async function handleRestart(config: AppConfig) {
try {
await showToast({
style: Toast.Style.Animated,
title: `Restarting apps in ${config.name}`,
});
await restartMultipleApps(config.apps);
await showToast({
style: Toast.Style.Success,
title: `Restarted apps in ${config.name}`,
});
} catch (error) {
showFailureToast(error, { title: "Failed to restart apps" });
}
}


export async function addAppConfig(config: Omit<AppConfig, "id">): Promise<AppConfig> {
const configs = await getAppConfigs();
const newConfig = { ...config, id: Date.now().toString() };

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: Using Date.now() for IDs can cause collisions in rare cases. Consider using a UUID instead for guaranteed uniqueness.

Suggested change
const newConfig = { ...config, id: Date.now().toString() };
const newConfig = { ...config, id: crypto.randomUUID() };

Comment on lines +134 to +140
async function handleSubmit(values: { name: string; bundleId: string; delay: string }) {
try {
const delay = parseInt(values.delay, 10);

if (isNaN(delay) || delay < 0) {
throw new Error("Delay must be a positive number");
}

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: Add validation for maximum delay value (e.g. 10000ms) to prevent excessive delays that could confuse users.

</ActionPanel>
}
>
<Form.TextField id="name" title="Name" placeholder="App Name" defaultValue={config?.name} autoFocus />

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: Add validation for empty name field - an app config should not be saved without a name.

Suggested change
<Form.TextField id="name" title="Name" placeholder="App Name" defaultValue={config?.name} autoFocus />
<Form.TextField id="name" title="Name" placeholder="App Name" defaultValue={config?.name} autoFocus required />

@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 Jun 17, 2025
@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.

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 status: stalled Stalled due inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants