feat: Add agent sync#146
Conversation
818964a to
e21bad4
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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.
| log.Error().Err(err).Str("client", client.Id).Msg("Failed to update last_seen") | ||
| } | ||
| case *messages.ClientMessage_DeployResult: | ||
| if !h.ResolveDeploy(p.DeployResult) { |
There was a problem hiding this comment.
Is this updating the db status?
There was a problem hiding this comment.
No, it's not updating the database. The ResolveDeploy call only completes the in-memory deployment handle
e09f8a0 to
c50e224
Compare
BREAKING CHANGE: the deployments dir is now hardcode to /deployments
66399ab to
4c994d3
Compare
Type of change
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.