To me, it's a little clearer if you put the problem into the Lagrangian format:
Write ##ds = \sqrt{dx^i dx_i} = \sqrt{\frac{dx^i}{ds} \frac{dx_i}{ds}} ds = \sqrt{\dot{x}^i \dot{x}_i} ds##, where ##\dot{x}^i \equiv \frac{dx^i}{ds}##. I know that seems kind of silly, because the expression ##\sqrt{\dot{x}^i \dot{x}_i}## is just identically equal to 1, but it makes the problem more conceptually similar to the classical Lagrangian formulation of mechanics:
##S = \int \mathcal{L}(x^i, \dot{x}^i) dt##
where the Lagrangian depends on location, ##x^j## as well as velocity, ##\dot{x}^j##. In our case, we switch the "time" parameter from ##t## to ##s## to get:
##S = \int \mathcal{L}(x^i, \dot{x}^i) ds##
where the relativistic lagrangian ##\mathcal{L}## is ##\sqrt{\dot{x}^i \dot{x}_i}##.
Now, if you vary the lagrangian, you get:
$$\delta \mathcal{L} = \frac{\partial \mathcal{L}}{\partial x^i} \delta x^i + \frac{\partial \mathcal{L}}{\partial \dot{x}^i} \delta \dot{x}^i$$
If you're dealing with Special Relativity, as opposed to General Relativity, then the relativistic Lagrangian doesn't depend on ##x^i##, only on ##\dot{x}^i##, so you have:
$$\delta \mathcal{L} = \frac{\partial \mathcal{L}}{\partial \dot{x}^i} \delta \dot{x}^i$$
Since ##\dot{x}_i = \pm \dot{x}^i## for Special Relativity (in GR, or when using noninertial coordinates, you have to write: ##\dot{x}_i = \sum_{ij} g_{ij} (\dot{x}^j)^2##), we can write: ##\mathcal{L} = \sqrt{\dot{x}^i \dot{x}_i} = \sqrt{\sum_i \pm \dot{x}^i}##. (In taking the derivative, there is a factor of 2 from the square-root, and a factor of 2 from ##(\dot{x}^j)^2##, and they cancel). So
$$\frac{\partial \mathcal{L}}{\partial \dot{x}^i} = \frac{\pm \dot{x}^i}{\sqrt{\dot{x}^i \dot{x}_i}} = \frac{\dot{x}_i}{\sqrt{\dot{x}^i \dot{x}_i}} $$
(That's slightly misleading: in the numerator, the ##i## is some particular index, while in the denominator, ##i## is a dummy index that is summed over.) So
$$\delta \mathcal{L} = \frac{\dot{x}_i}{\sqrt{\dot{x}^i \dot{x}_i}} \delta \dot{x}^i$$
Since ##\delta \dot{x}^i = \dot{\delta x^i}##, we get to the final form:
$$\delta S = \int \delta \mathcal{L} ds = \int \frac{\dot{x}_i}{\sqrt{\dot{x}^i \dot{x}_i}} \dot{\delta x}^i ds$$
Now is when you use partial integration: Write ##\frac{\dot{x}_i}{\sqrt{\dot{x}^i \dot{x}_i}} \dot{\delta x}^i = \frac{d}{ds} (\frac{\dot{x}_i}{\sqrt{\dot{x}^i \dot{x}_i}} \delta x^i) - \frac{d}{ds} (\frac{\dot{x}_i}{\sqrt{\dot{x}^i \dot{x}_i}}) \delta x^i##. That's just using ##A \frac{d}{ds} B = (\frac{d}{ds} AB) - (\frac{d}{ds} A) B## with ##A = \frac{\dot{x}_i}{\sqrt{\dot{x}^i \dot{x}_i}}## and ##B = \delta x^i##. So we have:
$$\delta S = \int [\frac{d}{ds} (\frac{\dot{x}_i}{\sqrt{\dot{x}^i \dot{x}_i}} \delta x^i) - \frac{d}{ds} (\frac{\dot{x}_i}{\sqrt{\dot{x}^i \dot{x}_i}}) \delta x^i] ds$$
Since integration and taking derivatives are sort of inverses, we can write (putting the limits back in): ##\int_a^b \frac{d}{ds} (\frac{\dot{x}_i}{\sqrt{\dot{x}^i \dot{x}_i}} \delta x^i) ds = (\frac{\dot{x}_i}{\sqrt{\dot{x}^i \dot{x}_i}} \delta x^i) |_{a}^b##. So
$$\delta S = [\frac{\dot{x}_i}{\sqrt{\dot{x}^i \dot{x}_i}} \delta x^i]|_a^b - \int_a^b [\frac{d}{ds} (\frac{\dot{x}_i}{\sqrt{\dot{x}^i \dot{x}_i}}) \delta x^i] ds$$
Now, we can remember, after intentionally forgetting temporarily, that ##\sqrt{\dot{x}^i \dot{x}_i} = 1##. So this simplifies to:
$$\delta S = [\dot{x}_i \delta x^i]|_a^b - \int_a^b (\frac{d}{ds} \dot{x}_i) \delta x^i ds$$
Your textbook is apparently using ##u^i## to mean ##\dot{x}^i##.
I'm a little fuzzy about why this business of forgetting and then remembering that ##\sqrt{\dot{x}^i \dot{x}_i} = 1## is necessary, but it works.