* 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.
()
| 409 | * non-interactive mode where trust is implicit. |
| 410 | */ |
| 411 | function prefetchSystemContextIfSafe(): void { |
| 412 | const isNonInteractiveSession = getIsNonInteractiveSession(); |
| 413 | |
| 414 | // In non-interactive mode (--print), trust dialog is skipped and |
| 415 | // execution is considered trusted (as documented in help text) |
| 416 | if (isNonInteractiveSession) { |
| 417 | logForDiagnosticsNoPII('info', 'prefetch_system_context_non_interactive'); |
| 418 | void getSystemContext(); |
| 419 | return; |
| 420 | } |
| 421 | |
| 422 | // In interactive mode, only prefetch if trust has already been established |
| 423 | const hasTrust = checkHasTrustDialogAccepted(); |
| 424 | if (hasTrust) { |
| 425 | logForDiagnosticsNoPII('info', 'prefetch_system_context_has_trust'); |
| 426 | void getSystemContext(); |
| 427 | } else { |
| 428 | logForDiagnosticsNoPII('info', 'prefetch_system_context_skipped_no_trust'); |
| 429 | } |
| 430 | // Otherwise, don't prefetch - wait for trust to be established first |
| 431 | } |
| 432 | |
| 433 | /** |
| 434 | * Start background prefetches and housekeeping that are NOT needed before first render. |
no test coverage detected