From 54501cbd73a329e2562dbdff1ae91ce6fab7f007 Mon Sep 17 00:00:00 2001 From: AndyMik90 Date: Thu, 18 Dec 2025 20:30:17 +0100 Subject: [PATCH] fix: additional fixes for http error handling and path resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - http-client.ts: Limit error response data collection to 10KB and add error handlers - RoadmapGenerationProgress.tsx, GenerationProgressScreen.tsx: Allow onStop to return Promise - insights_runner.py: Fix path resolution and load .env from auto-claude directory 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../src/main/updater/http-client.ts | 20 +++++++++++++++---- .../components/RoadmapGenerationProgress.tsx | 2 +- .../ideation/GenerationProgressScreen.tsx | 2 +- auto-claude/runners/insights_runner.py | 9 ++++++++- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/auto-claude-ui/src/main/updater/http-client.ts b/auto-claude-ui/src/main/updater/http-client.ts index 3ce86850..3a0811b6 100644 --- a/auto-claude-ui/src/main/updater/http-client.ts +++ b/auto-claude-ui/src/main/updater/http-client.ts @@ -27,13 +27,19 @@ export function fetchJson(url: string): Promise { } if (response.statusCode !== 200) { - // Collect response body for error details + // Collect response body for error details (limit to 10KB) + const maxErrorSize = 10 * 1024; let errorData = ''; - response.on('data', chunk => errorData += chunk); + response.on('data', chunk => { + if (errorData.length < maxErrorSize) { + errorData += chunk.toString().slice(0, maxErrorSize - errorData.length); + } + }); response.on('end', () => { const errorMsg = `HTTP ${response.statusCode}: ${errorData || response.statusMessage || 'No error details'}`; reject(new Error(errorMsg)); }); + response.on('error', reject); return; } @@ -86,13 +92,19 @@ export function downloadFile( if (response.statusCode !== 200) { file.close(); - // Collect response body for error details + // Collect response body for error details (limit to 10KB) + const maxErrorSize = 10 * 1024; let errorData = ''; - response.on('data', chunk => errorData += chunk); + response.on('data', chunk => { + if (errorData.length < maxErrorSize) { + errorData += chunk.toString().slice(0, maxErrorSize - errorData.length); + } + }); response.on('end', () => { const errorMsg = `HTTP ${response.statusCode}: ${errorData || response.statusMessage || 'No error details'}`; reject(new Error(errorMsg)); }); + response.on('error', reject); return; } diff --git a/auto-claude-ui/src/renderer/components/RoadmapGenerationProgress.tsx b/auto-claude-ui/src/renderer/components/RoadmapGenerationProgress.tsx index ef26ac1f..3a23a2c1 100644 --- a/auto-claude-ui/src/renderer/components/RoadmapGenerationProgress.tsx +++ b/auto-claude-ui/src/renderer/components/RoadmapGenerationProgress.tsx @@ -38,7 +38,7 @@ function useReducedMotion(): boolean { interface RoadmapGenerationProgressProps { generationStatus: RoadmapGenerationStatus; className?: string; - onStop?: () => void; + onStop?: () => void | Promise; } // Type for generation phases (excluding idle) diff --git a/auto-claude-ui/src/renderer/components/ideation/GenerationProgressScreen.tsx b/auto-claude-ui/src/renderer/components/ideation/GenerationProgressScreen.tsx index 923b6401..b839a03c 100644 --- a/auto-claude-ui/src/renderer/components/ideation/GenerationProgressScreen.tsx +++ b/auto-claude-ui/src/renderer/components/ideation/GenerationProgressScreen.tsx @@ -33,7 +33,7 @@ interface GenerationProgressScreenProps { onConvert: (idea: Idea) => void; onGoToTask?: (taskId: string) => void; onDismiss: (idea: Idea) => void; - onStop: () => void; + onStop: () => void | Promise; } export function GenerationProgressScreen({ diff --git a/auto-claude/runners/insights_runner.py b/auto-claude/runners/insights_runner.py index f9c3ac85..2dc6a83b 100644 --- a/auto-claude/runners/insights_runner.py +++ b/auto-claude/runners/insights_runner.py @@ -14,7 +14,14 @@ import sys from pathlib import Path # Add auto-claude to path -sys.path.insert(0, str(Path(__file__).parent)) +sys.path.insert(0, str(Path(__file__).parent.parent)) + +# Load .env file from auto-claude/ directory +from dotenv import load_dotenv + +env_file = Path(__file__).parent.parent / ".env" +if env_file.exists(): + load_dotenv(env_file) try: from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient