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

Method clear

src/node/services/devToolsService.ts:345–370  ·  view source on GitHub ↗
(workspaceId: string)

Source from the content-addressed store, hash-verified

343 }
344
345 async clear(workspaceId: string): Promise<void> {
346 assert(workspaceId.trim().length > 0, "DevToolsService.clear requires a workspaceId");
347
348 // Wait for any in-flight load to finish before clearing, otherwise the
349 // pending loadFromDisk can repopulate stale data after the clear.
350 const pendingLoad = this.loadingPromises.get(workspaceId);
351 if (pendingLoad) {
352 await pendingLoad;
353 }
354
355 const data = this.getOrCreateWorkspaceData(workspaceId);
356 data.runs.clear();
357 data.steps.clear();
358 data.clearGeneration += 1;
359 data.loaded = true;
360 this.pendingRunMetadata.delete(workspaceId);
361
362 // Enqueue truncation so clear() cannot race with pending appends.
363 await this.enqueueWrite(workspaceId, async () => {
364 const filePath = this.getSessionFilePath(workspaceId);
365 await fs.mkdir(path.dirname(filePath), { recursive: true });
366 await fs.writeFile(filePath, "", "utf-8");
367 });
368
369 this.emitWorkspaceEvent(workspaceId, { type: "cleared" });
370 }
371
372 private emitWorkspaceEvent(workspaceId: string, event: DevToolsEvent): void {
373 this.emit(`update:${workspaceId}`, event);

Callers

nothing calls this directly

Calls 8

enqueueWriteMethod · 0.95
getSessionFilePathMethod · 0.95
emitWorkspaceEventMethod · 0.95
getMethod · 0.65
writeFileMethod · 0.65
assertFunction · 0.50
deleteMethod · 0.45

Tested by

no test coverage detected