When using spells such as Invisibility and Mislead, and features or abilities such as the One with Shadows invocation and Misty Escape, you may become invisible and remain invisible until certain time limits or actions are taken, such as attacking or casting a spell.
Invisibility (Spell - PHB pg.254)
A creature you touch becomes invisible until the spell ends. Anything the target is wearing or carrying is invisible as long as it is on the target’s person. The spell ends for a target that attacks or casts a spell.
Misty Escape (PHB pg. 109)
...you can vanish in a puff of mist in response to harm. When you take damage, you can use your reaction to turn invisible and teleport up to 60 feet to an unoccupied space you can see. You remain invisible until the start of your next turn or until you attack or cast a spell.
I know some features allow you to remain invisible while attacking, like Greater Invisibility , but for those that do not, when exactly do you lose the invisibility trait? Is it different depending on whether or not you cast a spell, make a melee attack, or make a ranged weapon attack?
For instance, do you lose invisibility as soon as you nock an arrow, or when you let it fly, as simply placing it on your bow, or even drawing back the string is not attacking, per se.
Or perhaps you've cocked back a closed fist or heavy mace, do you lose your invisibility as soon as you begin to bring back the weapon, or when the steel connects with the target?
Also, if you were to cast Find Familiar, which has a casting time of 1 hour, are you invisible the entire time you are preparing the ritual up until the point the spell is finally cast, or are you immediately revealed as soon as you begin to prepare the ritual spell?
While this may seem trivial, it is something that I've found is very important for plans I intend to carry out, or even for a thief who is steadily preparing his getaway steed (Find Steed) after he breaks out of both invisibility and the home he is pilfering. Perhaps, there is an assassin who has crept up to his target and is slowly drawing back his blade to finish him off, but must remain invisible to carry out the entire attack.
There are several instances where I could see this coming into question. And RAW or otherwise creditable references would be greatly appreciated.