Skip to content

Commit 7258ffe

Browse files
committed
Highlight a specific line chosen by the model
1 parent a9adf74 commit 7258ffe

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

static/app/components/events/autofix/autofixRootCause.tsx

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,9 @@ function useSelectCause({groupId, runId}: {groupId: string; runId: string}) {
124124
}
125125

126126
function getLinesToHighlight(suggestedFix: AutofixRootCauseCodeContext): number[] {
127-
function getBacktickSubstrings(input: string): Set<string> {
128-
// Regular expression to match substrings wrapped in backticks
129-
const regex = /`([^`]+)`/g;
130-
const result = new Set<string>();
131-
let match: RegExpExecArray | null;
132-
do {
133-
match = regex.exec(input);
134-
if (match) {
135-
result.add(match[1]);
136-
}
137-
} while (match);
138-
return result;
139-
}
140-
141127
function findLinesWithSubstrings(
142128
input: string | undefined,
143-
substrings: Set<string>
129+
substring: string
144130
): number[] {
145131
if (!input) {
146132
return [];
@@ -149,11 +135,8 @@ function getLinesToHighlight(suggestedFix: AutofixRootCauseCodeContext): number[
149135
const result: number[] = [];
150136

151137
lines.forEach((line, index) => {
152-
for (const substring of substrings) {
153-
if (line.includes(substring)) {
154-
result.push(index + 1); // line numbers are 1-based
155-
break;
156-
}
138+
if (line.includes(substring)) {
139+
result.push(index + 1); // line numbers are 1-based
157140
}
158141
});
159142

@@ -162,7 +145,7 @@ function getLinesToHighlight(suggestedFix: AutofixRootCauseCodeContext): number[
162145

163146
const lineNumbersToHighlight = findLinesWithSubstrings(
164147
suggestedFix.snippet?.snippet,
165-
getBacktickSubstrings(suggestedFix.description)
148+
'***'
166149
);
167150
return lineNumbersToHighlight;
168151
}

0 commit comments

Comments
 (0)