* fix(tui): restore every terminal mode on signal and panic
The SIGHUP/SIGTERM cleanup emitted only `?1049l ?25h`, leaving kitty CSI-u (`ESC[>1u`), mouse capture, bracketed paste and focus reporting armed, so the next shell received CSI-u keys and typing looked dead. The panic hook had a third, narrower variant that also missed mouse capture and wrote to stderr.
One shared `write_terminal_disable_sequence` now backs both the signal cleanup and the panic hook: stdout (the stream the TUI armed modes on), inside `with_kitty_state_lock`, guarded by `editor_owns_terminal()`, with the kitty pop after the lock is released. The exec-handoff resume path adopts the inherited kitty entry (`adopt_keyboard_enhancement_ownership`) so a later exit pops it instead of leaking it.
Also fixes the resume hint: `crash_resume_hint_lines` and the `write_session_resume_hint` fallback named `jcode --resume`, which sends the operator to upstream jcode reading `~/.jcode` instead of `~/.kcode`; both now use `resume_binary_stem()` = "kcode". The picker line literal is unchanged.
Ports upstream 3222d46 (PR 1jehuang#1707, issue 1jehuang#1635), which this fork predates. `kcode server reload` was measured harmless (627 B repaint, same as control), so the defect is the client termination/exec path, not reload.
tx-agent: jcode
tx-validated: test
tx-lane: jcode:session_unicorn_1795249137497_783907915dc7755e
* refactor(tui): move terminal-mode ownership into tui/terminal_modes.rs
The A25 terminal-restore fix grew tui/mod.rs (2122 -> 2423) and
tui/app/commands.rs (3771 -> 3955), both already over the oversized-file
ratchet, so scripts/check_code_size_budget.py failed on this branch.
Pure relocation, no behavior change: the kitty push/pop statics, the
ownership and termination gates, the editor handoff, and their tests move
into a new module as-is. Only mechanical rewrites: `pub(crate)` on the
items other modules call, an explicit `use crate::tui::keyboard_protocol;`
for the bare `keyboard_protocol::` paths, and `pub use terminal_modes::*`
so every existing `crate::tui::*` / `jcode_tui::tui::*` path still resolves.
Disable-byte order, lock discipline, and item names are unchanged.
tui/mod.rs 2122 -> 1879, tui/app/commands.rs 3771 -> 3671,
terminal_modes.rs 841 (< 1200 threshold).
tx-agent: jcode
tx-validated: build,test
tx-lane: jcode:session_zebra_1795251286001_f002d14678692202
* style(tui): drop the extra blank line rustfmt flagged after the relocation
tx-agent: jcode
tx-validated: lint
tx-lane: jcode:session_zebra_1795251286001_f002d14678692202
* chore(guardrails): record the terminal-mode relocation in the swallowed-error baseline
Six `let _ =` sites moved from tui/mod.rs and tui/app/commands.rs into
tui/terminal_modes.rs, so the per-file baseline needs the new path.
Counts are moved, not added: mod.rs 1 -> 0, commands.rs 14 -> 9, new file 6.
The recorded total is left at 3846, which is >= the measured 3837, so no
budget is loosened.
tx-agent: jcode
tx-validated: lint
tx-lane: jcode:session_zebra_1795251286001_f002d14678692202
Closes #1635. Related #898.
The signal handler (SIGINT/SIGTERM/SIGHUP/SIGQUIT) restored raw mode, the primary screen and the cursor but never popped the kitty keyboard stack nor disabled bracketed paste, focus reporting or mouse capture. A signal exit could therefore leave the terminal in CSI u mode and the shell echoed raw sequences like
e1;1:3u.The handler now disables every TUI mode and calls
disable_keyboard_enhancement()before exiting. The pop is a no-op on terminals with no kitty stack, so it is safe unconditionally. This is the signal-exit path; #898 covers the same leak on the normal-exit path inside tmux.Also one-line
..Default::default()fix in provider_setup to keep a struct literal compiling after new fields.11 insertions, no behavior change on the normal-exit path. Single commit rebased onto current master.