How is the buildx TUI implememtned?

I was thinking of making a similar UI for CustomPiOS that I build and maintain, that has the build output that buildx has (I need to re-implement it in python):

I was wondering, how is this implemented?

I thought it would be somewhere around here:

But I can’t see where it would send the special chars to the terminal to go up lines, etc.

Any chance someone here could point me to the location?

Since it is written in GO and you want Python, you should search for “overwrite the same line in python”. A simple bash solution:

And a python

1 Like

Its not only the return carriage. Its going up and updating at least 3 different sections. I would like to see the code itself because it might have some design insight too.

I can read go to see what was done.

If you want to see the source code, you could clone buildkit (GitHub - moby/buildkit: concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit) and search for some texts seen in the progress to get closer where builtkit writes to the terminal.

That progress info is generated by buildkit.

I didn1t try to find whre it writes the terminal, but if I had to implement a feature like this, I would probably write calculate the size of the terminal, store the lines, calculate the available lines remained after the finished layers, and write the end of the list to the remaining lines in a loop. If you find the exact code that implements it, please, share it si we can learn from it too.