# Terminal interface

Starting with version **0.36.0**, `tuna http`, `tuna tcp`, `tuna ssh`, `tuna postgres`, `tuna redis` and `tuna kubernetes` show a full-screen interface (TUI) instead of a text log. It turns on automatically when output goes to a terminal.

## What's on the screen

The header always shows:

* the account;
* the tunnel address (Forwarding) and the local address it points to;
* the [inspector](https://tuna.am/en/docs/tunnels/http/inspect.md) address;
* connection status: `online` or `reconnecting`;
* messages from the server.

The main area depends on the tunnel type:

| Tunnel                                                                                                     | What it shows                                                                                                                                                                 |
| ---------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [HTTP](https://tuna.am/en/docs/tunnels/http.md)                                                            | A request feed (newest on top) and metrics: total requests, rpm, p50, p90, number of 4xx and 5xx responses. Enter opens request details: headers and a formatted JSON body    |
| [Postgres](https://tuna.am/en/docs/tunnels/postgres.md), [Redis](https://tuna.am/en/docs/tunnels/redis.md) | Sessions on the left: `●` — active, `○` — closed, `•` — has unseen events. Events of the selected session on the right, highlighted: queries, number of rows returned, errors |
| [SSHd](https://tuna.am/en/docs/tunnels/ssh.md)                                                             | Connection instructions and a session feed, including denied attempts. Enter on an active session opens a live view, on a finished one — its recording                        |
| [Kubernetes](https://tuna.am/en/docs/tunnels/kubernetes.md)                                                | The header shows the service account, namespace, restrictions and access expiry, below is the feed of guest requests                                                          |
| [TCP](https://tuna.am/en/docs/tunnels/tcp.md)                                                              | The tunnel log                                                                                                                                                                |

## Hotkeys

Common to all tunnels:

| Key        | Action                                                                                                                                                    |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Ctrl+C`   | Stop the tunnel and exit. This is the only way to exit, `q` only goes back. On the QR code screen and in the SSH session viewer `Ctrl+C` only closes them |
| `c`        | Copy the tunnel address                                                                                                                                   |
| `i`        | Open the inspector in a browser                                                                                                                           |
| `l`        | Show or hide the log (except TCP, where the log is the main screen)                                                                                       |
| `Q`        | Show a QR code for the tunnel address, `Enter` or `Ctrl+C` goes back, the tunnel keeps running                                                            |
| `↑` `↓`    | Select an entry                                                                                                                                           |
| `g` / `G`  | Jump to newest / oldest entries                                                                                                                           |
| `Esc`, `q` | Back from details and the log                                                                                                                             |

`g`, or `↑` on the first entry, turns on follow mode: the selection moves to new entries as they arrive.

HTTP:

| Key     | Action                                                    |
| ------- | --------------------------------------------------------- |
| `Enter` | Request details                                           |
| `r`     | Replay the request                                        |
| `/`     | Filter by method, path or status, `Esc` clears the filter |
| `o`     | Open the tunnel address in a browser                      |

Postgres and Redis:

| Key   | Action                                     |
| ----- | ------------------------------------------ |
| `Tab` | Switch between the session list and events |
| `y`   | Copy the query                             |

SSHd:

| Key     | Action                                                                                                      |
| ------- | ----------------------------------------------------------------------------------------------------------- |
| `Enter` | Watch an active session or replay a finished one. `Ctrl+C` closes only the viewer, the tunnel keeps running |

With the interface on, the `--qr` flag shows the QR code screen once after connecting, `Enter` or `Ctrl+C` returns to the main screen.

With `--inspect=false` requests and sessions are not recorded, so the HTTP, Postgres and Redis feeds stay empty.

## Turning it off

To get the text log back, start the tunnel with one of these flags:

```shell
tuna http 8080 --log=stdout
tuna http 8080 --log=stderr
tuna http 8080 --log-format=json

```

Or set the environment variable `TUNA_TUI=0`.

With `--log=/path/to/file.log` the interface stays on and the log is also written to the file.

The interface does not turn on automatically when:

* output is redirected to a file or a pipe, or the tunnel runs [as a service](https://tuna.am/en/docs/tunnels/guides/service.md) or under systemd;
* `CI` or `NONINTERACTIVE` is set;
* `TERM=dumb`;
* tuna is run by an AI agent (`AI_AGENT`, `CLAUDECODE` or `CURSOR_AGENT` is set). In this case you can turn it on with `TUNA_TUI=1`.

The `tuna start` command keeps its text output.
