CAUTION: My wife and I went to the gym. I left my phone in the trunk. She took her phone and locked the car. I left the gym early, so asked her to unlock the car for me. But when she looked at her phone, the car was unlocked. When I got to the car I just open the door, got in, stepped on the brake pedal and it was ready to drive (with my phone still in the trunk).
I tried using my card key to lock the car with my phone in the trunk. Swiping the card locked (folded the mirrors). I put the card 5 feet away, then just grabbed the door handle and it opened. Again, ready to drive.
If you leave a phone with the app in your trunk, you have to turn it off. You can leave a card in the truck as it has to be a few inches from the console or door pillar to function.
My 2016 Camry detects the key fob. I can only lock the car with a key fob in the truck with my key fob outside the car. So you can't accidentally lock your key fob in the trunk. Maybe Tesla could program something similar. In the mean time they should give us a warning that we aren't locked.