Objective
- Add alphabetical sorting to Tools → Contacts so staff can scan large contact lists and spot duplicate profiles next to each other.
- Support duplicate-cleanup workflows where teams need to merge contacts after visually comparing names in list order.
- Reduce daily friction for client care and schedulers who today scroll or search without a predictable name order.
Background
- Product feedback: staff want to sort contacts A–Z to find duplicates to merge. Reporter also suspects a separate search bug may have created duplicate contacts, but the immediate blocker is no sort control on the contacts table.
- Screenshot (current UI — search, role/period volume filters, tag filter; no sort):
- Current behavior (confirmed in code):
- Tools → Contacts (
ContactsListClient) loads GET contact with pagination, optional search, tag, and _roleId (for volume metric columns). No sort parameter is sent.
ContactsTableControls exposes search, tag, role, and period (3m / 6m / 12m) — no sort UI.
- Backend
GET /contact without search uses MainModel.find(...).skip().limit() with no .sort() — list order is not alphabetical.
- With search, results sort by relevance score, not name.
- Contact merge already ships (ATT-164 — Done): staff can merge two contacts from a profile, but finding duplicates at scale is still hard without list sort or duplicate discovery tooling.
Product Decisions
Locked
- Problem type — Feature gap. Alphabetical list sort does not exist today; this is not a broken sort control.
- Primary surface — Tools → Contacts main table (
/tools/contacts).
- User goal — Make duplicate profiles easier to see in list order, then use existing merge to consolidate.
- Merge scope — Contact merge is already built; this issue is list sort / findability, not rebuilding merge.
Open
- Sort key — Sort by last name then first name, first name only, or displayed full name as shown in the Name column?
- Default order — Should A–Z become the default list order, or stay unsorted until the user picks sort (preserving today’s behavior for users who rely on current order)?
- Sort directions — A–Z only, or A–Z and Z–A toggle?
- Sort + search — When the user is searching, should name sort override relevance ranking, be disabled, or be a separate “sort results by name” option?
- Sort + filters — When Role, Period, or Tag filters are active, should sort apply to the filtered page of results (server-side across full dataset vs client-side on current page only)?
- Duplicate discovery — Is alphabetical sort enough for v1, or should this link to ATT-1194 (duplicate report by email/phone/name)? Reporter’s duplicate worry may need that broader tool, not sort alone.
- Search-created duplicates — Reporter mentioned a search bug that may have created duplicates. Confirm separate bug ticket and keep out of scope for this feature unless product wants a combined cleanup epic.
Scope
Frontend (attik-frontend)
- Contacts list —
src/app/tools/contacts/ContactsListClient.tsx fetches paginated contacts; add sort control and pass sort params to the API.
- Table controls —
src/app/tools/contacts/ContactsTableControls.tsx is the natural place for a sort selector (alongside search, tag, role, period).
- Merge entry points — existing merge UI (
ContactSearchForMerge, contact profile merge flow) unchanged unless product ties sort rows to a “merge duplicates” shortcut.
Backend (attik-backend)
- List endpoint —
src/routes/contact.ts GET /contact: add supported sort query (e.g. lastName, firstName) for the non-search list path; ensure sort is stable and works with includeMeta pagination.
- Search path —
searchContactsOnly currently sorts by score; define behavior when sort is requested alongside search (see Open #4).
Out of scope (unless product expands)
- Automated duplicate detection / duplicate report grid (ATT-1194).
- Multi-contact merge in one flow (ATT-1191).
- Root-cause fix for search bug that may have created duplicates (track separately when ticket ID is known).
References
- Screenshot: inline image above
- Slack feedback thread (duplicate cleanup + search bug mention)
- Related backlog: ATT-1120 (alphabetical sort), ATT-1194 (duplicate discovery)
- Merge (shipped): ATT-164
- Key files:
attik-frontend/src/app/tools/contacts/ContactsListClient.tsx, attik-backend/src/routes/contact.ts