Skip to content

feat(terminal): selectable embedded shells + resilient PTY reader#4

Merged
jairoFernandez merged 2 commits into
mainfrom
feat/windows-terminal-shells
Jul 19, 2026
Merged

feat(terminal): selectable embedded shells + resilient PTY reader#4
jairoFernandez merged 2 commits into
mainfrom
feat/windows-terminal-shells

Conversation

@jairoFernandez

Copy link
Copy Markdown
Owner

Problema (Windows)

  1. Logs cortados: el shell embebido se congela cuando un proceso chatty (next start) inunda logs. El reader thread moría en cualquier error de read().
  2. Sin selección de shell: la PTY embebida siempre lanzaba cmd.exe (default_shell()). No había forma de elegir/detectar git-bash, powershell, pwsh ni wsl.

Cambios

Bug 1 — reader thread resiliente

terminal_cmd.rs: el loop ya no rompe en cualquier Err. Reintenta Interrupted/WouldBlock, termina solo en EOF/BrokenPipe/UnexpectedEof. Errores desconocidos → sleep + retry en vez de teardown.

Bug 2 — shells embebidos seleccionables

  • terminal_list_shells: detecta cmd/powershell/pwsh/git-bash/wsl (Windows), zsh/bash/fish (unix). git-bash sonda PATH + Git\bin\bash.exe.
  • terminal_spawn acepta arg shell; shell_command(id) mapea a (program, args) con fallback a default.
  • Persistencia: nuevo preferred_shell en KubeconfigSettings (#[serde(default)], retrocompatible). kubeconfig_settings_set hace merge — actualizar un campo no pisa el otro.
  • Resolución en spawn: arg explícito → preferencia guardada → auto.
  • UI: split-button con dropdown de shells en el dock; selector "Embedded shell" en settings.

Hardening

  • portable-pty 0.8 → 0.9 (arreglos ConPTY Windows). API compatible, sin cambios de código.

Verificación

  • cargo check -p knock-app
  • cargo test -p knock-core (settings_roundtrip, excluded_from_list) ✓
  • vite build (tsc) ✓ · tests frontend ✓

⚠️ Las rutas cfg(windows) solo compilan en Windows — verificado a mano (gating de which_win/env vars correcto). Falta prueba en Windows real: elegir PowerShell/git-bash/wsl y confirmar arranque + streaming de next start.

Embedded PTY previously hardcoded the platform default shell (cmd.exe on
Windows) and the reader thread died on any read error, freezing chatty
processes like `next start` on Windows ConPTY.

- Reader thread retries transient errors (Interrupted/WouldBlock), only
  ends on EOF/BrokenPipe. Fixes log streaming cutting out on Windows.
- terminal_list_shells detects cmd/powershell/pwsh/git-bash/wsl (Windows)
  and zsh/bash/fish (unix); terminal_spawn takes a shell arg.
- Persist preferred_shell in KubeconfigSettings; settings_set merges so
  one field no longer clobbers the other. Shell picker in the dock + a
  preference selector in kubeconfig settings.
- Bump portable-pty 0.8 -> 0.9 for Windows ConPTY read fixes.
@jairoFernandez
jairoFernandez merged commit 423fa47 into main Jul 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant