Files
multica/server/internal/handler/task_cancellation_actor.go
5132ac99eb MUL-7235: show cancellation actor in run history (#8249)
* MUL-7235: show cancellation actor in run history

Co-authored-by: multica-agent <[email protected]>

* fix(issues): simplify failed run recovery UI

Co-authored-by: multica-agent <[email protected]>

* Revert "fix(issues): simplify failed run recovery UI"

This reverts commit 1b337bbe46.

Co-authored-by: multica-agent <[email protected]>

* fix(tasks): keep cancellation attribution consistent

Co-authored-by: multica-agent <[email protected]>

---------

Co-authored-by: Lambda <[email protected]>
Co-authored-by: multica-agent <[email protected]>
2026-09-10 21:24:35 +08:00

36 lines
909 B
Go

package handler
import (
"context"
"github.com/multica-ai/multica/server/internal/service"
"github.com/multica-ai/multica/server/internal/util"
)
// taskCancellationActor snapshots the authenticated actor's display name for
// run history. Identity resolution is best-effort display metadata: the actor
// type and id still persist if the name lookup loses a concurrent race.
func (h *Handler) taskCancellationActor(
ctx context.Context,
actorType string,
actorID string,
) service.TaskCancellationActor {
actor := service.TaskCancellationActor{Type: actorType}
id, err := util.ParseUUID(actorID)
if err != nil {
return actor
}
actor.ID = id
switch actorType {
case "member":
if user, err := h.Queries.GetUser(ctx, id); err == nil {
actor.Name = user.Name
}
case "agent":
if agent, err := h.Queries.GetAgent(ctx, id); err == nil {
actor.Name = agent.Name
}
}
return actor
}