Skip to content

feat: update agent binaries and restart opencode server during sync#155

Merged
gricha merged 3 commits intomainfrom
feat/sync-update-agent-binaries
Feb 8, 2026
Merged

feat: update agent binaries and restart opencode server during sync#155
gricha merged 3 commits intomainfrom
feat/sync-update-agent-binaries

Conversation

@gricha
Copy link
Owner

@gricha gricha commented Feb 8, 2026

Summary

  • perry sync --all now runs agent binary updates (claude, opencode, pi) in addition to credential/config sync
  • After updating binaries, kills any running opencode serve process and starts a fresh one so it picks up the new binary
  • Previously, agent binary updates only ran during workspace create/start/clone — long-running workspaces would never get updates unless restarted

Comment on lines +1235 to +1236
await this.updateAgentBinaries(containerName);
await this.restartOpenCodeServer(containerName);

This comment was marked as outdated.

Comment on lines 610 to 614
private async restartOpenCodeServer(containerName: string): Promise<void> {
await docker.execInContainer(containerName, ['sh', '-c', 'pkill -f "opencode serve" || true'], {
user: 'workspace',
});
await this.startOpenCodeServer(containerName);

This comment was marked as outdated.

Comment on lines +611 to +621
await docker.execInContainer(
containerName,
[
'sh',
'-c',
'pkill -f "opencode serve" || true; for i in $(seq 1 20); do pgrep -f "opencode serve" > /dev/null || break; sleep 0.25; done',
],
{ user: 'workspace' }
);
await this.startOpenCodeServer(containerName);
}
Copy link

Choose a reason for hiding this comment

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

Bug: A race condition in restartOpenCodeServer can cause startOpenCodeServer to silently fail if the old server process takes more than 5 seconds to terminate.
Severity: MEDIUM

Suggested Fix

Increase the timeout in the wait loop from 5 seconds to a more conventional value, such as 10-30 seconds. Additionally, the return value from docker.execInContainer() should be checked. If the script failed to kill the old process in time, an error should be thrown or logged instead of proceeding to call startOpenCodeServer.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/workspace/manager.ts#L610-L621

Potential issue: The `restartOpenCodeServer` function executes a script to kill the
`opencode serve` process and then waits up to 5 seconds for it to terminate. If the
process takes longer than 5 seconds to shut down, the script exits successfully. The
subsequent call to `startOpenCodeServer` then detects the old, still-running process and
exits silently without starting a new one. This causes the intended server binary update
to fail without any notification, making it seem like the operation succeeded when it
did not.

@gricha gricha merged commit 6ed242d into main Feb 8, 2026
8 of 9 checks passed
@gricha gricha deleted the feat/sync-update-agent-binaries branch February 8, 2026 19:05
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.

1 participant