# Terminal TUI

| Command | Effect |
| --- | --- |
| `openprogram tui` | Terminal chat. Alias: `openprogram chat` |
| `openprogram` | Asks first: terminal UI or web UI |
| `openprogram tui --no-alt-screen` | Inline; keeps terminal scrollback |
| `openprogram tui --screen-reader` | Inline, no mouse tracking |
| `openprogram --resume <id>` | Opens a past session; ids from `openprogram sessions list` |

Exit: `/quit`, or `Ctrl-C` twice quickly while idle. [Tool permissions and live changes](https://fzkuji.github.io/OpenProgram/docs/capabilities/permissions.html).

## Keys

| Key | Action |
| --- | --- |
| `Enter` | Send |
| `Enter` while generating | Queue the message above the input; queued messages are sent one per turn when the turn ends or is stopped |
| `↑` on an empty prompt with messages queued | Select one: `Enter` or `e` edits it, `x` removes it, `Esc` goes back |
| `Alt+Enter` | Newline |
| `?` on an empty prompt | Keyboard shortcut reference |
| `Esc` | Clear the input; while generating, abort the turn |
| `Ctrl-C` while generating | First warns, second stops gracefully, third forces |
| `↑` `↓` | Input history; moves within an open completion menu |
| `Tab` | Accept file or slash-command completion |
| `→` at end of line, `Ctrl+E` | Accept the autocomplete suggestion |
| `Ctrl+A` `Ctrl+E` | Start or end of input, when no suggestion is being accepted |
| `Ctrl+W` | Delete the previous word |
| `Ctrl+R` | Search saved contexts |
| `Shift+Tab` | Cycle permission modes: Bypass permissions, Auto, Manual, Plan |
| `Ctrl+K` | Command palette, all slash commands |
| `Ctrl+O` | Show tool output whole, or fold it again |
| `Ctrl+V` (`Alt+V` on Windows) | Attach the image on the clipboard. Pasting or dragging the path of an image or PDF, or sending `@path` to one, attaches the file; delete its `[Image #1]` placeholder to drop it |
| `PageUp` `PageDown`, `Ctrl+U` `Ctrl+D` | Scroll by page, half page |
| `Home` `End` | Top, bottom |

Change keys in `~/.openprogram/keybindings.json`, for example `{"app.toolsExpand": "ctrl+t", "app.commandPalette": "none"}`; action names and the keys in force are listed under `?`. A mistake in the file is reported in the transcript at start and the rest still applies.

## Slash commands

| Command | Action |
| --- | --- |
| `/help` `/keybindings` | Command list, shortcut reference |
| `/model` `/fetch-models` | Switch model, re-fetch the model list |
| `/effort` | [Thinking effort](https://fzkuji.github.io/OpenProgram/docs/models/thinking-effort.html) |
| `/style` | Output style |
| `/new` `/resume` `/sessions` `/session` | New, resume, list, current session |
| `/compact` `/context` `/clear` | Compact context, view context, clear screen |
| `/permissions` `/sandbox` | Permission profiles, sandbox |
| `/login <provider>` `/logout` | [Provider login and logout](https://fzkuji.github.io/OpenProgram/docs/models/auth.html) |
| `/agents` `/agent` | Manage, switch agents |
| `/jobs` | Background job state |
| `/steer` | Give the current execution an instruction at its next safe point |
| `/fork` `/retry` | Branch or retry an execution from a checkpoint |
| `/mcp` `/memory` | Same data as the Web UI pages |
| `/cost` | Token usage for this session |
| `/export` `/copy` | Export the session, copy a reply |
| `/config` `/theme` `/bell` | Settings, theme, notification sound |
| `/doctor` | Health check |
| `/channel` `/attach` `/detach` `/connections` | Chat-channel hookup and session routing |
| `/search` `/review` `/diff` `/init` `/welcome` | Also available |
| `/quit` | Exit |

`/help` is the authoritative list. Completion also lists the shared command registry, as in the Web composer: skills, MCP prompts, plugin commands and Markdown files (optional YAML frontmatter) in `~/.openprogram/commands/` or `<project>/.openprogram/commands/`. Running one sends its expanded body as the message.

**Clipboard for `/copy`**

| Session | Uses |
| --- | --- |
| Wayland | `wl-copy` |
| X11 | `xclip` or `xsel` |
| WSL | `clip.exe` |
| SSH | OSC 52, with tmux passthrough and its paste buffer when available |

Native helpers have a bounded timeout, so a stale display cannot freeze the TUI.

**Which interface you get**

- Releases include a self-contained Node.js Ink interface on Windows, macOS and Linux. No separate Node.js install.
- The check is real raw-input capability, not an OS list. Windows Terminal, PowerShell under ConPTY and modern integrated terminals get full screen. Without raw input: the Python Rich interface, with a message. Git Bash in MinTTY may land here; PowerShell in Windows Terminal, the recommended Windows setup, does not.
- Full screen needs stdin and stdout to be terminals. Redirected or piped runs skip Ink before any ANSI frame and use line output; for automation use `openprogram --print`.
- Both implementations connect to the local worker over WebSocket and share sessions with the Web UI.
- The alternate screen restores the shell's contents on exit. Cursor and deletion work on whole Unicode grapheme clusters.
- With `--profile <name>`, startup diagnostics go to `~/.openprogram-<name>/logs/ink-startup.log`.

**Compaction**

- `/compact` summarizes older complete turns with their visible tool results and keeps recent turns. It changes the next model context; original messages stay in the session. Token counts before and after are local estimates. A short history, failed summary or summary that saves nothing leaves the context unchanged.
- Tool continuations can compact completed text results within one user message, with no command. Execution records are retained.
- If that is not enough, older complete text-only execution history can be replaced in the next request by a task summary. All user messages and the latest assistant segment stay verbatim. Not eligible: incomplete tool groups, multimodal input, signed reasoning. Reused only within the current invocation, same model and unchanged prefix; the DAG stays the durable record.
- Summary requests handle long text in bounded chunks, retry overflow with smaller chunks, and share a finite call and time budget. Failure leaves the history intact. A summary that fails is skipped and the request is fitted by shortening or leaving out older material; only a latest message that alone exceeds the window fails, and says so.

Channel messages whose user or assistant text is not a string are ignored for that field; existing background-session text is kept.
