* 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.
()
| 371 | * non-interactive mode where trust is implicit. |
| 372 | */ |
| 373 | function 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. |
no test coverage detected