My personal advice (as someone who has transitioned from a postdoc to industry) is that you should treat your postdoc like any other job. Generally it's a bad idea to announce you are looking for another job before you have a signed offer in hand, because it puts you in a very weak position. On the one hand, your host may be understanding and support you. On the other hand, they may look for a way to cut you out of the group. Either way, their reaction is not something you can control, and not a risk I would personally want to take.
I would not let the impact your departure will have on the work affect how you approach this situation. Ultimately that is not your responsibility. If the work is truly important to the PI and you are legitimately the only person who can do it, then they should hire you to do that work full time (I realize this isn't common in academia, but that's a flaw of the system you are working in). The fact that they haven't and won't is why you are in your current situation. I think it's more likely that either you are really not as irreplaceable as you think and the PI will find a student to get up to speed on what you've been doing, or it will turn out there is a path for the PI to achieve their main objectives without carrying on the direction you've been pursuing. Either way, the work and the PI will be fine. At the end of the day, there will be likely be some temporary pain associated with your departure, but that is completely normal ("part of the cost of doing business") and not your responsibility.
I think it's a good idea to leave on good terms if you can and try to give notice with some time to help finish off and/or transition work to others. But I don't think you should put yourself at risk to achieve that goal. Therefore, I think you should wait until you accept an offer to talk to your PI.