* 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.
()
| 358 | * non-interactive mode where trust is implicit. |
| 359 | */ |
| 360 | function prefetchSystemContextIfSafe(): void { |
| 361 | const isNonInteractiveSession = getIsNonInteractiveSession(); |
| 362 | |
| 363 | // In non-interactive mode (--print), trust dialog is skipped and |
| 364 | // execution is considered trusted (as documented in help text) |
| 365 | if (isNonInteractiveSession) { |
| 366 | logForDiagnosticsNoPII('info', 'prefetch_system_context_non_interactive'); |
| 367 | void getSystemContext(); |
| 368 | return; |
| 369 | } |
| 370 | |
| 371 | // In interactive mode, only prefetch if trust has already been established |
| 372 | const hasTrust = checkHasTrustDialogAccepted(); |
| 373 | if (hasTrust) { |
| 374 | logForDiagnosticsNoPII('info', 'prefetch_system_context_has_trust'); |
| 375 | void getSystemContext(); |
| 376 | } else { |
| 377 | logForDiagnosticsNoPII('info', 'prefetch_system_context_skipped_no_trust'); |
| 378 | } |
| 379 | // Otherwise, don't prefetch - wait for trust to be established first |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * Start background prefetches and housekeeping that are NOT needed before first render. |
no test coverage detected