Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions apps/frontend/src/main/changelog/changelog-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { app } from 'electron';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
import { AUTO_BUILD_PATHS, DEFAULT_CHANGELOG_PATH } from '../../shared/constants';
import { getToolPath } from '../cli-tool-manager';
import { getToolPath, getToolInfo } from '../cli-tool-manager';
import type {
ChangelogTask,
TaskSpecContent,
Expand Down Expand Up @@ -175,20 +175,30 @@ export class ChangelogService extends EventEmitter {
}
}

/**
* Ensure prerequisites are met for changelog generation
* Validates auto-build source path and Claude CLI availability
*/
private ensurePrerequisites(): { autoBuildSource: string } {
const autoBuildSource = this.getAutoBuildSourcePath();
if (!autoBuildSource) {
throw new Error('Auto-build source path not found');
}

const claudeInfo = getToolInfo('claude');
if (!claudeInfo.found) {
throw new Error(`Claude CLI not found. Please install Claude Code from https://claude.ai/download. ${claudeInfo.message || ''}`);
}
Comment on lines 189 to 193
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, verify the file exists and check the exact content at lines 188-191
cat -n apps/frontend/src/main/changelog/changelog-service.ts | sed -n '180,200p'

Repository: AndyMik90/Auto-Claude

Length of output: 882


🏁 Script executed:

# Check the full structure of the file to understand context
wc -l apps/frontend/src/main/changelog/changelog-service.ts
head -30 apps/frontend/src/main/changelog/changelog-service.ts

Repository: AndyMik90/Auto-Claude

Length of output: 1042


🏁 Script executed:

# Search for i18n usage in this file
rg "t\(" apps/frontend/src/main/changelog/changelog-service.ts -A 2 -B 2

Repository: AndyMik90/Auto-Claude

Length of output: 2519


🏁 Script executed:

# Search for generation-error handling
rg "generation-error" apps/frontend/src/main/changelog/changelog-service.ts -A 3 -B 3

Repository: AndyMik90/Auto-Claude

Length of output: 586


🏁 Script executed:

# Check how other errors are thrown/handled in this file
rg "throw new Error" apps/frontend/src/main/changelog/changelog-service.ts -B 2 -A 1

Repository: AndyMik90/Auto-Claude

Length of output: 436


🏁 Script executed:

# Check if i18n is used in any files in apps/frontend/src/main
rg "import.*i18n\|from.*i18n" apps/frontend/src/main/ --type ts --type tsx

Repository: AndyMik90/Auto-Claude

Length of output: 92


🏁 Script executed:

# Check cli-tool-manager for getToolInfo implementation
cat -n apps/frontend/src/main/cli-tool-manager.ts | head -100

Repository: AndyMik90/Auto-Claude

Length of output: 3970


🏁 Script executed:

# Search for how generation-error is handled on the renderer/frontend side
rg "generation-error" apps/frontend/src/ --type ts --type tsx -B 2 -A 3 | head -50

Repository: AndyMik90/Auto-Claude

Length of output: 92


🏁 Script executed:

# Search for generation-error handling in renderer code
rg "generation-error" apps/frontend/src --type ts -B 3 -A 5

Repository: AndyMik90/Auto-Claude

Length of output: 2924


🏁 Script executed:

# Check how errors are typically displayed in renderer
rg "generation-error\|emit.*error" apps/frontend/src/main --type ts -B 2 -A 3

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Look for error code patterns or error handling elsewhere in main
rg "error.*code\|errorCode" apps/frontend/src/main --type ts -B 1 -A 1

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Check if there's an error handling/translation pattern in the app
find apps/frontend/src -name "*error*" -o -name "*exception*" | head -20

Repository: AndyMik90/Auto-Claude

Length of output: 230


🏁 Script executed:

# Check the errors.json to see the i18n pattern
cat apps/frontend/src/shared/i18n/locales/en/errors.json | head -80

Repository: AndyMik90/Auto-Claude

Length of output: 406


🏁 Script executed:

# Check IPC handlers to see how error is sent
cat -n apps/frontend/src/main/ipc-handlers/changelog-handlers.ts | grep -A 10 "generation-error"

Repository: AndyMik90/Auto-Claude

Length of output: 663


🏁 Script executed:

# Check renderer side for how it handles CHANGELOG_GENERATION_ERROR
rg "CHANGELOG_GENERATION_ERROR" apps/frontend/src/renderer --type ts -B 3 -A 5

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Check IPC channels definitions
rg "CHANGELOG_GENERATION_ERROR" apps/frontend/src --type ts | head -10

Repository: AndyMik90/Auto-Claude

Length of output: 554


🏁 Script executed:

# Check how renderer displays the error message
rg "changelog-api\|generationError" apps/frontend/src/renderer --type ts -B 5 -A 5

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Look for any error message handling in renderer
rg "onChangelogGenerationError\|generation.*error" apps/frontend/src/renderer -B 3 -A 5

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Check the preload API to see how error is passed
cat -n apps/frontend/src/preload/api/modules/changelog-api.ts

Repository: AndyMik90/Auto-Claude

Length of output: 6389


🏁 Script executed:

# Check if i18n is available/used in main process
rg "i18n\|i18next" apps/frontend/src/main --type ts

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Check how other generation errors are handled (if any)
rg "emit.*error\|generation.*error" apps/frontend/src/main/changelog --type ts -B 5 -A 5

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Check the full error flow in changelog-handlers to see if there's any translation happening
cat -n apps/frontend/src/main/ipc-handlers/changelog-handlers.ts | head -60

Repository: AndyMik90/Auto-Claude

Length of output: 2560


🏁 Script executed:

# Check if renderer has any error translation logic
find apps/frontend/src/renderer -name "*.ts" -o -name "*.tsx" | xargs grep -l "error.*i18n\|i18n.*error\|t\(" | head -10

Repository: AndyMik90/Auto-Claude

Length of output: 88


🏁 Script executed:

# Check how the renderer handles other i18n for errors
rg "errors:" apps/frontend/src/renderer --type ts -B 2 -A 2 | head -40

Repository: AndyMik90/Auto-Claude

Length of output: 3459


🏁 Script executed:

# Check if there's a pattern for error codes in the codebase
rg "errorCode\|error.*code\|code.*error" apps/frontend/src/shared --type ts | head -20

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Look for other hardcoded error strings in main process that might be user-facing
rg "throw new Error\|emit.*error" apps/frontend/src/main --type ts | grep -v node_modules | head -30

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Check how changelog generation errors are handled in renderer
rg "onChangelogGenerationError\|CHANGELOG_GENERATION_ERROR" apps/frontend/src/renderer --type ts -B 5 -A 10

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Check if there's any error translation happening for generation errors
rg "generation.*error\|generationError" apps/frontend/src/renderer --type ts -B 3 -A 3

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Check if there's an error handler in the renderer for changelog generation
find apps/frontend/src/renderer -type f -name "*.ts" -o -name "*.tsx" | xargs grep -l "changelog" | head -10

Repository: AndyMik90/Auto-Claude

Length of output: 653


🏁 Script executed:

# Look for where generation errors are displayed
rg "generation" apps/frontend/src/renderer --type ts -l | head -5

Repository: AndyMik90/Auto-Claude

Length of output: 336


🏁 Script executed:

# Check if main process uses error codes or error objects anywhere
rg "error.*code\|errorCode\|error\s*:\s*\{" apps/frontend/src/main/changelog --type ts -B 2 -A 2

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Check changelog-store to see how errors are handled
cat -n apps/frontend/src/renderer/stores/changelog-store.ts | head -150

Repository: AndyMik90/Auto-Claude

Length of output: 5619


🏁 Script executed:

# Check the Changelog component for error handling
rg "onChangelogGenerationError\|generation.*error" apps/frontend/src/renderer/components/changelog --type ts -B 5 -A 10

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Check how the changelog-store handles errors
rg "generation-error\|generationError\|onChangelogGenerationError" apps/frontend/src/renderer/stores/changelog-store.ts -B 3 -A 5

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Check the rest of changelog-store for error handling
cat -n apps/frontend/src/renderer/stores/changelog-store.ts | sed -n '150,300p'

Repository: AndyMik90/Auto-Claude

Length of output: 6587


🏁 Script executed:

# Check the main Changelog component for error handling
cat -n apps/frontend/src/renderer/components/changelog/Changelog.tsx | head -150

Repository: AndyMik90/Auto-Claude

Length of output: 5710


🏁 Script executed:

# Search for where setError is called in changelog context
rg "setError\|onChangelogGenerationError" apps/frontend/src/renderer --type ts -B 3 -A 3

Repository: AndyMik90/Auto-Claude

Length of output: 47


🏁 Script executed:

# Search for where the error state is set in the hooks
rg "setError" apps/frontend/src/renderer --type ts -B 3 -A 3 | head -60

Repository: AndyMik90/Auto-Claude

Length of output: 4737


🏁 Script executed:

# Look for the useChangelog hook implementation
cat -n apps/frontend/src/renderer/components/changelog/hooks/useChangelog.ts | head -200

Repository: AndyMik90/Auto-Claude

Length of output: 9655


Localize the Claude CLI error message for users.

The error string at line 190 is user-facing—it flows through the IPC channel to the renderer and is displayed directly to users via the error state (see useChangelog hook line 155). Per the coding guidelines, all user-facing text must use i18n translation keys. Consider passing an error code from the main process and translating it in the renderer, or using an i18n key reference that the renderer can resolve.

🤖 Prompt for AI Agents
In `@apps/frontend/src/main/changelog/changelog-service.ts` around lines 188 -
191, The current throw in changelog-service.ts uses a hardcoded, user-facing
string from getToolInfo('claude'); instead, throw an Error that contains a
stable, translatable error identifier (e.g., code: "CLAUDE_CLI_NOT_FOUND") and
preserve claudeInfo.message in a non-user-facing detail field so the renderer
can map the code to an i18n key and display a localized message; update the
throw in the block that checks claudeInfo.found to include the error code (or
set error.name/error.code) and any diagnostic text on the Error object rather
than a literal message so useChangelog (renderer) can translate the code into
the localized text.


return { autoBuildSource };
}

/**
* Get or create the generator instance
*/
private getGenerator(): ChangelogGenerator {
if (!this.generator) {
const autoBuildSource = this.getAutoBuildSourcePath();
if (!autoBuildSource) {
throw new Error('Auto-build source path not found');
}

// Verify claude CLI is available
if (this.claudePath !== 'claude' && !existsSync(this.claudePath)) {
throw new Error(`Claude CLI not found. Please ensure Claude Code is installed. Looked for: ${this.claudePath}`);
}
const { autoBuildSource } = this.ensurePrerequisites();

const autoBuildEnv = this.loadAutoBuildEnv();

Expand Down Expand Up @@ -226,15 +236,7 @@ export class ChangelogService extends EventEmitter {
*/
private getVersionSuggester(): VersionSuggester {
if (!this.versionSuggester) {
const autoBuildSource = this.getAutoBuildSourcePath();
if (!autoBuildSource) {
throw new Error('Auto-build source path not found');
}

// Verify claude CLI is available
if (this.claudePath !== 'claude' && !existsSync(this.claudePath)) {
throw new Error(`Claude CLI not found. Please ensure Claude Code is installed. Looked for: ${this.claudePath}`);
}
const { autoBuildSource } = this.ensurePrerequisites();

this.versionSuggester = new VersionSuggester(
this.pythonPath,
Expand Down
Loading