4. Solution. First, let's determine the values that $x$ and $y$ can take:

$$
1-\sqrt{x-1}=\sqrt{y-1}
$$

from which $\left\{\begin{array}{c}x \geq 1, \\ 1-\sqrt{x-1} \geq 0 .\end{array} \rightarrow x \in[1,2]\right.$. Similarly, $y \in[1,2]$.

Solve the equation:

$$
1-\sqrt{x-1}=\sqrt{y-1}, \rightarrow y-1=1-2 \sqrt{x-1}+x-1 \text {, i.e. } y=1-2 \sqrt{x-1}+x
$$

Let $\sqrt{x-1}=t$, then we have $\left\{\begin{array}{c}x=t^{2}+1, \\ y=1-2 t+t^{2}+1 .\end{array} \rightarrow x+y=2 t^{2}-2 t+3\right.$.

Since $x \in[1,2]$, then $t \in[0,1]$. Thus, we need to investigate the quadratic function $f(t)=2 t^{2}-2 t+3$ for its maximum and minimum values on the interval $t \in[0,1]$. We can rewrite the function as

$$
f(t)=2\left(t-\frac{1}{2}\right)^{2}+\frac{5}{2}
$$

The graph of this function is a parabola with its branches directed upwards, with the vertex at the point $\left(\frac{1}{2} ; \frac{5}{2}\right)$. Therefore, the minimum value is taken at $t=\frac{1}{2}$ (when $x=y=\frac{5}{4}$), and the maximum value is taken at $t=0$ and $t=1 f(0)=f(1)=3$ (when $x=2, y=1$ or $x=1, y=2$).
Answer: $(x+y)_{\max }=3$ when $x=2, y=1$ or $x=1, y=2, (x+y)_{\min }=\frac{5}{2}$ when $x=y=\frac{5}{4}$.