Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
refactor(squads): edit name and description in place (MUL-8973) (#10321)
Jiayuan Zhangb6232fb79e97
diff --git a/packages/views/locales/en/squads.json b/packages/views/locales/en/squads.jsonindex b38b2d0154..118a0adb2e 100644--- a/packages/views/locales/en/squads.json+++ b/packages/views/locales/en/squads.json@@ -27,13 +27,7 @@"success": "Squad archived"},"name_editor": {- "title": "Rename squad",- "placeholder": "Squad name",- "required": "Name is required",- "cancel": "Cancel",- "save": "Save",- "saved": "Saved",- "save_failed": "Failed to save"+ "placeholder": "Squad name"},"add_member_dialog": {"title": "Add Member",@@ -53,12 +47,9 @@"empty": "Add role…","placeholder": "Role (e.g. Reviewer)"},- "description_dialog": {- "title": "Edit description",- "placeholder_empty": "Add a description",- "cancel": "Cancel",- "responsibility_placeholder": "What is this squad responsible for?",- "save": "Save"+ "description_editor": {+ "empty": "Add a description",+ "placeholder": "What is this squad responsible for?"},"members_tab": {"section_title": "Members",@@ -112,7 +103,8 @@"leader_updated": "Leader updated","leader_update_failed": "Failed to update leader","archive_failed": "Failed to archive squad",- "instructions_saved": "Instructions saved"+ "instructions_saved": "Instructions saved",+ "update_failed": "Failed to save"},"profile_card": {"unavailable": "Squad unavailable",diff --git a/packages/views/locales/es/squads.json b/packages/views/locales/es/squads.jsonindex c9343c2e98..569c9055ac 100644--- a/packages/views/locales/es/squads.json+++ b/packages/views/locales/es/squads.json@@ -27,13 +27,7 @@"success": "Squad archivado"},"name_editor": {- "title": "Renombrar squad",- "placeholder": "Nombre del squad",- "required": "El nombre es obligatorio",- "cancel": "Cancelar",- "save": "Guardar",- "saved": "Guardado",- "save_failed": "No se ha podido guardar"+ "placeholder": "Nombre del squad"},"add_member_dialog": {"title": "Añadir miembro",@@ -53,12 +47,9 @@"empty": "Añadir rol…","placeholder": "Rol (p. ej., Revisor)"},- "description_dialog": {- "title": "Editar descripción",- "placeholder_empty": "Añadir una descripción",- "cancel": "Cancelar",- "responsibility_placeholder": "¿De qué es responsable este squad?",- "save": "Guardar"+ "description_editor": {+ "empty": "Añadir una descripción",+ "placeholder": "¿De qué es responsable este squad?"},"members_tab": {"section_title": "Miembros",@@ -97,7 +88,8 @@"leader_updated": "Líder actualizado","leader_update_failed": "No se ha podido actualizar el líder","archive_failed": "No se ha podido archivar el squad",- "instructions_saved": "Instrucciones guardadas"+ "instructions_saved": "Instrucciones guardadas",+ "update_failed": "No se ha podido guardar"},"profile_card": {"unavailable": "Squad no disponible",diff --git a/packages/views/locales/fr/squads.json b/packages/views/locales/fr/squads.jsonindex 8e182ab33a..7c40825d92 100644--- a/packages/views/locales/fr/squads.json+++ b/packages/views/locales/fr/squads.json@@ -27,13 +27,7 @@"success": "Squad archivé"},"name_editor": {- "title": "Renommer le squad",- "placeholder": "Nom du squad",- "required": "Le nom est obligatoire",- "cancel": "Annuler",- "save": "Enregistrer",- "saved": "Enregistré",- "save_failed": "Échec de l'enregistrement"+ "placeholder": "Nom du squad"},"add_member_dialog": {"title": "Ajouter un membre",@@ -53,12 +47,9 @@"empty": "Ajouter un rôle…","placeholder": "Rôle (par exemple : Relecteur)"},- "description_dialog": {- "title": "Modifier la description",- "placeholder_empty": "Ajouter une description",- "cancel": "Annuler",- "responsibility_placeholder": "De quoi ce squad est-il responsable ?",- "save": "Enregistrer"+ "description_editor": {+ "empty": "Ajouter une description",+ "placeholder": "De quoi ce squad est-il responsable ?"},"members_tab": {"section_title": "Membres",@@ -112,7 +103,8 @@"leader_updated": "Responsable mis à jour","leader_update_failed": "Échec de la mise à jour du responsable","archive_failed": "Échec de l'archivage du squad",- "instructions_saved": "Instructions enregistrées"+ "instructions_saved": "Instructions enregistrées",+ "update_failed": "Échec de l'enregistrement"},"profile_card": {"unavailable": "Squad indisponible",diff --git a/packages/views/locales/ja/squads.json b/packages/views/locales/ja/squads.jsonindex 43ca304c6a..e071d5ecd3 100644--- a/packages/views/locales/ja/squads.json+++ b/packages/views/locales/ja/squads.json@@ -27,13 +27,7 @@"success": "スカッドをアーカイブしました"},"name_editor": {- "title": "スクワッド名を変更",- "placeholder": "スクワッド名",- "required": "名前を入力してください",- "cancel": "キャンセル",- "save": "保存",- "saved": "保存しました",- "save_failed": "保存できませんでした"+ "placeholder": "スクワッド名"},"add_member_dialog": {"title": "メンバーを追加",@@ -53,12 +47,9 @@"empty": "役割を追加…","placeholder": "役割(例:レビュアー)"},- "description_dialog": {- "title": "説明を編集",- "placeholder_empty": "説明を追加",- "cancel": "キャンセル",- "responsibility_placeholder": "このスクワッドの担当は何ですか?",- "save": "保存"+ "description_editor": {+ "empty": "説明を追加",+ "placeholder": "このスクワッドの担当は何ですか?"},"members_tab": {"section_title": "メンバー",@@ -112,7 +103,8 @@"leader_updated": "リーダーを更新しました","leader_update_failed": "リーダーを更新できませんでした","archive_failed": "スクワッドをアーカイブできませんでした",- "instructions_saved": "指示を保存しました"+ "instructions_saved": "指示を保存しました",+ "update_failed": "保存できませんでした"},"profile_card": {"unavailable": "スクワッドを利用できません",diff --git a/packages/views/locales/ko/squads.json b/packages/views/locales/ko/squads.jsonindex 21e34a9009..3b6f94c92d 100644--- a/packages/views/locales/ko/squads.json+++ b/packages/views/locales/ko/squads.json@@ -27,13 +27,7 @@"success": "스쿼드를 보관했습니다"},"name_editor": {- "title": "스쿼드 이름 변경",- "placeholder": "스쿼드 이름",- "required": "이름을 입력하세요",- "cancel": "취소",- "save": "저장",- "saved": "저장했습니다",- "save_failed": "저장하지 못했습니다"+ "placeholder": "스쿼드 이름"},"add_member_dialog": {"title": "멤버 추가",@@ -53,12 +47,9 @@"empty": "역할 추가...","placeholder": "역할(예: 리뷰어)"},- "description_dialog": {- "title": "설명 수정",- "placeholder_empty": "설명 추가",- "cancel": "취소",- "responsibility_placeholder": "이 스쿼드는 무엇을 담당하나요?",- "save": "저장"+ "description_editor": {+ "empty": "설명 추가",+ "placeholder": "이 스쿼드는 무엇을 담당하나요?"},"members_tab": {"section_title": "멤버",@@ -112,7 +103,8 @@"leader_updated": "리더를 업데이트했습니다","leader_update_failed": "리더를 업데이트하지 못했습니다","archive_failed": "스쿼드를 보관하지 못했습니다",- "instructions_saved": "지침을 저장했습니다"+ "instructions_saved": "지침을 저장했습니다",+ "update_failed": "저장하지 못했습니다"},"profile_card": {"unavailable": "스쿼드를 사용할 수 없습니다",diff --git a/packages/views/locales/ru/squads.json b/packages/views/locales/ru/squads.jsonindex 2f5fb3b52c..5760a05767 100644--- a/packages/views/locales/ru/squads.json+++ b/packages/views/locales/ru/squads.json@@ -27,13 +27,7 @@"success": "Команда архивирована"},"name_editor": {- "title": "Переименовать команду",- "placeholder": "Название команды",- "required": "Название обязательно",- "cancel": "Отмена",- "save": "Сохранить",- "saved": "Сохранено",- "save_failed": "Не удалось сохранить"+ "placeholder": "Название команды"},"add_member_dialog": {"title": "Добавить участника",@@ -53,12 +47,9 @@"empty": "Добавить роль…","placeholder": "Роль (например, Ревьюер)"},- "description_dialog": {- "title": "Изменить описание",- "placeholder_empty": "Добавить описание",- "cancel": "Отмена",- "responsibility_placeholder": "За что отвечает эта команда?",- "save": "Сохранить"+ "description_editor": {+ "empty": "Добавить описание",+ "placeholder": "За что отвечает эта команда?"},"members_tab": {"section_title": "Участники",@@ -112,7 +103,8 @@"leader_updated": "Лидер обновлён","leader_update_failed": "Не удалось обновить лидера","archive_failed": "Не удалось архивировать команду",- "instructions_saved": "Инструкции сохранены"+ "instructions_saved": "Инструкции сохранены",+ "update_failed": "Не удалось сохранить"},"profile_card": {"unavailable": "Команда недоступна",diff --git a/packages/views/locales/zh-Hans/squads.json b/packages/views/locales/zh-Hans/squads.jsonindex 8c25fabcb4..8d80619359 100644--- a/packages/views/locales/zh-Hans/squads.json+++ b/packages/views/locales/zh-Hans/squads.json@@ -27,13 +27,7 @@"success": "已归档小队"},"name_editor": {- "title": "重命名小队",- "placeholder": "小队名称",- "required": "名称不能为空",- "cancel": "取消",- "save": "保存",- "saved": "已保存",- "save_failed": "保存失败"+ "placeholder": "小队名称"},"add_member_dialog": {"title": "添加成员",@@ -53,12 +47,9 @@"empty": "添加角色…","placeholder": "角色(例如:审查者)"},- "description_dialog": {- "title": "编辑描述",- "placeholder_empty": "添加描述",- "cancel": "取消",- "responsibility_placeholder": "这个小队负责什么?",- "save": "保存"+ "description_editor": {+ "empty": "添加描述",+ "placeholder": "这个小队负责什么?"},"members_tab": {"section_title": "成员",@@ -112,7 +103,8 @@"leader_updated": "队长已更新","leader_update_failed": "更新队长失败","archive_failed": "归档小队失败",- "instructions_saved": "指引已保存"+ "instructions_saved": "指引已保存",+ "update_failed": "保存失败"},"profile_card": {"unavailable": "小队不可用",diff --git a/packages/views/locales/zh-Hant/squads.json b/packages/views/locales/zh-Hant/squads.jsonindex 0af8deb3c7..f6b4d585da 100644--- a/packages/views/locales/zh-Hant/squads.json+++ b/packages/views/locales/zh-Hant/squads.json@@ -27,13 +27,7 @@"success": "已歸檔小隊"},"name_editor": {- "title": "重新命名小隊",- "placeholder": "小隊名稱",- "required": "名稱不能為空",- "cancel": "取消",- "save": "儲存",- "saved": "已儲存",- "save_failed": "儲存失敗"+ "placeholder": "小隊名稱"},"add_member_dialog": {"title": "新增成員",@@ -53,12 +47,9 @@"empty": "新增角色…","placeholder": "角色(例如:審查者)"},- "description_dialog": {- "title": "編輯描述",- "placeholder_empty": "新增描述",- "cancel": "取消",- "responsibility_placeholder": "這個小隊負責什麼?",- "save": "儲存"+ "description_editor": {+ "empty": "新增描述",+ "placeholder": "這個小隊負責什麼?"},"members_tab": {"section_title": "成員",@@ -112,7 +103,8 @@"leader_updated": "隊長已更新","leader_update_failed": "更新隊長失敗","archive_failed": "歸檔小隊失敗",- "instructions_saved": "指引已儲存"+ "instructions_saved": "指引已儲存",+ "update_failed": "儲存失敗"},"profile_card": {"unavailable": "小隊不可用",diff --git a/packages/views/squads/components/squad-detail-page.test.tsx b/packages/views/squads/components/squad-detail-page.test.tsxindex b4b800150b..815a344f39 100644--- a/packages/views/squads/components/squad-detail-page.test.tsx+++ b/packages/views/squads/components/squad-detail-page.test.tsx@@ -28,7 +28,7 @@ vi.mock("@tanstack/react-query", () => ({refetch: vi.fn(),...mocks.queries[(options.queryKey ?? []).join("/")],}),- useQueryClient: () => ({ invalidateQueries: vi.fn() }),+ useQueryClient: () => ({ invalidateQueries: vi.fn(), setQueryData: vi.fn() }),useMutation: ({ mutationFn }: { mutationFn: (input?: unknown) => Promise<unknown> }) => ({mutate: (input?: unknown) => void mutationFn(input),mutateAsync: (input?: unknown) => mutationFn(input),@@ -81,6 +81,23 @@ vi.mock("../../editor/content-editor", () => ({/>),}));+vi.mock("../../editor/title-editor", () => ({+ TitleEditor: ({+ defaultValue,+ placeholder,+ onBlur,+ }: {+ defaultValue?: string;+ placeholder?: string;+ onBlur?: (value: string) => void;+ }) => (+ <input+ aria-label={placeholder}+ defaultValue={defaultValue}+ onBlur={(event) => onBlur?.(event.target.value)}+ />+ ),+}));vi.mock("@multica/ui/lib/clipboard", () => ({ copyText: mocks.copyText }));vi.mock("sonner", () => ({ toast: { success: vi.fn(), error: vi.fn() } }));@@ -284,6 +301,78 @@ describe("SquadDetailPage", () => {expect(mocks.api.updateSquad).toHaveBeenCalledWith("sq-1", { instructions: "Ship small." });});+ it("renames the squad in place and keeps the name when it is cleared", async () => {+ const user = userEvent.setup();+ renderPage();++ const name = screen.getByRole("textbox", { name: "Squad name" });+ await user.clear(name);+ await user.type(name, " Night Shift ");+ await user.tab();+ expect(mocks.api.updateSquad).toHaveBeenCalledWith("sq-1", { name: "Night Shift" });++ mocks.api.updateSquad.mockClear();+ await user.clear(screen.getByRole("textbox", { name: "Squad name" }));+ await user.tab();+ expect(mocks.api.updateSquad).not.toHaveBeenCalled();+ expect(screen.getByRole("textbox", { name: "Squad name" })).toHaveValue("Strike Team");+ });++ it("discards a name edit on Escape", async () => {+ const user = userEvent.setup();+ renderPage();++ const name = screen.getByRole("textbox", { name: "Squad name" });+ await user.type(name, " typo");+ await user.keyboard("{Escape}");+ await user.tab();+ expect(mocks.api.updateSquad).not.toHaveBeenCalled();+ expect(screen.getByRole("textbox", { name: "Squad name" })).toHaveValue("Strike Team");+ });++ it("edits the description in place: blur saves, Escape discards", async () => {+ const user = userEvent.setup();+ renderPage();++ await user.click(screen.getByRole("button", { name: "Ships the risky stuff" }));+ const field = screen.getByRole("textbox", { name: "What is this squad responsible for?" });+ expect(field).toHaveFocus();+ await user.type(field, " carefully");+ await user.tab();+ expect(mocks.api.updateSquad).toHaveBeenCalledWith("sq-1", {+ description: "Ships the risky stuff carefully",+ });++ mocks.api.updateSquad.mockClear();+ await user.click(screen.getByRole("button", { name: /Ships the risky stuff/ }));+ await user.type(screen.getByRole("textbox", { name: "What is this squad responsible for?" }), " never");+ await user.keyboard("{Escape}");+ expect(mocks.api.updateSquad).not.toHaveBeenCalled();+ expect(screen.queryByRole("textbox", { name: "What is this squad responsible for?" })).toBeNull();+ });++ it("keeps a description draft whose save failed so it can be retried", async () => {+ const user = userEvent.setup();+ mocks.api.updateSquad.mockRejectedValueOnce(new Error("offline"));+ renderPage();++ await user.click(screen.getByRole("button", { name: "Ships the risky stuff" }));+ await user.type(screen.getByRole("textbox", { name: "What is this squad responsible for?" }), " carefully");+ await user.tab();+ expect(mocks.api.updateSquad).toHaveBeenCalledTimes(1);+ expect(await screen.findByRole("button", { name: "Ships the risky stuff" })).toBeInTheDocument();++ await user.click(screen.getByRole("button", { name: "Ships the risky stuff" }));+ expect(screen.getByRole("textbox", { name: "What is this squad responsible for?" })).toHaveValue(+ "Ships the risky stuff carefully",+ );+ await user.tab();+ expect(mocks.api.updateSquad).toHaveBeenCalledTimes(2);+ expect(mocks.api.updateSquad).toHaveBeenLastCalledWith("sq-1", {+ description: "Ships the risky stuff carefully",+ });+ });+it("lists the squad's properties in the panel", () => {renderPage();@@ -301,6 +390,9 @@ describe("SquadDetailPage", () => {renderPage();expect(screen.getByRole("button", { name: "Assign work" })).toBeInTheDocument();+ expect(screen.getByRole("heading", { level: 1, name: "Strike Team" })).toBeInTheDocument();+ expect(screen.queryByRole("textbox", { name: "Squad name" })).toBeNull();+ expect(screen.queryByRole("button", { name: "Ships the risky stuff" })).toBeNull();expect(screen.queryByRole("button", { name: "Add member" })).toBeNull();expect(within(section("Instructions")).queryByRole("button", { name: "Edit" })).toBeNull();expect(screen.queryByTestId("avatar-upload")).toBeNull();diff --git a/packages/views/squads/components/squad-detail-page.tsx b/packages/views/squads/components/squad-detail-page.tsxindex 6f358cd891..7f8e1f612e 100644--- a/packages/views/squads/components/squad-detail-page.tsx+++ b/packages/views/squads/components/squad-detail-page.tsx@@ -1,6 +1,6 @@"use client";-import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";+import { useEffect, useMemo, useRef, useState } from "react";import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";import { api } from "@multica/core/api";import { useAuthStore } from "@multica/core/auth";@@ -47,6 +47,7 @@ import { Button, buttonVariants } from "@multica/ui/components/ui/button";import { IconButton } from "@multica/ui/components/common/icon-button";import { Input } from "@multica/ui/components/ui/input";import { Label } from "@multica/ui/components/ui/label";+import { Textarea } from "@multica/ui/components/ui/textarea";import { Skeleton } from "@multica/ui/components/ui/skeleton";import {DropdownMenu,@@ -86,6 +87,7 @@ import { cn } from "@multica/ui/lib/utils";import { ActorAvatar } from "../../common/actor-avatar";import { AvatarUploadControl } from "../../common/avatar-upload-control";import { ContentEditor } from "../../editor/content-editor";+import { TitleEditor } from "../../editor/title-editor";import { ReadonlyContent } from "../../editor/readonly-content";import { StatusIcon } from "../../issues/components/status-icon";import { useStatusLabel } from "../../issues/utils/status-label";@@ -169,14 +171,23 @@ export function SquadDetailPage() {const [showAddMember, setShowAddMember] = useState(false);const [confirmArchive, setConfirmArchive] = useState(false);+ // TitleEditor takes its text at mount, so remounting is how a rejected or+ // emptied name goes back to the saved one.+ const [nameResetToken, setNameResetToken] = useState(0);+ // TitleEditor blurs on Escape like it does on Enter; this marks that blur as+ // a discard so Escape cancels here the same way it does for the description.+ const discardNameRef = useRef(false);const updateSquadMut = useMutation({mutationFn: (data: { name?: string; description?: string; instructions?: string; avatar_url?: string; leader_id?: string }) => api.updateSquad(squadId, data),- onSuccess: () => {+ onSuccess: (updated) => {+ queryClient.setQueryData([...workspaceKeys.squads(wsId), squadId], updated);refetchSquad();refetchMembers();queryClient.invalidateQueries({ queryKey: workspaceKeys.squads(wsId) });},+ onError: (err) =>+ toast.error(err instanceof Error && err.message ? err.message : t(($) => $.toasts.update_failed)),});const addMemberMut = useMutation({@@ -297,6 +308,19 @@ export function SquadDetailPage() {});};+ const resetName = () => setNameResetToken((n) => n + 1);+ const saveName = (next: string) => {+ const discard = discardNameRef.current;+ discardNameRef.current = false;+ const trimmed = next.trim();+ if (trimmed === squad.name) return;+ if (!trimmed || discard) {+ resetName();+ return;+ }+ updateSquadMut.mutate({ name: trimmed }, { onError: resetName });+ };+return (<ObjectPagelayoutId={layoutId}@@ -380,10 +404,19 @@ export function SquadDetailPage() {}title={canManage ? (- <SquadNameEditor- value={squad.name}- onSave={async (next) => { await updateSquadMut.mutateAsync({ name: next.trim() }); }}- />+ <div+ onKeyDownCapture={(e) => {+ if (e.key === "Escape" && !isImeComposing(e)) discardNameRef.current = true;+ }}+ >+ <TitleEditor+ key={`name-${squad.id}-${nameResetToken}`}+ defaultValue={squad.name}+ placeholder={t(($) => $.name_editor.placeholder)}+ className={INLINE_FIELD}+ onBlur={saveName}+ />+ </div>) : (squad.name)@@ -391,8 +424,9 @@ export function SquadDetailPage() {description={canManage ? (<SquadDescriptionEditor+ key={squad.id}value={squad.description ?? ""}- onSave={async (next) => { await updateSquadMut.mutateAsync({ description: next }); }}+ onSave={(next) => updateSquadMut.mutateAsync({ description: next })}/>) : (squad.description || undefined@@ -976,135 +1010,6 @@ function SquadProperties({);}-// Inline name editor — reveals a Pencil affordance on hover, opens a small-// popover with a single-line input. Mirrors the NameAndDescription editor-// in the agent inspector.-function SquadNameEditor({- value,- onSave,-}: {- value: string;- onSave: (next: string) => Promise<void>;-}) {- const { t } = useT("squads");- return (- <InlineEditPopover- value={value}- onSave={onSave}- title={t(($) => $.name_editor.title)}- placeholder={t(($) => $.name_editor.placeholder)}- validate={(v) =>- v.trim().length > 0 ? null : t(($) => $.name_editor.required)- }- >- {(triggerProps) => (- <button- type="button"- {...triggerProps}- className="group -mx-1 inline-flex items-center gap-1.5 self-start rounded-xs px-1 text-left text-title font-semibold leading-tight transition-colors hover:bg-accent/50"- >- <span>{value}</span>- <Pencil className="h-3.5 w-3.5 shrink-0 text-transparent transition-colors group-hover:text-muted-foreground" />- </button>- )}- </InlineEditPopover>- );-}--function InlineEditPopover({- value,- onSave,- title,- placeholder,- validate,- children,-}: {- value: string;- onSave: (next: string) => Promise<void>;- title: string;- placeholder?: string;- validate?: (v: string) => string | null;- children: (triggerProps: { onClick: (e: React.MouseEvent) => void }) => ReactNode;-}) {- const { t } = useT("squads");- const [open, setOpen] = useState(false);- const [draft, setDraft] = useState(value);- const [saving, setSaving] = useState(false);- const [error, setError] = useState<string | null>(null);-- useEffect(() => {- if (open) {- setDraft(value);- setError(null);- }- }, [open, value]);-- const commit = async () => {- const err = validate?.(draft) ?? null;- if (err) {- setError(err);- return;- }- if (draft === value) {- setOpen(false);- return;- }- setSaving(true);- try {- await onSave(draft);- setOpen(false);- toast.success(t(($) => $.name_editor.saved));- } catch (e) {- toast.error(e instanceof Error ? e.message : t(($) => $.name_editor.save_failed));- } finally {- setSaving(false);- }- };-- return (- <Popover open={open} onOpenChange={setOpen}>- <PopoverTrigger- render={children({ onClick: () => setOpen(true) }) as React.ReactElement}- />- <PopoverContent align="start" className="w-72 p-3">- <div className="space-y-2">- <p className="text-caption font-medium">{title}</p>- <Input- autoFocus- value={draft}- onChange={(e) => {- setDraft(e.target.value);- if (error) setError(null);- }}- placeholder={placeholder}- onKeyDown={(e) => {- if (e.key === "Escape") {- setOpen(false);- return;- }- if (isImeComposing(e)) return;- if (e.key === "Enter") {- e.preventDefault();- void commit();- }- }}- className="h-8"- />- {error && <p className="text-caption text-destructive">{error}</p>}- <div className="flex items-center justify-end gap-2">- <Button variant="ghost" size="sm" onClick={() => setOpen(false)} disabled={saving}>- {t(($) => $.name_editor.cancel)}- </Button>- <Button size="sm" onClick={() => void commit()} disabled={saving || draft === value}>- {saving ? <Loader2 className="h-3.5 w-3.5 animate-spin" /> : t(($) => $.name_editor.save)}- </Button>- </div>- </div>- </PopoverContent>- </Popover>- );-}-// Two-step add-member dialog (mirrors CreateAgentDialog's compact layout):// 1) pick a target — Members + Agents in one searchable popover, each row// with an avatar so visual recognition matches the issue assignee picker;@@ -1322,107 +1227,94 @@ function RoleEditor({ value, onSave }: { value: string; onSave: (next: string) =);}-// Click-to-edit description editor for the identity block. Mirrors-// agent-detail-inspector's DescriptionEditor: opens a modal with a textarea-// (enough room for multi-paragraph descriptions); the inline trigger shows-// the current value (or a placeholder) with a hover-revealed Pencil.+// Name and description read as plain text and share one hover/focus wash, so+// clicking either doesn't shift the layout around it.+const INLINE_FIELD = "rounded-sm px-1 transition-colors hover:bg-accent/50 focus:bg-accent/50";++// Click-to-edit description for the identity block. Same rules as the name:+// blur or the send shortcut saves, Escape discards. The saved text stays on+// screen while the request is in flight instead of flashing the old value, and+// a failed save keeps its text so reopening the editor picks it up to retry.function SquadDescriptionEditor({value,onSave,}: {value: string;- onSave: (next: string) => Promise<void>;-}) {- const { t } = useT("squads");- const [open, setOpen] = useState(false);- return (- <>- <button- type="button"- onClick={() => setOpen(true)}- className="group -mx-1 inline-flex max-w-full items-start gap-1.5 rounded-sm px-1 text-left transition-colors hover:bg-accent/50"- >- {value ? (- <span className="line-clamp-2 text-muted-foreground">{value}</span>- ) : (- <span className="italic text-muted-foreground">{t(($) => $.description_dialog.placeholder_empty)}</span>- )}- <Pencil className="mt-1 h-3 w-3 shrink-0 text-transparent transition-colors group-hover:text-muted-foreground" />- </button>-- <Dialog open={open} onOpenChange={setOpen}>- <DialogContent className="sm:max-w-lg">- {open && (- <SquadDescriptionEditorBody- initialValue={value}- onSave={onSave}- onClose={() => setOpen(false)}- />- )}- </DialogContent>- </Dialog>- </>- );-}--function SquadDescriptionEditorBody({- initialValue,- onSave,- onClose,-}: {- initialValue: string;- onSave: (next: string) => Promise<void>;- onClose: () => void;+ onSave: (next: string) => Promise<unknown>;}) {const { t } = useT("squads");- const [draft, setDraft] = useState(initialValue);- const [saving, setSaving] = useState(false);- const savingRef = useRef(false);- const dirty = draft !== initialValue;+ const [editing, setEditing] = useState(false);+ const [draft, setDraft] = useState(value);+ const [pending, setPending] = useState<string | null>(null);+ const [unsaved, setUnsaved] = useState<string | null>(null);+ const discardRef = useRef(false);+ const shown = pending ?? value;+ const placeholder = t(($) => $.description_editor.placeholder);++ const startEditing = () => {+ discardRef.current = false;+ setDraft(unsaved ?? shown);+ setEditing(true);+ };- const commit = async () => {- if (savingRef.current) return;- if (!dirty) { onClose(); return; }- savingRef.current = true;- setSaving(true);- try {- await onSave(draft);- onClose();- } catch {- // toast handled by parent's mutation- } finally {- savingRef.current = false;- setSaving(false);+ const finish = () => {+ setEditing(false);+ if (discardRef.current || draft === shown) {+ setUnsaved(null);+ return;}+ const next = draft;+ setPending(next);+ onSave(next)+ .then(+ () => setUnsaved(null),+ // toast handled by the mutation+ () => setUnsaved(next),+ )+ .finally(() => setPending(null));};- return (- <>- <DialogHeader>- <DialogTitle>{t(($) => $.description_dialog.title)}</DialogTitle>- </DialogHeader>- <textarea+ if (editing) {+ return (+ <TextareaautoFocusvalue={draft}onChange={(e) => setDraft(e.target.value)}- placeholder={t(($) => $.description_dialog.responsibility_placeholder)}- rows={6}+ onFocus={(e) => {+ const end = e.currentTarget.value.length;+ e.currentTarget.setSelectionRange(end, end);+ }}+ onBlur={finish}onKeyDown={(e) => {- if (e.key === "Escape") { onClose(); return; }+ if (e.key === "Escape") {+ discardRef.current = true;+ e.currentTarget.blur();+ return;+ }if (e.defaultPrevented || e.repeat || isImeComposing(e)) return;if (shortcutMatchesEvent(getShortcut("send"), e.nativeEvent)) {e.preventDefault();- void commit();+ e.currentTarget.blur();}}}- className="w-full resize-none rounded-md border bg-transparent px-3 py-2 text-body outline-none focus-visible:border-input"+ aria-label={placeholder}+ placeholder={placeholder}+ rows={1}+ className={cn(+ INLINE_FIELD,+ "block min-h-0 resize-none rounded-sm border-0 py-0 text-body text-foreground focus-visible:ring-0 md:text-body dark:bg-accent/50",+ )}/>- <DialogFooter>- <Button variant="ghost" size="sm" onClick={onClose} disabled={saving}>{t(($) => $.description_dialog.cancel)}</Button>- <Button size="sm" onClick={() => void commit()} disabled={saving || !dirty}>- {saving ? <Loader2 className="h-3.5 w-3.5 animate-spin" /> : t(($) => $.description_dialog.save)}- </Button>- </DialogFooter>- </>+ );+ }++ return (+ <button type="button" onClick={startEditing} className={cn(INLINE_FIELD, "inline-flex max-w-full text-left")}>+ {shown ? (+ <span className="line-clamp-2">{shown}</span>+ ) : (+ <span className="italic">{t(($) => $.description_editor.empty)}</span>+ )}+ </button>);}