@@ -882,6 +882,10 @@ _humanize_monitor_codex() {
882882
883883 # Handle case when no log file exists for current session
884884 if [[ -z " $current_file " ]]; then
885+ # Track terminal dimensions to detect resize (fallback for SIGWINCH)
886+ local centered_last_cols=$( tput cols)
887+ local centered_last_rows=$( tput lines)
888+
885889 # Render centered no-log message if status changed or not yet shown
886890 if [[ " $last_no_log_status " != " $current_loop_status " ]]; then
887891 if [[ " $current_loop_status " == " active" ]]; then
@@ -903,11 +907,17 @@ _humanize_monitor_codex() {
903907 return 0
904908 fi
905909
906- # Handle terminal resize at a safe point
910+ # Detect terminal resize via both SIGWINCH flag and actual dimension change
907911 local redraw_centered_msg=false
908- if [[ " $resize_needed " == " true" ]]; then
912+ local cur_cols=$( tput cols)
913+ local cur_rows=$( tput lines)
914+ if [[ " $resize_needed " == " true" ]] || \
915+ [[ " $cur_cols " != " $centered_last_cols " ]] || \
916+ [[ " $cur_rows " != " $centered_last_rows " ]]; then
909917 resize_needed=false
910918 redraw_centered_msg=true
919+ centered_last_cols=" $cur_cols "
920+ centered_last_rows=" $cur_rows "
911921 # Check if terminal is too small
912922 if ! _check_terminal_size; then
913923 _display_terminal_too_small
@@ -919,6 +929,8 @@ _humanize_monitor_codex() {
919929 [[ " $monitor_running " != " true" ]] && break
920930 # Terminal is now big enough, reinitialize
921931 _setup_terminal
932+ centered_last_cols=$( tput cols)
933+ centered_last_rows=$( tput lines)
922934 else
923935 _update_scroll_region
924936 fi
@@ -1003,6 +1015,10 @@ _humanize_monitor_codex() {
10031015 local log_lines=$( _get_log_area_height)
10041016 tail -n " $log_lines " " $current_file " 2> /dev/null
10051017
1018+ # Track terminal dimensions to detect resize (fallback for SIGWINCH)
1019+ local follow_last_cols=$( tput cols)
1020+ local follow_last_rows=$( tput lines)
1021+
10061022 # Incremental monitoring loop
10071023 while [[ " $monitor_running " == " true" ]]; do
10081024 sleep 0.5 # Check more frequently for smoother output
@@ -1014,9 +1030,15 @@ _humanize_monitor_codex() {
10141030 return 0
10151031 fi
10161032
1017- # Handle terminal resize at a safe point
1018- if [[ " $resize_needed " == " true" ]]; then
1033+ # Detect terminal resize via both SIGWINCH flag and actual dimension change
1034+ local cur_cols=$( tput cols)
1035+ local cur_rows=$( tput lines)
1036+ if [[ " $resize_needed " == " true" ]] || \
1037+ [[ " $cur_cols " != " $follow_last_cols " ]] || \
1038+ [[ " $cur_rows " != " $follow_last_rows " ]]; then
10191039 resize_needed=false
1040+ follow_last_cols=" $cur_cols "
1041+ follow_last_rows=" $cur_rows "
10201042 # Check if terminal is too small
10211043 if ! _check_terminal_size; then
10221044 _display_terminal_too_small
@@ -1028,6 +1050,8 @@ _humanize_monitor_codex() {
10281050 [[ " $monitor_running " != " true" ]] && break
10291051 # Terminal is now big enough, reinitialize
10301052 _setup_terminal
1053+ follow_last_cols=$( tput cols)
1054+ follow_last_rows=$( tput lines)
10311055 else
10321056 _update_scroll_region
10331057 fi
0 commit comments