Without spoilers, there are several choices that can lead to the saving of the Nightsong while Shadowheart is in the group at the time.
And as for those complaining that Shadowheart left them because they left her behind when exploring a Shar Temple, complete Shar related tasks, and do the single most important decision to Shadowheart's entire story-line with her... What other outcome would you expect?
Choices have consequences. THis isn't the typ of game where you can make any choice you want, and it has no effect; I applaud Larian for making choices ACTUALLY MATTER.
In most cases you do get one final chance to change a companion's mind, but if you fail that - yes, they will leave (or sometimes even attack you).
I adore comments like these, they are rather disingenuous and go out of their way to ignore what people are actually saying.
The argument that Larian has achieved somethin brave and special about choices having actual consequences is rather funny since every RPG in existence has a scene/scenes like these. Companion has low opinion of you/you don't do something for them they leave, so again nothin ground breaking. (and they have all been criticized if done poorly so why is Larian any different)
What people take issue with is how it was done. Like OP and others have stated the bigger issue is with the writing and not the leaving.
This character (Shadowheart) that is willing to attack you (and dies for it) at the beginning of the game if you dare stand in her way/take the artifact from her is suddenly willing to disappear just like that. No scene where she sneaks back into the camp and tries to steal the artifact or kill you. No scene where she shows up at the House of Grief in Baldur's Gate, nothing.
But then again this is the same game that suddenly turns Shadowhart poly because they needed that option despite that being out of character for her. (this game has a tendency to forget/rewrite and make character act like brainlets for the sake of the 'omg choices/reactions')
This game is wide as the ocean and shallow as a puddle, its illusion is rather fun as long as you don't dip more than your pinky into it.
A scene from EA - (rewrites have affected this game and its story more than anyone is aware of)
A scene from the released game - (I'm being hunted and this is the only artifact that is stopping me from being a mind flayer to I don't need it and just disappearing from the game)