mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-14 05:39:08 +02:00
* feat(squad): accept avatar_url on CreateSquad Threads avatar_url through the SQL query, sqlc-generated code, and the Go handler so the create-squad flow can persist an avatar at creation time instead of forcing a follow-up PATCH. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai> * feat(squad): add avatar_url to CreateSquadRequest Extends the TS contract for the new backend field so the frontend can pass an uploaded avatar URL through api.createSquad. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai> * feat(squads): rework Create Squad modal to match CreateAgentDialog (MUL-2233) Replaces the cramped small-dialog flow with the same large-dialog shape used by Create Agent: identity row (AvatarPicker + name + description with char counter), grouped Leader picker (My Agents first, then Workspace Agents), and a new multi-select Additional Members picker covering agents and workspace members. The members trigger collapses to "+N" once more than three are selected; promoting an agent to leader auto-drops it from the additional-members list. After createSquad, additional members are attached via Promise.allSettled so a single failure surfaces a warning toast without blocking navigation — the squad still exists and the user can retry from the Members tab. Adds packages/views/modals/create-squad.test.tsx covering identity binding, leader-group ordering, leader/member conflict sanitization, the empty- and partial-failure success paths, and the create-failure recovery path. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai> * fix(squads): valid trigger HTML + drop conflicted leader from members Two issues from PR #2645 review: 1. AdditionalMembersPicker's PopoverTrigger was a <button> containing MemberChip's remove <button>, which React/HTML flags as nested interactive content (hydration + a11y warning). Render the trigger as a <div role="combobox"> via Base UI's render prop so the chip's remove button is valid. 2. sanitizedMembers only hid the leader from rendered/submitted output, so promoting an additional member to leader then switching leader away resurrected the hidden pick. Drop it from selectedMembers at the moment of promotion via handleLeaderChange; sanitizedMembers is no longer needed. Adds a test that promotes → switches leader and asserts the member is not resubmitted. Co-authored-by: multica-agent <github@multica.ai> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
75 lines
2.4 KiB
SQL
75 lines
2.4 KiB
SQL
-- name: CreateSquad :one
|
|
INSERT INTO squad (workspace_id, name, description, leader_id, creator_id, avatar_url)
|
|
VALUES ($1, $2, $3, $4, $5, $6)
|
|
RETURNING *;
|
|
|
|
-- name: GetSquad :one
|
|
SELECT * FROM squad WHERE id = $1;
|
|
|
|
-- name: GetSquadInWorkspace :one
|
|
SELECT * FROM squad WHERE id = $1 AND workspace_id = $2;
|
|
|
|
-- name: ListSquads :many
|
|
SELECT * FROM squad WHERE workspace_id = $1 AND archived_at IS NULL ORDER BY created_at ASC;
|
|
|
|
-- name: ListAllSquads :many
|
|
SELECT * FROM squad WHERE workspace_id = $1 ORDER BY created_at ASC;
|
|
|
|
-- name: UpdateSquad :one
|
|
UPDATE squad SET
|
|
name = COALESCE(sqlc.narg('name'), name),
|
|
description = COALESCE(sqlc.narg('description'), description),
|
|
leader_id = COALESCE(sqlc.narg('leader_id'), leader_id),
|
|
avatar_url = COALESCE(sqlc.narg('avatar_url'), avatar_url),
|
|
instructions = COALESCE(sqlc.narg('instructions'), instructions),
|
|
updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING *;
|
|
|
|
-- name: ArchiveSquad :one
|
|
UPDATE squad SET archived_at = now(), archived_by = $2, updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING *;
|
|
|
|
-- name: AddSquadMember :one
|
|
INSERT INTO squad_member (squad_id, member_type, member_id, role)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING *;
|
|
|
|
-- name: RemoveSquadMember :execrows
|
|
DELETE FROM squad_member
|
|
WHERE squad_id = $1 AND member_type = $2 AND member_id = $3;
|
|
|
|
-- name: ListSquadMembers :many
|
|
SELECT * FROM squad_member WHERE squad_id = $1 ORDER BY created_at ASC;
|
|
|
|
-- name: UpdateSquadMemberRole :one
|
|
UPDATE squad_member SET role = $4
|
|
WHERE squad_id = $1 AND member_type = $2 AND member_id = $3
|
|
RETURNING *;
|
|
|
|
-- name: IsSquadMember :one
|
|
SELECT EXISTS(
|
|
SELECT 1 FROM squad_member
|
|
WHERE squad_id = $1 AND member_type = $2 AND member_id = $3
|
|
) AS is_member;
|
|
|
|
-- name: CountSquadMembers :one
|
|
SELECT count(*) FROM squad_member WHERE squad_id = $1;
|
|
|
|
-- name: GetSquadByAssignee :one
|
|
-- Look up the squad when an issue is assigned to a squad.
|
|
SELECT s.* FROM squad s WHERE s.id = $1 AND s.workspace_id = $2;
|
|
|
|
-- name: ListSquadsByMember :many
|
|
-- Find all squads a given entity belongs to in a workspace.
|
|
SELECT s.* FROM squad s
|
|
JOIN squad_member sm ON sm.squad_id = s.id
|
|
WHERE s.workspace_id = $1 AND sm.member_type = $2 AND sm.member_id = $3
|
|
ORDER BY s.created_at ASC;
|
|
|
|
-- name: TransferSquadAssignees :exec
|
|
-- Transfer all issues assigned to a squad to the squad's leader agent.
|
|
UPDATE issue SET assignee_type = 'agent', assignee_id = $2, updated_at = now()
|
|
WHERE assignee_type = 'squad' AND assignee_id = $1;
|