> ## Documentation Index
> Fetch the complete documentation index at: https://radiusbrowser.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage a tab lifecycle

> Open, wait for, focus, navigate, separate, and close tabs.

## Open and wait

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
app="$(radius tab open "http://localhost:3000" --right-of "$RADIUS_TAB_ID")"
radius tab wait "$app" --load --timeout-ms 30000
```

Wait for a URL substring instead of page loading:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
radius tab wait "$app" --url "/dashboard" --timeout-ms 30000
```

## Navigate and focus

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
radius tab navigate "$app" "http://localhost:3000/settings"
radius tab focus "$app"
```

## Return focus to the terminal

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
radius tab focus "$RADIUS_TAB_ID"
```

## Remove a tab from a split

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
radius tab separate "$app"
```

The tab stays open as an ordinary tab in the group.

## Close created tabs

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
issue="$(radius tab open "https://linear.app")"
pull_request="$(radius tab open "https://github.com")"

radius tab close "$issue" "$pull_request"
```

## Clean up temporary tabs automatically

Use a Bash array and `trap` when tabs should exist only while a script runs:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
#!/usr/bin/env bash
set -euo pipefail

temporary_tabs=()
temporary_tabs+=("$(radius tab open "https://example.com/status")")
temporary_tabs+=("$(radius tab open "https://example.com/logs")")

cleanup() {
  if [ "${#temporary_tabs[@]}" -gt 0 ]; then
    radius tab close "${temporary_tabs[@]}"
  fi
}

trap cleanup EXIT

radius tab wait "${temporary_tabs[0]}" --load
```

Only use automatic cleanup for genuinely temporary tabs. Startup scripts
normally leave their tabs in place for the user.
