Files
trading_bot_v3/SCREENSHOT_PATH_FIXES.md
mindesbunister ff4e9737fb fix: timeframe handling and progress tracking improvements
- Fix timeframe parameter handling in enhanced-screenshot API route
- Support both 'timeframe' (singular) and 'timeframes' (array) parameters
- Add proper sessionId propagation for real-time progress tracking
- Enhance MACD analysis prompt with detailed crossover definitions
- Add progress tracker service with Server-Sent Events support
- Fix Next.js build errors in chart components (module variable conflicts)
- Change dev environment port from 9000:3000 to 9001:3000
- Improve AI analysis layout detection logic
- Add comprehensive progress tracking through all service layers
2025-07-17 10:41:18 +02:00

2.0 KiB

🔧 Screenshot Path & SSE Fixes

Issues Fixed

1. Screenshot File Path Duplication

Problem: Screenshot paths were showing /app/screenshots/app/screenshots/... causing ENOENT errors.

Root Cause: The takeScreenshot() method returns a full absolute path, but analyzeScreenshot() was treating it as a filename and joining it with the screenshots directory again.

Solution: Updated both analyzeScreenshot() and analyzeMultipleScreenshots() methods to handle both full paths and filenames:

// Check if it's already a full path or just a filename
if (path.isAbsolute(filenameOrPath)) {
  // It's already a full path
  imagePath = filenameOrPath
} else {
  // It's just a filename, construct the full path
  const screenshotsDir = path.join(process.cwd(), 'screenshots')
  imagePath = path.join(screenshotsDir, filenameOrPath)
}

2. Next.js Async Params Issue

Problem: SSE endpoint was using params.sessionId without awaiting it, causing Next.js 15 error.

Solution: Updated the SSE endpoint to properly await params:

// Before
{ params }: { params: { sessionId: string } }
const { sessionId } = params

// After  
{ params }: { params: Promise<{ sessionId: string }> }
const { sessionId } = await params

Files Modified

  1. /lib/ai-analysis.ts:

    • Fixed analyzeScreenshot() to handle full paths
    • Fixed analyzeMultipleScreenshots() to handle full paths
    • Updated variable references
  2. /app/api/progress/[sessionId]/stream/route.ts:

    • Added proper async/await for params in Next.js 15

Testing

After these fixes: Screenshots should save and load correctly AI analysis should find screenshot files SSE progress tracking should work without Next.js warnings Real-time progress updates should function properly

No Docker Restart Required

These are runtime fixes that don't require a Docker container restart. The application should work immediately after the files are updated.