MCPcopy Create free account
hub / github.com/T-Lab-CUHKSZ/claude-code / prefetchSystemContextIfSafe

Function prefetchSystemContextIfSafe

src/main.tsx:373–393  ·  view source on GitHub ↗

* Prefetch system context (including git status) only when it's safe to do so. * Git commands can execute arbitrary code via hooks and config (e.g., core.fsmonitor, * diff.external), so we must only run them after trust is established or in * non-interactive mode where trust is implicit.

()

Source from the content-addressed store, hash-verified

371 * non-interactive mode where trust is implicit.
372 */
373function prefetchSystemContextIfSafe(): void {
374 const isNonInteractiveSession = getIsNonInteractiveSession();
375
376 // In non-interactive mode (--print), trust dialog is skipped and
377 // execution is considered trusted (as documented in help text)
378 if (isNonInteractiveSession) {
379 logForDiagnosticsNoPII('info', 'prefetch_system_context_non_interactive');
380 void getSystemContext();
381 return;
382 }
383
384 // In interactive mode, only prefetch if trust has already been established
385 const hasTrust = checkHasTrustDialogAccepted();
386 if (hasTrust) {
387 logForDiagnosticsNoPII('info', 'prefetch_system_context_has_trust');
388 void getSystemContext();
389 } else {
390 logForDiagnosticsNoPII('info', 'prefetch_system_context_skipped_no_trust');
391 }
392 // Otherwise, don't prefetch - wait for trust to be established first
393}
394
395/**
396 * Start background prefetches and housekeeping that are NOT needed before first render.

Callers 1

startDeferredPrefetchesFunction · 0.85

Calls 3

logForDiagnosticsNoPIIFunction · 0.85

Tested by

no test coverage detected