How to automatically compensate (LDR?) for ambient light so as to eliminate the need for adjusting manually with potentiometer.
You don't explain what you want to detect with your phototransistor, but since it's not ambient light I'll presume that you want to detect some kind of data signal.
For remote control signal reception IR is used so you can use a photodetector which is less sensitive to visual light.
IR receiver modules also have a bandpass filter around a modulation frequency, often 36 or 38kHz,
so that the modulator again reduces sensitivity for ambient light, which is often constant, in case of daylight, or quasi constant for incandescent bulbs.
A third measure is a built-in AGC (Automatic Gain Control), which adjusts the receiver's sensitivity based upon the received signal strength. This can often be seen on an oscilloscope image: while there's no signal received the module sees all kind of noise, but as soon as the right signal is detected this noise is suppressed, and only the actual signal remains.
If you have some control over the transmitter, a very useful technique can be to modulate or switch it, and then filter the output to reject anything not at the modulation frequency or not synchronized with the switching of the source.
This can take various forms, from passive or op-amp type solutions to complicated DSP ones, to simple synchronous ideas such as "subtract the received level when the source is off from the received level when it is on"