defects of the first scene: Heimdall conjuring the bifrost, is power of the YggDrasil and not him , they gave it to him in the movie, if he had this power could have run from Hela at Ragnarok. Loki is a sorcerer with great intellect and a born strategist, acted with stupidity, is swift and used his left hand to wield a dagger against Thanos instead of magic and open a gate to escape (because it opens portals, is a Wizard) with the tesseract he could creating omnipresence, he could have died when entering the portal with Thor and the Hulk and Thanos attacking the gate making each go to a side and he get hurt or die. Or he could fall somewhere find Blackberry (would be better than show Thor forging gun, unnecessary scene)
Loki is a wizard, can open portals, has great intellect, had the space stone, you know create illusions (changing reality, he tricked Odin and in Hqs tricked the magicians of the Earth) could escape easily and take Thor and the Hulk with him. Could play the Tesseract false to Thanos, get Thor and by using the tesseract to create omnipresence open a Fast portal and Get Hulk too, Thanos could perceive and launch a magic within the portal that make everyone fall in a different place and he could die or fall in the land of the Dwarves and Thor meet him there when he was forging the weapon.The scene stole the magic and the intelligence of the Loki that show in 10 years in movies, making him attack Thanos with a knife and still using the left hand, and the character is right-handed. It would be the same as putting Tony Stark trying to kill Thanos without armor, using only hand-to-hand combat.