@brew_cat I had to carefully pour myself a beer while pondering your question.
You hit on two things - shorter one first: The initial foamy pour with the line out of the fridge is because CO2 comes out of solution as the beer warms while sitting in the hose. The carbonation chart says that at your 8 psig and fridge temps, about 2.2 volumes of CO2 will dissolve into beer. At the same pressure and room temps, that beer will only hold about 1.2 volumes in solution. As the cold carbonated beer from the keg warms in the line, CO2 comes out of solution and you have a line full of CO2 gas and flat beer, which pours as foam. Keeping the line cold, and/or keeping the warm section of line as short as possible, solves that issue.
As for cold line length, its a balancing act. About 5' of 3/16" line happens to be a decent balance for a keg at 8 psig. What we really want is for the pressure to drop gradually along the line as the beer flows from keg pressure to the room pressure of 0 psig. The higher the keg pressure, the more pressure drop desired along the line. Friction along the line is what causes pressure to drop as the beer flows - smaller hose diameter means more pressure drop as does longer length and higher flow rate. All 3 need to be balanced. For example, if you open the tap only very slightly, flow rate is low so there is minimal friction along the line - all the pressure drop happens at the tap and you get a glass of foam. At the other extreme, if we poured beer at a high flow rate from a short, large diameter fire hose, we'd also get a glass of foam.
A good pour is just another one of life's balancing acts.