# The terminal

Each session has its own terminals: shells that start in the session's folder, or its worktree,
beside the agent's work. They belong to Moontors' background service, as sessions do, so they keep
running when you close the window, open another session or quit Moontors: the background service
stays up while any terminal runs.

## Opening it

- The **Terminal** button at the window's right edge, under **Git**, opens the terminal over the
  board and the transcript for the open session, and closes it again. The view's header names the
  session, and its X button closes it.
- The first time you open it for a session, it starts a shell. After that it shows the session's
  terminals as you left them.
- With no session open the button is dimmed. Right after an update, it waits until the new version's
  background service has taken over, and its tooltip says so.

## Tabs

- Each terminal is a tab, named by the title its shell sets, or else by the shell's name. The arrow
  keys move between tabs.
- **New terminal**, the + beside the tabs, starts another shell. A session can have 10 terminals at
  once; at 10, the button says so.
- A tab's X closes it, ending its shell and whatever runs in it.
- When a shell exits, its tab is struck through and says the code it exited with. Its last screen
  stays until you close the tab.
- Showing a tab again shows its screen as it is now, with up to 10,000 lines of what came before,
  scrolled back to where you left it. Each session keeps its tabs, the one it showed and their
  scroll while the window is open.

## The shell

- On macOS, your login shell; on Linux, an interactive shell; on Windows, PowerShell.
- It starts in the session's folder, or its worktree, with the environment the agents get, never
  Moontors' own variables: on macOS and Linux, your login shell's; on Windows, the one Windows gives
  a new terminal, the machine's variables and yours, as System Properties sets them, with your
  session's.
- That environment is read again for each new terminal, so a variable you've changed shows in the
  next one.
- It keeps one size, the one it was last resized to.

## Keys

- The terminal keeps Escape and the shell's own control keys, such as Ctrl+C. Escape in the terminal
  never closes the view.
- Shift+Escape leaves the terminal for its tab, so the keyboard is never held there.
- Copy and paste as each system's terminals do:
  - macOS: Cmd+C and Cmd+V, from the Edit menu;
  - Windows: Ctrl+C copies what's selected, once, so pressed again it interrupts the shell; Ctrl+V
    pastes;
  - Linux: Ctrl+Shift+C and Ctrl+Shift+V.
- On Windows and Linux, the menus' shortcuts give way while the terminal has the focus.

## Links and the clipboard

- A web link the shell prints, or that a program names as a link, opens in your browser on a click.
  Only https links open.
- A program may put text on your clipboard, as some editors do, but never read what's there.

## Limits

- Nothing a terminal carries is logged, or kept in the session's transcript: what you type can be a
  password.
- Terminals end when their session is archived or deleted, and when Moontors restarts to update or
  its background service stops. None comes back after a restart.
- A large paste goes to the shell in pieces of up to about a million characters each, in order.
- On Windows, a terminal whose shell ends by itself, as when you type `exit`, leaves one console host
  process behind (Console Window Host, in Task Manager) until Moontors' background service stops.