π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π style(acceptance): show creator avatars in the workspace acceptance list (#21705)
Lobehub Coder7762e1435112
diff --git a/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx b/src/features/Acceptance/Workspace/AcceptanceListPanel.tsxindex c8ca8a319f3..aadeb83f7e4 100644--- a/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx+++ b/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx@@ -628,6 +628,8 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(// to carry it on the row or the affiliation is simply not on screen.// Inside a project every row belongs to it, so naming the project again is noise.const showRowProject = !projectId && groupMode !== 'project';+ // "Created by me" makes every row the viewer's own, so the avatar adds nothing.+ const showRowCreator = scope !== 'created';const orderedIds = (showGroups ? groups.flatMap((group) => group.items) : items).filter((item) => item.canManage)@@ -884,6 +886,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(active={item.id === acceptanceId}item={item}key={item.id}+ showCreator={showRowCreator}showProject={showRowProject}onChanged={mutate}{...rowSelectionProps(item)}@@ -904,6 +907,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(active={item.id === acceptanceId}item={item}key={item.id}+ showCreator={showRowCreator}showProject={showRowProject}onChanged={mutate}{...rowSelectionProps(item)}diff --git a/src/features/Acceptance/Workspace/AcceptanceRow.tsx b/src/features/Acceptance/Workspace/AcceptanceRow.tsxindex be80aa5aca1..4604f334bed 100644--- a/src/features/Acceptance/Workspace/AcceptanceRow.tsx+++ b/src/features/Acceptance/Workspace/AcceptanceRow.tsx@@ -34,6 +34,7 @@ import { useTranslation } from 'react-i18next';import { openRenameModal } from '@/components/RenameModal';import NavItem from '@/features/NavPanel/components/NavItem';+import TopicCreatorAvatar from '@/features/TopicCreatorAvatar';import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';import type { AcceptanceListItem } from '@/services/verify';import { verifyService } from '@/services/verify';@@ -48,6 +49,7 @@ import { getAcceptanceStatusActions } from '../Viewer/statusActions';import { openAcceptanceDeleteConfirm } from './AcceptanceDeleteConfirm';import { openMergeAcceptanceModal } from './MergeAcceptanceModal';import { useAcceptanceProjectMenuItem } from './useAcceptanceProjectMenuItem';+import { useAcceptanceRowCreator } from './useAcceptanceRowCreator';const styles = createStaticStyles(({ css }) => ({itemProject: css`@@ -123,144 +125,154 @@ const AcceptanceRow = memo<{* would only repeat the header.*/showProject?: boolean;+ /**+ * Lead the row with its creator's avatar when that creator resolves to a+ * workspace member, like the topic list. Off when every row is the viewer's+ * own ("created by me"), where the avatar would only repeat itself.+ */+ showCreator?: boolean;/** Multi-select is running: the row picks instead of navigating. */selectable?: boolean;selected?: boolean;onToggleSelect?: (shift: boolean) => void;-}>(({ active, item, onChanged, onToggleSelect, selectable, selected, showProject }) => {- const { t } = useTranslation('verify');- const navigate = useWorkspaceAwareNavigate();- const routeBase = useAcceptanceRouteBase();- const [mutating, setMutating] = useState(false);+}>(+ ({ active, item, onChanged, onToggleSelect, selectable, selected, showCreator, showProject }) => {+ const { t } = useTranslation('verify');+ const navigate = useWorkspaceAwareNavigate();+ const routeBase = useAcceptanceRouteBase();+ const [mutating, setMutating] = useState(false);- const glyph = glyphOf(item.status as AcceptanceStatus);- const meta = glyphMeta[glyph];- const title = item.subject.title || item.subjectId;+ const glyph = glyphOf(item.status as AcceptanceStatus);+ const meta = glyphMeta[glyph];+ const title = item.subject.title || item.subjectId;+ const creatorUserId = useAcceptanceRowCreator(item.userId, showCreator);- const refresh = () =>- Promise.all([onChanged(), useVerifyStore.getState().refreshAcceptanceBundle(item.id)]);-- /**- * The shared rename dialog, same as a topic's. An in-place input inside a- * narrow panel gave a long delivery title a ~200px editing window with no- * room to see what was being edited; the modal is also where the note about- * what a rename does and does not touch can actually be read.- */- const startRename = () =>- openRenameModal({- defaultValue: title,- description: t('acceptance.workspace.renameModal.description'),- title: t('acceptance.workspace.actions.rename'),- onSave: async (next) => {- setMutating(true);- try {- await verifyService.renameAcceptance(item.id, next);- await refresh();- toast.success(t('acceptance.workspace.renameSuccess'));- } catch (error) {- console.error('[acceptance:rename]', error);- toast.error(t('acceptance.workspace.renameError'));- // Re-throw: the shared modal closes on a RESOLVED save, which would- // discard the title the user just typed and leave no way to retry.- throw error;- } finally {- setMutating(false);- }- },- });+ const refresh = () =>+ Promise.all([onChanged(), useVerifyStore.getState().refreshAcceptanceBundle(item.id)]);- const changeStatus = async (status: 'accepted' | 'closed' | 'delivered' | 'rejected') => {- setMutating(true);- try {- await verifyService.updateAcceptanceStatus(item.id, status);- await refresh();- toast.success(t('acceptance.workspace.statusSuccess'));- } catch (error) {- console.error('[acceptance:status]', error);- toast.error(t('acceptance.workspace.statusError'));- } finally {- setMutating(false);- }- };+ /**+ * The shared rename dialog, same as a topic's. An in-place input inside a+ * narrow panel gave a long delivery title a ~200px editing window with no+ * room to see what was being edited; the modal is also where the note about+ * what a rename does and does not touch can actually be read.+ */+ const startRename = () =>+ openRenameModal({+ defaultValue: title,+ description: t('acceptance.workspace.renameModal.description'),+ title: t('acceptance.workspace.actions.rename'),+ onSave: async (next) => {+ setMutating(true);+ try {+ await verifyService.renameAcceptance(item.id, next);+ await refresh();+ toast.success(t('acceptance.workspace.renameSuccess'));+ } catch (error) {+ console.error('[acceptance:rename]', error);+ toast.error(t('acceptance.workspace.renameError'));+ // Re-throw: the shared modal closes on a RESOLVED save, which would+ // discard the title the user just typed and leave no way to retry.+ throw error;+ } finally {+ setMutating(false);+ }+ },+ });- const assignProject = async (projectId: string | null) => {- setMutating(true);- try {- await verifyService.setAcceptanceProject(item.id, projectId);- await refresh();- toast.success(- projectId- ? t(- item.project?.id- ? 'acceptance.workspace.project.moveSuccess'- : 'acceptance.workspace.project.addSuccess',- )- : t('acceptance.workspace.project.removeSuccess'),- );- } catch (error) {- console.error('[acceptance:project]', error);- toast.error(t('acceptance.workspace.project.error'));- } finally {- setMutating(false);- }- };+ const changeStatus = async (status: 'accepted' | 'closed' | 'delivered' | 'rejected') => {+ setMutating(true);+ try {+ await verifyService.updateAcceptanceStatus(item.id, status);+ await refresh();+ toast.success(t('acceptance.workspace.statusSuccess'));+ } catch (error) {+ console.error('[acceptance:status]', error);+ toast.error(t('acceptance.workspace.statusError'));+ } finally {+ setMutating(false);+ }+ };- const projectItem = useAcceptanceProjectMenuItem({- currentProjectId: item.project?.id,- onSelect: (projectId) => void assignProject(projectId),- });+ const assignProject = async (projectId: string | null) => {+ setMutating(true);+ try {+ await verifyService.setAcceptanceProject(item.id, projectId);+ await refresh();+ toast.success(+ projectId+ ? t(+ item.project?.id+ ? 'acceptance.workspace.project.moveSuccess'+ : 'acceptance.workspace.project.addSuccess',+ )+ : t('acceptance.workspace.project.removeSuccess'),+ );+ } catch (error) {+ console.error('[acceptance:project]', error);+ toast.error(t('acceptance.workspace.project.error'));+ } finally {+ setMutating(false);+ }+ };- /**- * Fold this entry into another acceptance β its checks (with rounds and- * evidence) move over and this row disappears. Navigating the active row to- * the target keeps the reviewer on the surface their checks just moved to,- * instead of on a 404.- */- const mergeIntoAcceptance = () => {- openMergeAcceptanceModal({- source: item,- onConfirm: async (targetId) => {- setMutating(true);- try {- const summary = await verifyService.mergeAcceptance(item.id, targetId);- if (active) navigate(acceptanceOverviewPath(targetId, routeBase), { replace: true });- await Promise.all([- onChanged(),- useVerifyStore.getState().refreshAcceptanceBundle(targetId),- ]);- toast.success(t('acceptance.workspace.merge.success', { count: summary.movedChecks }));- return true;- } catch (error) {- console.error('[acceptance:merge]', error);- toast.error(t('acceptance.workspace.merge.error'));- return false;- } finally {- setMutating(false);- }- },+ const projectItem = useAcceptanceProjectMenuItem({+ currentProjectId: item.project?.id,+ onSelect: (projectId) => void assignProject(projectId),});- };- const removeAcceptance = () => {- openAcceptanceDeleteConfirm({- ids: [item.id],- title,- onDelete: async (purge) => {- setMutating(true);- try {- await verifyService.deleteAcceptance(item.id, purge);- if (active) navigate(acceptanceListPath(routeBase), { replace: true });- await onChanged();- toast.success(t('acceptance.workspace.deleteSuccess'));- } finally {- setMutating(false);- }- },- });- };+ /**+ * Fold this entry into another acceptance β its checks (with rounds and+ * evidence) move over and this row disappears. Navigating the active row to+ * the target keeps the reviewer on the surface their checks just moved to,+ * instead of on a 404.+ */+ const mergeIntoAcceptance = () => {+ openMergeAcceptanceModal({+ source: item,+ onConfirm: async (targetId) => {+ setMutating(true);+ try {+ const summary = await verifyService.mergeAcceptance(item.id, targetId);+ if (active) navigate(acceptanceOverviewPath(targetId, routeBase), { replace: true });+ await Promise.all([+ onChanged(),+ useVerifyStore.getState().refreshAcceptanceBundle(targetId),+ ]);+ toast.success(t('acceptance.workspace.merge.success', { count: summary.movedChecks }));+ return true;+ } catch (error) {+ console.error('[acceptance:merge]', error);+ toast.error(t('acceptance.workspace.merge.error'));+ return false;+ } finally {+ setMutating(false);+ }+ },+ });+ };++ const removeAcceptance = () => {+ openAcceptanceDeleteConfirm({+ ids: [item.id],+ title,+ onDelete: async (purge) => {+ setMutating(true);+ try {+ await verifyService.deleteAcceptance(item.id, purge);+ if (active) navigate(acceptanceListPath(routeBase), { replace: true });+ await onChanged();+ toast.success(t('acceptance.workspace.deleteSuccess'));+ } finally {+ setMutating(false);+ }+ },+ });+ };- const statusItems: DropdownItem[] = getAcceptanceStatusActions(item.status, item.subjectType).map(- (action) => {+ const statusItems: DropdownItem[] = getAcceptanceStatusActions(+ item.status,+ item.subjectType,+ ).map((action) => {if (action === 'accept') {return {icon: <Icon icon={CircleCheck} />,@@ -283,132 +295,142 @@ const AcceptanceRow = memo<{label: t('acceptance.workspace.actions.markClosed'),onClick: () => void changeStatus('closed'),};- },- );+ });++ // Deciding the delivery is what this menu is FOR β status leads, then the+ // filing actions, then the destructive one behind its own divider. Buried+ // under rename/move/merge it read as an afterthought of housekeeping.+ const menuItems: DropdownItem[] = [+ ...(statusItems.length > 0+ ? [+ {+ children: statusItems,+ icon: <Icon icon={CircleDashed} />,+ key: 'status',+ label: t('acceptance.workspace.actions.status'),+ },+ { type: 'divider' as const },+ ]+ : []),+ {+ icon: <Icon icon={Pencil} />,+ key: 'rename',+ label: t('acceptance.workspace.actions.rename'),+ onClick: startRename,+ },+ projectItem,+ {+ icon: <Icon icon={GitMerge} />,+ key: 'merge',+ label: t('acceptance.workspace.actions.merge'),+ onClick: mergeIntoAcceptance,+ },+ { type: 'divider' as const },+ {+ danger: true,+ icon: <Icon icon={Trash2} />,+ key: 'delete',+ label: t('acceptance.workspace.actions.delete'),+ onClick: removeAcceptance,+ },+ ];- // Deciding the delivery is what this menu is FOR β status leads, then the- // filing actions, then the destructive one behind its own divider. Buried- // under rename/move/merge it read as an afterthought of housekeeping.- const menuItems: DropdownItem[] = [- ...(statusItems.length > 0- ? [- {- children: statusItems,- icon: <Icon icon={CircleDashed} />,- key: 'status',- label: t('acceptance.workspace.actions.status'),- },- { type: 'divider' as const },- ]- : []),- {- icon: <Icon icon={Pencil} />,- key: 'rename',- label: t('acceptance.workspace.actions.rename'),- onClick: startRename,- },- projectItem,- {- icon: <Icon icon={GitMerge} />,- key: 'merge',- label: t('acceptance.workspace.actions.merge'),- onClick: mergeIntoAcceptance,- },- { type: 'divider' as const },- {- danger: true,- icon: <Icon icon={Trash2} />,- key: 'delete',- label: t('acceptance.workspace.actions.delete'),- onClick: removeAcceptance,- },- ];+ const statusGlyph = (+ <Icon+ className={SPINNING_GLYPHS.has(glyph) ? styles.spin : undefined}+ icon={meta.icon}+ size={16}+ style={{ color: meta.color }}+ />+ );- const statusGlyph = (- <Icon- className={SPINNING_GLYPHS.has(glyph) ? styles.spin : undefined}- icon={meta.icon}- size={16}- style={{ color: meta.color }}- />- );+ // Workspace mode: the creator's avatar leads and the status glyph shrinks+ // into its corner badge, matching the topic list.+ const leadingIcon = creatorUserId ? (+ <TopicCreatorAvatar corner={statusGlyph} userId={creatorUserId} />+ ) : (+ statusGlyph+ );- // While selecting, the row PICKS instead of navigating:- // - `active` carries the ticked state β navigation is off, so no row can be- // "the open one" for the duration;- // - the checkbox takes the leading slot and the status glyph moves next to- // the timestamp, so a status sweep still sees what it is sweeping without- // the row growing a second line;- // - the row's own menu steps aside β the batch bar owns what happens to a- // selection, and one delete path per surface is enough.- return (- <NavItem- active={selectable ? selected : active}- icon={selectable ? undefined : statusGlyph}- key={item.id}- style={mutating ? { opacity: 0.62, pointerEvents: 'none' } : undefined}- title={title}- titleColor={cssVar.colorText}- // Only where the grouping does not already say it, and only when the row- // actually has one β stamping "ungrouped" on every other row would cost a- // line of height to say nothing.- // Someone else's acceptance (a participated row) offers no menu: every- // entry in it is a write its owner alone may make.- actions={- selectable || !item.canManage ? undefined : (- <DropdownMenu- iconSpaceMode={'group'}- items={menuItems}- placement={'bottomRight'}- popupProps={{ style: { minWidth: 160 } }}- >- <ActionIcon- icon={MoreHorizontal}- size={'small'}- title={t('acceptance.workspace.actions.more')}- />- </DropdownMenu>- )- }- description={- showProject && item.project ? (- <span className={styles.itemProject}>{item.project.name}</span>- ) : undefined- }- extra={- <Flexbox horizontal align={'center'} gap={6}>- {selectable && statusGlyph}- <span className={styles.itemTime}>{relativeTime(item.updatedAt ?? item.createdAt)}</span>- </Flexbox>- }- slots={- selectable- ? {- iconPostfix: (- <Center- flex={'none'}- height={showProject && item.project ? 22 : undefined}- style={showProject && item.project ? { alignSelf: 'flex-start' } : undefined}- width={28}- >- {/* Read-only on purpose: the whole row is the hit target, so+ // While selecting, the row PICKS instead of navigating:+ // - `active` carries the ticked state β navigation is off, so no row can be+ // "the open one" for the duration;+ // - the checkbox takes the leading slot and the status glyph moves next to+ // the timestamp, so a status sweep still sees what it is sweeping without+ // the row growing a second line;+ // - the row's own menu steps aside β the batch bar owns what happens to a+ // selection, and one delete path per surface is enough.+ return (+ <NavItem+ active={selectable ? selected : active}+ icon={selectable ? undefined : leadingIcon}+ key={item.id}+ style={mutating ? { opacity: 0.62, pointerEvents: 'none' } : undefined}+ title={title}+ titleColor={cssVar.colorText}+ // Only where the grouping does not already say it, and only when the row+ // actually has one β stamping "ungrouped" on every other row would cost a+ // line of height to say nothing.+ // Someone else's acceptance (a participated row) offers no menu: every+ // entry in it is a write its owner alone may make.+ actions={+ selectable || !item.canManage ? undefined : (+ <DropdownMenu+ iconSpaceMode={'group'}+ items={menuItems}+ placement={'bottomRight'}+ popupProps={{ style: { minWidth: 160 } }}+ >+ <ActionIcon+ icon={MoreHorizontal}+ size={'small'}+ title={t('acceptance.workspace.actions.more')}+ />+ </DropdownMenu>+ )+ }+ description={+ showProject && item.project ? (+ <span className={styles.itemProject}>{item.project.name}</span>+ ) : undefined+ }+ extra={+ <Flexbox horizontal align={'center'} gap={6}>+ {selectable && statusGlyph}+ <span className={styles.itemTime}>+ {relativeTime(item.updatedAt ?? item.createdAt)}+ </span>+ </Flexbox>+ }+ slots={+ selectable+ ? {+ iconPostfix: (+ <Center+ flex={'none'}+ height={showProject && item.project ? 22 : undefined}+ style={showProject && item.project ? { alignSelf: 'flex-start' } : undefined}+ width={28}+ >+ {/* Read-only on purpose: the whole row is the hit target, sothe box reflects the state rather than owning it. */}- <Checkbox readOnly checked={selected} />- </Center>- ),- }- : undefined- }- onClick={(e) => {- if (onToggleSelect && (selectable || e.shiftKey || e.metaKey || e.ctrlKey)) {- onToggleSelect(e.shiftKey);- return;+ <Checkbox readOnly checked={selected} />+ </Center>+ ),+ }+ : undefined}- navigate(acceptanceOverviewPath(item.id, routeBase));- }}- />- );-});+ onClick={(e) => {+ if (onToggleSelect && (selectable || e.shiftKey || e.metaKey || e.ctrlKey)) {+ onToggleSelect(e.shiftKey);+ return;+ }+ navigate(acceptanceOverviewPath(item.id, routeBase));+ }}+ />+ );+ },+);AcceptanceRow.displayName = 'AcceptanceRow';diff --git a/src/features/Acceptance/Workspace/useAcceptanceRowCreator.test.ts b/src/features/Acceptance/Workspace/useAcceptanceRowCreator.test.tsnew file mode 100644index 00000000000..771846cdef1--- /dev/null+++ b/src/features/Acceptance/Workspace/useAcceptanceRowCreator.test.ts@@ -0,0 +1,41 @@+import { renderHook } from '@testing-library/react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { useAcceptanceRowCreator } from './useAcceptanceRowCreator';++const useAuthorInfoMock = vi.hoisted(() => vi.fn());++vi.mock('@/business/client/hooks/useAuthorInfo', () => ({+ useAuthorInfo: useAuthorInfoMock,+}));+vi.mock('@/business/client/hooks/useHasActiveWorkspace', () => ({+ useHasActiveWorkspace: () => true,+}));++describe('useAcceptanceRowCreator', () => {+ beforeEach(() => {+ useAuthorInfoMock.mockReset();+ useAuthorInfoMock.mockImplementation((userId?: string) =>+ userId === 'user-alice' ? { avatar: 'a.png', fullName: 'Alice' } : undefined,+ );+ });++ it('returns the creator when they resolve to a workspace member', () => {+ const { result } = renderHook(() => useAcceptanceRowCreator('user-alice', true));++ expect(result.current).toBe('user-alice');+ });++ it('falls back to the status glyph when the creator does not resolve (personal mode)', () => {+ const { result } = renderHook(() => useAcceptanceRowCreator('user-bob', true));++ expect(result.current).toBeUndefined();+ });++ it('skips the creator when the list only holds the viewer own acceptances', () => {+ const { result } = renderHook(() => useAcceptanceRowCreator('user-alice', false));++ expect(result.current).toBeUndefined();+ expect(useAuthorInfoMock).not.toHaveBeenCalledWith('user-alice');+ });+});diff --git a/src/features/Acceptance/Workspace/useAcceptanceRowCreator.ts b/src/features/Acceptance/Workspace/useAcceptanceRowCreator.tsnew file mode 100644index 00000000000..da0024f8285--- /dev/null+++ b/src/features/Acceptance/Workspace/useAcceptanceRowCreator.ts@@ -0,0 +1,13 @@+import { useTopicCreator } from '@/features/TopicCreatorAvatar';++/**+ * The creator whose avatar should lead an acceptance row, or undefined for the+ * bare status glyph. Resolves only to a member of the active workspace, so+ * personal mode keeps the glyph, like the topic list.+ */+export const useAcceptanceRowCreator = (userId: string | undefined, showCreator?: boolean) => {+ const creatorUserId = showCreator ? userId : undefined;+ const creator = useTopicCreator(creatorUserId);++ return creator ? creatorUserId : undefined;+};