Skip to content

Capabilities(feat): Gate tmux features from one table - #887

Merged
tony merged 10 commits into
masterfrom
capabilities-table
Nov 22, 2026
Merged

tony merged 10 commits into
masterfrom
capabilities-table

Conversation

@tony

@tony tony commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add an internal capability table (libtmux._internal.support.capabilities) for tmux features gated by release.
  • Route existing Server and Pane version gates with matching cross-port IDs through the table with no change in runtime behaviour.
  • Publish capabilities.json (libtmux-capabilities/1), generated from the table via just build-capabilities and guarded by a drift test.
  • Render the capability matrix across tmux 3.2a–3.8 on /compatibility (moved to the top-level sidebar beneath Migration notes) via a new tmux-capabilities Sphinx directive.
  • Remove unreachable < 3.2 hook-scope gates below the 3.2a compatibility floor.

The release each gate compares against was a literal at its call site, so nothing listed what libtmux gates. The other ports publish a generated manifest keyed by shared capability ids; this gives Python the same table, starting with the ids whose tmux command, flag and release already match an existing gate, and renders it directly in the Sphinx documentation.

Changes

Capability table

  • src/libtmux/_internal/support/capabilities.py: Capability and Command dataclasses, the CAPABILITIES table, capability_since() for gates, and manifest() / render() for the published file.
  • capabilities.json: the generated manifest (schema libtmux-capabilities/1, port py, floor 3.2a).
  • justfile: build-capabilities regenerates the manifest.

Gates that now read the table

Capability id Method tmux command / flag Since Below since
run-shell-start-directory Server.run_shell run-shell -c 3.4 Warn, omit -c
run-shell-show-stderr Server.run_shell run-shell -E 3.6 Warn, omit -E
run-shell-args Server.run_shell run-shell arguments 3.7 Warn, omit arguments
list-keys-format Server.list_keys list-keys -F 3.7 Warn, omit -F
capture-trim-blank-cells Pane.capture_pane capture-pane -T 3.4 Warn, omit -T
capture-mode-screen Pane.capture_pane capture-pane -M 3.6 Warn, omit -M
capture-line-flags Pane.capture_pane capture-pane -F, -H, -L 3.7 Warn, omit flag
paste-buffer-no-vis Pane.paste_buffer paste-buffer -S 3.7 Warn, omit -S
floating-pane Pane.new_pane new-pane 3.7 Raise LibTmuxException

Documentation

  • docs/_ext/tmux_capabilities.py and docs/_ext/_static/css/tmux_capabilities.css: tmux-capabilities Sphinx directive rendering capabilities and workarounds across tmux releases with sphinx-ux-badges status pills and py:obj cross-references (refwarn=True) for every API and refusal exception.
  • docs/compatibility.md, docs/index.md, docs/project/index.md, docs/redirects.txt: move Compatibility out of Project to the top-level sidebar beneath Migration notes, render the capability matrix, and redirect both project/compatibility.md and api/compatibility.md.

Hooks

  • src/libtmux/hooks.py: run_hook, set_hook, unset_hook, show_hooks and _show_hook pass the -w / -p scope flag unconditionally; remove HooksMixin._tmux_bin, which had no other callers.

Design decisions

  • Gates still call has_gte_version() and take only the release from the table. The suite replaces that helper by module attribute in libtmux.server and libtmux.pane, so a gate that stopped calling it would stop seeing those replacements.
  • refresh-client -l stays on its literal. libtmux gates it at 3.7 and the shared clipboard-query id says 3.6a; the table should not publish an id with a release the vocabulary does not give it.
  • The other gates keep their literals. Their tmux command and flag match no shared id yet, and a shared id is defined in the ports' vocabulary before a port publishes it.
  • The table is internal, under libtmux._internal.support, the package name Support(feat): Verify connected tmux daemon meets the 3.3a minimum #779 introduces for version support. No public accessor is added until a caller outside the package needs one.
  • tmux-capabilities sets refwarn=True on every generated py:obj cross-reference so a normal just build-docs build warns immediately if any published API or refusal exception lacks a documented target.
  • The hook gates compared against 3.2, below the 3.2a minimum, and nothing enforces the minimum at runtime. On a tmux older than 3.2 a scoped hook call now reaches tmux and gets tmux's own error, where it used to warn and drop the flag. tmux(feat[minimum]): Require tmux 3.3a #888 and Support(feat): Verify connected tmux daemon meets the 3.3a minimum #779 remove the same gates as part of raising the minimum to 3.3a.

Verification

Verify no < 3.2 version gates or _tmux_bin references remain in hooks.py:

$ rg 'has_.*version|_tmux_bin' src/libtmux/hooks.py

Verify no stale project/compatibility references remain outside docs/redirects.txt:

$ rg 'project/compatibility' docs CHANGES

Test plan

  • test_manifest_matches_table: committed capabilities.json matches both capabilities.manifest() and capabilities.render() (fails on since edits and formatting drift)
  • test_gate_reads_its_release_from_the_table: every routed gate warns and omits its flag, or raises LibTmuxException, when its table since is raised above the running tmux
  • test_published_names_resolve: every API and error dotted path in the manifest imports
  • test_docs_capabilities.py: tmux-capabilities links documented APIs and refusal errors, warns on unresolved py:obj targets (refwarn=True mutation proven), supports :api:, :versions:, :group-releases:, :no-legend:, workarounds, and the text builder
  • Full suite on tmux 3.8a
  • Hook and capability tests on tmux 3.2a
  • ruff check, ruff format --check, mypy (including docs/_ext)
  • just build-docs and just -f docs/justfile checkbuild (including rediraffe redirects for /project/compatibility/ and /api/compatibility/)
  • Full tmux matrix in CI (3.2a through 3.8 and master)

Related issues and companion PRs

@codecov

codecov Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.61204% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.32%. Comparing base (7dcb107) to head (526a702).

Files with missing lines Patch % Lines
docs/_ext/tmux_capabilities.py 90.36% 10 Missing and 14 partials ⚠️
src/libtmux/_internal/support/capabilities.py 29.41% 24 Missing ⚠️
src/libtmux/hooks.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #887      +/-   ##
==========================================
+ Coverage   53.18%   55.32%   +2.14%     
==========================================
  Files          26       28       +2     
  Lines        3845     4110     +265     
  Branches      774      817      +43     
==========================================
+ Hits         2045     2274     +229     
- Misses       1496     1523      +27     
- Partials      304      313       +9     

☔ 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: capabilities.json is a new published file that tooling and the
shared documentation read.

what:
- Add a Development entry describing the manifest and how to
  regenerate it
tony added 4 commits November 21, 2026 18:28
why: The release each gate compares against was a literal at its call
site, so nothing listed what libtmux gates or published it. The other
libtmux ports publish a generated capability manifest keyed by shared
ids.

what:
- Add an internal capability table with the nine shared ids whose
  tmux command, flag and release match an existing gate
- Read the release for those eleven gates from the table, through the
  existing has_gte_version helper, so behaviour is unchanged
- Generate capabilities.json from the table, with a recipe to rebuild
  it and a test that fails when the file drifts
- Test that each routed gate falls back or refuses when its table
  release is raised
why: Five hook methods skipped the -w and -p scope flags on tmux
older than 3.2. libtmux supports 3.2a and newer, so the branch ran
only on a tmux it does not support.

what:
- Pass the scope flag unconditionally in run_hook, set_hook,
  unset_hook, show_hooks and _show_hook
- Remove the private _tmux_bin helper that only those gates read
why: capabilities.json is a new published file that tooling and the
shared documentation read.

what:
- Add a Development entry describing the manifest and how to
  regenerate it
why: The ports' shared naming puts version checks at support.versions
and optional features at support.capabilities.

what:
- Move the capability table to libtmux._internal.support.capabilities
- Add the support package with a module docstring
- Update the gates, the tests and the build-capabilities recipe
@tony
tony force-pushed the capabilities-table branch from 2a1e253 to e42a97d Compare November 22, 2026 00:54
tony added 6 commits November 22, 2026 05:37
why: Python, tmux, and platform compatibility sits alongside the
changelog and migration notes rather than contributor workflow guides
under Project.

what:
- Move docs/project/compatibility.md to docs/compatibility.md and place
  it beneath Migration notes in the root toctree
- Redirect project/compatibility.md and api/compatibility.md to
  compatibility.md
- Update internal {doc} and grid-card links across docs/
why: The compatibility page stated only the minimum tmux version, while
libtmux._internal.support.capabilities already lists each gated feature,
its release threshold, and the Python APIs and refusal errors it
concerns.

what:
- Add the docs._ext.tmux_capabilities Sphinx extension and the
  tmux-capabilities directive backed by sphinx-ux-badges
- Link each entry's APIs and refusal exception through Python-domain
  cross-references that warn when unresolved
- Render the capability matrix across tmux 3.2a through 3.8 on
  docs/compatibility.md
- Type-check docs/_ext under mypy and add directive, cross-reference,
  option, workaround, and text-builder tests
why: Readers scanning release notes can find the relocated compatibility
page and its tmux capability matrix.

what:
- Add a Documentation entry linking /compatibility and /migration
why: Comparing only parsed JSON skipped capabilities.render(), the
serializer just build-capabilities writes to capabilities.json.

what:
- Assert MANIFEST_PATH.read_text() equals capabilities.render() in
  test_manifest_matches_table
why: docs/project/compatibility.md moved to docs/compatibility.md.

what:
- List compatibility.md alongside project/ in the repository map
why: Changelog deliverable headings carry their (#NN) pull request
reference.

what:
- Add (#887) to the capability matrix heading in CHANGES
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