fix(update|watch|apply): re-exec with separate args, poll debugger without busy-loop, guard trailing spicetify_map comment - #3904
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe changes revise post-update command reruns, prevent out-of-range extension mapping access, and add a delay between debugger readiness checks. ChangesRuntime safeguards
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@spicetify.go`:
- Around line 295-300: Preserve parsed global options when spawning child
commands in the automatic backup/apply flow and the remaining-command rerun
around commands and flags. Build each child argument list by forwarding the
relevant original flags, including --bypass-admin when required, before
appending the command arguments; keep the existing len(remaining) > 0 guard and
ensure options such as -e and --no-restart reach both child processes.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e4bd4483-d6a0-46e3-9160-224e29d110e2
📒 Files selected for processing (3)
spicetify.gosrc/cmd/apply.gosrc/cmd/watch.go
|
Addressed the review comment in commit 39f5553 ( |
|
The first "fix" does not have the merit because |
Summary
Three small independent bugs found during a review of the v2.44.0 codebase. Three commits, one per fix.
1. fix(update): re-run remaining commands with updated binary
spicetify.go:293previously did:exec.Commanddoes not split on spaces, so after a successful update the child receives e.g."update backup apply"as one argv. The child's own arg parser (spicetify.go:55-67) then treats it as a single command token, which matches no case in the chainable-commands loop →fatal: Command "update backup apply" not found.printed to the user, and the intended re-run of the chain on the freshly-updated binary never happens.Reproduction: any
spicetify update ...invocation that finds an update (e.g.spicetify update backup apply) ends with the fatal "Command not found" message. Introduced ind5c773f(PR #2227, 2023-03-30).Fix: pass the commands as separate arguments, filtering out the
update/upgradetoken (so it works regardless of position in the chain), and skip re-exec when nothing remains:2. fix(watch): sleep while waiting for Spotify debugger
src/cmd/watch.go:240-242previously busy-looped:No sleep in the loop; each iteration performs a full HTTP GET + JSON parse against
localhost:9222/json/list(src/utils/watcher.go). While Spotify takes several seconds to launch, one core spins at 100% CPU and the local debugger endpoint is hammered. Present sinced30dcba(2020).Fix: poll with
time.Sleep(500 * time.Millisecond).3. fix(apply): guard remap when spicetify_map comment is on last line
src/cmd/apply.go:271-273(pushExtensions) previously did:If the
//spicetify_map{...}{...}comment sits on the final line of an.mjsextension,lines[i+1]is out of range → index-out-of-range panic duringspicetify apply/refresh -e/ watch of that extension. A trailing comment has no following line to remap, so it should simply be skipped.Fix: add the
i+1 < len(lines)guard.Verification
go build ./...passes,go vet ./...clean,gofmtclean.["update backup apply"]as one argv before the fix; after the fix the args are passed separately."line1\n// spicetify_map{A}{B}"→ panic before, no-op after.No test infrastructure exists in this repo; changes validated by build + the reproductions above. Happy to adjust if you want different polling intervals or a different approach for the re-exec.
Summary by CodeRabbit