Mains AC TRIAC offset circuit
Yikes!  The first thing I see is a LED being driven directly from the output of a full wave bridge that rectifies line voltage.  POOF!

You need to limit the current to what the LED in the opto can handle, and to minimize the power dissipation.  You also have to think about the maximum reverse voltage of the LED.  That's usually around 5 V, but the definitive answer is in the datasheet, of course.

For detecting line power, I usually use two optos back to back.  Each LED is driven from opposite polarity, so protect each other from excessive reverse voltage.  The two outputs are wired in a push-pull arrangement.  That gives you good drive and symmetric response.

Another problem is the gate drive of the triac.  It doesn't look like you have anything turning the gate on, only off.