Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat: allow quick actions without a target (MUL-7990) (#9210)

Timde198cd4c1f6
diff --git a/packages/core/types/quick-action.ts b/packages/core/types/quick-action.ts
index 49ca284629..89c109498c 100644
--- a/packages/core/types/quick-action.ts
+++ b/packages/core/types/quick-action.ts
@@ -3,7 +3,7 @@
* and what to say" on an existing issue.
*
* Running one is not a separate dispatch path: the server renders the prompt,
- * posts a `quick_action` comment carrying the target's mention markup, and the
+ * posts a comment with quick-action attribution and optional target mention markup, and the
* normal comment -> mention -> task trigger takes over. That is why the run
* response is a `Comment` with `trigger_outcomes` rather than a bespoke shape.
*/
@@ -11,8 +11,8 @@
/**
* The author's stated intent, chosen at creation.
*
- * - `public` — meant for the team. The server requires a target every member
- * can invoke, so it is runnable by everyone by construction.
+ * - `public` — meant for the team. If a target is set, every member must
+ * be able to invoke it.
* - `private` — meant for its creator only; any target is allowed, and the
* list endpoint returns it to nobody else.
*
@@ -21,7 +21,8 @@
*/
export type QuickActionVisibility = "private" | "public";
-export type QuickActionAssigneeType = "agent" | "squad";
+/** Empty means post the prompt without mentioning a target. */
+export type QuickActionAssigneeType = "agent" | "squad" | "";
export type QuickActionStatus = "active" | "archived";
@@ -56,8 +57,8 @@ export interface QuickAction {
export interface CreateQuickActionRequest {
name: string;
description?: string;
- assignee_type: QuickActionAssigneeType;
- assignee_id: string;
+ assignee_type?: QuickActionAssigneeType;
+ assignee_id?: string;
prompt: string;
visibility?: QuickActionVisibility;
}
diff --git a/packages/views/issues/components/quick-actions-section.tsx b/packages/views/issues/components/quick-actions-section.tsx
index 0af27340be..f3d64a60ea 100644
--- a/packages/views/issues/components/quick-actions-section.tsx
+++ b/packages/views/issues/components/quick-actions-section.tsx
@@ -230,9 +230,11 @@ function QuickActionRow({
<div className="space-y-0.5">
<div className="font-medium">{action.name}</div>
{action.description ? <div>{action.description}</div> : null}
- <div className="text-muted-foreground">
- {t(($) => $.detail.quick_action_runs_as, { name: targetName })}
- </div>
+ {action.assignee_type !== "" ? (
+ <div className="text-muted-foreground">
+ {t(($) => $.detail.quick_action_runs_as, { name: targetName })}
+ </div>
+ ) : null}
</div>
</TooltipContent>
</Tooltip>
diff --git a/packages/views/locales/en/settings.json b/packages/views/locales/en/settings.json
index d1ae1f277d..5306fa30c4 100644
--- a/packages/views/locales/en/settings.json
+++ b/packages/views/locales/en/settings.json
@@ -143,6 +143,8 @@
"field_name": "Name",
"field_name_placeholder": "Code Review",
"field_target": "Runs as",
+ "no_target": "No target",
+ "no_target_hint": "Posts a message without mentioning anyone.",
"field_prompt": "Prompt",
"field_prompt_placeholder": "Review the code linked to this issue. Focus on correctness and edge cases.",
"prompt_hint": "Sent as written. The agent already sees the issue.",
diff --git a/packages/views/locales/fr/settings.json b/packages/views/locales/fr/settings.json
index a2d02db685..0f2106dbc3 100644
--- a/packages/views/locales/fr/settings.json
+++ b/packages/views/locales/fr/settings.json
@@ -143,6 +143,8 @@
"field_name": "Nom",
"field_name_placeholder": "Relecture de code",
"field_target": "S'exécute en tant que",
+ "no_target": "Aucune cible",
+ "no_target_hint": "Publie un message sans mentionner personne.",
"field_prompt": "Invite",
"field_prompt_placeholder": "Relire le code lié à cette tâche. Se concentrer sur la justesse et les cas limites.",
"prompt_hint": "Envoyée telle quelle. L'agent voit déjà la tâche.",
diff --git a/packages/views/locales/ja/settings.json b/packages/views/locales/ja/settings.json
index 6c640daa62..0541294745 100644
--- a/packages/views/locales/ja/settings.json
+++ b/packages/views/locales/ja/settings.json
@@ -141,6 +141,8 @@
"field_name": "名前",
"field_name_placeholder": "コードレビュー",
"field_target": "実行者",
+ "no_target": "対象なし",
+ "no_target_hint": "誰もメンションせずにメッセージを投稿します。",
"field_prompt": "プロンプト",
"field_prompt_placeholder": "このタスクに関連するコードをレビューし、正確性とエッジケースを重点的に確認してください。",
"prompt_hint": "そのまま送られます。タスクの内容は既に読めます。",
diff --git a/packages/views/locales/ko/settings.json b/packages/views/locales/ko/settings.json
index 35b7f3b443..d60336406a 100644
--- a/packages/views/locales/ko/settings.json
+++ b/packages/views/locales/ko/settings.json
@@ -141,6 +141,8 @@
"field_name": "이름",
"field_name_placeholder": "코드 리뷰",
"field_target": "실행자",
+ "no_target": "대상 없음",
+ "no_target_hint": "아무도 멘션하지 않고 메시지를 게시합니다.",
"field_prompt": "프롬프트",
"field_prompt_placeholder": "이 태스크에 연결된 코드를 검토하고 정확성과 예외 상황을 중점적으로 확인하세요.",
"prompt_hint": "작성한 그대로 전달됩니다. 에이전트는 태스크를 이미 읽을 수 있습니다.",
diff --git a/packages/views/locales/zh-Hans/settings.json b/packages/views/locales/zh-Hans/settings.json
index ec7ffbd2e7..a3624d4ed0 100644
--- a/packages/views/locales/zh-Hans/settings.json
+++ b/packages/views/locales/zh-Hans/settings.json
@@ -141,6 +141,8 @@
"field_name": "名称",
"field_name_placeholder": "代码审查",
"field_target": "执行者",
+ "no_target": "无目标",
+ "no_target_hint": "发布消息,不提及任何人。",
"field_prompt": "提示词",
"field_prompt_placeholder": "请审查这个任务关联的代码,重点关注正确性和边界情况。",
"prompt_hint": "原样发送。智能体本来就能看到这个任务。",
diff --git a/packages/views/settings/components/quick-actions-tab.tsx b/packages/views/settings/components/quick-actions-tab.tsx
index 9977a19303..f794c9511e 100644
--- a/packages/views/settings/components/quick-actions-tab.tsx
+++ b/packages/views/settings/components/quick-actions-tab.tsx
@@ -138,6 +138,9 @@ function VisibilityBadge({ action, t }: { action: QuickAction; t: QuickActionsT
* failure is loud at click time, not silent).
*/
function TargetLine({ action, t }: { action: QuickAction; t: QuickActionsT }) {
+ if (action.assignee_type === "") {
+ return <span>{t(($) => $.quick_actions.no_target)}</span>;
+ }
if (action.target_missing === true) {
return (
<span className="inline-flex items-center gap-1 text-destructive">
@@ -159,7 +162,7 @@ function TargetLine({ action, t }: { action: QuickAction; t: QuickActionsT }) {
interface FormState {
name: string;
description: string;
- assigneeType: QuickActionAssigneeType;
+ assigneeType: Exclude<QuickActionAssigneeType, "">;
assigneeId: string;
prompt: string;
visibility: QuickActionVisibility;
@@ -397,7 +400,7 @@ export function QuickActionsTab() {
id: editing.id,
name: form.name,
description: form.description,
- assignee_type: form.assigneeType,
+ assignee_type: form.assigneeId ? form.assigneeType : "",
assignee_id: form.assigneeId,
prompt: form.prompt,
visibility: form.visibility,
@@ -406,7 +409,7 @@ export function QuickActionsTab() {
await createMutation.mutateAsync({
name: form.name,
description: form.description,
- assignee_type: form.assigneeType,
+ assignee_type: form.assigneeId ? form.assigneeType : "",
assignee_id: form.assigneeId,
prompt: form.prompt,
visibility: form.visibility,
@@ -463,7 +466,6 @@ function QuickActionDialog({
const canSave =
form.name.trim().length > 0 &&
form.prompt.trim().length > 0 &&
- form.assigneeId.length > 0 &&
templateToken === null;
const handleSubmit = async () => {
@@ -547,16 +549,30 @@ function QuickActionDialog({
<div className="space-y-1.5">
<FieldLabel>{t(($) => $.quick_actions.field_target)}</FieldLabel>
- <AgentPicker
- assignee={form.assigneeId ? { type: form.assigneeType, id: form.assigneeId } : null}
- onChange={(next) =>
- setForm((f) => ({ ...f, assigneeType: next.type, assigneeId: next.id }))
- }
- />
+ <div className="flex flex-wrap items-center gap-2">
+ <Button
+ type="button"
+ variant={form.assigneeId ? "outline" : "secondary"}
+ aria-pressed={!form.assigneeId}
+ onClick={() => setForm((f) => ({ ...f, assigneeId: "" }))}
+ >
+ {t(($) => $.quick_actions.no_target)}
+ </Button>
+ <AgentPicker
+ assignee={form.assigneeId ? { type: form.assigneeType, id: form.assigneeId } : null}
+ onChange={(next) =>
+ setForm((f) => ({ ...f, assigneeType: next.type, assigneeId: next.id }))
+ }
+ />
+ </div>
{/* Public promises "everyone can run this", so the server refuses a
target the team cannot invoke. Saying so here turns a 400 into
an expectation set before the user hits Save. */}
- {form.visibility === "public" ? (
+ {!form.assigneeId ? (
+ <p className="text-caption text-muted-foreground">
+ {t(($) => $.quick_actions.no_target_hint)}
+ </p>
+ ) : form.visibility === "public" ? (
<p className="text-caption text-muted-foreground">
{t(($) => $.quick_actions.public_target_hint)}
</p>
diff --git a/server/internal/handler/quick_action.go b/server/internal/handler/quick_action.go
index 18998e7409..7ba525c6b8 100644
--- a/server/internal/handler/quick_action.go
+++ b/server/internal/handler/quick_action.go
@@ -23,7 +23,7 @@ import (
//
// Contract highlights:
// - Running one is NOT a new dispatch path. It renders the prompt, posts an
-// ordinary comment carrying the target's mention markup (marked with
+// ordinary comment carrying optional target mention markup (marked with
// quick_action_id), and hands off to triggerTasksForComment. Permission, attribution, squad routing,
// the execution log, and pending-task coalescing are inherited from the
// comment path rather than reimplemented — the MUL-3375 lesson about four
@@ -35,7 +35,7 @@ import (
// with no explanation, which is harder to debug than a button that says
// why it refused.
// - `visibility` is the author's stated intent, not an authorization
-// decision. A `public` action must bind a target every member can invoke,
+// decision. A `public` action may only bind a target every member can invoke,
// so it is runnable by construction; the run-time gate still has the final
// say, so a target that goes private later fails loudly at click time
// rather than silently granting anything.
@@ -170,6 +170,9 @@ func validateQuickActionPrompt(raw string) (string, error) {
}
func validateQuickActionAssignee(assigneeType, assigneeID string) error {
+ if assigneeType == "" && assigneeID == "" {
+ return nil
+ }
if assigneeType != "agent" && assigneeType != "squad" {
return fmt.Errorf("assignee_type must be \"agent\" or \"squad\"")
}
@@ -214,6 +217,9 @@ type quickActionTarget struct {
// renders that as an unavailable target rather than failing the whole list.
func (h *Handler) resolveQuickActionTarget(ctx context.Context, qa db.QuickAction) quickActionTarget {
switch qa.AssigneeType {
+ case "":
+ // An intentionally unset target is available, not an orphaned binding.
+ return quickActionTarget{Found: true}
case "squad":
squad, err := h.Queries.GetSquadInWorkspace(ctx, db.GetSquadInWorkspaceParams{
ID: qa.AssigneeID,
@@ -338,6 +344,9 @@ func (h *Handler) loadQuickActionCatalog(ctx context.Context, workspaceID pgtype
// entirely from the pre-loaded maps. The two must agree; the shared shape of
// quickActionTarget is what keeps them honest.
func (c quickActionCatalog) resolve(qa db.QuickAction) (quickActionTarget, bool) {
+ if qa.AssigneeType == "" {
+ return quickActionTarget{Found: true}, true
+ }
if qa.AssigneeType == "squad" {
squad, ok := c.squads[uuidToString(qa.AssigneeID)]
if !ok || squad.ArchivedAt.Valid {
@@ -401,7 +410,7 @@ func (h *Handler) quickActionToResponse(ctx context.Context, qa db.QuickAction)
resp.TargetMissing = !target.Found
if target.Found {
resp.TargetName = target.Name
- resp.TargetPublic = h.agentInvocableByEveryone(ctx, target.Agent)
+ resp.TargetPublic = qa.AssigneeType == "" || h.agentInvocableByEveryone(ctx, target.Agent)
}
return resp
}
@@ -541,9 +550,12 @@ func (h *Handler) CreateQuickAction(w http.ResponseWriter, r *http.Request) {
writeError(w, http.StatusBadRequest, err.Error())
return
}
- assigneeUUID, ok := parseUUIDOrBadRequest(w, req.AssigneeID, "assignee_id")
- if !ok {
- return
+ var assigneeUUID pgtype.UUID
+ if req.AssigneeType != "" {
+ assigneeUUID, ok = parseUUIDOrBadRequest(w, req.AssigneeID, "assignee_id")
+ if !ok {
+ return
+ }
}
prompt, err := validateQuickActionPrompt(req.Prompt)
if err != nil {
@@ -660,9 +672,12 @@ func (h *Handler) UpdateQuickAction(w http.ResponseWriter, r *http.Request) {
writeError(w, http.StatusBadRequest, err.Error())
return
}
- newUUID, ok := parseUUIDOrBadRequest(w, newID, "assignee_id")
- if !ok {
- return
+ var newUUID pgtype.UUID
+ if newType != "" {
+ newUUID, ok = parseUUIDOrBadRequest(w, newID, "assignee_id")
+ if !ok {
+ return
+ }
}
if req.AssigneeType != nil || req.AssigneeID != nil {
params.AssigneeType = pgtype.Text{String: newType, Valid: true}
@@ -755,6 +770,9 @@ func trimmedWithinLimit(w http.ResponseWriter, raw string, limit int, field stri
// and, for a `public` action, that every member can invoke it. Writes the 400
// itself and returns false when the binding is rejected.
func (h *Handler) validateQuickActionBinding(w http.ResponseWriter, r *http.Request, assigneeType string, id, workspaceID pgtype.UUID, visibility string) bool {
+ if assigneeType == "" {
+ return true
+ }
qa := db.QuickAction{AssigneeType: assigneeType, AssigneeID: id, WorkspaceID: workspaceID}
target := h.resolveQuickActionTarget(r.Context(), qa)
if !target.Found {
@@ -805,7 +823,7 @@ func (h *Handler) RenderQuickAction(w http.ResponseWriter, r *http.Request) {
actorType, actorID := h.resolveActor(r, userID, workspaceID)
// Same gate as the run path: the preview would otherwise hand a user the
// exact text needed to trigger an agent they may not invoke.
- if !h.canInvokeAgent(r.Context(), target.Agent, actorType, actorID, h.invokeOriginatorFromRequest(r, actorType, actorID), workspaceID) {
+ if qa.AssigneeType != "" && !h.canInvokeAgent(r.Context(), target.Agent, actorType, actorID, h.invokeOriginatorFromRequest(r, actorType, actorID), workspaceID) {
h.writeDispatchBlocked(w, http.StatusForbidden, ReasonInvocationNotAllowed)
return
}
@@ -821,6 +839,9 @@ func (h *Handler) RenderQuickAction(w http.ResponseWriter, r *http.Request) {
// downstream. The prompt itself is passed through untouched — see the file
// header for why there is no interpolation step.
func buildQuickActionBody(qa db.QuickAction, target quickActionTarget) string {
+ if qa.AssigneeType == "" {
+ return qa.Prompt
+ }
return fmt.Sprintf("[@%s](mention://%s/%s)\n\n%s", target.Name, target.MentionType, target.MentionID, qa.Prompt)
}
@@ -864,10 +885,10 @@ func (h *Handler) RunQuickAction(w http.ResponseWriter, r *http.Request) {
// the action, not an invitation to talk, and Triage is where nobody has
// agreed the work should be done yet. Opening it later is deleting this if.
//
- // Before the comment is written, not after: a quick action is a comment AND
- // a run, and posting the prompt to an entry that will never run it leaves an
- // instruction addressed to nobody (MUL-7189 §2.3).
- if issue.TriageState.Valid {
+ // Before the comment is written, not after: a targeted action is a comment
+ // AND a run (MUL-7189 §2.3). Targetless actions are ordinary messages, so
+ // they can be posted in triage without dispatching work.
+ if qa.AssigneeType != "" && issue.TriageState.Valid {
h.writeDispatchBlocked(w, http.StatusForbidden, ReasonIssueInTriage)
return
}
@@ -882,7 +903,7 @@ func (h *Handler) RunQuickAction(w http.ResponseWriter, r *http.Request) {
originatorUserID := h.invokeOriginatorFromRequest(r, actorType, actorID)
// The single permission gate. Issue visibility never implies the right to
// trigger someone's private agent.
- if !h.canInvokeAgent(r.Context(), target.Agent, actorType, actorID, originatorUserID, workspaceID) {
+ if qa.AssigneeType != "" && !h.canInvokeAgent(r.Context(), target.Agent, actorType, actorID, originatorUserID, workspaceID) {
h.writeDispatchBlocked(w, http.StatusForbidden, ReasonInvocationNotAllowed)
return
}
diff --git a/server/internal/handler/quick_action_test.go b/server/internal/handler/quick_action_test.go
index 99a7601b68..4ff656aa35 100644
--- a/server/internal/handler/quick_action_test.go
+++ b/server/internal/handler/quick_action_test.go
@@ -1,8 +1,11 @@
package handler
import (
+ "net/http"
"strings"
"testing"
+
+ "github.com/multica-ai/multica/server/internal/testutil"
)
// TestValidateQuickActionPromptRejectsTemplateTokens locks the guard that
@@ -153,3 +156,81 @@ func TestValidateQuickActionPromptRejectsSideEffectMentions(t *testing.T) {
})
}
}
+
+func TestQuickActionClearsExistingAgentTarget(t *testing.T) {
+ const prompt = "Please check the latest changes when you pick this up."
+ agentID := dbfx.Agent(t, "Quick action target", testRuntimeID)
+ var action QuickActionResponse
+ testutil.Call(t, testHandler.CreateQuickAction, newRequest(http.MethodPost, "/api/quick-actions", map[string]any{
+ "name": "Check changes", "prompt": prompt, "visibility": "private",
+ "assignee_type": "agent", "assignee_id": agentID,
+ })).Want(http.StatusCreated).JSON(&action)
+ dbfx.Cleanup(t, `DELETE FROM quick_action WHERE id = $1`, action.ID)
+ if action.AssigneeType != "agent" || action.AssigneeID != agentID {
+ t.Fatalf("expected an existing agent target, got %+v", action)
+ }
+
+ var updated QuickActionResponse
+ testutil.Call(t, testHandler.UpdateQuickAction, testutil.WithURLParams(
+ newRequest(http.MethodPatch, "/api/quick-actions/"+action.ID, map[string]any{
+ "assignee_type": "", "assignee_id": "",
+ }), "id", action.ID,
+ )).Want(http.StatusOK).JSON(&updated)
+ if updated.AssigneeType != "" || updated.AssigneeID != "" {
+ t.Fatalf("clearing the target must empty both fields, got type %q and id %q", updated.AssigneeType, updated.AssigneeID)
+ }
+
+ issueID := dbfx.Issue(t, "Quick action cleared target", nil)
+ var preview struct {
+ Content string `json:"content"`
+ }
+ path := "/api/issues/" + issueID + "/quick-actions/" + action.ID + "/render"
+ testutil.Call(t, testHandler.RenderQuickAction, testutil.WithURLParams(
+ newRequest(http.MethodPost, path, nil), "id", issueID, "quickActionId", action.ID,
+ )).Want(http.StatusOK).JSON(&preview)
+ if preview.Content != prompt {
+ t.Fatalf("preview after clearing target = %q, want the prompt without mention markup %q", preview.Content, prompt)
+ }
+}
+
+func TestQuickActionWithoutAgentPostsPromptWithoutMentions(t *testing.T) {
+ const prompt = "Please check the latest changes when you pick this up."
+ var action QuickActionResponse
+ testutil.Call(t, testHandler.CreateQuickAction, newRequest(http.MethodPost, "/api/quick-actions", map[string]any{
+ "name": "Check changes", "prompt": prompt, "visibility": "public",
+ })).Want(http.StatusCreated).JSON(&action)
+ dbfx.Cleanup(t, `DELETE FROM quick_action WHERE id = $1`, action.ID)
+
+ // The issue can have an assignee without the action explicitly mentioning it.
+ agentID := dbfx.Agent(t, "Issue assignee", testRuntimeID)
+ issueID := dbfx.Issue(t, "Quick action message", testutil.Cols{
+ "assignee_type": "agent", "assignee_id": agentID,
+ })
+ dbfx.Cleanup(t, `DELETE FROM comment WHERE issue_id = $1`, issueID)
+ dbfx.Cleanup(t, `DELETE FROM agent_task_queue WHERE issue_id = $1`, issueID)
+ path := "/api/issues/" + issueID + "/quick-actions/" + action.ID
+ request := func(suffix string) *http.Request {
+ return testutil.WithURLParams(newRequest(http.MethodPost, path+suffix, nil),
+ "id", issueID, "quickActionId", action.ID)
+ }
+
+ var preview struct {
+ Content string `json:"content"`
+ }
+ testutil.Call(t, testHandler.RenderQuickAction, request("/render")).Want(http.StatusOK).JSON(&preview)
+ if preview.Content != prompt {
+ t.Fatalf("preview = %q, want the prompt without mention markup %q", preview.Content, prompt)
+ }
+
+ var comment CommentResponse
+ testutil.Call(t, testHandler.RunQuickAction, request("/run")).Want(http.StatusCreated).JSON(&comment)
+ if comment.ID == "" || comment.IssueID != issueID || comment.Content != prompt {
+ t.Fatalf("expected an issue comment containing only the prompt, got %+v", comment)
+ }
+ if comment.QuickActionID == nil || *comment.QuickActionID != action.ID {
+ t.Fatalf("comment must retain its quick action attribution, got %+v", comment.QuickActionID)
+ }
+ if len(comment.TriggerOutcomes) != 0 {
+ t.Fatalf("a mention-free action must not explicitly trigger a target, got %+v", comment.TriggerOutcomes)
+ }
+}
diff --git a/server/migrations/584_quick_action_optional_target.down.sql b/server/migrations/584_quick_action_optional_target.down.sql
new file mode 100644
index 0000000000..fa63d93bb8
--- /dev/null
+++ b/server/migrations/584_quick_action_optional_target.down.sql
@@ -0,0 +1,7 @@
+-- Targetless actions cannot be represented by the previous schema.
+DELETE FROM quick_action WHERE assignee_type = '';
+ALTER TABLE quick_action
+ DROP CONSTRAINT IF EXISTS quick_action_assignee_type_check,
+ ALTER COLUMN assignee_id SET NOT NULL,
+ ADD CONSTRAINT quick_action_assignee_type_check
+ CHECK (assignee_type IN ('agent', 'squad'));
diff --git a/server/migrations/584_quick_action_optional_target.up.sql b/server/migrations/584_quick_action_optional_target.up.sql
new file mode 100644
index 0000000000..5b3d30752b
--- /dev/null
+++ b/server/migrations/584_quick_action_optional_target.up.sql
@@ -0,0 +1,7 @@
+ALTER TABLE quick_action
+ DROP CONSTRAINT IF EXISTS quick_action_assignee_type_check,
+ ALTER COLUMN assignee_id DROP NOT NULL,
+ ADD CONSTRAINT quick_action_assignee_type_check CHECK (
+ (assignee_type = '' AND assignee_id IS NULL) OR
+ (assignee_type IN ('agent', 'squad') AND assignee_id IS NOT NULL)
+ );
diff --git a/server/pkg/db/generated/quick_action.sql.go b/server/pkg/db/generated/quick_action.sql.go
index e86310b784..6a8ce08fa2 100644
--- a/server/pkg/db/generated/quick_action.sql.go
+++ b/server/pkg/db/generated/quick_action.sql.go
@@ -237,7 +237,8 @@ UPDATE quick_action SET
name = COALESCE($3, name),
description = COALESCE($4, description),
assignee_type = COALESCE($5, assignee_type),
- assignee_id = COALESCE($6, assignee_id),
+ assignee_id = CASE WHEN $5::text IS NOT NULL
+ THEN $6::uuid ELSE assignee_id END,
prompt = COALESCE($7, prompt),
visibility = COALESCE($8, visibility),
status = COALESCE($9, status),
@@ -259,8 +260,8 @@ type UpdateQuickActionParams struct {
}
// COALESCE-on-narg partial update: an omitted field keeps its stored value.
-// assignee_type and assignee_id move together (the handler requires both), so
-// a type swap can never land with a mismatched id.
+// The handler resolves the resulting assignee pair and writes both columns.
+// A supplied type also permits clearing the UUID for a targetless action.
func (q *Queries) UpdateQuickAction(ctx context.Context, arg UpdateQuickActionParams) (QuickAction, error) {
row := q.db.QueryRow(ctx, updateQuickAction,
arg.ID,
diff --git a/server/pkg/db/queries/quick_action.sql b/server/pkg/db/queries/quick_action.sql
index 18abdb93d8..149b4cb765 100644
--- a/server/pkg/db/queries/quick_action.sql
+++ b/server/pkg/db/queries/quick_action.sql
@@ -40,13 +40,14 @@ RETURNING *;
-- name: UpdateQuickAction :one
-- COALESCE-on-narg partial update: an omitted field keeps its stored value.
--- assignee_type and assignee_id move together (the handler requires both), so
--- a type swap can never land with a mismatched id.
+-- The handler resolves the resulting assignee pair and writes both columns.
+-- A supplied type also permits clearing the UUID for a targetless action.
UPDATE quick_action SET
name = COALESCE(sqlc.narg('name'), name),
description = COALESCE(sqlc.narg('description'), description),
assignee_type = COALESCE(sqlc.narg('assignee_type'), assignee_type),
- assignee_id = COALESCE(sqlc.narg('assignee_id'), assignee_id),
+ assignee_id = CASE WHEN sqlc.narg('assignee_type')::text IS NOT NULL
+ THEN sqlc.narg('assignee_id')::uuid ELSE assignee_id END,
prompt = COALESCE(sqlc.narg('prompt'), prompt),
visibility = COALESCE(sqlc.narg('visibility'), visibility),
status = COALESCE(sqlc.narg('status'), status),