Skip to content

Commit b3989a8

Browse files
committed
add heading level
1 parent 6b853f4 commit b3989a8

4 files changed

Lines changed: 60 additions & 29 deletions

File tree

static/app/components/events/autofix/v3/drawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function useHandleCopyMarkdown({
9696
const markdown = getOrderedAutofixSections(aiAutofix.runState)
9797
.map(getAutofixArtifactFromSection)
9898
.filter(defined)
99-
.map(artifactToMarkdown)
99+
.map(artifact => artifactToMarkdown(artifact))
100100
.filter(defined)
101101
.join('\n\n');
102102
copy(markdown, {successMessage: t('Analysis copied to clipboard.')});

static/app/components/events/autofix/v3/utils.ts

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,44 +17,51 @@ import {
1717
type RepoPRState,
1818
} from 'sentry/views/seerExplorer/types';
1919

20-
export function artifactToMarkdown(artifact: AutofixArtifact): string | null {
20+
export function artifactToMarkdown(
21+
artifact: AutofixArtifact,
22+
headingLevel: 1 | 2 | 3 = 1
23+
): string | null {
2124
if (isRootCauseArtifact(artifact)) {
22-
return rootCauseArtifactToMarkdown(artifact);
25+
return rootCauseArtifactToMarkdown(artifact, headingLevel);
2326
}
2427

2528
if (isSolutionArtifact(artifact)) {
26-
return solutionArtifactToMarkdown(artifact);
29+
return solutionArtifactToMarkdown(artifact, headingLevel);
2730
}
2831

2932
if (isCodeChangesArtifact(artifact)) {
30-
return filePatchesToMarkdown(artifact);
33+
return filePatchesToMarkdown(artifact, headingLevel);
3134
}
3235

3336
if (isPullRequestsArtifact(artifact)) {
34-
return repoPRStatesToMarkdown(artifact);
37+
return repoPRStatesToMarkdown(artifact, headingLevel);
3538
}
3639

3740
if (isCodingAgentsArtifact(artifact)) {
38-
return codingAgentsToMarkdown(artifact);
41+
return codingAgentsToMarkdown(artifact, headingLevel);
3942
}
4043

4144
return null; // unknown artifact
4245
}
4346

4447
function rootCauseArtifactToMarkdown(
45-
artifact: Artifact<RootCauseArtifact>
48+
artifact: Artifact<RootCauseArtifact>,
49+
headingLevel: number
4650
): string | null {
4751
const rootCause = artifact.data;
4852
if (!defined(rootCause)) {
4953
return null;
5054
}
5155

52-
const parts: string[] = ['# Root Cause', '', rootCause.one_line_description];
56+
const h1 = '#'.repeat(headingLevel);
57+
const h2 = '#'.repeat(headingLevel + 1);
58+
59+
const parts: string[] = [`${h1} Root Cause`, '', rootCause.one_line_description];
5360

5461
if (rootCause.five_whys.length) {
5562
parts.push(
5663
'',
57-
'## Why did this happen?',
64+
`${h2} Why did this happen?`,
5865
'',
5966
...rootCause.five_whys.map(why => `- ${why}`)
6067
);
@@ -63,7 +70,7 @@ function rootCauseArtifactToMarkdown(
6370
if (rootCause.reproduction_steps?.length) {
6471
parts.push(
6572
'',
66-
'## Reproduction Steps',
73+
`${h2} Reproduction Steps`,
6774
'',
6875
...rootCause.reproduction_steps.map((step, index) => `${index + 1}. ${step}`)
6976
);
@@ -72,21 +79,28 @@ function rootCauseArtifactToMarkdown(
7279
return parts.join('\n');
7380
}
7481

75-
function solutionArtifactToMarkdown(artifact: Artifact<SolutionArtifact>): string | null {
82+
function solutionArtifactToMarkdown(
83+
artifact: Artifact<SolutionArtifact>,
84+
headingLevel: number
85+
): string | null {
7686
const solution = artifact.data;
7787
if (!defined(solution)) {
7888
return null;
7989
}
8090

81-
const parts: string[] = ['# Plan', '', solution.one_line_summary];
91+
const h1 = '#'.repeat(headingLevel);
92+
const h2 = '#'.repeat(headingLevel + 1);
93+
const h3 = '#'.repeat(headingLevel + 2);
94+
95+
const parts: string[] = [`${h1} Plan`, '', solution.one_line_summary];
8296

8397
if (solution.steps.length) {
8498
parts.push(
8599
'',
86-
'## Steps to Resolve',
100+
`${h2} Steps to Resolve`,
87101
'',
88102
...solution.steps.flatMap((step, index) => [
89-
`### ${index + 1}. ${step.title}`,
103+
`${h3} ${index + 1}. ${step.title}`,
90104
step.description,
91105
])
92106
);
@@ -95,17 +109,23 @@ function solutionArtifactToMarkdown(artifact: Artifact<SolutionArtifact>): strin
95109
return parts.join('\n');
96110
}
97111

98-
function filePatchesToMarkdown(artifact: ExplorerFilePatch[]): string | null {
112+
function filePatchesToMarkdown(
113+
artifact: ExplorerFilePatch[],
114+
headingLevel: number
115+
): string | null {
99116
if (!artifact.length) {
100117
return null;
101118
}
102119

103-
const parts: string[] = ['# Code Changes'];
120+
const h1 = '#'.repeat(headingLevel);
121+
const h2 = '#'.repeat(headingLevel + 1);
122+
123+
const parts: string[] = [`${h1} Code Changes`];
104124

105125
parts.push(
106126
...artifact.flatMap(filePatch => [
107127
'',
108-
`## Repository: ${filePatch.repo_name}`,
128+
`${h2} Repository: ${filePatch.repo_name}`,
109129
'',
110130
'```diff',
111131
filePatch.diff,
@@ -116,12 +136,17 @@ function filePatchesToMarkdown(artifact: ExplorerFilePatch[]): string | null {
116136
return parts.join('\n');
117137
}
118138

119-
function repoPRStatesToMarkdown(artifact: RepoPRState[]): string | null {
139+
function repoPRStatesToMarkdown(
140+
artifact: RepoPRState[],
141+
headingLevel: number
142+
): string | null {
120143
if (!artifact.length) {
121144
return null;
122145
}
123146

124-
const parts: string[] = ['# Pull Requests', ''];
147+
const h1 = '#'.repeat(headingLevel);
148+
149+
const parts: string[] = [`${h1} Pull Requests`, ''];
125150

126151
parts.push(
127152
...artifact
@@ -137,12 +162,18 @@ function repoPRStatesToMarkdown(artifact: RepoPRState[]): string | null {
137162
return parts.join('\n');
138163
}
139164

140-
function codingAgentsToMarkdown(artifact: ExplorerCodingAgentState[]): string | null {
165+
function codingAgentsToMarkdown(
166+
artifact: ExplorerCodingAgentState[],
167+
headingLevel: number
168+
): string | null {
141169
if (!artifact.length) {
142170
return null;
143171
}
144172

145-
const parts: string[] = ['# Coding Agents', ''];
173+
const h1 = '#'.repeat(headingLevel);
174+
const h2 = '#'.repeat(headingLevel + 1);
175+
176+
const parts: string[] = [`${h1} Coding Agents`, ''];
146177

147178
parts.push(
148179
...artifact
@@ -152,7 +183,7 @@ function codingAgentsToMarkdown(artifact: ExplorerCodingAgentState[]): string |
152183
}
153184

154185
return [
155-
`## ${getCodingAgentName(codingAgent.provider)}`,
186+
`${h2} ${getCodingAgentName(codingAgent.provider)}`,
156187
'',
157188
`[${codingAgent.name}](${codingAgent.agent_url})`,
158189
];

static/app/views/issueDetails/streamline/eventNavigation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export function IssueEventNavigation({event, group}: IssueEventNavigationProps)
117117

118118
// Get data for markdown copy functionality
119119
const {data: groupSummaryData} = useGroupSummaryData(group);
120-
const {runState: autofixData} = useExplorerAutofix(group.id);
120+
const {runState: autofixData} = useExplorerAutofix(group.id, {enabled: false});
121121

122122
const handleCopyMarkdown = useCallback(() => {
123123
const markdownText = issueAndEventToMarkdown(

static/app/views/issueDetails/streamline/hooks/useCopyIssueDetails.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,17 @@ export const issueAndEventToMarkdown = (
184184
: null;
185185

186186
const rootCauseCopyText = rootCauseArtifact
187-
? artifactToMarkdown(rootCauseArtifact)
187+
? artifactToMarkdown(rootCauseArtifact, 2)
188188
: null;
189189
const solutionCopyText = solutionArtifact
190-
? artifactToMarkdown(solutionArtifact)
190+
? artifactToMarkdown(solutionArtifact, 2)
191191
: null;
192192

193193
if (rootCauseCopyText) {
194-
markdownText += `\n## Root Cause\n\`\`\`\n${rootCauseCopyText}\n\`\`\`\n`;
194+
markdownText += `\n${rootCauseCopyText}\n`;
195195
}
196196
if (solutionCopyText) {
197-
markdownText += `\n## Solution\n\`\`\`\n${solutionCopyText}\n\`\`\`\n`;
197+
markdownText += `\n${solutionCopyText}\n`;
198198
}
199199
}
200200

@@ -209,7 +209,7 @@ export const useCopyIssueDetails = (group: Group, event?: Event) => {
209209
const organization = useOrganization();
210210

211211
const {data: groupSummaryData} = useGroupSummaryData(group);
212-
const {runState: autofixData} = useExplorerAutofix(group.id);
212+
const {runState: autofixData} = useExplorerAutofix(group.id, {enabled: false});
213213
const activeThreadId = useActiveThreadId();
214214

215215
const text = useMemo(() => {

0 commit comments

Comments
 (0)