Skip to content

Conversation

@sanoojes
Copy link
Contributor

@sanoojes sanoojes commented Oct 2, 2025

Use exact match as it now kills apps like spotify_player

Summary by CodeRabbit

  • Bug Fixes
    • Improved restart reliability on macOS and Linux by matching the exact Spotify process name to avoid terminating similarly named processes.
    • Reduces accidental shutdowns and makes restart flows more predictable.
    • No behavioral changes on Windows.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Oct 2, 2025

📝 Walkthrough

Walkthrough

Use exact-name matching for process detection/termination in src/cmd/restart.go: on Linux pgrep -x/pkill -x "spotify" are used; on macOS the previous ps | grep pipeline was replaced (detection logic unchanged) and pkill -x "Spotify" is used; Windows taskkill remains unchanged.

Changes

Cohort / File(s) Summary
Process termination logic
src/cmd/restart.go
Linux: switch to exact-match pgrep -x "spotify" and pkill -x "spotify"; Darwin: replace `ps

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I hop through logs with whiskered care, exact names loud and clear,
I match the string and tip my hat, no fuzzy trails to fear.
On Linux fields and Darwin boughs, I nudge the processes light—
Windows hums its steady tune, the restart's done just right. 🥕🐇

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: using exact match with pkill to terminate Spotify, which directly aligns with the PR's core objective of preventing unintended process termination.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/cmd/restart.go (1)

20-25: Use exact match with pgrep for consistency.

Line 21 uses pgrep spotify without the -x flag, which will match process names like spotify_player. For consistency with the exact-match termination on line 24, and to avoid false positives in the detection logic, add the -x flag to pgrep as well.

Apply this diff:

-		isRunning := exec.Command("pgrep", "spotify")
+		isRunning := exec.Command("pgrep", "-x", "spotify")
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 15d1365 and 8aad069.

📒 Files selected for processing (1)
  • src/cmd/restart.go (1 hunks)

@sanoojes sanoojes closed this Oct 23, 2025
@sanoojes sanoojes reopened this Dec 11, 2025
@rxri
Copy link
Member

rxri commented Dec 15, 2025

I'm not going to review it until you look into coderabbit's suggestions

@sanoojes
Copy link
Contributor Author

@rxri can you check it out rn

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/cmd/restart.go`:
- Around line 26-31: The macOS branch in restart.go uses lowercase "spotify", so
update the two exec.Command calls in the case "darwin" block (the
exec.Command("pgrep", "-x", "spotify") and exec.Command("pkill", "-x",
"spotify").Run()) to use the correct process name "Spotify" (capital S) so
pgrep/pkill will match and terminate the running app.
🧹 Nitpick comments (1)
src/cmd/restart.go (1)

20-31: Consider consolidating duplicate platform logic.

The linux and darwin cases now have nearly identical logic (the only difference should be the process name casing). Once the darwin case is fixed to use the correct capitalization, consider whether this duplication is intentional or could be consolidated.

♻️ Optional consolidation (after fixing the darwin case)
 	case "linux":
 		isRunning := exec.Command("pgrep", "-x", "spotify")
 		_, err := isRunning.Output()
 		if err == nil {
 			exec.Command("pkill", "-x", "spotify").Run()
 		}
 	case "darwin":
-		isRunning := exec.Command("pgrep", "-x", "spotify")
-		_, err := isRunning.Output()
+		isRunning := exec.Command("pgrep", "-x", "Spotify")
+		_, err := isRunning.Output()
 		if err == nil {
-			exec.Command("pkill", "-x", "spotify").Run()
+			exec.Command("pkill", "-x", "Spotify").Run()
 		}

Alternatively, if both platforms should use the same logic, a helper function could reduce duplication—but keeping them separate is also reasonable for platform-specific flexibility.

case "darwin":
isRunning := exec.Command("sh", "-c", "ps aux | grep 'Spotify' | grep -v grep")
_, err := isRunning.CombinedOutput()
isRunning := exec.Command("pgrep", "-x", "Spotify")
Copy link
Member

@rxri rxri Jan 22, 2026

Choose a reason for hiding this comment

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

pgrep isn't natively available on macOS. You have to use change the syntax of previous cmd

Copy link
Contributor Author

Choose a reason for hiding this comment

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

woops then the old way was probably good, am updating it rn

@rxri rxri merged commit a06256c into spicetify:main Jan 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants