Skip to content

Client(feat): Request a terminal clipboard - #889

Merged
tony merged 4 commits into
masterfrom
feat/client-clipboard-request
Nov 28, 2026
Merged

tony merged 4 commits into
masterfrom
feat/client-clipboard-request

Conversation

@tony

@tony tony commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add Client.request_clipboard() for a selected terminal on tmux 3.6a and later.
  • Check the connected daemon release before issuing a clipboard query.
  • Preserve Server.refresh_client(request_clipboard=True) and its tmux 3.7 warning floor.
  • Extract attached_terminal() into tests/terminal.py for client and popup PTY tests.

Changes by area

Client and server API

  • src/libtmux/client.py: add _CLIPBOARD_GATE and Client.request_clipboard() to check the connected daemon's #{version} and run refresh-client -t <client_name> -l.
  • src/libtmux/server.py: point Server.refresh_client() callers needing 3.6a per-client clipboard queries to Client.request_clipboard().

Documentation and changelog

  • docs/topics/clients.md: document Client.request_clipboard(), tty target lifetime after detachment, the 3.6a daemon floor, and asynchronous OSC 52 paste-buffer creation.
  • CHANGES: add the Request a terminal clipboard (#889) deliverable under ### What's new.

Tests

  • tests/terminal.py: add the shared attached_terminal() PTY client context manager with optional output draining.
  • tests/test_client.py: cover _CLIPBOARD_GATE version matching, selected-terminal OSC 52 round trips, older-daemon refusal, detached clients, and missing client_name.
  • tests/test_pane.py, tests/test_server.py: reuse attached_terminal(..., drain_output=True) for popup tests and verify <3.7 warning versus >=3.7 -l emission on Server.refresh_client().

Design decisions

  • Gate Client.request_clipboard() on the connected daemon's #{version} inside if-shell -F rather than has_gte_version("3.6a") or capability_since() from Capabilities(feat): Gate tmux features from one table #887: get_version() strips patch letters (comparing 3.6 equal to 3.6a), client and daemon releases can differ, and sending refresh-client -l to a 3.2a daemon terminates the server (server exited unexpectedly).
  • Use the 3.6a clipboard-query floor from libtmux-ts on Client.request_clipboard() while keeping Server.refresh_client(request_clipboard=True) at its existing 3.7 warning floor.

Existing Server.refresh_client() display refresh (3.7 floor; warns and refreshes display on 3.6a):

server.refresh_client(target_client=tty, request_clipboard=True)

Direct per-client clipboard request (3.6a floor; raises VersionTooLow on older daemons before sending -l, and creates a paste buffer asynchronously when the terminal answers OSC 52):

server.clients.get(client_name=tty).request_clipboard()

Test plan

  • Confirm only the selected terminal receives the OSC 52 query and its reply creates a paste buffer
  • Verify VersionTooLow refusal through tmux 3.6 and clipboard round trips across 3.6a, 3.7, 3.7a, 3.7b, 3.8a, and next-3.9
  • Check cross-version client/daemon pairs (3.8a client against 3.2a daemon and 3.6 client against 3.8a daemon)
  • Verify Client.request_clipboard() raises ValueError without client_name and LibTmuxException after detachment
  • Verify Server.refresh_client(request_clipboard=True) warns and omits -l below 3.7 and passes -l from 3.7
  • uv run pytest, uv run ruff check ., uv run mypy, and just build-docs pass

@codecov

codecov Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.48148% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.41%. Comparing base (639de6c) to head (0711bbd).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
src/libtmux/client.py 58.82% 6 Missing and 1 partial ⚠️
tests/terminal.py 91.89% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #889      +/-   ##
==========================================
+ Coverage   58.01%   58.41%   +0.39%     
==========================================
  Files          29       30       +1     
  Lines        4416     4470      +54     
  Branches      895      900       +5     
==========================================
+ Hits         2562     2611      +49     
- Misses       1543     1548       +5     
  Partials      311      311              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

tony added a commit that referenced this pull request Nov 21, 2026
why: Callers need the minimum tmux release and the point at which
clipboard data becomes available.

what:
- Document the selected client, the asynchronous reply and PR #889.
tony added a commit that referenced this pull request Nov 22, 2026
why: Callers need the minimum tmux release and the point at which
clipboard data becomes available.

what:
- Document the selected client, the asynchronous reply and PR #889.
@tony
tony force-pushed the feat/client-clipboard-request branch from 9c159a5 to 5ff1f71 Compare November 22, 2026 00:25
tony added a commit that referenced this pull request Nov 22, 2026
why: Callers need the minimum tmux release and the point at which
clipboard data becomes available.

what:
- Document the selected client, the asynchronous reply and PR #889.
@tony
tony force-pushed the feat/client-clipboard-request branch from 5ff1f71 to 1400a06 Compare November 22, 2026 13:19
tony added a commit that referenced this pull request Nov 22, 2026
why: Callers need the minimum tmux release and the point at which
clipboard data becomes available.

what:
- Document the selected client, the asynchronous reply and PR #889.
@tony
tony force-pushed the feat/client-clipboard-request branch from 1400a06 to 342774b Compare November 22, 2026 14:54
tony added a commit that referenced this pull request Nov 22, 2026
why: Callers need the minimum tmux release and the point at which
clipboard data becomes available.

what:
- Document the selected client, the asynchronous reply and PR #889.
@tony
tony force-pushed the feat/client-clipboard-request branch from 342774b to 06f52c4 Compare November 22, 2026 19:27
@tony tony added the area: options-formats Options, formats, names, targets label Nov 24, 2026
tony added a commit that referenced this pull request Nov 25, 2026
why: Callers need the minimum tmux release and the point at which
clipboard data becomes available.

what:
- Document the selected client, the asynchronous reply and PR #889.
@tony
tony force-pushed the feat/client-clipboard-request branch from 06f52c4 to a67455b Compare November 25, 2026 08:13
tony added a commit that referenced this pull request Nov 28, 2026
why: Callers need the minimum tmux release and the point at which
clipboard data becomes available.

what:
- Document the selected client, the asynchronous reply and PR #889.
@tony
tony force-pushed the feat/client-clipboard-request branch from a67455b to fc63fbd Compare November 28, 2026 12:49
@tony tony mentioned this pull request Nov 28, 2026
43 of 62 tasks
@tony tony added this to the 0.70.0 milestone Nov 28, 2026
tony added a commit that referenced this pull request Nov 28, 2026
why: Callers need the minimum tmux release and the point at which
clipboard data becomes available.

what:
- Document the selected client, the asynchronous reply and PR #889.
@tony
tony force-pushed the feat/client-clipboard-request branch from fc63fbd to db67b18 Compare November 28, 2026 13:27
tony added 4 commits November 28, 2026 16:10
why: Callers can select an attached terminal and ask tmux 3.6a for its
clipboard. The classic server option starts sending requests at 3.7.

what:
- Target the selected client and check its daemon in the same command.
- Return when tmux accepts the request and surface command errors.
- Exercise terminal selection and delayed replies with two attached
  terminals and verify the classic warning boundary.
why: A tty name can be assigned to a new terminal after detachment.

what:
- Explain when tmux resolves the clipboard request's target.
- Describe the error when no client has that name.
why: Callers need the minimum tmux release and the point at which
clipboard data becomes available.

what:
- Document the selected client, the asynchronous reply and PR #889.
why: A vendor build can report a label without a tmux release number.
The terminal test must exercise the refusal path on that build.

what:
- Check release strings and their expected results in one tmux command.
- Exercise the selected terminal on the connected daemon's branch.
@tony
tony force-pushed the feat/client-clipboard-request branch from db67b18 to 0711bbd Compare November 28, 2026 22:11
@tony
tony merged commit 9b2a277 into master Nov 28, 2026
14 checks passed
@tony
tony deleted the feat/client-clipboard-request branch November 28, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: options-formats Options, formats, names, targets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant