Skip to content

fix(windows): keep Ctrl-W in Git Bash terminals - #13232

Open
innocarpe wants to merge 7 commits into
stablyai:mainfrom
innocarpe:fix/windows-git-bash-ctrl-w
Open

fix(windows): keep Ctrl-W in Git Bash terminals#13232
innocarpe wants to merge 7 commits into
stablyai:mainfrom
innocarpe:fix/windows-git-bash-ctrl-w

Conversation

@innocarpe

@innocarpe innocarpe commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Description

On native Windows, Git Bash now receives physical Ctrl+W when the terminal-first shortcut policy is enabled instead of Orca closing the active tab. The exception is fail-closed: it requires an active terminal pane, KeyW, Ctrl with no other modifiers, an authoritative active local-session shell override identifying Git Bash, and a native Windows terminal host.

Focused fix

  • In scope: route physical Ctrl+W to an active native Windows Git Bash session under Terminal first.
  • Preserved: Orca first, non-terminal surfaces, non-Git-Bash Windows shells, mismatched physical keys, and modified chords retain Orca's existing close/shortcut behavior.
  • Held: WSL and IME behavior are unchanged.

Compatibility and gaps

  • No RPC, stream, persisted-data, dependency, workflow, or downloaded-content changes.
  • macOS, Linux, SSH, and mixed-version native execution were not exercised; the exception is gated away from those paths.
  • Folder workspaces remain supported because the decision uses active terminal-session metadata rather than Git worktree assumptions.

Evidence

  • Focused policy/metadata regression: 15/15.
  • Native Windows Git Bash Electron E2E: 5/5, covering readline delivery, global and per-tab Git Bash selection, negative shell/policy cases, physical-key mismatch, and non-terminal ownership.
  • Rebase seal on current main: stable patch IDs and aggregate patch are unchanged; affected shortcut/PTY unit suites 131/131, renderer/CLI/node typecheck, direct changed-file oxlint, and Electron/CLI build passed.

User-regression tradeoffs

Ctrl+W is intentionally consumed by Git Bash only for an authoritative active native Windows Git Bash pane under Terminal first, matching Bash previous-word deletion instead of tab closure.

Fixes #13015

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7231ca6f-36f5-440b-b973-1724e55c78b7

📥 Commits

Reviewing files that changed from the base of the PR and between 7a50a60 and bbcce40.

📒 Files selected for processing (1)
  • tests/e2e/terminal-windows-git-bash-ctrl-w.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/terminal-windows-git-bash-ctrl-w.spec.ts

📝 Walkthrough

Walkthrough

The terminal shortcut policy identifies unmodified Ctrl+W events. On Windows Git Bash panes, terminal-first mode sends plain Ctrl+W to Git Bash instead of closing the pane. The keyboard handler detects Git Bash from session metadata and Windows terminal-host state. Unit and Windows end-to-end tests cover shortcut routing, pane closure, PTY input, shell overrides, and focus outside terminal surfaces.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the fix and evidence, but it omits the required template sections for screenshots, testing checkboxes, AI review, security audit, and notes. Use the required section headings and add the testing checklist, AI cross-platform review, security audit, screenshots statement, and notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the Windows Git Bash Ctrl-W fix.
Linked Issues check ✅ Passed The implementation routes Ctrl-W to native Windows Git Bash under Terminal first and preserves the behaviors listed in issue #13015.
Out of Scope Changes check ✅ Passed The changes are limited to Windows Git Bash Ctrl-W routing, related detection logic, and focused regression coverage.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/keyboard-handlers.ts (1)

328-350: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add direct coverage for active-pane Git Bash detection.

The new policy test receives an already-resolved gitBash boolean. It does not test session metadata, tab override, or global Windows shell fallback. Add cases for Git Bash session metadata and non-Git-Bash Windows shells.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ff8a785-bcaf-40c6-a372-4eee59431c1f

📥 Commits

Reviewing files that changed from the base of the PR and between 6da7b8e and 706d01a.

📒 Files selected for processing (3)
  • src/renderer/src/components/terminal-pane/keyboard-handlers.ts
  • src/renderer/src/components/terminal-pane/terminal-shortcut-policy-windows-git-bash.test.ts
  • src/renderer/src/components/terminal-pane/terminal-shortcut-policy.ts

@innocarpe
innocarpe force-pushed the fix/windows-git-bash-ctrl-w branch from 706d01a to 37e585a Compare August 9, 2026 01:25
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (37e585a7b3)

Address review: Git Bash terminal-first Ctrl-W now uses the IME-safe physical-code matcher, adds the mismatched code/key regression, and covers session metadata/global fallback detection. Validation: Node 24.18.0 targeted Vitest 5 tests passed; renderer typecheck passed; changed-code quality gate passed. Commit: 37e585a.

@AmethystLiang
AmethystLiang requested a review from OrcaWin August 9, 2026 16:52
@AmethystLiang AmethystLiang added the P1 High priority: bug or day-to-day user frustration label Aug 9, 2026
@OrcaWin
OrcaWin force-pushed the fix/windows-git-bash-ctrl-w branch from 37e585a to 7a50a60 Compare August 10, 2026 21:55
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b59f6b2e-532a-45a0-bee0-ca5556950eec

📥 Commits

Reviewing files that changed from the base of the PR and between 1fafbe6 and 7a50a60.

📒 Files selected for processing (5)
  • src/renderer/src/components/terminal-pane/keyboard-handlers.ts
  • src/renderer/src/components/terminal-pane/terminal-shortcut-policy-windows-git-bash.test.ts
  • src/renderer/src/components/terminal-pane/terminal-shortcut-policy.ts
  • src/renderer/src/components/terminal-pane/windows-git-bash-shortcut.ts
  • tests/e2e/terminal-windows-git-bash-ctrl-w.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/terminal-pane/keyboard-handlers.ts
  • src/renderer/src/components/terminal-pane/terminal-shortcut-policy.ts

Comment thread tests/e2e/terminal-windows-git-bash-ctrl-w.spec.ts Outdated
@innocarpe
innocarpe force-pushed the fix/windows-git-bash-ctrl-w branch from 7a50a60 to bbcce40 Compare August 11, 2026 01:02
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (bbcce40786)

Addressed the review by reusing the terminal-close confirmation settling path before asserting that the tab was removed. The rebased commit also keeps the existing regression coverage intact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High priority: bug or day-to-day user frustration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Ctrl+W closes tab in Windows Git Bash when "Terminal first" is enabled

3 participants