@humanu/orchestra 0.5.37 → 0.5.39

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": "@humanu/orchestra",
3
- "version": "0.5.37",
3
+ "version": "0.5.39",
4
4
  "description": "AI-powered Git worktree and tmux session manager with modern TUI",
5
5
  "keywords": [
6
6
  "git",
@@ -668,7 +668,7 @@ tmux_get_active_pane() {
668
668
  tmux list-panes -t "$win" -F '#{pane_active} #{pane_id}' 2>/dev/null | awk '$1==1{print $2; exit}' || true
669
669
  }
670
670
 
671
- # Capture enhanced session preview showing current terminal view (~15 lines)
671
+ # Capture enhanced session preview showing current terminal view (bottom lines)
672
672
  # Usage: tmux_session_preview <session_name>
673
673
  tmux_session_preview() {
674
674
  local s="$1"
@@ -681,31 +681,48 @@ tmux_session_preview() {
681
681
  return 0
682
682
  fi
683
683
 
684
- # Capture from the bottom of the pane with ANSI escape sequences preserved
684
+ # Always capture from the BOTTOM of the terminal buffer (last visible lines)
685
685
  # -e flag preserves escape sequences for colors and formatting
686
- # -S - means start from the current position (bottom)
687
- # -E - means end at the current position
688
- # This captures the visible content from the bottom up
686
+ # -p prints to stdout
687
+ # NO -S/-E flags means capture the current viewport (what's visible NOW)
688
+ # This ensures we always see the bottom/most recent output
689
689
  local txt
690
- txt="$(tmux capture-pane -e -p -S - -E - -t "$pane" 2>/dev/null)"
690
+ txt="$(tmux capture-pane -e -p -t "$pane" 2>/dev/null)"
691
691
 
692
692
  if [[ -z "$txt" ]]; then
693
693
  echo "(no output yet)"
694
694
  return 0
695
695
  fi
696
696
 
697
- # Also get the terminal type for color mode detection
698
- local term_info
697
+ # Check if the pane is idle (cursor at prompt, no running process)
698
+ local pane_cmd pane_mode
699
+ pane_cmd="$(tmux display-message -t "$pane" -p '#{pane_current_command}' 2>/dev/null || echo "")"
700
+ pane_mode="$(tmux display-message -t "$pane" -p '#{pane_mode}' 2>/dev/null || echo "")"
701
+
702
+ # Detect idle state: shell running and not in copy mode
703
+ local is_idle="false"
704
+ case "$pane_cmd" in
705
+ bash|zsh|sh|fish|dash|ksh)
706
+ # Shell is running, check if we're at a prompt (not in copy mode)
707
+ if [[ "$pane_mode" == "" ]]; then
708
+ is_idle="true"
709
+ fi
710
+ ;;
711
+ esac
712
+
713
+ # Optimized: Get terminal info in a single command instead of multiple calls
714
+ local term_info has_rgb
699
715
  term_info="$(tmux show-environment -t "$s" TERM 2>/dev/null | cut -d= -f2 || echo "unknown")"
700
716
 
701
- # Check if true color is supported in this session
702
- local has_rgb="false"
717
+ # Fast check for RGB support without full grep
703
718
  if tmux show-options -t "$s" -s terminal-overrides 2>/dev/null | grep -q "RGB"; then
704
719
  has_rgb="true"
720
+ else
721
+ has_rgb="false"
705
722
  fi
706
723
 
707
724
  # For ANSI-preserved preview with color mode info
708
- # Add markers for the Rust parser to detect color capabilities
725
+ # Add markers for the Rust parser to detect color capabilities and idle state
709
726
  if [[ "$has_rgb" == "true" || "$term_info" == *"direct"* || "$term_info" == *"truecolor"* ]]; then
710
727
  echo "<<<COLORMODE:RGB>>>"
711
728
  elif [[ "$term_info" == *"256color"* ]]; then
@@ -713,12 +730,12 @@ tmux_session_preview() {
713
730
  else
714
731
  echo "<<<COLORMODE:16>>>"
715
732
  fi
716
- echo "$txt"
717
733
 
718
- # If no content after processing, show placeholder
719
- if [[ -z "$txt" ]]; then
720
- echo "(session active, no visible output)"
721
- return 0
734
+ # Add idle marker so Rust can stop polling when terminal is idle
735
+ if [[ "$is_idle" == "true" ]]; then
736
+ echo "<<<IDLE:true>>>"
737
+ else
738
+ echo "<<<IDLE:false>>>"
722
739
  fi
723
740
 
724
741
  echo "$txt"
@@ -29,6 +29,8 @@ source "$SCRIPT_DIR/shell/bridge/copy_env.sh"
29
29
  source "$SCRIPT_DIR/shell/git/bridge_worktree.sh"
30
30
  source "$SCRIPT_DIR/shell/git/bridge_repo.sh"
31
31
  source "$SCRIPT_DIR/shell/git/bridge_merge.sh"
32
+ source "$SCRIPT_DIR/shell/git/bridge_enhanced_git_status.sh"
33
+ source "$SCRIPT_DIR/shell/git/bridge_git_status.sh"
32
34
 
33
35
  # Define utilities we need
34
36
  err() { printf '❌ %s\n' "$*" >&2; }
@@ -29,9 +29,13 @@ bridge_enhanced_git_status() {
29
29
  ahead="$(echo "$ahead_behind" | cut -f1)"
30
30
  behind="$(echo "$ahead_behind" | cut -f2)"
31
31
 
32
+ # Get all diff stats in bulk for performance
33
+ staged_stats="$(git diff --cached --numstat 2>/dev/null)"
34
+ unstaged_stats="$(git diff --numstat 2>/dev/null)"
35
+
32
36
  # Process each file and get diff stats
33
37
  files_payload=""
34
- echo "$status_lines" | while IFS= read -r line; do
38
+ while IFS= read -r line; do
35
39
  if [[ -n "$line" ]]; then
36
40
  index_status="${line:0:1}"
37
41
  workdir_status="${line:1:1}"
@@ -43,8 +47,8 @@ bridge_enhanced_git_status() {
43
47
 
44
48
  # Check for staged changes first
45
49
  if [[ "$index_status" != " " && "$index_status" != "?" ]]; then
46
- # Staged changes - use --cached
47
- stats="$(git diff --cached --numstat "$filepath" 2>/dev/null | head -1)"
50
+ # Look up stats in bulk staged diff
51
+ stats="$(echo "$staged_stats" | grep -F " $filepath" | head -1)"
48
52
  if [[ -n "$stats" && "$stats" != "- -"* ]]; then
49
53
  added="$(echo "$stats" | cut -f1)"
50
54
  deleted="$(echo "$stats" | cut -f2)"
@@ -56,8 +60,8 @@ bridge_enhanced_git_status() {
56
60
 
57
61
  # Check for working directory changes if no staged stats or if workdir is also modified
58
62
  if [[ "$workdir_status" != " " && "$workdir_status" != "?" ]] && [[ $added -eq 0 && $deleted -eq 0 ]]; then
59
- # Working directory changes
60
- stats="$(git diff --numstat "$filepath" 2>/dev/null | head -1)"
63
+ # Look up stats in bulk unstaged diff
64
+ stats="$(echo "$unstaged_stats" | grep -F " $filepath" | head -1)"
61
65
  if [[ -n "$stats" && "$stats" != "- -"* ]]; then
62
66
  added="$(echo "$stats" | cut -f1)"
63
67
  deleted="$(echo "$stats" | cut -f2)"
@@ -86,7 +90,7 @@ bridge_enhanced_git_status() {
86
90
  "lines_deleted:n=$deleted")"
87
91
  files_payload+="$file_json"$'\n'
88
92
  fi
89
- done
93
+ done <<< "$status_lines"
90
94
 
91
95
  if [[ -n "$files_payload" ]]; then
92
96
  files_json="$(json_array_from_json_lines "$files_payload")"