MCPcopy Create free account
hub / github.com/freecodexyz/free-code / getGlobalConfig

Function getGlobalConfig

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

Source from the content-addressed store, hash-verified

1062}
1063
1064export function getGlobalConfig(): GlobalConfig {
1065 if (process.env.NODE_ENV === 'test') {
1066 return TEST_GLOBAL_CONFIG_FOR_TESTING
1067 }
1068
1069 // Fast path: pure memory read. After startup, this always hits — our own
1070 // writes go write-through and other instances' writes are picked up by the
1071 // background freshness watcher (never blocks this path).
1072 if (globalConfigCache.config) {
1073 configCacheHits++
1074 return globalConfigCache.config
1075 }
1076
1077 // Slow path: startup load. Sync I/O here is acceptable because it runs
1078 // exactly once, before any UI is rendered. Stat before read so any race
1079 // self-corrects (old mtime + new content → watcher re-reads next tick).
1080 configCacheMisses++
1081 try {
1082 let stats: { mtimeMs: number; size: number } | null = null
1083 try {
1084 stats = getFsImplementation().statSync(getGlobalClaudeFile())
1085 } catch {
1086 // File doesn't exist
1087 }
1088 const config = migrateConfigFields(
1089 getConfig(getGlobalClaudeFile(), createDefaultGlobalConfig),
1090 )
1091 globalConfigCache = {
1092 config,
1093 mtime: stats?.mtimeMs ?? Date.now(),
1094 }
1095 lastReadFileStats = stats
1096 ? { mtime: stats.mtimeMs, size: stats.size }
1097 : null
1098 startGlobalConfigFreshnessWatcher()
1099 return config
1100 } catch {
1101 // If anything goes wrong, fall back to uncached behavior
1102 return migrateConfigFields(
1103 getConfig(getGlobalClaudeFile(), createDefaultGlobalConfig),
1104 )
1105 }
1106}
1107
1108/**
1109 * 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