I'm trying to understand the extent to which taking invariants of a reductive group action "commutes" with completion. More precisely:
Let $X = \operatorname{Spec} A$ be a reduced finite type affine scheme over $\operatorname{Spec} R$, where $R$ is a discrete valuation ring. Let $G$ be a reductive algebraic group with connected fibers over $\operatorname{Spec} R$ that acts on $X$, and let $G'$ be the formal completion of $G$ at the identity in the special fiber.
Now if $x$ is a point in the special fiber of $X$, defined over the residue field of $R$, and corresponding to a maximal ideal ${\mathfrak m}$ of $A$, the action of $G$ on $X$ induces an action of $G'$ on the formal completion $X_x$ of $X$ at $x$. Let ${\mathcal O}_{X,x}^{G'}$ denote the ring of functions on $X_x$ that are invariant for this action.
If we let ${\mathcal O}_X^G$ denote the ring of $G$-invariant functions on $X$, and let ${\mathfrak m}'$ be the intersection of ${\mathfrak m}$ with ${\mathcal O}_X^G$, then we have a natural map:
$$\left({\mathcal O}_X^G\right)_{\mathfrak m'} \rightarrow {\mathcal O}_{X,x}^{G'}$$
[Here the subscript ${\mathfrak m'}$ denotes completion at ${\mathfrak m'}$.]
Under what conditions is this map an isomorphism?
It's clear that the map fails to be injective if there is an irreducible component of $X$ that meets the closure of the orbit of $x$ but does not contain $x$: the left hand side ``sees'' this component whereas the right hand side does not. Will the map always be injective if $x$ lies on every irreducible component that meets the orbit closure of $X$?
Will the map be surjective in general?
I am happy to make additional assumptions to guarantee that the map is an isomorphism. (In particular, in the applications I have in mind, $G = {\operatorname{GL}}_n$, $R$ is a $p$-adic integer ring, and $X$ is a complete intersection that is flat over $\operatorname{Spec} R$.)

