Skip to content

Don't load all the diffs ahead of time when using the Show one file at a time option in an MR

Proposal

When a user is reviewing an MR with the option Show one file at a time enabled, the batch_diffs.json requests are still triggered for the whole of the MR file set.

This proposal is to load the diff only for the current file and subsequently fetch form the server the files as the user switches to them.

Optional: We can use some somewhat-clever strategy of prefetching the neighbouring files too, if possible.

Context

The idea behind this proposal is to decrease unnecessary load form the servers but also provide a good experience, since the file will load instantly when the MR first renders, instead of having to wait for all the previous batches to load before seeing the content (imagine the user picks the last file on the file tree).

Timeline

Diffs XHR requests when using this option:

image

Questions

  • Re: backend can this be done performantly?

  • Can we leverage the existing endpoint params on batch_diffs.json? Or do we need to devise further options (say pass multiple paths, so we can load file N, file N-1 and file N+1 in one go?

  • ....

Testing

Feature spec to be added (or updated if already exists) to cycle through files one at a time to ensure no regression issues.

Edited by Jay McCure