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

Method fetchSecondaryWorkspaceRepos

src/browser/stores/GitStatusStore.ts:940–987  ·  view source on GitHub ↗
(
    fetchKey: string,
    projectPathsByWorkspaceId: ReadonlyMap<string, string>
  )

Source from the content-addressed store, hash-verified

938 }
939
940 private async fetchSecondaryWorkspaceRepos(
941 fetchKey: string,
942 projectPathsByWorkspaceId: ReadonlyMap<string, string>
943 ): Promise<void> {
944 if (!this.client || !this.isActive) {
945 return;
946 }
947
948 for (const [projectPath, workspaceId] of projectPathsByWorkspaceId) {
949 const metadata = this.workspaceMetadata.get(workspaceId);
950 if (!this.client || !this.isActive) {
951 return;
952 }
953 if (!metadata) {
954 console.debug(
955 `[fetch] Skipping secondary repo fetch for ${fetchKey} (${projectPath}): workspace ${workspaceId} is no longer tracked`
956 );
957 continue;
958 }
959 if (
960 !canRunPassiveRuntimeCommand(
961 metadata.runtimeConfig,
962 this.runtimeStatusStore.getStatus(workspaceId)
963 )
964 ) {
965 // Secondary repo fetches also run in the runtime context, so re-check passive
966 // eligibility before each repo in case the owning runtime stopped after the
967 // primary fetch or another workspace on the same fetch key scheduled this repo.
968 console.debug(
969 `[fetch] Skipping secondary repo fetch for ${fetchKey} (${projectPath}): workspace ${workspaceId} is no longer eligible`
970 );
971 continue;
972 }
973
974 assert(projectPath.trim().length > 0, "Secondary repo fetch requires a projectPath");
975 assert(workspaceId.trim().length > 0, "Secondary repo fetch requires a workspaceId");
976 try {
977 await this.executeWorkspaceFetch(workspaceId, projectPath);
978 } catch (secondaryError) {
979 // Secondary fetches are best-effort so a single stale repo does not back off
980 // the entire workspace's primary background refresh loop.
981 console.debug(
982 `[fetch] Secondary repo fetch failed for ${fetchKey} (${projectPath}) via ${workspaceId}:`,
983 secondaryError
984 );
985 }
986 }
987 }
988
989 /**
990 * Fetch updates for a workspace.

Callers 2

fetchWorkspaceMethod · 0.95

Calls 6

executeWorkspaceFetchMethod · 0.95
debugMethod · 0.80
getMethod · 0.65
getStatusMethod · 0.65
assertFunction · 0.50

Tested by

no test coverage detected