@@ -740,9 +740,10 @@ func (c *controllerV1) handleGetWorkspaceAgent(w http.ResponseWriter, r *http.Re
740// @Accept json
740// @Accept json
741// @Param id path string true "Workspace ID"
741// @Param id path string true "Workspace ID"
742// @Param request body proto.AgentMessage true "Agent message"
742// @Param request body proto.AgentMessage true "Agent message"
743−// @Success 200
743+// @Success 202
744// @Failure 400 {object} proto.Error
744// @Failure 400 {object} proto.Error
745// @Failure 404 {object} proto.Error
745// @Failure 404 {object} proto.Error
746+// @Failure 409 {object} proto.Error
746// @Failure 500 {object} proto.Error
747// @Failure 500 {object} proto.Error
747// @Router /workspaces/{id}/agent [post]
748// @Router /workspaces/{id}/agent [post]
748func (c *controllerV1) handlePostWorkspaceAgent(w http.ResponseWriter, r *http.Request) {
749func (c *controllerV1) handlePostWorkspaceAgent(w http.ResponseWriter, r *http.Request) {
@@ -767,7 +768,7 @@ func (c *controllerV1) handlePostWorkspaceAgent(w http.ResponseWriter, r *http.R
767 c.handleError(w, r, err)
768 c.handleError(w, r, err)
770− w.WriteHeader(http.StatusOK)
771+ w.WriteHeader(http.StatusAccepted)
773// handlePostWorkspaceAgentInit initializes the agent for a workspace.
774// handlePostWorkspaceAgentInit initializes the agent for a workspace.
@@ -1061,6 +1062,8 @@ func (c *controllerV1) handleError(w http.ResponseWriter, r *http.Request, err e
1061 status = http.StatusBadRequest
1062 status = http.StatusBadRequest
1062 case errors.Is(err, backend.ErrClientNotAttached):
1063 case errors.Is(err, backend.ErrClientNotAttached):
1063 status = http.StatusNotFound
1064 status = http.StatusNotFound
1065+ case errors.Is(err, backend.ErrWorkspaceClosing):
1066+ status = http.StatusConflict
1065 c.server.logError(r, err.Error())
1068 c.server.logError(r, err.Error())
1066 jsonError(w, status, err.Error())
1069 jsonError(w, status, err.Error())