Repository: microsoft/playwright
File: packages/playwright/src/mcp/browser/config.ts (TypeScript)

Code before:
    action: number;
    navigation: number;
  },
  skillMode?: boolean;
  configFile?: string;
  sessionConfig?: SessionConfig;
};

export async function resolveConfig(config: Config): Promise<FullConfig> {
  return mergeConfig(defaultConfig, config);
}

export async function resolveCLIConfig(cliOptions: CLIOptions): Promise<FullConfig> {
  const envOverrides = configFromEnv();
  const daemonOverrides = await configForDaemonSession(cliOptions);
  const cliOverrides = configFromCLIOptions(cliOptions);
  const configFile = cliOverrides.configFile ?? envOverrides.configFile ?? daemonOverrides.configFile;
  const configInFile = await loadConfig(configFile);

  let result = defaultConfig;
  result = mergeConfig(result, configInFile);
  result = mergeConfig(result, daemonOverrides.config);
  result = mergeConfig(result, envOverrides.config);
  result = mergeConfig(result, cliOverrides.config);

  if (cliOptions.daemonSession)
    result.skillMode = true;

  if (!result.browser.userDataDir && daemonOverrides.sessionConfig?.userDataDirPrefix) {
    // No custom value provided, use the daemon data dir.
    const browserToken = result.browser.launchOptions?.channel ?? result.browser?.browserName;
    const userDataDir = `${daemonOverrides.sessionConfig.userDataDirPrefix}-${browserToken}`;
    result.browser.userDataDir = userDataDir;
  }

  if (result.browser.browserName === 'chromium' && result.browser.launchOptions.chromiumSandbox === undefined) {
    if (process.platform === 'linux')
      result.browser.launchOptions.chromiumSandbox = result.browser.launchOptions.channel !== 'chromium';
    else
      result.browser.launchOptions.chromiumSandbox = true;
  }

  result.configFile = configFile;
  result.sessionConfig = daemonOverrides.sessionConfig;

  // Daemon has different defaults.
  if (result.sessionConfig && result.browser.launchOptions.headless !== false && !result.browser.contextOptions.viewport)
    result.browser.contextOptions.viewport = { width: 1280, height: 720 };

  await validateConfig(result);


Review comment (suggestion):
```suggestion
  if (daemonOverrides.sessionConfig)
```

Code after:
    action: number;
    navigation: number;
  },
  skillMode?: boolean;
  configFile?: string;
  sessionConfig?: SessionConfig;
};

export async function resolveConfig(config: Config): Promise<FullConfig> {
  return mergeConfig(defaultConfig, config);
}

export async function resolveCLIConfig(cliOptions: CLIOptions): Promise<FullConfig> {
  const envOverrides = configFromEnv();
  const daemonOverrides = await configForDaemonSession(cliOptions);
  const cliOverrides = configFromCLIOptions(cliOptions);
  const configFile = cliOverrides.configFile ?? envOverrides.configFile ?? daemonOverrides.configFile;
  const configInFile = await loadConfig(configFile);

  let result = defaultConfig;
  result = mergeConfig(result, configInFile);
  result = mergeConfig(result, daemonOverrides);
  result = mergeConfig(result, envOverrides);
  result = mergeConfig(result, cliOverrides);

  if (daemonOverrides.sessionConfig) {
    result.skillMode = true;

    if (!result.extension && !result.browser.userDataDir && daemonOverrides.sessionConfig.userDataDirPrefix) {
      // No custom value provided, use the daemon data dir.
      const browserToken = result.browser.launchOptions?.channel ?? result.browser?.browserName;
      const userDataDir = `${daemonOverrides.sessionConfig.userDataDirPrefix}-${browserToken}`;
      result.browser.userDataDir = userDataDir;
    }
  }

  if (result.browser.browserName === 'chromium' && result.browser.launchOptions.chromiumSandbox === undefined) {
    if (process.platform === 'linux')
      result.browser.launchOptions.chromiumSandbox = result.browser.launchOptions.channel !== 'chromium';
    else
      result.browser.launchOptions.chromiumSandbox = true;
  }

  result.configFile = configFile;
  result.sessionConfig = daemonOverrides.sessionConfig;

  // Daemon has different defaults.
  if (result.sessionConfig && result.browser.launchOptions.headless !== false)
    result.browser.contextOptions.viewport ??= { width: 1280, height: 720 };

  await validateConfig(result);