Skip to content

Revert "Map Shift+Enter to raw newline in Ghostty" - #2407

Merged
austinywang merged 1 commit into
mainfrom
revert-2355-issue-2352-shift-enter-tmux
Mar 31, 2026
Merged

austinywang merged 1 commit into
mainfrom
revert-2355-issue-2352-shift-enter-tmux

Conversation

@austinywang

@austinywang austinywang commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor

Reverts #2355


Summary by cubic

Reverts the Shift+Enter-to-newline behavior and removes tmux state detection/telemetry. Shift+Enter now follows normal Ghostty keybinding resolution with no tmux-specific remapping.

  • Refactors
    • Removed tmux plumbing: shell integration reporting, socket command report_tmux_state, workspace/tab state, tmux detection helpers, and related tests.
    • Simplified key handling by deleting Shift+Enter remap logic and the user-config scan for Shift+Enter; binding flag lookup is inlined.
    • Shell integration updates: stop reporting tmux state; require CMUX_PANEL_ID before sending shell activity; resolve and report TTY once.

Written for commit a5120be. Summary will update on new commits.

Summary by CodeRabbit

Release Notes

  • Refactor

    • Removed tmux state reporting functionality across shell integration and terminal management.
    • Removed Shift+Enter key remapping for tmux compatibility.
    • Removed tmux detection and panel state tracking.
  • Tests

    • Removed tests related to tmux state reporting, detection, and Shift+Enter behavior.

@vercel

vercel Bot commented Mar 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment Mar 31, 2026 4:57am

@austinywang
austinywang merged commit 341aed8 into main Mar 31, 2026
10 of 14 checks passed
@coderabbitai

coderabbitai Bot commented Mar 31, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9c96eacc-2acc-46d8-946c-ba593f461068

📥 Commits

Reviewing files that changed from the base of the PR and between 112358e and a5120be.

📒 Files selected for processing (9)
  • Resources/shell-integration/cmux-bash-integration.bash
  • Resources/shell-integration/cmux-zsh-integration.zsh
  • Sources/GhosttyTerminalView.swift
  • Sources/TabManager.swift
  • Sources/TerminalController.swift
  • Sources/TerminalSSHSessionDetector.swift
  • Sources/Workspace.swift
  • cmuxTests/GhosttyConfigTests.swift
  • cmuxTests/TerminalControllerSocketSecurityTests.swift

📝 Walkthrough

Walkthrough

This PR removes tmux-state reporting infrastructure across shell integration scripts and terminal controller components, while eliminating Shift+Enter remapping support driven by user configuration. Multiple helper functions, state tracking, and conditional control flows are deleted to simplify the codebase.

Changes

Cohort / File(s) Summary
Shell Integration – Tmux State Reporting Removal
Resources/shell-integration/cmux-bash-integration.bash, Resources/shell-integration/cmux-zsh-integration.zsh
Removed tmux-state reporting helper functions, payload construction, and signature caching. Updated _cmux_preexec_command/_cmux_preexec and _cmux_prompt_command/_cmux_precmd to stop calling tmux-state reporters. Added stricter CMUX_PANEL_ID gating and refactored flows to always emit shell activity state without tmux-state deduplication.
Swift – Terminal View Key-Handling Refactor
Sources/GhosttyTerminalView.swift
Removed Shift+Enter remapping support, including user config scanning, runtime key-handling conditional, and helper functions (scanShiftEnterConfigFile, userConfigDefinesShiftEnterBinding, shouldRemapShiftEnterForTmux). Inlined binding-flag computation in performKeyEquivalent to remove intermediate helper ghosttyBindingFlags(for:surface:).
Swift – Tmux State Tracking Removal
Sources/TabManager.swift, Sources/Workspace.swift, Sources/TerminalController.swift, Sources/TerminalSSHSessionDetector.swift
Removed tmux-state tracking from Workspace (panelTmuxStates storage and related methods), deleted TabManager.updateSurfaceTmuxState(...), eliminated socket command plumbing and state parser in TerminalController, and removed isInsideTmux(...) detection and helpers from TerminalSSHSessionDetector.
Tests – Tmux & Shift+Enter Test Case Removal
cmuxTests/GhosttyConfigTests.swift, cmuxTests/TerminalControllerSocketSecurityTests.swift
Removed XCTest cases validating Shift+Enter config binding, shouldRemapShiftEnterForTmux gating, tmux detection, and tmux-state socket command routing. Deleted helper waitForCondition(...) used only by removed tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Hoppy cleanup day! ✨
Tmux states and Shift+Enter binds,
All swept away like morning dew—
Shell flows now clean and true,
Simpler code hops toward the light! 🌿

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revert-2355-issue-2352-shift-enter-tmux

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 and usage tips.

@greptile-apps

greptile-apps Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR is a clean revert of #2355, which had added a feature to map Shift+Enter to a raw newline ( ) when the terminal is inside tmux in Ghostty. The revert removes the entire feature stack end-to-end.

What was removed:

  • Shell integration (bash + zsh): _cmux_report_tmux_state and its helpers (_cmux_report_tmux_state_payload, _cmux_tmux_state_report_signature), plus the _CMUX_TMUX_STATE_SIGNATURE_LAST deduplication variable. _cmux_precmd/_cmux_prompt_command and _cmux_preexec/_cmux_preexec_command are restructured to return early on missing CMUX_PANEL_ID (restoring pre-Map Shift+Enter to raw newline in Ghostty #2355 behavior).
  • GhosttyTerminalView.swift: userConfigDefinesShiftEnterBinding, UserShiftEnterConfigSummary, scanShiftEnterConfigFile, userShiftEnterConfigSummary, keybindDirectiveTargetsShiftEnter, shouldRemapShiftEnterForTmux (both static and instance variants), and ghosttyBindingFlags (inlined back at its one call site — semantically identical).
  • TerminalController.swift: The report_tmux_state socket command handler, its per-surface deduplication cache, and the normalizedReportedTTYName/resolvePanelIdByTTY/parseReportedTmuxState helpers.
  • Workspace.swift / TabManager.swift: panelTmuxStates dictionary and the updatePanelTmuxState/panelIsInsideTmux/updateSurfaceTmuxState methods, plus their cleanup in all panel-removal paths.
  • TerminalSSHSessionDetector.swift: isInsideTmux(forTTY:), isInsideTmuxForTesting, and the generalized isForegroundProcess helper (SSH check inlined back directly).
  • Tests: All test coverage added by Map Shift+Enter to raw newline in Ghostty #2355 is removed in lockstep.

The revert is thorough: a post-revert grep confirms zero dangling references to any removed symbol across both Sources/ and cmuxTests/.

Confidence Score: 5/5

This PR is safe to merge — it is a complete, consistent revert with no dangling references or behavioral regressions.

Every removed symbol was verified to have no remaining callers; all inlined replacements are semantically identical to the methods they replace; shell integration guard restructuring restores the documented pre-#2355 flow; all associated tests are removed in lockstep. No P0 or P1 findings were identified.

No files require special attention.

Important Files Changed

Filename Overview
Sources/GhosttyTerminalView.swift Removes the Shift+Enter tmux remapping logic and inlines the previously extracted ghosttyBindingFlags closure back at the call site — functionally identical.
Sources/TerminalController.swift Removes the report_tmux_state socket command handler, its deduplication cache, and associated helpers.
Sources/Workspace.swift Removes panelTmuxStates dictionary and its management methods from all panel-pruning/removal call sites.
Sources/TerminalSSHSessionDetector.swift Removes isInsideTmux* methods and inlines the SSH-specific foreground process check directly.
Sources/TabManager.swift Removes updateSurfaceTmuxState forwarding method; no callers remain.
Resources/shell-integration/cmux-zsh-integration.zsh Removes _cmux_report_tmux_state family and restores pre-#2355 CMUX_PANEL_ID guard placement.
Resources/shell-integration/cmux-bash-integration.bash Same as zsh: removes tmux state reporting and restores early-return guard at function top.
cmuxTests/GhosttyConfigTests.swift Removes all tests covering the reverted feature.
cmuxTests/TerminalControllerSocketSecurityTests.swift Removes testReportTmuxStateResolvesPanelByTTY and the waitForCondition helper used only by it.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Shift+Enter keyDown\n(GhosttyNSView)"] --> B["Check bindingFlags\n(inlined closure)"]
    B -->|"is binding"| C["Handle Ghostty keybinding"]
    B -->|"not binding"| D["Normal keyDown path"]

    subgraph REMOVED ["Removed by this revert"]
        R1["shouldRemapShiftEnterForTmux()"]
        R2["panelIsInsideTmux() / panelTmuxStates"]
        R3["TerminalSSHSessionDetector.isInsideTmux()"]
        R4["Shell: _cmux_report_tmux_state"]
        R5["Socket: report_tmux_state handler"]
        R6["userConfigDefinesShiftEnterBinding"]
    end

    D -.->|"was intercepted"| R1
    R1 -.-> R2
    R1 -.-> R3
    R4 -.->|"socket message"| R5
    R5 -.-> R2
    R6 -.-> R1
Loading

Reviews (1): Last reviewed commit: "Revert "Map Shift+Enter to raw newline i..." | Re-trigger Greptile

bn-l pushed a commit to bn-l/cmux that referenced this pull request Apr 3, 2026
…e-2352-shift-enter-tmux

Revert "Map Shift+Enter to raw newline in Ghostty"

This branch was successfully deployed

1 active deployment
Preview — a5120be3 Deployed Mar 31, 2026 by vercel[bot]
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