Files
g3/g3-plan/completed_todo_2025-12-10_16-17-02.md
Jochen 87bceba54f Fix planner UI whitespace and workspace logs directory
Resolve two critical issues in planner mode that persisted through
multiple fix attempts:

1. Remove excessive whitespace between tool call displays by replacing
   direct println!() calls with ui_writer methods and eliminating
   redundant newlines in agent response streaming.

2. Ensure all log files (errors, sessions, tool calls, context dumps)
   are written to <workspace>/logs instead of codepath by properly
   initializing G3_WORKSPACE_PATH from --workspace argument.
2025-12-10 16:18:49 +11:00

2.6 KiB

Planner Mode UI Output Fixes - Fifth Attempt - Implementation Complete

Issue 1: Tool Call Display Has Excessive Whitespace - FIXED

  • Fix print_agent_response() in llm.rs to NOT add back any newline
    • Current code strips trailing whitespace but adds back one \n if original had any
    • This causes cumulative blank lines between tool calls
    • Solution: Strip all trailing whitespace and DON'T add any back
    • The tool header already uses println!() which adds its own newline
  • Verify no other sources of extra newlines in the agent loop
  • Test the actual app to confirm fix

Issue 2: Logs Written to Wrong Directory - FIXED

  • Ensure logs directory is created BEFORE Agent starts writing
    • Call project.ensure_logs_dir() after creating Project
    • This creates /logs/ if it doesn't exist
  • Add debug output to track where logs are written
  • Verify G3_WORKSPACE_PATH is actually being used by get_logs_dir()
  • Test with actual app from different directory

Implementation Summary

Files Modified:

  1. crates/g3-planner/src/llm.rs - Fixed both issues

Changes Made:

Issue 1 Fix (lines 287-297):

  • Modified print_agent_response() to strip trailing whitespace completely
  • REMOVED the code that was adding back a newline when original content ended with one
  • This prevents cumulative blank lines between tool calls
  • Tool headers already use println!() which adds their own newline

Issue 2 Fix (lines 337-344):

  • Added project.ensure_logs_dir() call AFTER creating Project and BEFORE creating Agent
  • This ensures <workspace>/logs/ directory exists before any log writes
  • Added debug output to confirm logs directory location
  • Combined with existing G3_WORKSPACE_PATH environment variable (set in planner.rs)

Build Status: SUCCESS

Finished `release` profile [optimized] target(s) in 23.49s

Manual Testing Required ⚠️

The user MUST test the application to verify both fixes:

# Clean up logs
rm -rf /tmp/g3_test_workspace ~/RustroverProjects/g3/logs/*

# Prepare test workspace
mkdir -p /tmp/g3_test_workspace/g3-plan
echo 'Test requirements' > /tmp/g3_test_workspace/g3-plan/new_requirements.md

# Run from different directory
cd /tmp
cargo run --bin g3 -- --planning --codepath ~/RustroverProjects/g3 --workspace /tmp/g3_test_workspace

Verify:

  1. Tool calls display with NO blank lines between them
  2. Debug output shows workspace=/tmp/g3_test_workspace
  3. Debug output shows logs directory created/verified
  4. All logs go to /tmp/g3_test_workspace/logs/
  5. NO logs in ~/RustroverProjects/g3/logs/