Skip to content

fix(tui): tmux text selection with auto-scroll and OSC 52 copy - #5

Open
FeiSong123 wants to merge 7 commits into
Owen718:mainfrom
FeiSong123:feat/search-cost
Open

fix(tui): tmux text selection with auto-scroll and OSC 52 copy#5
FeiSong123 wants to merge 7 commits into
Owen718:mainfrom
FeiSong123:feat/search-cost

Conversation

@FeiSong123

@FeiSong123FeiSong123 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What

Mouse selection in tmux, plus one tool-contract fix.

1. Click-drag text selection with OSC 52 copy

Left-button drag selects text in the rendered window with reverse-video highlight, and release copies the plain text to the system clipboard via OSC 52. Selection points live in full-content coordinates, so scrolling mid-drag keeps the anchor on the same text.

2. Auto-scroll across screens

Dragging past the top or bottom edge scrolls the viewport and extends the selection. Auto-scroll runs on a timer once the drag rests on an edge, so it keeps stepping even when the mouse stops moving. It only engages after a real drag (head strictly above the anchor at the top edge, strictly below at the bottom), so a click on an edge row does not start scrolling against the first movement.

3. Highlight under the cursor

The highlight was indexed as if the render buffer were always the visible window, so in the non-scroll viewport the reverse-video landed on a line that had scrolled off screen. The renderer now tracks the content line of the buffer's first row separately for highlighting and mouse mapping.

4. Document the write size limit

The write tool has no size cap itself, but the tool-call channel does (roughly 8KB raw, CJK counting ~6x once JSON-escaped). The write description now says so and points at the bash heredoc escape hatch. This moves the frozen tool schema, so the pinned Cache ABI and request golden hashes move with it.

Tests

  • tui-scroll 10/10 (includes selection mapping, highlight position, and auto-scroll cases)
  • Full local suites pass: protocol 103/103, context 113/113, journal 49/49, effects 115/115, session 173/173, recovery 84 pass + 1 skip
  • npm run check passes

…rdinates
Dragging past the top or bottom edge now scrolls the viewport and
extends the selection, so a drag can copy more than one screen of
history. Selection points moved from screen-window coordinates to
full-content coordinates so scrolling mid-drag keeps the anchor on the
same text instead of drifting with the viewport.
…atch
The write tool itself has no size cap, but the tool-call channel does:
roughly 8KB of raw text, with CJK characters counting about six times
their byte size once JSON-escaped. Say so in the write tool description
so the model reaches for a bash heredoc instead of retrying a doomed
write. This moves the frozen tool schema, so the pinned Cache ABI and
request golden hashes move with it.
@FeiSong123FeiSong123 changed the title fix(tui): auto-scroll mouse selection across screensfix(tui): auto-scroll selection; document the write size limitAug 13, 2026
Dragging at the top or bottom edge forced a synchronous full repaint on
every motion report, which stuttered and flickered. Scroll now moves one
line per 50ms interval and leaves the repaint to the batched render
timer; when there is no more content in that direction the selection head
pins to the edge so the highlight follows the cursor instead of jumping.
Auto-scroll now runs on a setTimeout chain once the drag rests on an
edge, so it keeps stepping even when the mouse stops moving. It also
only scrolls while the drag is already moving that way (head above the
anchor at the top edge, below it at the bottom), which stops the
occasional reverse flicker at the edge.
In the non-scroll viewport the render pipeline keeps the full content,
but the highlight was indexed as if it were already the visible window,
so the reverse-video landed on a line that had scrolled off screen while
the selection under the mouse stayed unhighlighted. Track the content
line of newLines[0] separately for highlighting and mouse mapping.
The auto-scroll direction check used <= and >=, so a click on the top or
bottom row already qualified as a drag and the viewport started scrolling
against the user's first movement. Match prime-agent's strict comparison:
only scroll up once the head is strictly above the anchor, and only scroll
down once it is strictly below.
@FeiSong123FeiSong123 changed the title fix(tui): auto-scroll selection; document the write size limitfix(tui): tmux text selection with auto-scroll and OSC 52 copyAug 13, 2026
Sign up for freeto 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

@FeiSong123