Start a workflow from the iPhone Action button

This commit is contained in:
Ian Gulliver
2026-10-22 17:02:49 -07:00
parent f8fde62aab
commit 9df0c800dc
13 changed files with 724 additions and 370 deletions
+31
View File
@@ -41,6 +41,37 @@ func (s *Server) UpdateDefaultModel(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, u)
}
func (s *Server) UpdateQuickRun(w http.ResponseWriter, r *http.Request) {
req := api.QuickRun{}
if !readJSON(w, r, &req) {
return
}
if (req.ProjectId == "") != (req.Workflow == "") {
writeError(w, http.StatusBadRequest, errors.New("project_id and workflow are set together"))
return
}
if req.ProjectId != "" {
_, err := s.store.GetProject(r.Context(), req.ProjectId)
if err != nil {
writeStoreError(w, err)
return
}
_, err = s.store.GetWorkflow(r.Context(), req.Workflow)
if err != nil {
writeStoreError(w, err)
return
}
}
u, err := s.store.UpdateQuickRun(r.Context(), actor(r), req)
if err != nil {
writeStoreError(w, err)
return
}
writeJSON(w, http.StatusOK, u)
}
func (s *Server) UpdateAway(w http.ResponseWriter, r *http.Request) {
req := api.Away{}
if !readJSON(w, r, &req) {
+8 -5
View File
@@ -378,20 +378,23 @@ func (s *Server) CreateTask(w http.ResponseWriter, r *http.Request, projectID st
}
if req.Workflow != nil {
if req.Prompt != nil || req.Images != nil {
writeError(w, http.StatusBadRequest, errors.New("prompt and images can't be given with workflow"))
if req.Images != nil {
writeError(w, http.StatusBadRequest, errors.New("images can't be given with workflow"))
return
}
if title == "" {
writeError(w, http.StatusBadRequest, errors.New("title is required with workflow"))
return
title = *req.Workflow
}
brief := title
if req.Prompt != nil && strings.TrimSpace(*req.Prompt) != "" {
brief = *req.Prompt
}
u, err := s.store.GetUser(r.Context(), actor(r))
if err != nil {
writeStoreError(w, err)
return
}
tasks, err := s.agents.StartWorkflow(r.Context(), p, u, title, p.DefaultBranch, u.Login, *req.Workflow, title, nil, "")
tasks, err := s.agents.StartWorkflow(r.Context(), p, u, title, p.DefaultBranch, u.Login, *req.Workflow, brief, nil, "")
if err != nil {
writeAgentError(w, err)
return