I am trying to understand the following example from René Schilling's Brownian Motion.
Here, we try to solve the one-dimensional SDE $$dX_t = 1_{(0,\infty)}(X_t)dB_t, \; X_0 = x \in \mathbb{R}.$$
Take the stopping time $\tau = \inf \{t \ge 0: x+B_t \le 0\}$, and set $X_t:= x+B_{t\wedge \tau}$.
Then, it is clear from the equations here, since $\tau(\omega)>s$ is the same as $x+B_{s\wedge\tau(\omega)}(\omega)>0$ (by the continuity of the Brownian Motion), and we get the result.
But why does this argument still hold if the initial condition $X_0$ is a random variable independent of $B_t$? In this case, I think we need to take the product space of $X_0$ and $B_t$, but I am not sure how to formulate the equivalence of the middle equality.
I have been struggling to set these details out. I would greatly appreciate any help.

For $s<\tau$ you have $x+B_s>0$ and for $s\ge \tau $ you get $x+B_{s\land\tau}=x+B_\tau=0$ so that indeed the claimed equality holds.
If $X_0$ is a random variable, it has of course also to be used in the construction of the random variable $\tau$. The whole computation only invokes one single point of the probability space, if you fix that point then it is simple calculus (with Ito integrals).