# v0.4.0

URL: https://tuios.dev/releases/v0-4-0

> The web terminal moves out into the sip library, tape scripting gets a recorder and a manager UI, and a ShowKeys overlay draws your keypresses for recordings.

51 commits between v0.3.0 and v0.4.0, with four patch releases along the way.
Three things are new:

- A web terminal, as the separate `tuios-web` binary built on the
  [sip](https://github.com/Gaurav-Gosain/sip) library.
- Tape scripting, with a recorder and a manager UI.
- ShowKeys, an overlay that draws your keypresses for screen recordings.

The patch releases fixed resizing in floating mode and made the quit dialog ask
only when something is running.

## The web terminal

`tuios-web` serves tuios in a browser. It is a separate binary, so the main
`tuios` binary carries no server code, and people who never use a browser
never install one. It is a thin wrapper that hands tuios instances to sip's
Handler interface. sip serves any Bubble Tea app in a browser.

It went through three designs before the release. It started as a `tuios web`
subcommand: WebTransport with a WebSocket fallback, xterm.js with WebGL on the
client, and a bundled Nerd Font. That embedded about 10MB of web assets in the
repository and put an HTTP server in the window manager. The command then
became its own binary, and the server moved into sip, taking the 10MB with it.

`tuios web` was added and removed within this cycle, so no tagged release ever
shipped it and there is nothing to migrate.

The rebuilds fixed two defects:

- Web sessions used to start the tuios binary as a subprocess. They now run
  tuios in-process over pipes, like the SSH server.
- The first frame was drawn at a fixed 80x24 before the browser reported its
  size, which left artifacts. The session is now created after the browser's
  first resize, so the first frame has the right size.

## Tape scripting

A `.tape` script drives tuios from a file: open terminals, type into them,
manage windows, switch workspaces and modes, and pause between steps.

- `tuios tape validate` checks a script.
- `tuios tape play` runs it live with a progress indicator.
- Playback goes through the same Bubble Tea update loop as live input, so a
  tape and a person at the keyboard run the same code.
- The recorder captures your starting state, window actions, mode switches and
  workspace switches. Consecutive characters become one `Type` command, so a
  recorded tape reads like one written by hand.
- The tape manager on `Ctrl+B T m` browses, records and manages tapes without
  leaving the session.

A headless `tape run` mode existed during development. It never worked
properly and was removed rather than shipped.

## ShowKeys

tuios can draw your keypresses in the bottom right as you type, inspired by
nvzone/showkeys. Turn it on with `--show-keys` or toggle it with `Ctrl+B D k`.

- Keys are drawn as pills styled like the window title, with modifiers spelled
  out.
- Repeats collapse into a count (`j ×3`).
- Keys stay for three seconds. The first version used one, which was too short
  to read.

The leader key is now configurable as well. It was fixed at `Ctrl+B`, and now
comes from `leader_key` in the `[keybindings]` section. The help menu and
every chord follow it, and ShowKeys highlights it so a viewer can spot it in a
recording.

*[An interactive figure goes here. Open the page to use it.](https://tuios.dev/releases/v0-4-0)*

## Changed: the patch releases

v0.3.1 to v0.3.4 shipped in the first week of November. Most of it fixed
resizing in floating mode.

- During a drag, the window geometry updates at once and the PTY resize waits
  until release, so the shell no longer gets a stream of resize signals.
- The emulator's size stays in sync with the window's, so content no longer
  sticks at the old size while the border moves.
- A "Resizing... WxH" indicator shows in the window during a drag. In tiling
  mode, neighbours pulled along by the drag show it too.
- After a drag, PTY buffers are flushed and polling waits for the shell to
  redraw its prompt at the new width, which fixed half-drawn prompts.
- If the cursor ends up below the view after a height reduction, the view
  scrolls to keep the prompt visible.
- Dragging right after a resize no longer freezes the window.

Other changes in the patches:

- Quitting with open terminals shows a confirmation. It asks only when a
  terminal's foreground process is running something, so quitting idle shells
  just quits.
- The welcome screen shows on any workspace with no visible windows, not only
  when the whole session is empty.
- The shell is configurable. This mattered most on Windows, where tuios always
  started PowerShell.

## Fixed

- Decimal durations in tapes parse correctly, so `1.5s` no longer rounds.
- The render cache is cleared when leaving resize mode, so the resize
  indicator disappears at once.
- ShowKeys compares modifiers, so `Ctrl+L` followed by `L` shows two keys
  instead of one pill.

## Project

- A contributing guide.
- Package doc comments across all internal packages, a golangci-lint cleanup,
  and a modernization pass (`any` over `interface{}`, `slices.Delete`, built-in
  `min` and `max`).
- README keybindings use kbd tags.
- `tuios.exe` is gitignored.

The `.tape` format introduced here is the one project tapes were later built
on.
