First off, let's talk about how custody determinations work. There are two critical points in a person's case that will have a significant impact on whether they remain in jail custody or not during the pendency of the case.
(1) Critical Point #1: If the officer actually arrests you and what charges you are booked on. On more minor charges, (take driving without a license, for example) the officer can just write you a citation and tell you to appear in court. Alternatively, if you are taken to the jail, you will be booked in on the charges as described by your arresting officer and this will decide your bail (for the time being). Additionally, if you are being supervised (probation, parole, PRCS) or if you have an out of county warrant that is extraditable, you will likely get a "hold" put on you. That means even if you post bail and are "free" on the new case, your hold will keep you in custody. Be careful with posting bail if you think you may have a hold - if the hold is going to keep you in custody, bail is a waste of money, and if you are "no longer in custody" on a case, you stop earning credits in that case, which you would otherwise be entitled to any time you're incarcerated.
(2) Critical Point #2: a bail hearing in front of a judge. If you do not make bail or get released at the jail's discretion prior to your next court date, you will go in front of the judge for an in custody arraignment. The point of an arraignment is to let you know what charges were filed against you. Sometimes this is not as serious as what you were arrested for, and sometimes the prosecutor reviews the police report and decides to file more serious charges than what you were arrested for, which they can technically do as long as they believe they will be able to prove those charges. It is important to have a lawyer at arraignment because that lawyer will immediately argue for your release if possible, or try to do damage control if the prosecutor is trying to increase your bail and keep you in custody. If you haven't already hired a lawyer by the time of your arraignment, the judge will ask if you can afford to hire your own lawyer, and determine whether you qualify to have the Public Defender's Office appointed. Typically they will be appointed on the spot and will immediately stand up and say "not guilty" and try to get you released if possible. The release practices vary by case and by court. In felony arraignments, the probation department usually submits a written memo that recommends for or against release and lists out things like how many failures to appear you have had. Even though the attorney understands everyone wants to get out of jail, they may decide to just submit on the recommendation instead of giving the prosecutor an opportunity to argue for an increase in bail that makes it even harder for you. This is true even if you are not expecting to make bail, because sometimes a crowded jail will make room by releasing people, and if all other things are equal between you and another inmate but your bail is a little lower, that could get you released to appear by the jail. Alternatively, they may make a pitch to the judge asking for your release, offering to have you abide by conditions, etc.
Being out of custody pending trial is obviously the desired option. But what if you are held in custody and decide to settle your case at some point prior to trial? That's where you may be interested in a "Cruz waiver." What this means is you are negotiating for your release prior to sentencing, but after having taken a plea deal. For example, maybe the prosecutor is okay with you not having to serve any more jail, but you are getting probation and the probation department still needs to meet with you before sentencing and prepare a report. In that situation, the judge can release you, IF you promise you will appear in court and hold up your end of the bargain by cooperating with the probation department. You might also get a Cruz waiver in a situation where you are going to prison, but you convinced the court to release you and give you a little time to get your affairs in order before you serve your term.
The upside is obvious: you get out. Sometimes the DA is totally unwilling to do a Cruz waiver, but sometimes they will do it because you're already taking a plea deal. The downside can be pretty terrible though. If you manage to get a Cruz waiver and then don't show up to court, or you get arrested again while you're out of custody, you can end up with a "Cruz Waiver Violation" and that means the judge can max you out on whatever you pled to, even if you were originally going to get probation or something less than the max. The judge can't bring back dismissed charges on a Cruz waiver violation, so it's only what you actually pled to, but this can be pretty extreme in practice. For example, you could have bargained for "time served" and probation, but by not showing up to court as ordered, end up sent to prison instead. So be careful what you wish for before you ask for a Cruz waiver.
You are entitled to a hearing on whether you violated the Cruz waiver agreement, but keep in mind that these hearings aren't full blown jury trials. I recommend keeping your lawyer's business card in a pocket in the days leading up to your sentencing date if you are out on a Cruz waiver. Life can be unpredictable and you want to be able to call that lawyer if there is an emergency that affects your ability to come to court (like if you end up in the hospital, for example). It may seem like it will easily resolve itself later if you really are in an emergency, but the more informed your lawyer is, the better they can navigate the situation on your behalf.