mirror of
https://github.com/multica-ai/multica.git
synced 2026-08-04 17:18:35 +02:00
Replaces the half-functional `position = 0` write-default + client-side `sortIssues` re-sort with a server-authoritative sort_by/sort_direction matrix and float8 fractional indexing for drag-drop: - Server: ListIssues / ListGroupedIssues accept sort_by (position, priority, start_date, due_date, created_at, updated_at, title) and sort_direction; unknown values silently downgrade to created_at desc per the API compatibility contract. - Server: new issues allocate MIN(position) - 1.0 inside the existing IncrementIssueCounter transaction so the legacy `position ASC` ordering still places new issues at the top for old desktop clients. - Server: migration 093 backfills existing rows with sparse float positions (newest first) and adds a (workspace_id, status, position) index. - Server: new PositionRebalanceService re-spaces a bucket asynchronously once the neighbour gap drops below 1e-9, then publishes the new `issue:rebalanced` WS event. - Frontend: issueKeys.list / myList carry a sort tuple in their key, so every list-cache reader/writer migrated from exact `setQueryData` to prefix `setQueriesData` / `getQueriesData` (mutations, ws-updaters, delete-cache, mention-suggestion, issue-chip, issue-detail). Snapshots and rollbacks iterate per-variant so every mounted sort variant rolls back cleanly. - Frontend: `packages/views/issues/utils/sort.ts` deleted; list-view / board-view trust server order, and drag-drop is guarded to Manual sort with a toast pointing the user back to Manual. - Frontend: `issue:rebalanced` parses through `parseWithFallback` with a zod schema + EMPTY_ISSUE_REBALANCED_PAYLOAD fallback; both the strict and the fallback paths invalidate `list` / `myAll` / `assigneeGroupsAll` / `myAssigneeGroupsAll` prefixes so server-authoritative refetch fixes order. - Tests: Go regression for unknown sort_by fallback and `MIN(position)-1` ordering; new core schema test covers the four failure modes for the rebalance payload. Existing 575+ FE tests and full Go suite pass. Phase 1+2 are bundled per Leader's release directive — splitting would leave a window where new issues regress to "appears at the bottom" for old clients. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>