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

Function getGlobalConfig

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

Source from the content-addressed store, hash-verified

1042}
1043
1044export function getGlobalConfig(): GlobalConfig {
1045 if (process.env.NODE_ENV === 'test') {
1046 return TEST_GLOBAL_CONFIG_FOR_TESTING
1047 }
1048
1049 // Fast path: pure memory read. After startup, this always hits — our own
1050 // writes go write-through and other instances' writes are picked up by the
1051 // background freshness watcher (never blocks this path).
1052 if (globalConfigCache.config) {
1053 configCacheHits++
1054 return globalConfigCache.config
1055 }
1056
1057 // Slow path: startup load. Sync I/O here is acceptable because it runs
1058 // exactly once, before any UI is rendered. Stat before read so any race
1059 // self-corrects (old mtime + new content → watcher re-reads next tick).
1060 configCacheMisses++
1061 try {
1062 let stats: { mtimeMs: number; size: number } | null = null
1063 try {
1064 stats = getFsImplementation().statSync(getGlobalClaudeFile())
1065 } catch {
1066 // File doesn't exist
1067 }
1068 const config = migrateConfigFields(
1069 getConfig(getGlobalClaudeFile(), createDefaultGlobalConfig),
1070 )
1071 globalConfigCache = {
1072 config,
1073 mtime: stats?.mtimeMs ?? Date.now(),
1074 }
1075 lastReadFileStats = stats
1076 ? { mtime: stats.mtimeMs, size: stats.size }
1077 : null
1078 startGlobalConfigFreshnessWatcher()
1079 return config
1080 } catch {
1081 // If anything goes wrong, fall back to uncached behavior
1082 return migrateConfigFields(
1083 getConfig(getGlobalClaudeFile(), createDefaultGlobalConfig),
1084 )
1085 }
1086}
1087
1088/**
1089 * Returns the effective value of remoteControlAtStartup. Precedence:

Callers 15

showSetupScreensFunction · 0.85
submitMessageMethod · 0.85
runMigrationsFunction · 0.85
runFunction · 0.85
setupFunction · 0.85
getValueFunction · 0.85
getDefaultTeammateModelFunction · 0.85
AutoUpdaterFunction · 0.85
SessionBackgroundHintFunction · 0.85
shouldShowRemoteCalloutFunction · 0.85
shouldShowEffortCalloutFunction · 0.85
generateTokenChartFunction · 0.85

Calls 4

getFsImplementationFunction · 0.85
migrateConfigFieldsFunction · 0.85
getConfigFunction · 0.70

Tested by

no test coverage detected