IDLE PROBLEMS ?!
Your trusty 4.0 ltr. Is crying out for attention . Aside from a tune up from the O2 sensor straight up to the spark plugs , cleaning idle air passage and motor plunger , the EGR port is probably caked up and the valve itself maybe malfunctioning and in need of replacement . You should also look for intake manifold leaks and check for excess movement from the distributor shaft .
Don't overlook a leaking vacuum line or accessory that draws vacuum that will contribute to poor idle . As long as you must go this far in your diagnostics , a compression check should be performed as well . A leak down test couldn't hurt if you got a tester . Its nice to know how your compression is but the leak rate will tell more about the engine than just how much air it can compress. You'll want to know what your engine is doing with this air , like , are you loosing it through rings , poor valve seal, etc. . Your engine is trying desperately to run , but there is a fault(s) that are causing it to run rough. Read the spark plugs and start from there . The plugs will tell you how your engine is running. Misfiring, running hot , rich or lean , leaking injectors , etc. .
A lot to work on , but neglect causes these problems even when we swear we are doing all we can for our rigs . Check these
items and record the results . A lot can be researched just from what you find to further diagnose causes. Best of luck .