Diagonalizable Operators and characteristic polynomials
Consider each $d_i\times d_i$ block separately. Clearly every $d_i\times d_i$ block commutes with the corresponding diagonal block of A, which is a multiple of the identity block, so that the dimension of V is at least $d_1^2+...+d_k^2$.
Since the action of any such B leaves the eigenspaces of A invariant, B is a block diagonal matrix of the same type as A (of course the blocks of B are not necessarily diagonal themselves), consequently the dimension of V is at most $d_1^2+...+d_k^2$.