Your thoughts are almost accurate.
- If the second action of the two entails the ending of the first, then the past perfect simple emphasises completion, while the past perfect continuous emphasises duration.
I had waited for three hours when you finally arrived.
Emphasises the completion of the action "Waiting".
It indicates that the action was complete at the time referred to. This does not mean that the job itself was completed - it merely indicates a hiatus in the job when the manager arrived.
I had been waiting for three hours when you finally arrived.
Emphasises the duration of the action "Waiting".
It indicates that the action has started but was incomplete at the time referred to.
And in both sentences the meaning is the same: I waited for three hours, then you arrived.
You made a distinction, therefore the claim that they are the same cannot be true.
The other problem is that the verb you have chosen (to wait) is durative: this will obscure the point of your example.
- If the second action however, doesn't entail the ending of the first, then the past perfect simple means the ending and completion of the first action, while the past perfect continuous means that the first action could've either
went on continued, or stopped at that moment.
I had worked for three hours when the manager came.
He came and I had already finished working those 3 hours.
This contradicts your earlier claim.
I had been working for three hours when the manager came.
Three hours exactly [There is no “exactly” in the original example.] had passed the moment he came. Maybe he came to check how the work was going, and didn't interrupt and left, so I resumed working. And maybe he asked me to come to him, so that I stopped working. I don't know which of these two speculations or if something else happened, so both meanings are possible.
You have missed the point of the past perfect. Its use is to provide context and background to the “main event”, i.e. the “theme” of the sentence.
In “I had been working for three hours when the manager came”, what you are telling us is that the manager arrived - the theme is the manager came. “I had been working for three hours” is background/context to the manager’s arrival.
“I had been working for three hours” tells us that the process of working had started but was incomplete – you were still working when the manager arrived. The cause of this meaning is not the duration but the incompleteness - regardless of what you did when the manager arrived - the intention was to continue as the job was incomplete.
Finally, what happens after the manager leaves is not the concern of the verb form that you have used so it indicates nothing.