MCPcopy Index your code
hub / github.com/coder/mux / buildRunSummary

Method buildRunSummary

src/node/services/devToolsService.ts:509–561  ·  view source on GitHub ↗
(data: WorkspaceData, runId: string)

Source from the content-addressed store, hash-verified

507 }
508
509 private buildRunSummary(data: WorkspaceData, runId: string): DevToolsRunSummary {
510 const run = data.runs.get(runId);
511 assert(run, `DevToolsService.buildRunSummary missing run ${runId}`);
512
513 const steps = Array.from(data.steps.values())
514 .filter((step) => step.runId === runId)
515 .sort((a, b) => getStepSortKey(a).localeCompare(getStepSortKey(b)));
516
517 const firstStep = steps[0];
518
519 let firstMessage = "";
520 if (firstStep?.input && isRecord(firstStep.input)) {
521 const prompt = firstStep.input.prompt;
522 if (isUnknownArray(prompt)) {
523 for (let index = prompt.length - 1; index >= 0; index -= 1) {
524 const message = prompt[index];
525 if (!isRecord(message) || message.role !== "user") {
526 continue;
527 }
528
529 const text = extractText(message.content ?? message);
530 if (!text.trim()) {
531 continue;
532 }
533
534 firstMessage = truncateMessage(text.trim());
535 break;
536 }
537 }
538 }
539
540 const hasError = steps.some((step) => Boolean(step.error));
541 const isInProgress = steps.some((step) => step.durationMs == null && !step.error);
542
543 let totalDurationMs: number | null = 0;
544 for (const step of steps) {
545 if (step.durationMs == null) {
546 totalDurationMs = null;
547 break;
548 }
549 totalDurationMs += step.durationMs;
550 }
551
552 return {
553 ...run,
554 stepCount: steps.length,
555 firstMessage,
556 hasError,
557 isInProgress,
558 totalDurationMs,
559 modelId: firstStep?.modelId ?? null,
560 };
561 }
562
563 /**
564 * Serialize all disk writes per workspace so clear() and appendToFile()

Callers 5

createRunMethod · 0.95
createStepMethod · 0.95
updateStepMethod · 0.95
getRunsMethod · 0.95
getRunWithStepsMethod · 0.95

Calls 7

getStepSortKeyFunction · 0.85
truncateMessageFunction · 0.85
isRecordFunction · 0.70
isUnknownArrayFunction · 0.70
extractTextFunction · 0.70
getMethod · 0.65
assertFunction · 0.50

Tested by

no test coverage detected