Skip to content

Ctrl+Delete word-forward-delete parity with Ctrl+Backspace - #20

Merged
rockyway merged 5 commits into
developfrom
feature/ctrl-delete-word-forward
Jul 23, 2026
Merged

Ctrl+Delete word-forward-delete parity with Ctrl+Backspace#20
rockyway merged 5 commits into
developfrom
feature/ctrl-delete-word-forward

Conversation

@rockyway

Copy link
Copy Markdown
Contributor

Summary

  • Adds Ctrl+Delete word-forward-delete, matching Ctrl+Backspace across every shell context (PowerShell, cmd, Git Bash/WSL, and Kitty-protocol TUIs).
  • Fixes a pre-existing gap: Ctrl+Backspace did not reliably word-delete in POSIX/readline shells (Git Bash, WSL) due to a documented ConPTY limitation where Ctrl+Backspace and literal Ctrl+H both encode to the same byte (0x08).
  • Kitty protocol path was already correct/tested; Win32-Input-Mode path was already correct for Ctrl+Delete but untested (now locked in with a regression test); the new piece is an explicit shim in TerminalEngine.ts that sends readline's native word-kill sequences (ESC DEL / ESC d) directly to POSIX/readline shells, gated by a new shellType engine option threaded from the app.

Design / plan docs

  • termflow-fabric/docs/design/005-word-delete-shim-design.md
  • termflow-fabric/docs/plan/006-word-delete-shim-implementation.md

Test plan

  • bun run test:workspace (terminal-core unit tests, 436 passing, incl. new wordDeleteShim.test.ts and the Win32-Input-Mode Ctrl+Delete regression test)
  • bun run test (main app suite, 592 passing)
  • tsc --noEmit (clean)
  • bun run build (terminal-core + renderer, succeeds)
  • Manual: Ctrl+Backspace/Ctrl+Delete in Git Bash, WSL, PowerShell, cmd, and a Kitty-protocol TUI (see plan doc Task 5 Step 3) — not yet performed, no GUI-automation available in this session

- isPosixShell: flip from blacklist (default-to-POSIX) to whitelist
  (default-to-false). 'default' is a real, persistent shellType value
  (StateManager.resetToDefaultLayout, TerminalPane's fallback chain before
  shell profiles load) that very often resolves to an actual PowerShell
  session (pushed first with is_default:true in pty_manager.rs) -- the old
  default direction would misfire ESC-byte garbage into PSReadLine.
- Swallow the keyup paired with a shimmed keydown via uiClaimedKeydownKeys
  (matching the existing scroll-key shim pattern), so Win32-Input-Mode
  --  active for the whole Windows session regardless of shellType -- doesn't
  leak a stray Kd=0 release record after the shim's synthetic bytes.
- shellType is now a live getter (matching smartCopy/enhancedKeyboard),
  since the engine-construction effect only depends on [terminalId] and
  never re-reads a plain captured value after mount.

Found by codex (gpt-5.6-sol) reviewing PR #20; verified against pty_manager.rs
and StateManager.ts before applying. agy's independent review characterized
the isPosixShell issue as a minor/hypothetical custom-profile edge case --
verification showed it's a concrete, reachable regression via the 'default'
placeholder.
@rockyway

Copy link
Copy Markdown
Contributor Author

Automated review round

Dispatched two independent external reviewers (agy/Gemini 3.6 Flash, codex/gpt-5.6-sol) against this PR.

agy: full approval, no blocking findings.

codex: found 2 P1s + 1 P2, all confirmed on independent verification against pty_manager.rs/StateManager.ts and fixed in 07bf400:

  1. isPosixShell default direction was unsafe. The original heuristic defaulted anything that wasn't literally cmd/powershell/pwsh to POSIX. 'default' is a real, persisted shellType value (StateManager.resetToDefaultLayout, and TerminalPane's fallback chain before shell profiles finish loading) that frequently resolves to an actual PowerShell session — PowerShell 7 ships is_default: true and is pushed first in compute_available_shells(). The old default direction would have sent raw ESC-byte garbage into a real PSReadLine session. Flipped to a whitelist of known POSIX profile ids (bash, zsh, fish, sh, cygwin, git-bash, wsl(-*)), defaulting everything ambiguous to not shimmed (i.e. today's pre-PR behavior, not a new regression).
  2. The keyup paired with a shimmed keydown wasn't swallowed. Win32-Input-Mode stays active for the whole Windows session regardless of shell, so the unswallowed keyup fell through to that encoder and leaked a stray release record. Fixed via the same uiClaimedKeydownKeys claim the scroll-key shim already uses for this exact problem.
  3. shellType was captured once at mount, inconsistent with the established live-getter pattern (smartCopy, enhancedKeyboard) used for exactly this class of "can change after mount, engine doesn't remount" problem. Converted to a getter.

New regression tests lock in all three: wordDeleteShim.test.ts ('default' → not POSIX) and a new engine.wordDeleteShim.test.ts (keydown/keyup pairing across POSIX vs. PowerShell vs. 'default').

Full suite: 446 terminal-core tests, 592 app tests, clean typecheck, all green post-fix.

@rockyway
rockyway merged commit f30ecb5 into develop Jul 23, 2026
4 checks passed
@rockyway
rockyway deleted the feature/ctrl-delete-word-forward branch July 23, 2026 05:46
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.

2 participants