# Review Fixes Design

Fixes identified from full project code review. Excludes: protocol version handshake, `send_initial_state` lock duration, build configuration, DA/DSR deferred deadlock, spawn_blocking batching, CI/CD.

## Phase 1: Small Bug Fixes (low risk, independent)

### 1.1 Session::Drop — skip join when kill skipped
`src/session.rs:278-308`. When `try_lock()` fails and child is not killed, `handle.join()` blocks forever because reader is waiting on PTY read.

Fix: When child kill is skipped, take and drop the `JoinHandle` instead of joining (detach the thread).

### 1.2 drop_blocking_with_timeout — handle JoinError
`src/server/mod.rs:20-29`. `result.is_err()` only catches timeout, not task panic.

Fix: Match both `Ok(Err(join_err))` and `Err(elapsed)`.

### 1.3 FocusIn break scope
`src/client/mod.rs:232-240`. `break` exits inner `for action` loop, not outer `loop`.

Fix: Use labeled break `'outer: loop` and `break 'outer` on write error.

### 1.4 Clippy dead code warnings
`src/screen/grid.rs` and `src/screen/grid_mutator.rs`. Methods on `GridMutator` trait not called through trait.

Fix: Remove unused methods from `GridMutator` trait (`restore_scrollback`, `scrollback_len`, `set_pending_start`). Keep them as direct `Grid` methods only.

## Phase 2: Terminal Emulation — Missing Sequences

### 2.1 NEL (ESC E — Next Line)
`src/screen/performer.rs` esc_dispatch. Standard VT100: CR + LF.

Add `([], b'E')` arm: set cursor_x to 0, scroll if at scroll_bottom, else advance cursor_y.

### 2.2 DECALN (ESC # 8 — Screen Alignment)
`src/screen/performer.rs` esc_dispatch. Fill screen with 'E', reset scroll region and cursor.

Add `([b'#'], b'8')` arm: fill all visible rows with 'E' cells, reset scroll region, cursor to (0,0).

### 2.3 REP double charset mapping
`src/screen/performer.rs:581`. REP calls `self.print(c)` which applies `map_charset` again on already-mapped char.

Fix: Store pre-map character in `last_printed_char` (move the assignment before `map_charset`).

### 2.4 CSI t — Title Push/Pop (22;0t / 23;0t)
`src/screen/performer.rs:621`. Currently no-op.

Add: `title_stack: Vec<String>` to `ScreenState` (bounded, max 16). Handle `22;0t` (push title), `23;0t` (pop title).

## Phase 3: DECOM (Origin Mode)

### 3.1 Add origin_mode to TerminalModes
`src/screen/grid.rs:65-78`. Add `origin_mode: bool` (default false).

### 3.2 Handle ?6 in csi_set_dec_private_mode
`src/screen/performer.rs:439-472`. Add `Some(6) => ...` arm to set `origin_mode`.

### 3.3 Origin-aware cursor positioning
CUP (`csi_cursor_position`), VPA (`csi_line_position_absolute`): when origin mode active, offset row by `scroll_top` and clamp within scroll region.

DECSTBM (`csi_set_scrolling_region`): when origin mode active, cursor goes to origin (top of scroll region), not absolute (0,0). Already moves to (0,0) which is correct when origin mode is off.

### 3.4 Save/restore origin mode
`save_cursor` / `restore_cursor`: include `origin_mode` in `SavedCursor`.

### 3.5 Emit/delta origin mode in render
`emit_mode` / `emit_mode_delta`: emit `?6h` / `?6l`.

## Phase 4: Underline Color (SGR 58/59)

### 4.1 Add underline_color field to Style
`src/screen/style.rs:54-65`. Add `pub underline_color: Option<Color>`.

### 4.2 Parse SGR 58/59 in apply_sgr
`src/screen/style.rs:194-247`. `58` → parse extended color → set `underline_color`. `59` → reset to None.

### 4.3 Emit underline color in write_sgr_to
After underline style, emit `58;5;N` or `58;2;R;G;B` if set.

## Phase 5: Housekeeping

### 5.1 Fix MEMORY.md version
Update `0.6.3` → `0.7.3`.
