# Planner Mode UI Output Fixes - Fifth Attempt - Implementation Complete ✅

## Issue 1: Tool Call Display Has Excessive Whitespace - FIXED ✅
- [x] Fix print_agent_response() in llm.rs to NOT add back any newline
  - [x] Current code strips trailing whitespace but adds back one `\n` if original had any
  - [x] This causes cumulative blank lines between tool calls
  - [x] Solution: Strip all trailing whitespace and DON'T add any back
  - [x] The tool header already uses println!() which adds its own newline
- [x] 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 ✅
- [x] Ensure logs directory is created BEFORE Agent starts writing
  - [x] Call project.ensure_logs_dir() after creating Project
  - [x] This creates <workspace>/logs/ if it doesn't exist
- [x] Add debug output to track where logs are written
- [x] 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:

```bash
# 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/