mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-17 11:48:42 +02:00
* fix(labels): apply attach optimistically so chips render before round-trip Attach went through onSuccess only, so users waited for the server before seeing the new chip — out of step with detach (already optimistic) and with status/assignee/priority via useUpdateIssue. Mirror the detach pattern: snapshot the byIssue cache, look up the full label from the workspace list cache, patch byIssue + the issue list/detail caches via onIssueLabelsChanged in onMutate, and roll back on error. onSuccess and onSettled keep the existing reconcile behavior. * fix(labels): only patch attach when prev label set is known GPT-Boy's review caught a corruption case: when byIssue cache was unpopulated (user clicked before issueLabelsOptions resolved), the optimistic patch fell back to an empty prev.labels, then mirrored [label] into issue list/detail via onIssueLabelsChanged — wiping any denormalized labels already on the issue. Worse, onError only restored byIssue when ctx.prev existed, so the wipe persisted on failure. Match useDetachLabel's invariant: skip the optimistic patch unless prev is in cache. The chip will wait for the round-trip in the rare race window, but caches stay consistent and rollback always works.