MCPcopy
hub / github.com/codeaashu/claude-code / computeTrustDialogAccepted

Function computeTrustDialogAccepted

src/utils/config.ts:705–743  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

703}
704
705function computeTrustDialogAccepted(): boolean {
706 // Check session-level trust (for home directory case where trust is not persisted)
707 // When running from home dir, trust dialog is shown but acceptance is stored
708 // in memory only. This allows hooks and other features to work during the session.
709 if (getSessionTrustAccepted()) {
710 return true
711 }
712
713 const config = getGlobalConfig()
714
715 // Always check where trust would be saved (git root or original cwd)
716 // This is the primary location where trust is persisted by saveCurrentProjectConfig
717 const projectPath = getProjectPathForConfig()
718 const projectConfig = config.projects?.[projectPath]
719 if (projectConfig?.hasTrustDialogAccepted) {
720 return true
721 }
722
723 // Now check from current working directory and its parents
724 // Normalize paths for consistent JSON key lookup
725 let currentPath = normalizePathForConfigKey(getCwd())
726
727 // Traverse all parent directories
728 while (true) {
729 const pathConfig = config.projects?.[currentPath]
730 if (pathConfig?.hasTrustDialogAccepted) {
731 return true
732 }
733
734 const parentPath = normalizePathForConfigKey(resolve(currentPath, '..'))
735 // Stop if we've reached the root (when parent is same as current)
736 if (parentPath === currentPath) {
737 break
738 }
739 currentPath = parentPath
740 }
741
742 return false
743}
744
745/**
746 * Check trust for an arbitrary directory (not the session cwd).

Callers 1

Calls 5

getSessionTrustAcceptedFunction · 0.85
getGlobalConfigFunction · 0.85
getCwdFunction · 0.85
resolveFunction · 0.70

Tested by

no test coverage detected