Skip to content

fix: skip tmux -T title flag on versions older than 3.3 - #40

Merged
umputun merged 2 commits into
masterfrom
fix-tmux-title-compat
Apr 6, 2026
Merged

umputun merged 2 commits into
masterfrom
fix-tmux-title-compat

Conversation

@umputun

@umputun umputun commented Apr 6, 2026

Copy link
Copy Markdown
Owner

The -T flag for tmux display-popup was added in tmux 3.3. On older versions (common on remote servers), the flag causes an error and the overlay fails to open.

Detects tmux version and conditionally includes -T in both launcher scripts. Also removes Go runtime version from --version output.

The -T flag for display-popup was added in tmux 3.3. Detect version
and conditionally include it to avoid errors on older tmux installs.
Also remove go runtime version from --version output.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 6, 2026

Copy link
Copy Markdown

Deploying revdiff with  Cloudflare Pages  Cloudflare Pages

Latest commit: af05b26
Status: ✅  Deploy successful!
Preview URL: https://d6b17e70.revdiff.pages.dev
Branch Preview URL: https://fix-tmux-title-compat.revdiff.pages.dev

View logs

Copilot AI review requested due to automatic review settings April 6, 2026 20:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves compatibility of the revdiff overlay launchers with older tmux versions by only using the display-popup -T title flag when supported (tmux 3.3+), and simplifies revdiff --version output by removing the Go runtime version.

Changes:

  • Add tmux version detection to conditionally include display-popup -T in both launcher scripts.
  • Remove Go runtime version from revdiff --version output.
  • Refactor tmux invocation in the scripts to build arguments incrementally.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
plugins/revdiff-planning/scripts/launch-plan-review.sh Conditionally adds -T based on detected tmux version when launching the plan review popup.
.claude-plugin/skills/revdiff/scripts/launch-revdiff.sh Conditionally adds -T based on detected tmux version when launching the revdiff popup.
cmd/revdiff/main.go Adjusts --version output to only print the build revision.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +40 to +43
TMUX_VER=$(tmux -V 2>/dev/null | sed 's/[^0-9.]//g')
if [ -n "$TMUX_VER" ] && [ "$(printf '%s\n' "3.3" "$TMUX_VER" | sort -V | head -1)" = "3.3" ]; then
TMUX_ARGS+=(-T " $OVERLAY_TITLE ")
fi

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sort -V is a GNU extension and isn’t available on macOS/BSD sort. Because these scripts run with set -euo pipefail, a missing -V will cause the command substitution in the if test to fail and the whole launcher to exit (preventing the overlay from opening). Consider doing the tmux version comparison in pure bash (parse major/minor from tmux -V) or otherwise avoiding sort -V, and ensure version probing can fail without aborting the script (e.g., fall back to “no -T”).

Suggested change
TMUX_VER=$(tmux -V 2>/dev/null | sed 's/[^0-9.]//g')
if [ -n "$TMUX_VER" ] && [ "$(printf '%s\n' "3.3" "$TMUX_VER" | sort -V | head -1)" = "3.3" ]; then
TMUX_ARGS+=(-T " $OVERLAY_TITLE ")
fi
TMUX_VER=$(tmux -V 2>/dev/null || true)
TMUX_VER=${TMUX_VER#tmux }
TMUX_MAJOR=${TMUX_VER%%[^0-9]*}
TMUX_REST=${TMUX_VER#"$TMUX_MAJOR"}
TMUX_MINOR=
if [ "${TMUX_REST#.}" != "$TMUX_REST" ]; then
TMUX_MINOR_PART=${TMUX_REST#.}
TMUX_MINOR=${TMUX_MINOR_PART%%[^0-9]*}
fi
case "$TMUX_MAJOR:$TMUX_MINOR" in
''*|*:[!0-9]*|[!0-9]*:*)
;;
*)
if [ "$TMUX_MAJOR" -gt 3 ] || { [ "$TMUX_MAJOR" -eq 3 ] && [ "$TMUX_MINOR" -ge 3 ]; }; then
TMUX_ARGS+=(-T " $OVERLAY_TITLE ")
fi
;;
esac

Copilot uses AI. Check for mistakes.
Comment on lines +48 to +52
# -T (title) requires tmux 3.3+; skip on older versions
TMUX_ARGS=(tmux display-popup -E -w "$POPUP_W" -h "$POPUP_H")
TMUX_VER=$(tmux -V 2>/dev/null | sed 's/[^0-9.]//g')
if [ -n "$TMUX_VER" ] && [ "$(printf '%s\n' "3.3" "$TMUX_VER" | sort -V | head -1)" = "3.3" ]; then
TMUX_ARGS+=(-T " $OVERLAY_TITLE ")

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tmux version gate relies on sort -V, which isn’t supported by macOS/BSD sort. With set -euo pipefail enabled, this can cause the launcher to exit when running inside tmux on macOS. Consider replacing the comparison with a bash-only major/minor check (or another portable approach) and making the version-detection logic non-fatal so the script can safely fall back to omitting -T.

Suggested change
# -T (title) requires tmux 3.3+; skip on older versions
TMUX_ARGS=(tmux display-popup -E -w "$POPUP_W" -h "$POPUP_H")
TMUX_VER=$(tmux -V 2>/dev/null | sed 's/[^0-9.]//g')
if [ -n "$TMUX_VER" ] && [ "$(printf '%s\n' "3.3" "$TMUX_VER" | sort -V | head -1)" = "3.3" ]; then
TMUX_ARGS+=(-T " $OVERLAY_TITLE ")
# -T (title) requires tmux 3.3+; skip on older versions or if version detection fails
TMUX_ARGS=(tmux display-popup -E -w "$POPUP_W" -h "$POPUP_H")
TMUX_VER_RAW=$(tmux -V 2>/dev/null || true)
TMUX_VER=${TMUX_VER_RAW#tmux }
if [[ "$TMUX_VER" =~ ^([0-9]+)\.([0-9]+) ]]; then
TMUX_VER_MAJOR=${BASH_REMATCH[1]}
TMUX_VER_MINOR=${BASH_REMATCH[2]}
if [ "$TMUX_VER_MAJOR" -gt 3 ] || { [ "$TMUX_VER_MAJOR" -eq 3 ] && [ "$TMUX_VER_MINOR" -ge 3 ]; }; then
TMUX_ARGS+=(-T " $OVERLAY_TITLE ")
fi

Copilot uses AI. Check for mistakes.
sort -V is a GNU extension not available on all platforms.
Use bash BASH_REMATCH for portable major/minor comparison.
@umputun
umputun merged commit cd3760c into master Apr 6, 2026
3 checks passed
@umputun
umputun deleted the fix-tmux-title-compat branch April 6, 2026 20:45
sanchesfree pushed a commit to sanchesfree/revdiff that referenced this pull request Apr 8, 2026
* fix: skip tmux -T title flag on versions older than 3.3

The -T flag for display-popup was added in tmux 3.3. Detect version
and conditionally include it to avoid errors on older tmux installs.
Also remove go runtime version from --version output.

* fix: use bash regex instead of sort -V for tmux version check

sort -V is a GNU extension not available on all platforms.
Use bash BASH_REMATCH for portable major/minor comparison.
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