Skip to content

Add the shared AssigneeList UI component and the assignment API client #2892

Closed

Description

@propr-dev

Context

The request asks for one specific visual treatment: "The visualisation of assigned users should be ascetic and similar to github (avatar + username)." That same treatment is needed in at least six places - the Tasks ledger row, the mobile task card, the task detail header, the Plans list, the Goals queue and the Automations list - plus the to-do items. Building it once and reusing it is what makes the result consistent; building it per surface is how six slightly different avatar sizes appear.

The repository already has the right primitive. propr-ui/src/components/UserAvatar.tsx renders an avatar with an accessible initials fallback when the image fails, and GitHubAccountIdentity.tsx already pairs it with @username for the desktop account row. This task generalises that pairing into a reusable component with the density variants the different surfaces need, and adds the API client the next two tasks call.

This task adds no behaviour to any page. It is the component and the client, with unit tests, so the two UI tasks that follow stay small.

Requirements

  1. Add propr-ui/src/components/AssigneeList.tsx exporting:
    • AssigneeChip - one avatar + @login pair, built on UserAvatar.
    • AssigneeList - a bounded row of chips with a +N overflow marker and a tooltip naming everyone.
    • AssigneeStack - avatars only, overlapped, for dense table cells.
    • UnassignedMarker - the quiet em-dash placeholder that keeps a column aligned.
  2. Three density variants, matching the existing conventions: compact (14px avatar, login hidden below sm), default (18px), prominent (24px, for the detail header).
  3. Accessibility: the list is a role="list", each chip has an accessible name of the form Assigned to @login, the overflow marker names the hidden users, and avatars are decorative because the login is already text beside them.
  4. Visual restraint, per the request: no coloured pill backgrounds, no borders by default, monospace login at text-xs in slate, matching the repository chip and reference chip treatment already used in the ledger.
  5. Add propr-ui/src/api/taskAssignment.ts with getTaskAssignees, setTaskAssignees and getAssignableUsers, using apiFetch / handleApiResponse, and re-export through proprApi.ts.
  6. Add assignees?: AttributedUser[] to the UI Task types in propr-ui/src/api/tasks.ts and propr-ui/src/components/TaskList/types.ts, and pass assignee through GetTasksOptions in proprTypes.ts / proprApi.ts.
  7. Vitest tests covering the fallback path, overflow, accessible names, the unassigned marker and the client's URL encoding.

Implementation Specification

Files added

  • propr-ui/src/components/AssigneeList.tsx
  • propr-ui/src/api/taskAssignment.ts
  • propr-ui/src/components/AssigneeList.test.tsx

Files modified

  • propr-ui/src/api/proprApi.ts - re-export the new client module.
  • propr-ui/src/api/proprTypes.ts - add assignee to GetTasksOptions.
  • propr-ui/src/api/tasks.ts - add assignees to Task and assignee to ListTasksOptions.
  • propr-ui/src/components/TaskList/types.ts - add assignees to the list Task type.

Step-by-step

  1. Write AssigneeList.tsx. Keep UserAvatar as the only image path so the initials fallback and the user.id keyed image reset are inherited rather than reimplemented.
  2. Cap the rendered chips at the variant's limit and render the remainder as +N, with the hidden logins in the title so nothing is unreachable.
  3. Write the API client. Encode taskId with encodeURIComponent, matching every other task client call.
  4. Thread the types through, leaving assignees optional so an older server response still type-checks.
  5. Add the test file.

Acceptance Criteria

  • npm run typecheck and npm run lint pass for propr-ui.
  • AssigneeChip renders the avatar and @login; when the avatar image fails to load it falls back to two-letter initials and stays accessible.
  • AssigneeList with more assignees than the variant's limit renders exactly the limit plus one +N marker, and the marker's tooltip names every hidden login.
  • AssigneeList with an empty array renders the UnassignedMarker, not an empty element, so table columns stay aligned.
  • Each chip exposes an accessible name of the form Assigned to @octocat.
  • In the compact variant the login text is hidden below the sm breakpoint while the avatar stays visible, and the accessible name is unchanged.
  • getTaskAssignees, setTaskAssignees and getAssignableUsers call the expected paths with the task id percent-encoded.
  • No page renders differently in this change: the component is added but not yet mounted anywhere.

Created by ProPR AI Planner

Activity

  1. propr-dev commented on Oct 8, 2026

    @propr-dev
    ContributorAuthor

    Suggested Implementation:

    Implementation Approach

    The brief is explicit about the visual target: ascetic, GitHub-like, avatar plus username. GitHub's own treatment is a small round avatar with the login in plain text, no pill, no colour. The existing ledger already speaks that language - TaskRepository renders a bare monospace repo name and the comment there explains why a chip was rejected ("a chip around it only stacks identical bubbles down the list"). Assignees follow the same rule.

    Rather than a new avatar implementation, this builds on UserAvatar, which already solves the two things that actually break in practice: a GitHub avatar URL that 404s after an account change, and an image that must be rebuilt when the identity changes (its key includes user.id). Reimplementing that would mean reimplementing those bugs.

    Three variants exist because the surfaces have genuinely different budgets, not for configurability's sake:

    • compact for the ledger cell and the mobile card, where the row is two fixed lines and there is no room for a login on a phone. The login is hidden with max-sm:hidden rather than removed, so the accessible name is unchanged and a screen reader still announces it.
    • default for list rows with room for text.
    • prominent for the detail header, where assignment is a primary fact rather than metadata.

    An alternative was to render only avatars everywhere and put logins in tooltips. Rejected: the request explicitly asks for "avatar + username", and a tooltip-only login is unreachable by keyboard and invisible on touch.

    Overflow is bounded per variant with a +N marker whose title names the hidden logins. Rendering every assignee would let a task with ten assignees reflow a table row, which the ledger's fixed column widths exist to prevent.

    The empty state renders a visible em-dash rather than nothing, matching TaskAgent and TaskScore in the same table: an empty cell reads as a rendering bug, and a dash reads as "nobody".

    File: propr-ui/src/components/AssigneeList.tsx (new file)

    Why this file: one component for all six surfaces is what makes the treatment consistent. It is built on UserAvatar so the image-failure fallback and the identity-keyed image reset are inherited, and it owns the overflow rule so a task with many assignees cannot reflow the ledger's fixed columns.

    import React from 'react';
    import UserAvatar from './UserAvatar';
    import type { AttributedUser } from '@propr/shared';
    
    /**
     * Density variants, one per surface budget rather than for configurability:
     * - compact: the ledger cell and the mobile card, where the row is two fixed
     *   lines and a phone has no width for a login.
     * - default: list rows with room for text.
     * - prominent: the task detail header, where assignment is a primary fact.
     */
    export type AssigneeDensity = 'compact' | 'default' | 'prominent';
    
    interface DensitySpec {
      avatar: string;
      text: string;
      gap: string;
      /** Beyond this, the rest collapse into a +N marker so a row cannot reflow. */
      limit: number;
      /** compact hides the login below sm; the accessible name is unaffected. */
      hideTextOnPhone: boolean;
    }
    
    const DENSITY: Record<AssigneeDensity, DensitySpec> = {
      compact: { avatar: 'h-3.5 w-3.5', text: 'text-[11px]', gap: 'gap-1', limit: 2, hideTextOnPhone: true },
      default: { avatar: 'h-[18px] w-[18px]', text: 'text-xs', gap: 'gap-1.5', limit: 3, hideTextOnPhone: false },
      prominent: { avatar: 'h-6 w-6', text: 'text-sm', gap: 'gap-2', limit: 4, hideTextOnPhone: false },
    };
    
    /**
     * The ascetic treatment the brief asks for: a round avatar and a plain
     * monospace login in slate. No pill, no border, no colour - matching
     * TaskRepository in the ledger, where a chip was rejected because identical
     * bubbles stacked down a list read as noise.
     */
    export const AssigneeChip: React.FC<{
      user: AttributedUser;
      density?: AssigneeDensity;
      className?: string;
    }> = ({ user, density = 'default', className = '' }) => {
      const spec = DENSITY[density];
      return (
        <span
          role="listitem"
          className={`inline-flex min-w-0 items-center ${spec.gap} ${className}`.trim()}
          title={'Assigned to @' + user.login + (user.displayName !== user.login ? ' (' + user.displayName + ')' : '')}
        >
          {/* Decorative: the login is already text beside it, so announcing the
              avatar too would read the same name twice. */}
          <UserAvatar
            user={{ id: user.id, username: user.login, displayName: user.displayName, avatarUrl: user.avatarUrl }}
            className={`${spec.avatar} flex-none rounded-full border border-slate-200 object-cover text-[8px] font-bold`}
            fallbackClassName="flex items-center justify-center bg-slate-100 text-slate-600"
            decorative
            referrerPolicy="no-referrer"
          />
          {/* The accessible name lives here, not on the avatar, so it is announced
              once and stays correct when the text is visually hidden on a phone. */}
          <span className="sr-only">{'Assigned to @' + user.login}</span>
          <span
            aria-hidden="true"
            className={`min-w-0 truncate font-mono ${spec.text} text-slate-600${spec.hideTextOnPhone ? ' max-sm:hidden' : ''}`}
          >
            @{user.login}
          </span>
        </span>
      );
    };
    
    /**
     * The quiet placeholder for a task nobody owns.
     *
     * A visible dash rather than nothing: an empty table cell reads as a rendering
     * failure, and this matches how TaskAgent and TaskScore mark an absent value.
     */
    export const UnassignedMarker: React.FC<{ className?: string }> = ({ className = '' }) => (
      <span className={`text-xs text-slate-300 ${className}`.trim()} aria-label="Unassigned">
        &mdash;
      </span>
    );
    
    export const AssigneeList: React.FC<{
      users: readonly AttributedUser[] | undefined;
      density?: AssigneeDensity;
      /** Override the variant's limit where a surface genuinely has more room. */
      limit?: number;
      className?: string;
    }> = ({ users, density = 'default', limit, className = '' }) => {
      const spec = DENSITY[density];
      const assignees = users ?? [];
      if (assignees.length === 0) return <UnassignedMarker className={className} />;
      const max = limit ?? spec.limit;
      const shown = assignees.slice(0, max);
      const hidden = assignees.slice(max);
      return (
        <span
          role="list"
          aria-label={'Assignees: ' + assignees.map(user => '@' + user.login).join(', ')}
          className={`inline-flex min-w-0 items-center ${spec.gap} ${className}`.trim()}
        >
          {shown.map(user => <AssigneeChip key={user.id} user={user} density={density} />)}
          {hidden.length > 0 && (
            // The hidden logins live in the title so nothing is unreachable, and
            // in an sr-only span so they are not keyboard- or touch-only.
            <span
              role="listitem"
              className={`flex-none font-mono ${spec.text} text-slate-400`}
              title={hidden.map(user => '@' + user.login).join(', ')}
            >
              <span className="sr-only">{'and ' + hidden.map(user => '@' + user.login).join(', ')}</span>
              <span aria-hidden="true">+{hidden.length}</span>
            </span>
          )}
        </span>
      );
    };
    
    /**
     * Avatars only, overlapped, for the narrowest cells.
     *
     * Used where even a compact login would push a fixed column: the overlap keeps
     * the footprint near-constant as the number of assignees grows, and the
     * accessible name still names everyone.
     */
    export const AssigneeStack: React.FC<{
      users: readonly AttributedUser[] | undefined;
      limit?: number;
      className?: string;
    }> = ({ users, limit = 3, className = '' }) => {
      const assignees = users ?? [];
      if (assignees.length === 0) return <UnassignedMarker className={className} />;
      const shown = assignees.slice(0, limit);
      const hidden = assignees.length - shown.length;
      return (
        <span
          role="list"
          aria-label={'Assignees: ' + assignees.map(user => '@' + user.login).join(', ')}
          className={`inline-flex flex-none items-center ${className}`.trim()}
        >
          {shown.map((user, index) => (
            <span
              key={user.id}
              role="listitem"
              title={'Assigned to @' + user.login}
              // Negative margin after the first avatar gives the GitHub-style
              // overlap; the ring separates adjacent avatars without a border that
              // would change the element's size.
              className={index === 0 ? '' : '-ml-1.5'}
            >
              <span className="sr-only">{'Assigned to @' + user.login}</span>
              <UserAvatar
                user={{ id: user.id, username: user.login, displayName: user.displayName, avatarUrl: user.avatarUrl }}
                className="h-4 w-4 flex-none rounded-full object-cover text-[8px] font-bold ring-1 ring-white"
                fallbackClassName="flex items-center justify-center bg-slate-100 text-slate-600"
                decorative
                referrerPolicy="no-referrer"
              />
            </span>
          ))}
          {hidden > 0 && (
            <span role="listitem" className="-ml-1.5 flex h-4 items-center rounded-full bg-slate-100 px-1 font-mono text-[10px] text-slate-500 ring-1 ring-white">
              +{hidden}
            </span>
          )}
        </span>
      );
    };

    File: propr-ui/src/api/taskAssignment.ts (new file)

    Why this file: keeps the three assignment calls together and separate from tasks.ts, which is already the list/stop/delete client. The task detail editor and the Tasks filter both import from here, so the encoding rule lives in one place.

    import type { AttributedUser } from '@propr/shared';
    import { API_BASE_URL, apiFetch, handleApiResponse } from './apiClient';
    
    /** The GitHub issue or pull request a task is assigned through. Used by the UI to label the control. */
    export interface TaskAssignmentSubject {
      owner: string;
      repo: string;
      number: number;
      kind: 'issue' | 'pull_request';
    }
    
    export interface TaskAssigneesResponse {
      assignees: AttributedUser[];
      subject: TaskAssignmentSubject;
    }
    
    export interface AssignableUsersResponse {
      users: AttributedUser[];
      repository?: string;
      cached?: boolean;
      /** True when GitHub could not be reached: the picker shows a typed-entry fallback. */
      unavailable?: boolean;
    }
    
    /**
     * Current assignees. Refreshes from GitHub by default so an assignment made in
     * the GitHub UI shows immediately; pass `{ refresh: false }` from a poll, which
     * must stay on the cheap cached path.
     */
    export const getTaskAssignees = async (
      taskId: string,
      options: { refresh?: boolean } = {},
    ): Promise<TaskAssigneesResponse> => {
      const query = options.refresh === false ? '?refresh=false' : '';
      const response = await apiFetch(
        `${API_BASE_URL}/api/task/${encodeURIComponent(taskId)}/assignees${query}`,
        { credentials: 'include' },
      );
      await handleApiResponse(response);
      return response.json();
    };
    
    /**
     * Replace (or extend) the assignment.
     *
     * `replace` is the default because this is an explicit operator action from
     * the picker, which must be able to unassign.
     */
    export const setTaskAssignees = async (
      taskId: string,
      logins: readonly string[],
      mode: 'add' | 'replace' = 'replace',
    ): Promise<TaskAssigneesResponse> => {
      const response = await apiFetch(`${API_BASE_URL}/api/task/${encodeURIComponent(taskId)}/assignees`, {
        method: 'PUT',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ logins: [...logins], mode }),
        credentials: 'include',
      });
      await handleApiResponse(response);
      return response.json();
    };
    
    /** Repository members GitHub will accept, so the picker cannot offer an assignment GitHub drops. */
    export const getAssignableUsers = async (taskId: string): Promise<AssignableUsersResponse> => {
      const response = await apiFetch(
        `${API_BASE_URL}/api/task/${encodeURIComponent(taskId)}/assignable-users`,
        { credentials: 'include' },
      );
      await handleApiResponse(response);
      return response.json();
    };

    File: propr-ui/src/api/proprApi.ts

    Why this file: the facade every page imports from. Re-exporting keeps assignment consistent with how tasks, goals and the other domain clients are reached.

    --- a/propr-ui/src/api/proprApi.ts
    +++ b/propr-ui/src/api/proprApi.ts
    @@
     export * from './tasks';
    +// Task assignment reads, writes and the assignable-user picker.
    +export * from './taskAssignment';
     export * from './repoTodosApi';

    The list query needs to carry the filter:

    @@ in getTasksRequest
       if (options.groupBy) params.append('groupBy', options.groupBy);
       if (options.task) params.append('task', options.task);
    +  // Only sent when set, so an unfiltered request is byte-identical to before
    +  // and cannot invalidate a shared in-flight read.
    +  if (options.assignee) params.append('assignee', options.assignee);

    File: propr-ui/src/api/proprTypes.ts

    Why this file: GetTasksOptions is the shape the facade's getTasks accepts, so the filter has to be declared here for callers to pass it.

    --- a/propr-ui/src/api/proprTypes.ts
    +++ b/propr-ui/src/api/proprTypes.ts
    @@
     export interface GetTasksOptions {
       status?: string;
    @@
       /** With `groupBy: 'task'`: only the task this run belongs to, with all its runs, whatever the filters. */
       task?: string;
    +  /**
    +   * `all`, `me`, `unassigned`, or a comma-separated list of GitHub logins.
    +   * `me` is resolved server-side from the session, so the client never sends
    +   * its own id.
    +   */
    +  assignee?: string;
     }

    File: propr-ui/src/api/tasks.ts

    Why this file: the typed /api/tasks client. assignees is optional so a response from an older server still type-checks during a rolling deploy.

    --- a/propr-ui/src/api/tasks.ts
    +++ b/propr-ui/src/api/tasks.ts
    @@
    +import type { AttributedUser } from '@propr/shared';
    +
     /**
      * Represents a task in the system.
      */
     export interface Task {
    @@
       /** Status of associated plan issue */
       planIssueStatus: PlanIssueStatus;
    +  /**
    +   * GitHub assignees of the task's issue or pull request. Optional so a
    +   * response from an older server still type-checks during a rolling deploy;
    +   * treat a missing value the same as an empty list.
    +   */
    +  assignees?: AttributedUser[];
     }
    @@
     export interface ListTasksOptions {
    @@
       /** Exclude tasks where plan_issue_status is 'merged' */
       excludeMerged?: boolean;
    +  /** `all`, `me`, `unassigned`, or a comma-separated list of GitHub logins. */
    +  assignee?: string;
     }
    @@ in listTasks, beside the other optional params
       if (options.excludeMerged) {
         params.set('excludeMerged', 'true');
       }
    +  if (options.assignee) {
    +    params.set('assignee', options.assignee);
    +  }

    File: propr-ui/src/components/TaskList/types.ts

    Why this file: the list components read this Task type rather than the client one, so the ledger cannot render assignees until it is declared here.

    --- a/propr-ui/src/components/TaskList/types.ts
    +++ b/propr-ui/src/components/TaskList/types.ts
    @@
     import type { PublishedVisualPreview } from '@propr/shared';
    +import type { AttributedUser } from '@propr/shared';
     export interface Task {
    @@
       /** The score the run recorded when it completed (a review's `6/10`), when it was scored. */
       score?: number | null;
    +  /** GitHub assignees of the task's issue or pull request; absent means unassigned. */
    +  assignees?: AttributedUser[];
     }

    File: propr-ui/src/components/AssigneeList.test.tsx (new file)

    Why this file: the failure modes worth pinning are the ones a happy-path render hides - a broken avatar URL, an assignee list longer than the row can hold, and the compact variant's visually hidden login. Each has a specific regression: an empty box, a reflowed table row, and an avatar a screen reader cannot name.

    import { describe, it, expect, vi } from 'vitest';
    import { render, screen, fireEvent } from '@testing-library/react';
    import { AssigneeChip, AssigneeList, AssigneeStack, UnassignedMarker } from './AssigneeList';
    import type { AttributedUser } from '@propr/shared';
    
    const user = (login: string, avatarUrl: string | null = 'https://avatars.example/' + login): AttributedUser =>
      ({ id: login + '-id', login, displayName: login, avatarUrl });
    
    describe('AssigneeChip', () => {
      it('renders the avatar and the login', () => {
        render(<AssigneeChip user={user('octocat')} />);
        expect(screen.getByText('@octocat')).toBeTruthy();
        expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
      });
    
      it('falls back to initials when the avatar fails to load', () => {
        render(<AssigneeChip user={user('octocat')} />);
        // The regression: a dead GitHub avatar URL leaving a broken-image box in
        // every row. UserAvatar owns the fallback; this asserts it is reached.
        fireEvent.error(screen.getByRole('img', { hidden: true }));
        expect(screen.getByText('OC')).toBeTruthy();
      });
    
      it('exposes an accessible name even without an avatar URL', () => {
        render(<AssigneeChip user={user('hubot', null)} />);
        expect(screen.getByText('Assigned to @hubot')).toBeTruthy();
      });
    
      it('keeps the login accessible while hiding it visually in the compact variant', () => {
        render(<AssigneeChip user={user('octocat')} density="compact" />);
        // The visible text is aria-hidden and class-hidden on phones; the
        // accessible name must not depend on it.
        expect(screen.getByText('@octocat').className).toContain('max-sm:hidden');
        expect(screen.getByText('Assigned to @octocat')).toBeTruthy();
      });
    });
    
    describe('AssigneeList', () => {
      it('renders the unassigned marker for an empty list', () => {
        const { container } = render(<AssigneeList users={[]} />);
        // A dash, not nothing: an empty cell reads as a rendering failure and
        // misaligns the ledger column.
        expect(container.textContent).toContain('—');
      });
    
      it('caps the rendered chips and names the hidden users', () => {
        render(<AssigneeList users={[user('a'), user('b'), user('c'), user('d'), user('e')]} />);
        expect(screen.getByText('+2')).toBeTruthy();
        expect(screen.getByText('and @d, @e')).toBeTruthy();
      });
    
      it('labels the whole list for assistive technology', () => {
        render(<AssigneeList users={[user('a'), user('b')]} />);
        expect(screen.getByRole('list').getAttribute('aria-label')).toBe('Assignees: @a, @b');
      });
    
      it('honours an explicit limit override', () => {
        render(<AssigneeList users={[user('a'), user('b'), user('c')]} limit={1} />);
        expect(screen.getByText('+2')).toBeTruthy();
      });
    });
    
    describe('AssigneeStack', () => {
      it('overlaps avatars and counts the overflow', () => {
        render(<AssigneeStack users={[user('a'), user('b'), user('c'), user('d')]} />);
        expect(screen.getByText('+1')).toBeTruthy();
      });
    
      it('shows the unassigned marker when there is nobody', () => {
        const { container } = render(<AssigneeStack users={undefined} />);
        expect(container.textContent).toContain('—');
      });
    });
    
    describe('UnassignedMarker', () => {
      it('is labelled for assistive technology', () => {
        render(<UnassignedMarker />);
        expect(screen.getByLabelText('Unassigned')).toBeTruthy();
      });
    });
    
    // The client module is covered by mocking global fetch and asserting the three
    // paths, chiefly that a task id containing a slash is percent-encoded rather
    // than corrupting the route - the same regression taskPathEncoding.test.ts
    // already guards for the other task endpoints.
  2. propr-dev commented on Oct 9, 2026

    @propr-dev
    ContributorAuthor

    🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: claude
    • Model: claude-opus-5-5
    • Branch: 2892/claude-opus-5-5-add-the-shared-assigneeli-20261009-0509-0dw
    • Base Branch: 2888-epic-task-assignment-1m4
    • Worktree: issue-2892-20261009-0509-claude-opus-5-5-0dw

    🔍 Track Task Execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions