MCPcopy Create free account
hub / github.com/Noumena-Network/code / initializeIdeIntegration

Function initializeIdeIntegration

src/utils/ide.ts:1347–1407  ·  view source on GitHub ↗
(
  onIdeDetected: (ide: DetectedIDEInfo | null) => void,
  ideToInstallExtension: IdeType | null,
  onShowIdeOnboarding: () => void,
  onInstallationComplete: (
    status: IDEExtensionInstallationStatus | null,
  ) => void,
)

Source from the content-addressed store, hash-verified

1345 * @param onInstallationComplete Callback to be called when extension installation is complete
1346 */
1347export async function initializeIdeIntegration(
1348 onIdeDetected: (ide: DetectedIDEInfo | null) => void,
1349 ideToInstallExtension: IdeType | null,
1350 onShowIdeOnboarding: () => void,
1351 onInstallationComplete: (
1352 status: IDEExtensionInstallationStatus | null,
1353 ) => void,
1354): Promise<void> {
1355 // Don't await so we don't block startup, but return a promise that resolves with the status
1356 void findAvailableIDE().then(onIdeDetected)
1357
1358 const shouldAutoInstall = getGlobalConfig().autoInstallIdeExtension ?? true
1359 if (
1360 !isEnvTruthy(process.env.CLAUDE_CODE_IDE_SKIP_AUTO_INSTALL) &&
1361 shouldAutoInstall
1362 ) {
1363 const ideType = ideToInstallExtension ?? getTerminalIdeType()
1364 if (ideType) {
1365 if (isVSCodeIde(ideType)) {
1366 void isIDEExtensionInstalled(ideType).then(async isAlreadyInstalled => {
1367 void maybeInstallIDEExtension(ideType)
1368 .catch(error => {
1369 const ideInstallationStatus: IDEExtensionInstallationStatus = {
1370 installed: false,
1371 error: error.message || 'Installation failed',
1372 installedVersion: null,
1373 ideType: ideType,
1374 }
1375 return ideInstallationStatus
1376 })
1377 .then(status => {
1378 onInstallationComplete(status)
1379
1380 if (status?.installed) {
1381 // If we installed and don't yet have an IDE, search again.
1382 void findAvailableIDE().then(onIdeDetected)
1383 }
1384
1385 if (
1386 !isAlreadyInstalled &&
1387 status?.installed === true &&
1388 !ideOnboardingDialog().hasIdeOnboardingDialogBeenShown()
1389 ) {
1390 onShowIdeOnboarding()
1391 }
1392 })
1393 })
1394 } else if (isJetBrainsIde(ideType)) {
1395 // Always check installation to populate the sync cache used by status notices
1396 void isIDEExtensionInstalled(ideType).then(async installed => {
1397 if (
1398 installed &&
1399 !ideOnboardingDialog().hasIdeOnboardingDialogBeenShown()
1400 ) {
1401 onShowIdeOnboarding()
1402 }
1403 })
1404 }

Callers 1

useIDEIntegrationFunction · 0.85

Calls 9

isEnvTruthyFunction · 0.90
findAvailableIDEFunction · 0.85
getTerminalIdeTypeFunction · 0.85
isVSCodeIdeFunction · 0.85
isIDEExtensionInstalledFunction · 0.85
maybeInstallIDEExtensionFunction · 0.85
ideOnboardingDialogFunction · 0.85
isJetBrainsIdeFunction · 0.85
getGlobalConfigFunction · 0.70

Tested by

no test coverage detected