kaeru 0.1.4

Reopens your terminal tabs, and the coding agent sessions in them, after the terminal closes or the computer restarts.
# Testing

## Automated tests

`cargo test` runs two kinds of tests, and CI runs them on Windows, macOS and Ubuntu:

- Unit tests, next to the code they test. They use made-up input: fake process trees
  (`procs::fake::FakeTable`) and invented environment variables, folders and ids.
- [tests/conventions.rs]../tests/conventions.rs, which checks the repository against the
  rules in [CONVENTIONS.md]../CONVENTIONS.md that a program can check.

## End-to-end tests

Each terminal has a manual checklist below. Run it once kaeru supports that terminal; the
[roadmap](../README.md#roadmap) says which ones it does.

Every checklist follows the same idea: open some tabs, close the whole terminal, open it again,
and check that the right tabs come back.

### Use a second copy of the terminal

Test in a separate copy of the terminal, so that you can close it completely without closing
the one you work in.

- Windows Terminal: download the portable zip (`Microsoft.WindowsTerminal_<version>_x64.zip`)
  from the [releases page]https://github.com/microsoft/terminal/releases, check that
  `WindowsTerminal.exe` is signed by Microsoft, and put an empty file named `.portable` next to
  it, so that it keeps its own settings. In its settings, set
  `"warning.confirmCloseAllTabs": false`, so that it closes without asking.

### Windows Terminal

1. Run `kaeru install`. Start Codex once, trust the kaeru hook when it asks, and quit it. Open a
   new tab in the test terminal: `kaeru doctor` reports no problems there.
2. In the test terminal, open four tabs:
   - A: a shell in some folder;
   - B: Claude Code in another folder, with one message sent;
   - C: Codex in a third folder, with one message sent;
   - D: a plain shell.
3. Close tab D, then open a new tab. `kaeru list` no longer shows D.
4. Close the whole test terminal window.
5. Open the test terminal again. The picker lists A, B and C, but not D.
6. Press Enter: the cursor starts on Done, so the checked tabs come back, one about every
   second, in the order they were first opened, while the picker's tab shows `Reopening 1 of 3`
   and so on. Then the picker's tab closes, so that the test terminal has three tabs. A comes
   back in its folder, B comes back with `claude --resume`, and C comes back with
   `codex resume`, all in the test terminal and not in your main one.
7. Run a command that fails, such as `Get-Item nothing-here`, in a tab with a prompt theme that
   shows failures, such as oh-my-posh or starship. The prompt shows the failure.
8. Close the test terminal. The next time you're asked, press `a` to uncheck every tab, check
   that Done says `forget`, and press Enter, to forget the test tabs.

Run the checklist twice for Codex: once with the `codex-no-daemon` option on, which you turn on
in `kaeru install`, and once with `codex-no-daemon = false` in kaeru's `config.toml`. In the
first run, C runs in its tab; in the second, Codex's shared background server runs it.

### Git Bash

Git Bash runs in Windows Terminal, with Git Bash's profile, and in its own windows (mintty). Test
both, in the test copy of Windows Terminal and in Git Bash windows that you open from the Start
menu.

1. Run `kaeru install`, and let it add its line to `~/.bashrc`. Open a new Git Bash window:
   `kaeru doctor` reports no problems there, and says that the window is tracked.
2. In the test terminal, open two Git Bash tabs: E in some folder, and F with Claude Code in
   another folder, with one message sent. Close the test terminal, and open it again with a Git
   Bash tab. The picker lists E and F; press Enter. E comes back in its folder, and F comes back
   with `claude --resume`. After you quit Claude Code in F, the tab is a bash to type in.
3. Open two Git Bash windows, G in some folder and H with Claude Code in another folder. In
   kaeru's options (`o` in the picker, or `single-window-close = "offer"` in `config.toml`),
   choose to offer closed single windows. Close both windows, and open a new Git Bash window.
   The picker shows in it, through `winpty`; press Enter. G and H come back as Git Bash windows,
   with Git Bash's icon, H with `claude --resume`, and the window that showed the picker closes.
4. Run a command that fails, such as `false`, in a tab with a prompt theme that shows failures,
   such as starship. The prompt shows the failure.
5. Set the option back, and forget the test tabs as in step 8 above.

### Warp

Warp has no separate test copy, so use a Warp with nothing to keep, and close its tabs that
you don't need. Warp builds the `PATH` of its shells from the one Windows keeps, so in a Warp
tab, `claude` is the real Claude Code.

1. Run `kaeru install` if the profile line isn't there yet. Open a Warp tab: `kaeru doctor`
   says that the tab of Warp is tracked.
2. In a Warp tab, start Claude Code and send one message. In a second tab, go to some folder.
3. Wait a minute or two, because Warp saves its tabs a while after they change. Then end Warp
   and everything it started, as a crash or restart would, from a Windows Terminal tab:
   `taskkill /F /T /IM warp.exe`. Ending only `warp.exe`, as `Stop-Process -Name warp` does,
   leaves the tabs' shells and agents running without a window, and kaeru then rightly sees the
   session as still running.
4. Start Warp. It brings back both tabs in their folders. The first tab says that it had a
   Claude Code session and that `kaeru resume` resumes it. The second says nothing, and no tab
   shows the list for these tabs.
5. Run `kaeru resume` in the first tab: the session comes back, with `claude --resume`. Run it
   in the second tab: it says that no session waits there.
6. Repeat with a crash that leaves the tabs' programs running: end only Warp's process, with
   `Stop-Process -Name warp -Force`. The first tab says that its session still runs without a
   window. `kaeru resume` ends the hidden Claude Code and resumes the session in the tab.