MCPcopy
hub / github.com/codeaashu/claude-code / generateTitle

Function generateTitle

src/components/Feedback.tsx:447–474  ·  view source on GitHub ↗
(description: string, abortSignal: AbortSignal)

Source from the content-addressed store, hash-verified

445 return baseUrl + encodedPrefix + truncatedEncodedErrors + ellipsis + encodedSuffix + encodedNote;
446}
447async function generateTitle(description: string, abortSignal: AbortSignal): Promise<string> {
448 try {
449 const response = await queryHaiku({
450 systemPrompt: asSystemPrompt(['Generate a concise, technical issue title (max 80 chars) for a public GitHub issue based on this bug report for Claude Code.', 'Claude Code is an agentic coding CLI based on the Anthropic API.', 'The title should:', '- Include the type of issue [Bug] or [Feature Request] as the first thing in the title', '- Be concise, specific and descriptive of the actual problem', '- Use technical terminology appropriate for a software issue', '- For error messages, extract the key error (e.g., "Missing Tool Result Block" rather than the full message)', '- Be direct and clear for developers to understand the problem', '- If you cannot determine a clear issue, use "Bug Report: [brief description]"', '- Any LLM API errors are from the Anthropic API, not from any other model provider', 'Your response will be directly used as the title of the Github issue, and as such should not contain any other commentary or explaination', 'Examples of good titles include: "[Bug] Auto-Compact triggers to soon", "[Bug] Anthropic API Error: Missing Tool Result Block", "[Bug] Error: Invalid Model Name for Opus"']),
451 userPrompt: description,
452 signal: abortSignal,
453 options: {
454 hasAppendSystemPrompt: false,
455 toolChoice: undefined,
456 isNonInteractiveSession: false,
457 agents: [],
458 querySource: 'feedback',
459 mcpTools: []
460 }
461 });
462 const title = response.message.content[0]?.type === 'text' ? response.message.content[0].text : 'Bug Report';
463
464 // Check if the title contains an API error message
465 if (startsWithApiErrorPrefix(title)) {
466 return createFallbackTitle(description);
467 }
468 return title;
469 } catch (error) {
470 // If there's any error in title generation, use a fallback title
471 logError(error);
472 return createFallbackTitle(description);
473 }
474}
475function createFallbackTitle(description: string): string {
476 // Create a safe fallback title based on the bug description
477

Callers 1

FeedbackFunction · 0.85

Calls 5

queryHaikuFunction · 0.85
asSystemPromptFunction · 0.85
startsWithApiErrorPrefixFunction · 0.85
createFallbackTitleFunction · 0.85
logErrorFunction · 0.50

Tested by

no test coverage detected