If you run the sample code below you will see a series of short strings scroll down the serial monitor. Then, type something to send back and you will see there is a 1-1.5 second interruption in the stream of strings. My UNO to PC programs "talks" back and forth in real time but this delay when switching between send and receive puts a damper on the flow. Is there a way to eliminate the delay?
Serial.readString() reads characters from the serial buffer into a String. The function terminates if it times out (see setTimeout()).
From the Serial.setTimeout() reference page:
Serial.setTimeout() sets the maximum milliseconds to wait for serial data. It defaults to 1000 milliseconds.
So that delay you're encountering is the wait for Serial.readString() to time out. You might consider using Serial.readStringUntil() instead. That function has the same timeout behavior as Serial.readString(), but it will immediately return if the terminator character is received. You can set Serial Monitor to automatically add a terminator character to the end of the sent data in its line ending menu. If you set the Serial Monitor line ending menu to "Newline" then it will add a newline (\n) to the end of the text you send from Serial Monitor. Then you could use this in your code:
str = Serial.readStringUntil('\n');
If you wanted to stick with Serial.readString(), then you might consider using Serial.setTimeout() to set the timeout duration to something less than the ridiculously conservative 1000 ms.