Repository navigation
Conversation
paperclipai service start/restart/install and update re-rendered the launchd plist and systemd unit from a fixed template, so any variable an operator had added (PATH, ENABLE_CLAUDEAI_MCP_SERVERS, bind hosts) was silently dropped. Read the installed definition, keep every non-managed environment key, and render it back. The health check compares against the same rendering so customized definitions are not reported as stale. Fixes paperclipai#16435
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] Changes how service definitions preserve custom environment variables. The PR still needs the existing service-reload issue fixed before merging. Findings
Fix with agent prompt### Issue 1
cli/src/services/service-manager.ts:undefined-306
If an operator adds `Environment="PATH=/opt/bin:/usr/bin"` immediately before `WorkingDirectory`, preserving it leaves the file unchanged. `ensureCurrent` then skips `daemon-reload`, so restart uses systemd's previously loaded settings. The same issue affects launchd install/start: an unchanged file skips `bootout`, and the fallback `kickstart` uses the loaded job. Reload based on whether the supervisor has the current settings, not just whether this call rewrites the file.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryThe PR keeps operator-added environment settings when the CLI rewrites service definitions.
Changes since the last review only remove code comments. Reviews (3) · Last reviewed commit: "chore(cli): drop code comments added in ..." · Reviewed by Greptile |
|
|
||
| private async ensureCurrent(): Promise<boolean> { | ||
| const changed = await writeIfChanged(this.definitionPath, this.renderDefinition()); | ||
| const changed = await writeIfChanged(this.definitionPath, await this.renderCurrentDefinition()); |
There was a problem hiding this comment.
If an operator adds Environment="PATH=/opt/bin:/usr/bin" immediately before WorkingDirectory, preserving it leaves the file unchanged. ensureCurrent then skips daemon-reload, so restart uses systemd's previously loaded settings. The same issue affects launchd install/start: an unchanged file skips bootout, and the fallback kickstart uses the loaded job. Reload based on whether the supervisor has the current settings, not just whether this call rewrites the file.
Prompt To Fix With AI
This is a comment left during a code review.
Path: cli/src/services/service-manager.ts
Line: 281
Comment:
**Restart keeps old settings**
If an operator adds `Environment="PATH=/opt/bin:/usr/bin"` immediately before `WorkingDirectory`, preserving it leaves the file unchanged. `ensureCurrent` then skips `daemon-reload`, so restart uses systemd's previously loaded settings. The same issue affects launchd install/start: an unchanged file skips `bootout`, and the fallback `kickstart` uses the loaded job. Reload based on whether the supervisor has the current settings, not just whether this call rewrites the file.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Re-escaping a decoded Environment= value doubled %-specifiers (%h became %%h) and dropped multi-assignment and single-quoted lines. Keep each operator assignment exactly as written and drop only the CLI-managed keys. Also decode numeric XML character references when reading launchd values.
|
Pushed 7f9362d for the review findings:
Not changed: an unchanged file still skips |
Thinking Path
Linked Issues or Issue Description
Fixes #16435
What Changed
extractExtraEnvironmentFromLaunchdPlistandextractExtraEnvironmentFromSystemdUnit. They return the environment keys in an installed definition, except the three keys that the CLI manages.renderLaunchdPlistandrenderSystemdUnitaccept an optionalextraEnvironmentmap and render it after the managed keys, with the same escaping as the managed values.ServiceManager.renderDefinition(existingDefinition?)takes the installed definition.install,start, andrestarton both managers render from the installed file beforewriteIfChanged.start+restart) and systemd (restart, quoted and unquotedEnvironment=lines).Verification
vitest run cli/src/__tests__/service-manager.test.ts: the two new tests fail onmaster(custom keys are gone after the re-render) and pass with this change. All 21 tests in the file pass.service-health-check.test.tslocally because it needs the full workspace deps. CI runs it.Risks
PAPERCLIP_HOMEand the others) from the old file, so it still controls those values.Model Used
Checklist
Fixes: #/Closes #/Refs #OR (b) described the issue in-PR following the relevant issue template