orca icon indicating copy to clipboard operation
orca copied to clipboard

[Feature]: Add four-way terminal splitting and spatial pane focus

Open mistcoversmyeyes opened this issue 4 months ago • 2 comments

Problem or use case

Orca terminal pane shortcuts currently support splitting only to the right (terminal.splitRight) or down (terminal.splitDown). They do not offer equivalent split-left or split-up actions, so users cannot build pane layouts consistently in all four directions from the keyboard.

Pane focus is also limited to terminal.focusPreviousPane and terminal.focusNextPane. These actions cycle through pane order rather than moving to the pane that is visually adjacent. In nested or grid-like layouts, the result has no clear spatial relationship to what the user sees and becomes difficult to predict as the number of panes grows.

The use case is to create and navigate multi-pane terminal layouts entirely by keyboard with the same left/right/up/down mental model supported by Windows Terminal.

Proposed solution

Add independently configurable terminal shortcut actions for:

  • Split left
  • Split right
  • Split up
  • Split down
  • Focus pane left
  • Focus pane right
  • Focus pane up
  • Focus pane down

A directional split should place the new pane on the requested side of the active pane, including in nested layouts.

Directional focus should use the rendered pane geometry and select the nearest eligible pane in the requested direction, rather than relying on DOM or creation order. If no pane exists in that direction, the behavior should be deterministic and documented—preferably keeping focus on the current pane instead of wrapping unexpectedly.

Expose these actions consistently in keyboard shortcut settings and relevant command menus. Keep the existing focusPreviousPane, focusNextPane, splitRight, and splitDown actions working for backward compatibility.

The implementation should preserve Orca's cross-platform shortcut handling and labels on macOS, Windows, and Linux. It should also behave consistently for local, WSL, and SSH/remote terminals because navigation is an Orca pane-layout concern rather than an execution-host concern.

Tests should cover nested horizontal and vertical splits, uneven pane sizes, ties between directional candidates, layout edges, and expanded-pane behavior.

Alternatives or additional context

Windows Terminal provides the interaction model being requested: users can split panes and move focus according to spatial direction.

The existing previous/next focus actions remain useful as sequential navigation and should not be removed. They are not an adequate substitute for directional focus in layouts with multiple rows and columns because pane order does not reliably communicate visual adjacency.

mistcoversmyeyes avatar Jul 11 '26 09:07 mistcoversmyeyes

The geometry-based focus model sounds much more predictable than creation-order cycling for grid layouts. One case worth defining explicitly is when two panes overlap equally in the requested direction but have different center-point distances: should overlap, edge distance, or center distance take precedence? A focused unit test for that tie-breaker would keep directional navigation stable if the layout algorithm changes later.

hiSandog avatar Jul 11 '26 10:07 hiSandog

should overlap, edge distance, or center distance take precedence?

I think Orca should follow Windows Terminal’s existing directional pane-navigation behavior rather than introduce a new center-distance heuristic. Windows Terminal is the original inspiration for this proposal, and adopting its established selection semantics would provide a proven and familiar interaction model.

One important edge case is a layout with one pane on the left and two equally sized panes stacked on the right:

┌──────────┬──────────┐
│          │    B     │
│    A     ├──────────┤
│          │    C     │
└──────────┴──────────┘

When focus is on A and moves right, comparing pane centers alone leaves B and C equally distant, so it cannot select a target without an additional arbitrary tie-breaker.

Windows Terminal avoids this ambiguity by navigating the pane split tree and finding a visually adjacent leaf. For a rightward move, the candidate must share A’s right-hand boundary, and A’s top-left anchor on the perpendicular axis must fall within the candidate’s vertical span. In this example, that selects B. Moving left from either B or C selects A.

The relevant Windows Terminal implementation is in NavigateDirection, _IsAdjacent, and _FindNeighborForPane.

Rather than defining a separate ranking between overlap, edge distance, and center distance, I suggest adopting those semantics and covering the equivalent one-to-two, two-to-one, uneven-size, and nested-split layouts with focused unit tests.

mistcoversmyeyes avatar Jul 11 '26 11:07 mistcoversmyeyes

#15068 implements the spatial pane focus half of this issue.

Four bindable actions: terminal.focusPaneLeft / Right / Up / Down. Neighbor selection follows the Windows Terminal adjacency rules discussed above (shared travel-axis border + source top-left in the candidate’s perpendicular span; no wrap). Defaults are Mod+Alt+Arrow (⌘⌥←/→/↑/↓ on macOS).

Out of scope here:

  • Directional split (splitLeft / splitUp) remains #13984
  • terminal.focusNextPane / focusPreviousPane (Cmd+[ / Cmd+]) stay creation-order

Happy to adjust defaults or the neighbor test if maintainers want a different chord family.

zyh94946 avatar Aug 17 '26 08:08 zyh94946

Closing as a duplicate of #7922. Disagree? Please respond! I will re-visit this ticket in 5 days. If you respond, I will re-open it 🙏.

nwparker avatar Aug 23 '26 00:08 nwparker