MCPcopy
hub / github.com/opentrace/opentrace / startJob

Method startJob

ui/src/job/browserJobService.ts:190–849  ·  view source on GitHub ↗
(message: JobMessage)

Source from the content-addressed store, hash-verified

188 }
189
190 async startJob(message: JobMessage): Promise<JobStream> {
191 // Server-mode indexing (Fix #6): when the store is backed by an
192 // `opentrace serve` agent, ask the agent to do the work instead of
193 // running tree-sitter in the browser. The agent owns its own DB
194 // and the browser pipeline's writes would no-op against the
195 // read-only ServerGraphStore.
196 if (
197 (message.type === 'index-repo' || message.type === 'reindex-repo') &&
198 this.store instanceof ServerGraphStore
199 ) {
200 return this.startServerIndexUrlJob(message);
201 }
202
203 let input: LoaderInput;
204 const isReindex = message.type === 'reindex-repo';
205 if (message.type === 'index-repo' || message.type === 'reindex-repo') {
206 input = {
207 kind: 'url',
208 url: message.repoUrl,
209 token: message.token,
210 ref: message.ref,
211 };
212 } else if (message.type === 'index-directory') {
213 input = {
214 kind: 'directory',
215 files: message.files,
216 name: message.name,
217 };
218 } else if (message.type === 'import-file') {
219 return this.startImportFileJob(message.file, message.name);
220 } else {
221 throw new Error(
222 `Unsupported job type: ${(message as { type: string }).type}`,
223 );
224 }
225
226 const channel = new EventChannel<JobEvent>();
227 const abortController = new AbortController();
228 let cancelled = false;
229
230 // Debug log — attached to window for console access
231 const debug = new PipelineDebugLog({ enabled: true });
232 (globalThis as Record<string, unknown>).__pipelineDebug = debug;
233
234 // Hoisted so the catch handler can report partial progress
235 let persistedNodes = 0;
236 let persistedRels = 0;
237 let storeStage: StoreStage | undefined;
238
239 const run = async () => {
240 const pipelineStartTime = performance.now();
241 debug.start();
242
243 // 1. Initialize parsers + DB in parallel
244 debug.log('init', 'loading tree-sitter parsers + DB');
245 channel.push({
246 ...emptyEvent(),
247 kind: JobEventKind.JOB_EVENT_KIND_PROGRESS,

Callers

nothing calls this directly

Calls 10

startImportFileJobMethod · 0.95
logMethod · 0.95
dumpMethod · 0.95
pushMethod · 0.95
closeMethod · 0.95
emptyEventFunction · 0.85
errorMethod · 0.80
runFunction · 0.50
statsMethod · 0.45

Tested by

no test coverage detected