if it is related to the ac, it would have to be part of the high idle circuit. if it is acting up and turn turn the ac off, does it level out?

one thing to keep in mind is the coil could be bad and still putting out the correct voltage. I dont personally own a voltmeter that can read the voltage sent by a coil to a spark plug. BUT if you want to test the ignition system do this: take off the appearance covers and etc that hide the wires, and coil pack. wait until it is dark. start the car, and mist water over the wires and coil pack, if you see sparks, or it quits running, then replace what ever you spray. (spray on wire at a time. then the coil pack). do not touch anything in the engine while you do it or you will get shocked.

Ok, on with the ac. IT could be several things. I would immediately jump to the coolant temp sensor since you have had issues with the thermostat. so start with that.