tmuxclihook 0.5.12 → 0.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmuxclihook",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "description": "交互式 TUI 安装器:环境侦测、AI CLI 侦测、tmux-ai-status hooks 装/卸/修、TPM 软链校验",
5
5
  "type": "module",
6
6
  "bin": {
@@ -959,13 +959,17 @@ _cleanup_stale_panes() {
959
959
  # (tr -c 'A-Za-z0-9._-' '_'),无法从 key 反推 client → 反向枚举存活集比对。
960
960
  # 实测关注:长期运行的 server 会累积已 detach 的 client 键(8 option / 4 存活)。
961
961
  _prune_prev_sess_options() {
962
- local alive=" " name key opt
962
+ local alive=" " name key opt clients opts
963
+ # 两次 tmux 查询都必须成功才剪枝:tmux 抖动(server 重启/连接失败)时
964
+ # list-clients 返回空会被误判为「无存活 client」→ 把全部键删光。
965
+ clients=$(tmux list-clients -F '#{client_name}' 2>/dev/null) || return 0
966
+ opts=$(tmux show-options -g 2>/dev/null) || return 0
963
967
  while IFS= read -r name; do
964
968
  [ -n "$name" ] || continue
965
969
  key=$(printf '%s' "$name" | tr -c 'A-Za-z0-9._-' '_')
966
970
  alive="$alive$key "
967
- done < <(tmux list-clients -F '#{client_name}' 2>/dev/null)
968
- for opt in $(tmux show-options -g 2>/dev/null | awk '/^@ai_prev_sess_/{print $1}'); do
971
+ done <<< "$clients"
972
+ for opt in $(printf '%s\n' "$opts" | awk '/^@ai_prev_sess_/{print $1}'); do
969
973
  key="${opt#@ai_prev_sess_}"
970
974
  case "$alive" in
971
975
  *" $key "*) ;;