/** * Moves a retry-suppressed inline send error to the session selected by an * inactive-session resume. The record stays visible while the retry runs, but * must follow the eventual mutation target so success/error can resolve it. */ export function migrateSuppressedSendError( errors: Readonly>, sourceSessionId: string, resolvedSessionId: string, ): Record { if (sourceSessionId === resolvedSessionId) return errors as Record const source = errors[sourceSessionId] if (!source?.restoreSuppressed) return errors as Record const next = { ...errors } delete next[sourceSessionId] // The retry being resumed is the authoritative in-flight operation, so it // intentionally supersedes any stale target-session error record. next[resolvedSessionId] = source return next }