Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const cli = meow(`
In interactive mode, 🚦n% indicates high CPU usage and 🐏n% indicates high memory usage.
Supports fuzzy search in the interactive mode.

When multiple processes match your search, a "Kill all" option appears
to kill all matching processes at once.

The process name is case-insensitive by default.
`, {
importMeta: import.meta,
Expand Down
15 changes: 12 additions & 3 deletions interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,25 @@ const listProcesses = async (processes, flags) => {
const cpuThreshold = flags.verbose ? 0 : 3;
const searcher = new FuzzySearch(processes, ['name'], {caseSensitive: false});

const selectedPid = await search({
const selectedValue = await search({
message: 'Running processes:',
pageSize: 10,
async source(term = '') {
const matchingProcesses = filterAndSortProcesses(processes, term, searcher, flags);
return matchingProcesses.map(process_ => renderProcessForDisplay(process_, flags, memoryThreshold, cpuThreshold));
const choices = matchingProcesses.map(process_ => renderProcessForDisplay(process_, flags, memoryThreshold, cpuThreshold));

if (term && matchingProcesses.length > 1) {
choices.unshift({
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Placing the “Kill all” choice at the top (unshift) makes it the default/first result for any multi-match search, which increases the chance of accidentally killing all matching processes when the user presses Enter after typing a term. Consider adding an extra confirmation step when this option is chosen, or move it below the individual process results so it’s not the first selectable item.

Suggested change
choices.unshift({
choices.push({

Copilot uses AI. Check for mistakes.
name: `${chalk.red.bold('Kill all')} ${chalk.dim(`(${matchingProcesses.length} processes matching "${term}")`)}`,
value: matchingProcesses.map(process_ => process_.pid),
Comment on lines +268 to +269
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The display string wraps the search term in double quotes. If the user enters a term containing " or control characters, the rendered label can become confusing or misleading in the UI. Consider escaping/quoting the term more robustly (or using single quotes) before interpolating it into the prompt label.

Copilot uses AI. Check for mistakes.
});
}

return choices;
},
});

performKillSequence(selectedPid);
performKillSequence(selectedValue);
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

performKillSequence is async but is called without await here. If the forced-kill path throws (or any other rejection bubbles up), this can become an unhandled promise rejection. Consider awaiting it and handling any errors (for example, by catching and exiting with a non-zero code / showing a message) so failures don’t get lost.

Copilot uses AI. Check for mistakes.
};

const init = async flags => {
Expand Down
Loading