Skip to content

Commit f189588

Browse files
committed
clean up
1 parent 732021c commit f189588

2 files changed

Lines changed: 22 additions & 85 deletions

File tree

‎packages/mcp-core/src/internal/formatting.ts‎

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,6 @@ export function formatEventOutput(
229229
availableToolNames?: ReadonlySet<string>;
230230
directToolNames?: ReadonlySet<string>;
231231
};
232-
// strip replay ids without rendering the replay note, for callers that report replays separately
233-
stripReplayIds?: boolean;
234232
},
235233
) {
236234
let output = "";
@@ -239,10 +237,9 @@ export function formatEventOutput(
239237
user?: z.infer<typeof EventSchema>["user"];
240238
}
241239
).user;
242-
const eventToRender =
243-
options?.replaySummary || options?.stripReplayIds
244-
? stripReplayMetadata(event)
245-
: event;
240+
const eventToRender = options?.replaySummary
241+
? stripReplayMetadata(event)
242+
: event;
246243

247244
if (options?.replaySummary) {
248245
output += formatIssueReplayOutput({
@@ -2146,13 +2143,15 @@ export function formatIssueOutput({
21462143

21472144
if (aiConversations && aiConversations.length > 0) {
21482145
output += "\n## Response Notes\n\n";
2149-
output += formatAIConversationResponseNote({
2146+
for (const note of buildAIConversationResponseNotes({
21502147
aiConversations,
21512148
organizationSlug,
21522149
experimentalMode: experimentalMode ?? false,
21532150
availableToolNames,
21542151
directToolNames,
2155-
});
2152+
})) {
2153+
output += `- ${note}\n`;
2154+
}
21562155
}
21572156

21582157
// For unsupported event types, return early without trying to render event details
@@ -2413,18 +2412,6 @@ function buildAIConversationResponseNotes({
24132412
];
24142413
}
24152414

2416-
function formatAIConversationResponseNote(args: {
2417-
aiConversations: AIConversationReference[];
2418-
organizationSlug: string;
2419-
experimentalMode: boolean;
2420-
availableToolNames?: ReadonlySet<string>;
2421-
directToolNames?: ReadonlySet<string>;
2422-
}): string {
2423-
return `${buildAIConversationResponseNotes(args)
2424-
.map((note) => `- ${note}`)
2425-
.join("\n")}\n`;
2426-
}
2427-
24282415
const MAX_DISPLAY_REPLAYS = 5;
24292416

24302417
function formatIssueReplayOutput({
@@ -2560,7 +2547,7 @@ function normalizeReplayId(replayId: string | null | undefined): string | null {
25602547
return trimmedReplayId.replace(/-/g, "");
25612548
}
25622549

2563-
function stripReplayMetadata(event: Event): Event {
2550+
export function stripReplayMetadata(event: Event): Event {
25642551
const tags = event.tags?.filter(
25652552
(tag) => tag.key !== "replay.id" && tag.key !== "replayId",
25662553
);

‎packages/mcp-core/src/tools/catalog/get-issue-details.ts‎

Lines changed: 14 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
getSuspectCommit,
2424
isPerformanceIssueType,
2525
isSupportedEventType,
26+
stripReplayMetadata,
2627
} from "../../internal/formatting";
2728
import type { AIConversationReference } from "../../internal/tool-helpers/ai-conversation-actions";
2829
import { apiServiceFromContext } from "../../internal/tool-helpers/api";
@@ -172,6 +173,15 @@ function buildReplays(
172173
};
173174
}
174175

176+
type IssueDetailsArgs = Parameters<typeof formatIssueOutput>[0];
177+
178+
function issueDetailsResult(args: IssueDetailsArgs) {
179+
if (args.experimentalMode && isSupportedEventType(args.event)) {
180+
return structuredResult(buildIssueDetailsPayload(args));
181+
}
182+
return formatIssueOutput(args);
183+
}
184+
175185
function buildIssueDetailsPayload({
176186
organizationSlug,
177187
issue,
@@ -187,22 +197,7 @@ function buildIssueDetailsPayload({
187197
experimentalMode,
188198
availableToolNames,
189199
directToolNames,
190-
}: {
191-
organizationSlug: string;
192-
issue: Issue;
193-
event: Event;
194-
apiService: SentryApiService;
195-
autofixState?: AutofixRunState;
196-
performanceTrace?: Trace;
197-
externalIssues?: ExternalIssueList;
198-
relatedReplayIds?: string[];
199-
aiConversations?: AIConversationReference[];
200-
codeLocation?: CodeLocation;
201-
committers?: CommitterList;
202-
experimentalMode?: boolean;
203-
availableToolNames?: ReadonlySet<string>;
204-
directToolNames?: ReadonlySet<string>;
205-
}): GetIssueDetailsPayload {
200+
}: IssueDetailsArgs): GetIssueDetailsPayload {
206201
const autofix = autofixState?.autofix;
207202
const summaries = autofix ? getAutofixArtifactSummaries(autofix) : undefined;
208203
const isPerf = isPerformanceIssueType(issue) && !!issue.metadata;
@@ -243,10 +238,7 @@ function buildIssueDetailsPayload({
243238
? event.message
244239
: null,
245240
// replays are their own field below
246-
body: formatEventOutput(event, {
247-
performanceTrace,
248-
stripReplayIds: true,
249-
}),
241+
body: formatEventOutput(stripReplayMetadata(event), { performanceTrace }),
250242
},
251243
seer: autofix
252244
? {
@@ -426,28 +418,7 @@ export default defineTool({
426418
}),
427419
]);
428420

429-
if (context.experimentalMode && isSupportedEventType(event)) {
430-
return structuredResult(
431-
buildIssueDetailsPayload({
432-
organizationSlug: orgSlug,
433-
issue,
434-
event,
435-
apiService,
436-
autofixState,
437-
performanceTrace,
438-
externalIssues,
439-
relatedReplayIds,
440-
aiConversations,
441-
codeLocation,
442-
committers,
443-
experimentalMode: context.experimentalMode,
444-
availableToolNames: context.availableToolNames,
445-
directToolNames: context.directToolNames,
446-
}),
447-
);
448-
}
449-
450-
return formatIssueOutput({
421+
return issueDetailsResult({
451422
organizationSlug: orgSlug,
452423
issue,
453424
event,
@@ -534,28 +505,7 @@ export default defineTool({
534505
}),
535506
]);
536507

537-
if (context.experimentalMode && isSupportedEventType(event)) {
538-
return structuredResult(
539-
buildIssueDetailsPayload({
540-
organizationSlug: orgSlug,
541-
issue,
542-
event,
543-
apiService,
544-
autofixState,
545-
performanceTrace,
546-
externalIssues,
547-
relatedReplayIds,
548-
aiConversations,
549-
codeLocation,
550-
committers,
551-
experimentalMode: context.experimentalMode,
552-
availableToolNames: context.availableToolNames,
553-
directToolNames: context.directToolNames,
554-
}),
555-
);
556-
}
557-
558-
return formatIssueOutput({
508+
return issueDetailsResult({
559509
organizationSlug: orgSlug,
560510
issue,
561511
event,

0 commit comments

Comments
 (0)