Fix tmux Shift+Enter state reporting

This commit is contained in:
austinpower1258 2026-03-30 03:49:00 -07:00
parent 9ce4997ced
commit f4c99d34f3
5 changed files with 215 additions and 56 deletions

View file

@ -267,12 +267,19 @@ _cmux_report_shell_activity_state() {
_cmux_report_tmux_state_payload() {
[[ -n "$CMUX_TAB_ID" ]] || return 0
[[ -n "$CMUX_PANEL_ID" ]] || return 0
local state="outside"
[[ -n "$TMUX" ]] && state="inside"
printf '%s\n' "report_tmux_state $state --tab=$CMUX_TAB_ID --panel=$CMUX_PANEL_ID"
local payload="report_tmux_state $state --tab=$CMUX_TAB_ID"
if [[ -n "$TMUX" ]]; then
[[ -n "$_CMUX_TTY_NAME" ]] && payload+=" --tty=$_CMUX_TTY_NAME"
else
[[ -n "$CMUX_PANEL_ID" ]] || return 0
payload+=" --panel=$CMUX_PANEL_ID"
fi
printf '%s\n' "$payload"
}
_cmux_tmux_state_report_signature() {
@ -536,7 +543,6 @@ _cmux_preexec_command() {
[[ -S "$CMUX_SOCKET_PATH" ]] || return 0
[[ -n "$CMUX_TAB_ID" ]] || return 0
[[ -n "$CMUX_PANEL_ID" ]] || return 0
if [[ -z "$_CMUX_TTY_NAME" ]]; then
local t
@ -545,9 +551,12 @@ _cmux_preexec_command() {
[[ -n "$t" && "$t" != "not a tty" ]] && _CMUX_TTY_NAME="$t"
fi
_cmux_report_shell_activity_state running
if [[ -n "$CMUX_PANEL_ID" ]]; then
_cmux_report_shell_activity_state running
fi
_cmux_report_tmux_state
_cmux_report_tty_once
[[ -n "$CMUX_PANEL_ID" ]] || return 0
_cmux_ports_kick
_cmux_stop_pr_poll_loop
}
@ -561,9 +570,21 @@ _cmux_prompt_command() {
[[ -S "$CMUX_SOCKET_PATH" ]] || return 0
[[ -n "$CMUX_TAB_ID" ]] || return 0
[[ -n "$CMUX_PANEL_ID" ]] || return 0
_cmux_report_shell_activity_state prompt
if [[ -z "$_CMUX_TTY_NAME" ]]; then
local t
t="$(tty 2>/dev/null || true)"
t="${t##*/}"
[[ "$t" != "not a tty" ]] && _CMUX_TTY_NAME="$t"
fi
if [[ -n "$CMUX_PANEL_ID" ]]; then
_cmux_report_shell_activity_state prompt
fi
_cmux_report_tmux_state
_cmux_report_tty_once
[[ -n "$CMUX_PANEL_ID" ]] || return 0
local now=$SECONDS
local pwd="$PWD"
@ -580,16 +601,6 @@ _cmux_prompt_command() {
fi
fi
# Resolve TTY name once.
if [[ -z "$_CMUX_TTY_NAME" ]]; then
local t
t="$(tty 2>/dev/null || true)"
t="${t##*/}"
[[ "$t" != "not a tty" ]] && _CMUX_TTY_NAME="$t"
fi
_cmux_report_tty_once
# CWD: keep the app in sync with the actual shell directory.
if [[ "$pwd" != "$_CMUX_PWD_LAST_PWD" ]]; then
_CMUX_PWD_LAST_PWD="$pwd"