Skip to content

feat: Add agent sync#146

Open
maximbigler wants to merge 17 commits into
mainfrom
feature/add-agent-sync
Open

feat: Add agent sync#146
maximbigler wants to merge 17 commits into
mainfrom
feature/add-agent-sync

Conversation

@maximbigler
Copy link
Copy Markdown
Member

@maximbigler maximbigler commented May 7, 2026

Type of change

  • 🐛 Bug fix
  • 🚀 New feature
  • ❓ Other (please specify)

Description

Fixes #33

This PR introduces the initial implementation of the agent sync. It copies docker-compose.yml into the agent volume, and sets the application status accordingly.

Comment thread backend/internal/agent/deploy.go Fixed
Comment thread backend/internal/agent/deploy.go Fixed
Comment thread backend/internal/hub/websocket/hub.go Outdated
Comment thread backend/internal/agent/deploy.go Outdated
Comment thread backend/internal/agent/websocket.go Outdated
Comment thread backend/internal/agent/deploy.go Outdated
Comment thread backend/internal/hub/applications/sync.go Outdated
@maximbigler maximbigler force-pushed the feature/add-agent-sync branch from 818964a to e21bad4 Compare May 11, 2026 21:01
Comment thread backend/internal/agent/docker/deploy.go Fixed
Comment thread backend/internal/agent/docker/deploy.go Fixed
Comment thread backend/internal/agent/docker/deploy.go Fixed
@maximbigler maximbigler marked this pull request as ready for review May 11, 2026 21:21
Copilot AI review requested due to automatic review settings May 11, 2026 21:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an initial “agent sync/deploy” flow: the Hub can request an Agent deployment over WebSocket, the Agent writes the compose file to a deployments directory and runs docker compose up, and the Hub updates application sync/health status; the UI gets a manual trigger.

Changes:

  • Add protobuf messages + Hub WebSocket plumbing to start a deploy request and correlate an async deploy result.
  • Add Hub-side deploy manager + application route (POST /applications/:id/deploy) and integrate deployment into the sync worker.
  • Add Agent-side deploy execution that writes compose files into a configured deployments directory and runs Docker Compose, plus docker-compose volume/env wiring and frontend trigger.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/src/routes/_authenticated/applications/$id.index.tsx Replace fake “sync” delay with a real deploy call and UI disabled/loading state.
frontend/src/lib/applications.ts Add deployApplication() API client for /applications/:id/deploy.
frontend/messages/en.json Add deploy-related i18n strings.
frontend/messages/de.json Add deploy-related i18n strings (German).
docker-compose.yml Mount agent deployments volume into the container.
docker-compose.dev.yml Mount deployments volume and set DEPLOYMENTS_DIR for dev agent.
backend/internal/proto/messages.proto Add DeployRequest/DeployResult messages in WS protocol.
backend/internal/hub/websocket/hub.go Track pending deploys; start deploy requests; resolve results; fail pending on disconnect.
backend/internal/hub/websocket/hub_test.go Add tests for deploy request lifecycle and disconnect/unavailable scenarios.
backend/internal/hub/websocket/handler.go Handle inbound DeployResult messages and resolve pending deploys.
backend/internal/hub/websocket/handler_test.go Update tests for new handler signature and behavior.
backend/internal/hub/routes/applications.go Add DeployApplicationHandler HTTP endpoint to trigger agent deployment and mark app syncing.
backend/internal/hub/routes/applications_test.go Add route tests for deploy success and agent-unavailable behavior.
backend/internal/hub/handlers.go Register deploy route and initialize the default deployer with the WS hub.
backend/internal/hub/applications/sync.go Replace placeholder deployment logic with DeployAndWait and status updates based on result.
backend/internal/hub/applications/deploy.go New Hub-side deploy manager: start deploys, await/track manual deploys, and update statuses + SSE.
backend/internal/hub/applications/applications_test.go Update sync/queue tests to stub deployer and allow new deployment behavior.
backend/internal/agent/websocket.go Handle DeployRequest server messages; execute deployment; send DeployResult; serialize outbound writes.
backend/internal/agent/websocket_test.go Add tests for deploy request handling and deploy result sending.
backend/internal/agent/docker/docker.go Add deploymentsDir to docker client and update constructor signature.
backend/internal/agent/docker/docker_test.go Update docker client tests for new constructor signature.
backend/internal/agent/docker/deploy.go New agent deploy implementation: write compose file to deployments dir and run compose up with wait.
backend/internal/agent/docker/deploy_test.go Add tests for deploy writing/compose invocation and (intended) unsafe id rejection.
backend/internal/agent/agent.go Wire DEPLOYMENTS_DIR into docker client and pass sender/deployer into WS handler.
backend/internal/agent/agent_config_test.go Add tests for default and overridden DEPLOYMENTS_DIR.
.env.example Document DEPLOYMENTS_DIR env var for the agent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/internal/agent/docker/deploy.go
Comment thread frontend/src/routes/_authenticated/applications/$id.index.tsx Outdated
Comment thread .env.example Outdated
Comment thread backend/internal/agent/docker/deploy.go Fixed
Comment thread backend/internal/agent/docker/deploy.go Outdated
Comment thread backend/internal/agent/agent.go
Comment thread backend/internal/agent/websocket.go
Comment thread backend/internal/hub/applications/sync.go Outdated
log.Error().Err(err).Str("client", client.Id).Msg("Failed to update last_seen")
}
case *messages.ClientMessage_DeployResult:
if !h.ResolveDeploy(p.DeployResult) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this updating the db status?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, it's not updating the database. The ResolveDeploy call only completes the in-memory deployment handle

Comment thread backend/internal/hub/websocket/hub.go Outdated
Comment thread .env.example Outdated
Comment thread docker-compose.dev.yml Outdated
Comment thread docker-compose.yml Outdated
@maximbigler maximbigler force-pushed the feature/add-agent-sync branch from e09f8a0 to c50e224 Compare May 12, 2026 20:48
@maximbigler maximbigler force-pushed the feature/add-agent-sync branch from 66399ab to 4c994d3 Compare May 13, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: automatic and manual application sync

5 participants