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

Method startForegroundAwait

src/node/services/taskService.ts:4035–4058  ·  view source on GitHub ↗
(workspaceId: string)

Source from the content-addressed store, hash-verified

4033 }
4034
4035 private startForegroundAwait(workspaceId: string): () => void {
4036 assert(workspaceId.length > 0, "startForegroundAwait: workspaceId must be non-empty");
4037
4038 const current = this.foregroundAwaitCountByWorkspaceId.get(workspaceId) ?? 0;
4039 assert(
4040 Number.isInteger(current) && current >= 0,
4041 "startForegroundAwait: expected non-negative integer counter"
4042 );
4043
4044 this.foregroundAwaitCountByWorkspaceId.set(workspaceId, current + 1);
4045
4046 return () => {
4047 const current = this.foregroundAwaitCountByWorkspaceId.get(workspaceId) ?? 0;
4048 assert(
4049 Number.isInteger(current) && current > 0,
4050 "startForegroundAwait cleanup: expected positive integer counter"
4051 );
4052 if (current <= 1) {
4053 this.foregroundAwaitCountByWorkspaceId.delete(workspaceId);
4054 } else {
4055 this.foregroundAwaitCountByWorkspaceId.set(workspaceId, current - 1);
4056 }
4057 };
4058 }
4059
4060 private registerBackgroundableForegroundWaiter(
4061 workspaceId: string,

Callers 3

waitForWorkspaceTurnMethod · 0.95
waitForAgentReportMethod · 0.95

Calls 4

setMethod · 0.80
getMethod · 0.65
assertFunction · 0.50
deleteMethod · 0.45

Tested by

no test coverage detected