Tricky situation as it involved three programs: the terminal, the shell and the newly launched app.
Your approach of essentially by-passing the shell and communicating between the two GUI apps is likely the most viable.
Otherwise we would need some standard protocol/interface between shell and terminal so that the shell could ask for a new activation token every time it launches something. And there are many shells, probably too many to make this work for enough users.
Yeah, it is all not that easy. Perhaps others have better ideas or one will be able to generalize some dbus api other terminal emulators could then expose, too. Or we see the solution is crap in real life ;)
The primary issue is always that the shell is an “unaware participant”, essentially blocking the flow of information between the terminal and the newly launched application. Your approach essentially creates a by-pass communication channel which is likely the least hackish way even if it might not feel like that.
I have tried to come up with alternative ideas but they all have their own difficulties.
One option would be to use a mechanism like LD_PRELOAD to intercept the shell’s exec-family calls and inject an updated activation token.
A rather wild idea was to run the shell in-process on a thread of the terminal. This would then allow access to the now shared environment.
Probably best to somehow get various terminal developers together to think about this. They all have this use case at hand and best understand how they are currently “embedding” the shell.

