* 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.
()
| 505 | * non-interactive mode where trust is implicit. |
| 506 | */ |
| 507 | function prefetchSystemContextIfSafe(): void { |
| 508 | const isNonInteractiveSession = getIsNonInteractiveSession(); |
| 509 | |
| 510 | // In non-interactive mode (--print), trust dialog is skipped and |
| 511 | // execution is considered trusted (as documented in help text) |
| 512 | if (isNonInteractiveSession) { |
| 513 | logForDiagnosticsNoPII('info', 'prefetch_system_context_non_interactive'); |
| 514 | void getSystemContext(); |
| 515 | return; |
| 516 | } |
| 517 | |
| 518 | // In interactive mode, only prefetch if trust has already been established |
| 519 | const hasTrust = checkHasTrustDialogAccepted(); |
| 520 | if (hasTrust) { |
| 521 | logForDiagnosticsNoPII('info', 'prefetch_system_context_has_trust'); |
| 522 | void getSystemContext(); |
| 523 | } else { |
| 524 | logForDiagnosticsNoPII('info', 'prefetch_system_context_skipped_no_trust'); |
| 525 | } |
| 526 | // Otherwise, don't prefetch - wait for trust to be established first |
| 527 | } |
| 528 | |
| 529 | /** |
| 530 | * Start background prefetches and housekeeping that are NOT needed before first render. |
no test coverage detected