First, check your SES ("Service Engine Soon" dash warning light) codes. Jump terminals A and B (the two top right terminals) of the computer plug under the dash just below the steering column and turn the ignition on but do not start your truck. Count the flashes of the light. It will blink two numbers, pause, repeat three times, then go to the next code. See the link in my signature for the buyers guide, scroll down to download the document which tells you what the codes mean. This will take only a few minutes and can
save you hours of useless and expensive guessing and replacing working parts, like the TPS you already replaced!
Then, if there are no codes, the shop manual says to check this list for a "hunting" idle (surging is considered an issue while in motion, not while at idle says the manual).
> Motor mounts damaged, grounding on frame, mispositioned
> Battery cables clean and secure. Loose or bad grounds will cause the ECM to not have a consistent idle.
> Timing (doh!)
> IAC (Idle air controller). The manual says if it's stuck open, high idle. Stuck closed, low idle. If stuck part way, rough idle and "will not respond to engine load changes". Reset it by turning the ignition on then off one time. Remove and inspect for clogging, clean or replace if needed.
> Alternator less than 9 volts or more than 16 volts
> PCV valve
> MAP - to test, start engine, unplug electrical connector. If idle improves, replace it.
> A/C refrigerant pressure too high. Check for overcharge or faulty pressure switch
> Leaking fuel injectors
> Fuel pressure. Less than 9 PSI will cause problems. Too high will cause rich condition and gas odor in exhaust.
> Sticking throttle shaft. If a high idle, the ECM will not control the idle.
> Vacuum leaks
> EGR - there should be no EGR at idle.
> Inspect O2 sensor for silicon contamination. If it's got a white coating, replace it. Check for voltage less than 300 mV (0.3 volt). 800mV or more means contaminated O2 sensor.
I am experiencing something similar - an occasional miss at idle - and I think it's the IAC but will confirm after I put the one from my other truck in there.