fix(session): address code review feedback
- Add init_session_tracking() call in main() before loop starts - Use literal escape codes for color in --reset-session output - Remove conditional in reset_session() to always create file - Remove unused old_session_id variable - Remove duplicate SESSION_EXPIRATION_SECONDS (keep in response_analyzer.sh) - Add clarifying comments for RALPH_SESSION_FILE vs CLAUDE_SESSION_FILE All 265 tests pass.
This commit is contained in:
parent
d3310d1f3f
commit
274f496f77
1 changed files with 10 additions and 14 deletions
|
|
@ -34,9 +34,9 @@ CLAUDE_SESSION_FILE=".claude_session_id" # Session ID persistence file
|
||||||
CLAUDE_MIN_VERSION="2.0.76" # Minimum required Claude CLI version
|
CLAUDE_MIN_VERSION="2.0.76" # Minimum required Claude CLI version
|
||||||
|
|
||||||
# Session management configuration (Phase 1.2)
|
# Session management configuration (Phase 1.2)
|
||||||
RALPH_SESSION_FILE=".ralph_session" # Ralph-specific session tracking
|
# Note: SESSION_EXPIRATION_SECONDS is defined in lib/response_analyzer.sh (86400 = 24 hours)
|
||||||
|
RALPH_SESSION_FILE=".ralph_session" # Ralph-specific session tracking (lifecycle)
|
||||||
RALPH_SESSION_HISTORY_FILE=".ralph_session_history" # Session transition history
|
RALPH_SESSION_HISTORY_FILE=".ralph_session_history" # Session transition history
|
||||||
SESSION_EXPIRATION_SECONDS=86400 # 24 hours in seconds
|
|
||||||
|
|
||||||
# Valid tool patterns for --allowed-tools validation
|
# Valid tool patterns for --allowed-tools validation
|
||||||
# Tools can be exact matches or pattern matches with wildcards in parentheses
|
# Tools can be exact matches or pattern matches with wildcards in parentheses
|
||||||
|
|
@ -508,12 +508,8 @@ get_session_id() {
|
||||||
reset_session() {
|
reset_session() {
|
||||||
local reason=${1:-"manual_reset"}
|
local reason=${1:-"manual_reset"}
|
||||||
|
|
||||||
# Log the transition before clearing
|
# Always create/overwrite the session file to ensure consistent state
|
||||||
local old_session_id=$(get_session_id)
|
cat > "$RALPH_SESSION_FILE" << EOF
|
||||||
|
|
||||||
# Clear the session file
|
|
||||||
if [[ -f "$RALPH_SESSION_FILE" ]]; then
|
|
||||||
cat > "$RALPH_SESSION_FILE" << EOF
|
|
||||||
{
|
{
|
||||||
"session_id": "",
|
"session_id": "",
|
||||||
"created_at": "",
|
"created_at": "",
|
||||||
|
|
@ -522,12 +518,9 @@ reset_session() {
|
||||||
"reset_reason": "$reason"
|
"reset_reason": "$reason"
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
fi
|
|
||||||
|
|
||||||
# Also clear the Claude session file for consistency
|
# Also clear the Claude session file for consistency
|
||||||
if [[ -f "$CLAUDE_SESSION_FILE" ]]; then
|
rm -f "$CLAUDE_SESSION_FILE" 2>/dev/null
|
||||||
rm -f "$CLAUDE_SESSION_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Log the session transition
|
# Log the session transition
|
||||||
log_session_transition "active" "reset" "$reason" "${loop_count:-0}"
|
log_session_transition "active" "reset" "$reason" "${loop_count:-0}"
|
||||||
|
|
@ -896,7 +889,10 @@ main() {
|
||||||
echo "Ralph projects should contain: PROMPT.md, @fix_plan.md, specs/, src/, etc."
|
echo "Ralph projects should contain: PROMPT.md, @fix_plan.md, specs/, src/, etc."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Initialize session tracking before entering the loop
|
||||||
|
init_session_tracking
|
||||||
|
|
||||||
log_status "INFO" "Starting main loop..."
|
log_status "INFO" "Starting main loop..."
|
||||||
log_status "INFO" "DEBUG: About to enter while loop, loop_count=$loop_count"
|
log_status "INFO" "DEBUG: About to enter while loop, loop_count=$loop_count"
|
||||||
|
|
||||||
|
|
@ -1107,7 +1103,7 @@ while [[ $# -gt 0 ]]; do
|
||||||
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
||||||
source "$SCRIPT_DIR/lib/date_utils.sh"
|
source "$SCRIPT_DIR/lib/date_utils.sh"
|
||||||
reset_session "manual_reset_flag"
|
reset_session "manual_reset_flag"
|
||||||
echo -e "${GREEN}✅ Session state reset successfully${NC}"
|
echo -e "\033[0;32m✅ Session state reset successfully\033[0m"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
--circuit-status)
|
--circuit-status)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue