gpt-engineer-app[bot] commited on
Commit
2d7d8b7
·
1 Parent(s): 58b2212
src/routes/dashboard.branch-debug.tsx CHANGED
@@ -970,6 +970,65 @@ function ExportButtons({ result, mode }: { result: DebugResult; mode: "diff" | "
970
  download(`branchdebug-report-${stamp}.md`, lines.join("\n"), "text/markdown");
971
  };
972
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
973
  return (
974
  <div className="flex items-center gap-1">
975
  <button
@@ -986,6 +1045,13 @@ function ExportButtons({ result, mode }: { result: DebugResult; mode: "diff" | "
986
  >
987
  <FileJson className="h-3 w-3" /> .json
988
  </button>
 
 
 
 
 
 
 
989
  </div>
990
  );
991
  }
 
970
  download(`branchdebug-report-${stamp}.md`, lines.join("\n"), "text/markdown");
971
  };
972
 
973
+ const createJiraTicket = async () => {
974
+ const stored = typeof window !== "undefined" ? localStorage.getItem("branchdebug.jiraBaseUrl") : "";
975
+ let base = stored || "";
976
+ if (!base) {
977
+ const input = window.prompt("Enter your Jira base URL (e.g. https://acme.atlassian.net):", "https://your-domain.atlassian.net");
978
+ if (!input) return;
979
+ base = input.replace(/\/$/, "");
980
+ localStorage.setItem("branchdebug.jiraBaseUrl", base);
981
+ }
982
+
983
+ const top = result.suspects[0];
984
+ const summary = top
985
+ ? `BranchDebug: ${top.changeSummary} (${top.filePath})`
986
+ : `BranchDebug: ${(result.summary || "Root-cause report").slice(0, 80)}`;
987
+
988
+ const body: string[] = [];
989
+ body.push(`*Mode:* ${mode === "snippet" ? "Code snippet" : mode === "diff" ? "Git diff" : "Unknown"}`);
990
+ body.push(`*Generated:* ${new Date().toLocaleString()}`);
991
+ body.push("");
992
+ body.push(`h2. Verdict`);
993
+ body.push(result.summary || "_No summary available._");
994
+ body.push("");
995
+ body.push(`h2. IP Shield Sanitization Stats`);
996
+ body.push(`* ${result.sanitizationStats.identifiersTokenized} identifiers tokenized`);
997
+ body.push(`* ${result.sanitizationStats.commentsStripped} comment lines stripped`);
998
+ body.push(`* ${result.sanitizationStats.secretsBlocked} secrets blocked`);
999
+ body.push("");
1000
+ body.push(`h2. Ranked Suspects (${result.suspects.length})`);
1001
+ if (result.suspects.length === 0) {
1002
+ body.push("_No suspect changes identified._");
1003
+ } else {
1004
+ result.suspects.forEach((s, i) => {
1005
+ body.push(`h3. #${i + 1} [${s.confidence.toUpperCase()}] ${s.changeSummary}`);
1006
+ body.push(`* *File:* {{${s.filePath}}}`);
1007
+ body.push(`* *Lines:* ${s.lineStart}${s.lineEnd !== s.lineStart ? `-${s.lineEnd}` : ""}`);
1008
+ if (s.functionName) body.push(`* *Function:* {{${s.functionName}()}}`);
1009
+ body.push(`*Mechanism:* ${s.mechanism}`);
1010
+ if (s.beforeSnippet || s.afterSnippet) {
1011
+ body.push(`{code}`);
1012
+ if (s.beforeSnippet) s.beforeSnippet.split("\n").forEach((l) => body.push(`- ${l}`));
1013
+ if (s.afterSnippet) s.afterSnippet.split("\n").forEach((l) => body.push(`+ ${l}`));
1014
+ body.push(`{code}`);
1015
+ }
1016
+ body.push("");
1017
+ });
1018
+ }
1019
+
1020
+ const description = body.join("\n");
1021
+ try {
1022
+ await navigator.clipboard.writeText(description);
1023
+ toast.success("Ticket description copied — paste into Jira");
1024
+ } catch {
1025
+ toast.message("Could not copy automatically — paste manually in Jira");
1026
+ }
1027
+
1028
+ const url = `${base}/secure/CreateIssue!default.jspa?summary=${encodeURIComponent(summary)}`;
1029
+ window.open(url, "_blank", "noopener,noreferrer");
1030
+ };
1031
+
1032
  return (
1033
  <div className="flex items-center gap-1">
1034
  <button
 
1045
  >
1046
  <FileJson className="h-3 w-3" /> .json
1047
  </button>
1048
+ <button
1049
+ onClick={createJiraTicket}
1050
+ className="h-7 px-2 rounded-md border border-[#2684ff]/40 bg-[#2684ff]/10 hover:bg-[#2684ff]/20 hover:border-[#2684ff] text-[#2684ff] text-[10px] font-mono uppercase tracking-widest flex items-center gap-1"
1051
+ title="Create Jira ticket with sanitization stats and ranked suspects"
1052
+ >
1053
+ <Ticket className="h-3 w-3" /> Jira
1054
+ </button>
1055
  </div>
1056
  );
1057
  }