The short answer: using the info you and your friend provided, Ripple did what was best for everyone.
I don't know how to pull up the details of the transaction number you link to (I have no affiliation with Ripple other than as a user). But using the Ripple Live Graph I can infer the account of your friend and I note that currently your friend has no trust line to Bitstamp.
- why didn't it send entirely Bitstamp BTC to Bitstamp?
So I'm guessing that what happened was that your friend had 0.1022 BTC IOU from Bitstamp but had the trust set to zero indicating they don't want more and would like to get rid of what they have (i.e. your friend told Ripple they don't trust Bitstamp). Your friend had specified that they trust you to pay them back BTC by opening a trust line to you
It's in your friends best interests to hold an IOU from a trusted source (you) rather than an untrusted source (Bitstamp). It's in your interest to have Bitstamp get the funds you asked to send in the cheapest way possible.
The way Ripple found to achieve both those results at once was to route part of your payment through your friend. Both directly sending back Bitstamp's IOU and routing through your friend had no transfer fee, only the 0.000010 XRP transaction fee) so either should be equally good to you.
- how are [we] supposed to settle that?
As with any loan between friends it's up to you. With some friends I've made my repayment policies very clear, with others I'm more informal. [As an asside, I'll note that previous ripple implementations like classic.ripplepay.com wouldn't let your friend trust you without you agreeing.]
i.e. should I explicitly send BTC through Ripple to my friend
No, that would add to the debt, giving your friend more of your IOUs.
or simply when he tries to spend them he'll tap from my pool (hence no explicit action is needed)?
That is most likely the best option, and certainly the simplest. When they next send a payment, Ripple will consider going through you. If the recipient trusts you then they may end up with your IOU (by the way your IOUs have no trasfer fee, Bitstamp IOUs have a 0.2% transfer fee).
If the recipient trusts Bitstamp (and you still hold the Bitstamp IOU) then the recipient may get Bitstamp IOUs and your IOU will decrease or zero.
If before this, you were to use your Bitstamp IOU in payments (e.g. to Bitstamp for withdraw) then you'd have a negative balance and your friend would be unable to use (spend) your IOU except to others that accept it (trust you).
If your friend wants to explicitly redeem your IOU (i.e. asks you to pay him back) you could send him actual bitcoin outside of Ripple and at the same time he'd pay you the matching amount in Ripple to zero/decrease your debt. If you hold Bitstamp IOUs (perhaps you get some more via a deposit just so you have enough to cover your debt because you were asked to) you can just tell your friend to simply pay himself via his Bitstamp account.