MCPcopy Create free account
hub / github.com/Noumena-Network/code / createGitHubIssueUrl

Function createGitHubIssueUrl

src/components/Feedback.tsx:396–449  ·  view source on GitHub ↗
(feedbackId: string, title: string, description: string, errors: Array<{
  error?: string;
  timestamp?: string;
}>)

Source from the content-addressed store, hash-verified

394 </Dialog>;
395}
396export function createGitHubIssueUrl(feedbackId: string, title: string, description: string, errors: Array<{
397 error?: string;
398 timestamp?: string;
399}>): string {
400 const sanitizedTitle = redactSensitiveInfo(title);
401 const sanitizedDescription = redactSensitiveInfo(description);
402 const bodyPrefix = `**Bug Description**\n${sanitizedDescription}\n\n` + `**Environment Info**\n` + `- Platform: ${env.platform}\n` + `- Terminal: ${env.terminal}\n` + `- Version: ${MACRO.VERSION || 'unknown'}\n` + `- Feedback ID: ${feedbackId}\n` + `\n**Errors**\n\`\`\`json\n`;
403 const errorSuffix = `\n\`\`\`\n`;
404 const errorsJson = jsonStringify(errors);
405 const baseUrl = `${GITHUB_ISSUES_REPO_URL}/new?title=${encodeURIComponent(sanitizedTitle)}&labels=user-reported,bug&body=`;
406 const truncationNote = `\n**Note:** Content was truncated.\n`;
407 const encodedPrefix = encodeURIComponent(bodyPrefix);
408 const encodedSuffix = encodeURIComponent(errorSuffix);
409 const encodedNote = encodeURIComponent(truncationNote);
410 const encodedErrors = encodeURIComponent(errorsJson);
411
412 // Calculate space available for errors
413 const spaceForErrors = GITHUB_URL_LIMIT - baseUrl.length - encodedPrefix.length - encodedSuffix.length - encodedNote.length;
414
415 // If description alone exceeds limit, truncate everything
416 if (spaceForErrors <= 0) {
417 const ellipsis = encodeURIComponent('…');
418 const buffer = 50; // Extra safety margin
419 const maxEncodedLength = GITHUB_URL_LIMIT - baseUrl.length - ellipsis.length - encodedNote.length - buffer;
420 const fullBody = bodyPrefix + errorsJson + errorSuffix;
421 let encodedFullBody = encodeURIComponent(fullBody);
422 if (encodedFullBody.length > maxEncodedLength) {
423 encodedFullBody = encodedFullBody.slice(0, maxEncodedLength);
424 // Don't cut in middle of %XX sequence
425 const lastPercent = encodedFullBody.lastIndexOf('%');
426 if (lastPercent >= encodedFullBody.length - 2) {
427 encodedFullBody = encodedFullBody.slice(0, lastPercent);
428 }
429 }
430 return baseUrl + encodedFullBody + ellipsis + encodedNote;
431 }
432
433 // If errors fit, no truncation needed
434 if (encodedErrors.length <= spaceForErrors) {
435 return baseUrl + encodedPrefix + encodedErrors + encodedSuffix;
436 }
437
438 // Truncate errors to fit (prioritize keeping description)
439 // Slice encoded errors directly, then trim to avoid cutting %XX sequences
440 const ellipsis = encodeURIComponent('…');
441 const buffer = 50; // Extra safety margin
442 let truncatedEncodedErrors = encodedErrors.slice(0, spaceForErrors - ellipsis.length - buffer);
443 // If we cut in middle of %XX, back up to before the %
444 const lastPercent = truncatedEncodedErrors.lastIndexOf('%');
445 if (lastPercent >= truncatedEncodedErrors.length - 2) {
446 truncatedEncodedErrors = truncatedEncodedErrors.slice(0, lastPercent);
447 }
448 return baseUrl + encodedPrefix + truncatedEncodedErrors + ellipsis + encodedSuffix + encodedNote;
449}
450async function generateTitle(description: string, abortSignal: AbortSignal): Promise<string> {
451 try {
452 const response = await queryHaiku({

Callers 1

FeedbackFunction · 0.85

Calls 2

redactSensitiveInfoFunction · 0.85
jsonStringifyFunction · 0.85

Tested by

no test coverage detected