Skip to content

Keep typing predictions inside side-by-side panes - #1441

Closed
csillag wants to merge 2 commits into
mobile-shell:masterfrom
csillag:pane-aware-prediction
Closed

csillag wants to merge 2 commits into
mobile-shell:masterfrom
csillag:pane-aware-prediction

Conversation

@csillag

@csillag csillag commented Nov 7, 2026

Copy link
Copy Markdown

When the screen is split into side-by-side panes (tmux with vertical splits, vim's :vsplit, emacs side-by-side windows), typing in one pane changes only that pane. The prediction engine assumes the whole rest of the row moves, so a key typed in any pane but the rightmost is predicted to push the pane borders and the neighbouring panes one cell to the right, and backspace pulls them left. When the server's echo arrives, the moved border does not match, so all predictions are discarded and the engine waits for the server again. In those panes there is effectively no local echo, and keys typed ahead make the borders jump right and back.

This change finds the pane around the cursor on the displayed frame: the nearest column on each side that holds a vertical line (U+2502, U+2503, U+2551 or |) continuing on the row above or below, so a lone | in a shell pipeline is not a border. Insertion, backspace, the left and right arrows, last-column handling and wrap, and CR use the pane's edges instead of the screen's, and a character typed at a pane's left edge no longer copies the border's renditions. Without such borders the pane is the whole row, and nothing changes. MOSH_PREDICTION_PANES=no restores the old behaviour.

terminaloverlay.cc moves into a noinst library so that the new src/tests/prediction-panes can drive PredictionEngine against a real Terminal::Complete; 13 of its 15 tests fail on master. make check passes, the lines added to terminaloverlay.cc have 100% line coverage, and I have been using it in tmux with four side-by-side panes over a real link.

🤖 Generated with Claude Code

csillag and others added 2 commits November 7, 2026 12:13
When the screen is split into side-by-side panes, as tmux, vim and
emacs draw them, typing in one pane changes only that pane. The
prediction engine assumed the whole rest of the row moves, so a key
typed in any pane but the rightmost shifted the borders and the panes
to its right. When the server's echo arrived, the moved border did not
match, and mosh threw away all predictions and waited for the server
again. In those panes there was effectively no local echo, and keys
typed ahead made the borders jump right and back.

The engine now finds the pane around the cursor on the screen: a
vertical line (U+2502, U+2503, U+2551 or '|') that continues on the row
above or below. Typing, backspace, the arrow keys, wrapping and Enter
stay between those borders, and a key typed at a pane's left edge no
longer takes the border's colours. Without borders the pane is the
whole row, as before.

MOSH_PREDICTION_PANES=no restores the old behaviour.

The prediction engine moves into libmoshoverlay.a so that the new test,
src/tests/prediction-panes.cc, can drive it against the real emulator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clang-format 14 breaks the braced initializer in the TEST() macro over
several lines. Build each entry with a constructor instead, which it
leaves on one line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@achernya

achernya commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

We are not accepting LLM contributions at this time.

@achernya achernya closed this Nov 7, 2026
@csillag

csillag commented Nov 7, 2026

Copy link
Copy Markdown
Author

We are not accepting LLM contributions at this time.

I'm sorry, is this documented somewhere? I tried to look before submitting (PR template, contributor's guide, etc) but couldn't find anything.

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