()
| 1702 | |
| 1703 | // NOTE: Nested function required - needs closure access to applyMcpServerChanges and updateSdkMcp |
| 1704 | async function installPluginsAndApplyMcpInBackground(): Promise<void> { |
| 1705 | try { |
| 1706 | // Join point for user settings (fired at runHeadless entry) and managed |
| 1707 | // settings (fired in main.tsx preAction). downloadUserSettings() caches |
| 1708 | // its promise so this awaits the same in-flight request. |
| 1709 | await Promise.all([ |
| 1710 | feature('DOWNLOAD_USER_SETTINGS') && |
| 1711 | (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE) || getIsRemoteMode()) |
| 1712 | ? withDiagnosticsTiming('headless_user_settings_download', () => |
| 1713 | downloadUserSettings(), |
| 1714 | ) |
| 1715 | : Promise.resolve(), |
| 1716 | withDiagnosticsTiming('headless_managed_settings_wait', () => |
| 1717 | waitForRemoteManagedSettingsToLoad(), |
| 1718 | ), |
| 1719 | ]) |
| 1720 | |
| 1721 | const pluginsInstalled = await installPluginsForHeadless() |
| 1722 | |
| 1723 | if (pluginsInstalled) { |
| 1724 | await applyPluginMcpDiff() |
| 1725 | } |
| 1726 | } catch (error) { |
| 1727 | logError(error) |
| 1728 | } |
| 1729 | } |
| 1730 | |
| 1731 | // Background plugin installation for all headless users |
| 1732 | // Installs marketplaces from extraKnownMarketplaces and missing enabled plugins |
no test coverage detected