GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(cli/load,tests) Migrate display-message to typed wrapper by tony · Pull Request #1039 · tmux-python/tmuxp

Conversation

@tony

@tony tony commented May 10, 2026

Copy link
Copy Markdown
Member

Summary

  • Drop the last two cmd("display-message", "-p", ...) escape hatches in the codebase: one in production (cli/load._reattach), six in test code (the plugin-system suite).
  • Same tmux invocation under the hood, just routed through libtmux's typed Pane.display_message(cmd, get_text=True) wrapper. No behavior change.
  • Follows the libtmux 0.56.0 bump in py(deps) Bump libtmux 0.56.0 #1038 — the wrapper itself has been around since 0.55.0, but with 0.56.0 now landed there's no remaining reason to keep the cmd() escape for this particular subcommand.

Why now

PR #1038 broadened the Pane.display_message flag coverage in libtmux 0.56.0 (format_string=, verbose=, delay=, notify=, target_client=). While auditing tmuxp for spots that could move to the new typed surface, the only remaining cmd() escape in production turned out to be the post-reattach session-name echo loop in cli/load._reattach. Five of the six other usages were in tests asserting on session/window names via the same idiom — leaving them on cmd() while production migrated would split the call shape across the codebase.

The migration itself doesn't depend on a 0.56.0-only API; this is consistency cleanup that 0.56.0's broader display_message surface made an obvious moment to do.

Changes in this PR

c54893e5 — cli/load(refactor[_reattach]) Use Pane.display_message wrapper

Production change. Replaces:

proc = builder.session.cmd("display-message", "-p", "'#S'")
for line in proc.stdout:
    ...

with:

active_pane = builder.session.active_pane
assert active_pane is not None
lines = active_pane.display_message("'#S'", get_text=True)
for line in lines:
    ...

The narrowing assert mirrors the existing assert builder.session is not None already at the top of _reattach(). tmux's display-message without -t defaults to the session's active pane, so the underlying invocation is byte-for-byte identical.

46b52f16 — tests(refactor[plugin_system]) Use Pane.display_message wrapper

Migrates six test sites in tests/cli/test_cli.py::test_reattach_plugins and four test_plugin_system_* checks in tests/workspace/test_builder.py to the same typed wrapper. Hoists active_pane once in the multi-query test that asserts on both '#S' and '#W' (replaces two separate cmd() roundtrips with two calls on the same pane reference).

Test plan

  • uv run ruff check . --fix --show-fixes clean before each commit
  • uv run ruff format . clean before each commit
  • uv run mypy clean before each commit (the narrowing assert was load-bearing — without it, Pane | None typing rejects the call)
  • uv run py.test --reruns 0 -vvv — 797 passed, 2 skipped, before each commit
  • just build-docs succeeds before each commit
  • No remaining cmd("display-message", ...) calls anywhere in src/ or tests/ (verified via grep -rn 'cmd("display-message"' src/ tests/)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@codecov

codecov Bot commented May 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.56%. Comparing base (98af6d1) to head (cfeee5c).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1039      +/-   ##
==========================================
+ Coverage   82.55%   82.56%   +0.01%     
==========================================
  Files          31       31              
  Lines        2768     2770       +2     
  Branches      518      518              
==========================================
+ Hits         2285     2287       +2     
  Misses        346      346              
  Partials      137      137              

☔ 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tony
tony force-pushed the libtmux-v0.56-plus-api-updates branch from 46b52f1 to c1ed962 Compare June 6, 2026 12:51
@tony
tony force-pushed the libtmux-v0.56-plus-api-updates branch from c1ed962 to 3846dc1 Compare July 4, 2026 14:01
@tony
tony force-pushed the master branch from 63172d2 to eeb6912 Compare July 25, 2026 17:00
tony added 2 commits October 24, 2026 04:48
@tony
cli/load(refactor[_reattach]) Use Pane.display_message wrapper
4b4224e
why: The reattach loop reached for libtmux's `Server.cmd()` escape
hatch to invoke `tmux display-message -p '#S'` for the session
name, even though libtmux has exposed a typed
`Pane.display_message()` wrapper for this exact subcommand for
several releases. With libtmux 0.56.0 now in the dependency tree
(it broadens `display_message`'s flag coverage on top of the
existing get_text path), there's no remaining reason to keep this
particular cmd() escape.

what:
- Replace `builder.session.cmd("display-message", "-p", "'#S'")`
  in `_reattach()` with
  `active_pane.display_message("'#S'", get_text=True)` against
  `builder.session.active_pane`. Same tmux invocation under the
  hood; typed call site instead of stringly-typed positional args.
- Add a narrowing assert on `active_pane` (returns `Pane | None`
  in libtmux's typing) so mypy can prove the call site is
  well-typed. Mirrors the existing `assert builder.session is not
  None` pattern at the top of `_reattach()`.
- Iterate the returned `list[str]` directly. Previously the loop
  consumed `proc.stdout` (a list), so the iteration shape is
  identical and the per-line `tmuxp_echo` / `logger.debug` body
  is unchanged.

No behavior change: the active pane is what tmux's display-message
defaults to anyway when no `-t` is passed, so the underlying tmux
invocation is byte-for-byte identical.
@tony
tests(refactor[plugin_system]) Use Pane.display_message wrapper
cfeee5c
why: Six tests in the plugin-system suite were querying tmux for
session/window names via the same `session.cmd("display-message",
"-p", "'#S'")` escape hatch that production just migrated away
from in `cli/load.py:_reattach`. Keeping the tests on the typed
wrapper that production now uses keeps the call shape consistent
across the codebase and removes the last `cmd("display-message",
...)` site from the repo.

what:
- `tests/cli/test_cli.py::test_reattach_plugins`: replace the
  `cmd()` call with `active_pane.display_message("'#S'",
  get_text=True)` so the post-reattach assertion uses the typed
  wrapper.
- `tests/workspace/test_builder.py`: migrate four
  `test_plugin_system_*` checks (`before_workspace_builder`,
  `on_window_create`, `after_window_finished`, and the
  multi-window variant covering both `before_script` and
  `after_window_finished`) onto `active_pane.display_message()`.
  The multi-window variant hoists the active_pane lookup once and
  reuses it for both the `'#S'` and `'#W'` queries.
- Each call site adds a narrowing assert on `active_pane`
  (libtmux types it as `Pane | None`) so mypy can prove the call
  is well-typed. Mirrors the production assert added in
  `_reattach()`.

No behavior change: tmux's `display-message` defaults to the
session's active pane when no `-t` is passed, so the underlying
tmux invocations are byte-for-byte identical to the prior
`session.cmd(...)` calls.
@tony
tony force-pushed the libtmux-v0.56-plus-api-updates branch from 3846dc1 to cfeee5c Compare October 24, 2026 09:57

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@tony
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.