# Remote control
A conversation another pic is running can be watched and steered from a second process: another
terminal, a script, an editor, or a phone over ssh. `pic attach` shows it and `pic send` messages
it. Neither takes the conversation over: the pic running it keeps running it, and nothing listens
on a port.
## Watching: pic attach
`pic attach` follows the latest conversation of the workspace (`--session ID` for another; `-c`
says latest explicitly). It prints what has happened since the start of the conversation's latest
request, then each message, tool call and result as it is saved, and keeps going until stopped.
- The default output is Pi's JSON events, one per line, as `pic --mode json` prints them, each with
the `seq` of the entry it came from. `--from SEQ` starts after that entry (0: from the beginning),
so a client that reconnects with the last `seq` it saw misses nothing and sees nothing twice.
- `--format text` prints short lines instead: what you sent, the reply, each tool call and the first
line of its result, and how each request ended.
- `--no-follow` prints what is saved and exits.
Text the model is still streaming is not shown: a reply appears when it is complete.
## Steering: pic send
`pic send steer TEXT` sends a steer to the conversation (`--session ID`, else the latest):
delivered after the running tool calls finish, as a steer typed into that pic would be. `pic send
follow_up TEXT` runs after the request ends, and `pic send abort` cancels it, even if the pic
running it dies before it has stopped. A whole Pi RPC
command works too: `pic send '{"type":"steer","message":"look at the tests"}'`.
`pic send` prints the message's state and its key, and returns as soon as the message is saved;
`--wait` waits for it to be delivered and prints the response the running pic gave. The pic running
a request in the conversation delivers it within moments, whichever way it was started: the
terminal, `pic ask`, `--mode json` or `--mode rpc`.
- A message is delivered once. Sending the same `--key` and message again (after a lost
connection, say) changes nothing; the same key with a different message is refused.
- A message to a conversation with nothing running waits until a request runs there. It expires
if it waits too long: 10 minutes for a steer or abort, a day for a follow-up (`--expires
SECONDS` sets it, up to a week). An abort sent when nothing runs is refused at once.
- At most 100 messages (or 64 MB) can wait in a conversation.
## Both at once: pic attach -i
`pic attach -i` follows the conversation and acts on each line you type:
- While a request is running (started here or anywhere else), the line is a steer for it.
- When nothing is running, the line starts a request, as `pic ask --session ID TEXT` would: its
reply and tool calls are shown as they are saved, and then `pic attach` goes back to following.
`--model` and `--thinking` given before `attach` apply to it. The request runs in a process of
its own, so a dropped connection does not stop it.
- `/abort` cancels the running request, whichever process runs it.
- If a request it started cannot run (an unknown model, another request already running), it says
why, and lines sent to that request meanwhile are reported not delivered; the next line starts
a request again. Lines that reach a request as it finishes start the next one.
It says when each message is sent and delivered. With its input closed it waits for what it sent
to be delivered and for a request it started to end, then exits.
Starting a request here is you acting from another terminal, the same as typing `pic ask`; it is
not one conversation waking another, which pic does not do.
## From a phone
`pic attach` works over ssh, with nothing more to install. In the terminal interface,
`/remote-control` (or `/rc`) shows how for the conversation you are in; `pic remote-control` (or
`pic rc`) prints the same in a shell:
- a QR code of the Mac's `ssh://` address: scan it with an ssh app such as Blink or Termius, log in,
then run the command shown under it (`cd` to the project, `pic attach -i -c --format text`);
- the whole command for any ssh client, which `c` copies to the clipboard (in a window too short for
the QR code, it is left out and the rest is shown);
- checks: whether Remote Login is on, and whether Tailscale is up. The address is the Mac's
Tailscale name when it is, so the phone reaches it from anywhere; otherwise its name on the local
network, reachable only from there.
To set it up:
1. On the Mac, turn on Remote Login (System Settings, General, Sharing).
2. Put the Mac and the phone on one Tailscale network (or any network that can reach the Mac).
3. Open the address (or run the command) from the phone.
The command names pic by its full path when a login over ssh might not find it on its path.
Watch the run, type a line to steer it, and close the connection when done; the run carries on.
## What it cannot do yet
- Start a request with `pic send`: a follow-up to an idle conversation waits until a request runs
there (`pic attach -i` starts one).
- Reach a conversation in another workspace, or on another machine without ssh.
- Show text as it streams.