Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(autopilots): let a prompt be cleared (#11485)
pseudoyuef59a939d632
diff --git a/server/internal/handler/autopilot_description_test.go b/server/internal/handler/autopilot_description_test.gonew file mode 100644index 0000000000..84e5551220--- /dev/null+++ b/server/internal/handler/autopilot_description_test.go@@ -0,0 +1,33 @@+package handler++import (+ "net/http"+ "testing"++ "github.com/multica-ai/multica/server/internal/testutil"+)++// The edit dialog clears a prompt by sending an explicit null; leaving the+// field out of the PATCH must keep it.+func TestUpdateAutopilot_NullDescriptionClearsPrompt(t *testing.T) {+ agentID := createWebhookTestAgent(t, "ClearPrompt Agent")+ apID := createWebhookTestAutopilot(t, agentID, "active", "run_only")++ patch := func(body map[string]any) *string {+ t.Helper()+ req := newRequest("PATCH", "/api/autopilots/"+apID+"?workspace_id="+testWorkspaceID, body)+ var resp AutopilotResponse+ testutil.Call(t, testHandler.UpdateAutopilot, withURLParam(req, "id", apID)).Want(http.StatusOK).JSON(&resp)+ return resp.Description+ }++ if got := patch(map[string]any{"description": "Old prompt"}); got == nil || *got != "Old prompt" {+ t.Fatalf("set description = %v, want Old prompt", got)+ }+ if got := patch(map[string]any{"title": "Renamed"}); got == nil || *got != "Old prompt" {+ t.Fatalf("description after a title-only PATCH = %v, want Old prompt", got)+ }+ if got := patch(map[string]any{"description": nil}); got != nil {+ t.Fatalf("description after a null PATCH = %q, want nil", *got)+ }+}diff --git a/server/pkg/db/generated/autopilot.sql.go b/server/pkg/db/generated/autopilot.sql.goindex 33c06b9eae..28716dd10f 100644--- a/server/pkg/db/generated/autopilot.sql.go+++ b/server/pkg/db/generated/autopilot.sql.go@@ -2377,7 +2377,7 @@ func (q *Queries) TouchAutopilotTriggerFiredAt(ctx context.Context, id pgtype.UUconst updateAutopilot = `-- name: UpdateAutopilot :oneUPDATE autopilot SETtitle = COALESCE($2, title),- description = COALESCE($3, description),+ description = $3,assignee_type = COALESCE($4, assignee_type),assignee_id = COALESCE($5::uuid, assignee_id),status = COALESCE($6, status),diff --git a/server/pkg/db/queries/autopilot.sql b/server/pkg/db/queries/autopilot.sqlindex 986b019ee9..3503df4272 100644--- a/server/pkg/db/queries/autopilot.sql+++ b/server/pkg/db/queries/autopilot.sql@@ -66,7 +66,7 @@ INSERT INTO autopilot (-- name: UpdateAutopilot :oneUPDATE autopilot SETtitle = COALESCE(sqlc.narg('title'), title),- description = COALESCE(sqlc.narg('description'), description),+ description = sqlc.narg('description'),assignee_type = COALESCE(sqlc.narg('assignee_type'), assignee_type),assignee_id = COALESCE(sqlc.narg('assignee_id')::uuid, assignee_id),status = COALESCE(sqlc.narg('status'), status),