MCPcopy
hub / github.com/coder/mux / tryReadPersistedReport

Method tryReadPersistedReport

src/node/services/taskService.ts:5227–5277  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5225 }
5226
5227 const tryReadPersistedReport = async (): Promise<{
5228 reportMarkdown: string;
5229 planFilePath?: string;
5230 structuredOutput?: unknown;
5231 title?: string;
5232 } | null> => {
5233 if (!requestingWorkspaceId) {
5234 return null;
5235 }
5236
5237 const sessionDir = this.config.getSessionDir(requestingWorkspaceId);
5238 const artifact = await readSubagentReportArtifact(sessionDir, taskId);
5239 if (!artifact) {
5240 return null;
5241 }
5242
5243 // Cache for the current process (best-effort). Disk is the source of truth.
5244 this.completedReportsByTaskId.set(taskId, {
5245 reportMarkdown: artifact.reportMarkdown,
5246 title: artifact.title,
5247 planFilePath: artifact.planFilePath,
5248 structuredOutput: artifact.structuredOutput,
5249 workflowOwnedAncestorWorkspaceIds: artifact.workflowOwnedAncestorWorkspaceIds,
5250 ancestorWorkspaceIds: artifact.ancestorWorkspaceIds,
5251 });
5252 this.enforceCompletedReportCacheLimit();
5253
5254 const entry = findWorkspaceEntry(this.config.loadConfigOrDefault(), taskId);
5255 if (entry != null && !hasCompletedAgentReport(entry.workspace)) {
5256 await this.editWorkspaceEntry(
5257 taskId,
5258 (workspace) => {
5259 workspace.taskStatus = "reported";
5260 workspace.reportedAt = getIsoNow();
5261 delete workspace.taskRecoveryAttempts;
5262 },
5263 { allowMissing: true }
5264 );
5265 await this.maybeStartPatchGenerationForReportedTask(taskId);
5266 await this.emitWorkspaceMetadata(taskId);
5267 await this.maybeStartQueuedTasks();
5268 await this.cleanupReportedLeafTask(taskId);
5269 }
5270
5271 return {
5272 reportMarkdown: artifact.reportMarkdown,
5273 title: artifact.title,
5274 planFilePath: artifact.planFilePath,
5275 structuredOutput: artifact.structuredOutput,
5276 };
5277 };
5278
5279 // Persisted terminal failures (e.g. model_refusal) are checked AFTER reports —
5280 // report monotonicity — and surface as rejections, never as reportMarkdown.

Callers

nothing calls this directly

Calls 13

editWorkspaceEntryMethod · 0.95
emitWorkspaceMetadataMethod · 0.95
maybeStartQueuedTasksMethod · 0.95
findWorkspaceEntryFunction · 0.90
hasCompletedAgentReportFunction · 0.90
getIsoNowFunction · 0.85
setMethod · 0.80
loadConfigOrDefaultMethod · 0.80

Tested by

no test coverage detected