mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 17:44:33 +00:00
fix(browser): default to openclaw profile when unspecified (#32031)
This commit is contained in:
@@ -12,15 +12,19 @@ describe("browser config", () => {
|
||||
expect(resolved.cdpHost).toBe("127.0.0.1");
|
||||
expect(resolved.cdpProtocol).toBe("http");
|
||||
const profile = resolveProfile(resolved, resolved.defaultProfile);
|
||||
expect(profile?.name).toBe("chrome");
|
||||
expect(profile?.driver).toBe("extension");
|
||||
expect(profile?.cdpPort).toBe(18792);
|
||||
expect(profile?.cdpUrl).toBe("http://127.0.0.1:18792");
|
||||
expect(profile?.name).toBe("openclaw");
|
||||
expect(profile?.driver).toBe("openclaw");
|
||||
expect(profile?.cdpPort).toBe(18800);
|
||||
expect(profile?.cdpUrl).toBe("http://127.0.0.1:18800");
|
||||
|
||||
const openclaw = resolveProfile(resolved, "openclaw");
|
||||
expect(openclaw?.driver).toBe("openclaw");
|
||||
expect(openclaw?.cdpPort).toBe(18800);
|
||||
expect(openclaw?.cdpUrl).toBe("http://127.0.0.1:18800");
|
||||
const chrome = resolveProfile(resolved, "chrome");
|
||||
expect(chrome?.driver).toBe("extension");
|
||||
expect(chrome?.cdpPort).toBe(18792);
|
||||
expect(chrome?.cdpUrl).toBe("http://127.0.0.1:18792");
|
||||
expect(resolved.remoteCdpTimeoutMs).toBe(1500);
|
||||
expect(resolved.remoteCdpHandshakeTimeoutMs).toBe(3000);
|
||||
});
|
||||
@@ -239,31 +243,30 @@ describe("browser config", () => {
|
||||
expect(resolved.ssrfPolicy).toEqual({});
|
||||
});
|
||||
|
||||
// Tests for headless/noSandbox profile preference (issue #14895)
|
||||
describe("headless/noSandbox profile preference", () => {
|
||||
it("defaults to chrome profile when headless=false and noSandbox=false", () => {
|
||||
describe("default profile preference", () => {
|
||||
it("defaults to openclaw profile when defaultProfile is not configured", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
headless: false,
|
||||
noSandbox: false,
|
||||
});
|
||||
expect(resolved.defaultProfile).toBe("chrome");
|
||||
expect(resolved.defaultProfile).toBe("openclaw");
|
||||
});
|
||||
|
||||
it("prefers openclaw profile when headless=true", () => {
|
||||
it("keeps openclaw default when headless=true", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
headless: true,
|
||||
});
|
||||
expect(resolved.defaultProfile).toBe("openclaw");
|
||||
});
|
||||
|
||||
it("prefers openclaw profile when noSandbox=true", () => {
|
||||
it("keeps openclaw default when noSandbox=true", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
noSandbox: true,
|
||||
});
|
||||
expect(resolved.defaultProfile).toBe("openclaw");
|
||||
});
|
||||
|
||||
it("prefers openclaw profile when both headless and noSandbox are true", () => {
|
||||
it("keeps openclaw default when both headless and noSandbox are true", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
headless: true,
|
||||
noSandbox: true,
|
||||
@@ -271,7 +274,7 @@ describe("browser config", () => {
|
||||
expect(resolved.defaultProfile).toBe("openclaw");
|
||||
});
|
||||
|
||||
it("explicit defaultProfile config overrides headless preference", () => {
|
||||
it("explicit defaultProfile config overrides defaults in headless mode", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
headless: true,
|
||||
defaultProfile: "chrome",
|
||||
@@ -279,7 +282,7 @@ describe("browser config", () => {
|
||||
expect(resolved.defaultProfile).toBe("chrome");
|
||||
});
|
||||
|
||||
it("explicit defaultProfile config overrides noSandbox preference", () => {
|
||||
it("explicit defaultProfile config overrides defaults in noSandbox mode", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
noSandbox: true,
|
||||
defaultProfile: "chrome",
|
||||
|
||||
@@ -264,17 +264,13 @@ export function resolveBrowserConfig(
|
||||
);
|
||||
const cdpProtocol = cdpInfo.parsed.protocol === "https:" ? "https" : "http";
|
||||
|
||||
// In headless/noSandbox environments (servers), prefer "openclaw" profile over "chrome"
|
||||
// because Chrome extension relay requires a GUI browser which isn't available headless.
|
||||
// Issue: https://github.com/openclaw/openclaw/issues/14895
|
||||
const preferOpenClawProfile = headless || noSandbox;
|
||||
const defaultProfile =
|
||||
defaultProfileFromConfig ??
|
||||
(preferOpenClawProfile && profiles[DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME]
|
||||
? DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME
|
||||
: profiles[DEFAULT_BROWSER_DEFAULT_PROFILE_NAME]
|
||||
? DEFAULT_BROWSER_DEFAULT_PROFILE_NAME
|
||||
: DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME);
|
||||
(profiles[DEFAULT_BROWSER_DEFAULT_PROFILE_NAME]
|
||||
? DEFAULT_BROWSER_DEFAULT_PROFILE_NAME
|
||||
: profiles[DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME]
|
||||
? DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME
|
||||
: "chrome");
|
||||
|
||||
const extraArgs = Array.isArray(cfg?.extraArgs)
|
||||
? cfg.extraArgs.filter((a): a is string => typeof a === "string" && a.trim().length > 0)
|
||||
|
||||
@@ -2,7 +2,7 @@ export const DEFAULT_OPENCLAW_BROWSER_ENABLED = true;
|
||||
export const DEFAULT_BROWSER_EVALUATE_ENABLED = true;
|
||||
export const DEFAULT_OPENCLAW_BROWSER_COLOR = "#FF4500";
|
||||
export const DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME = "openclaw";
|
||||
export const DEFAULT_BROWSER_DEFAULT_PROFILE_NAME = "chrome";
|
||||
export const DEFAULT_BROWSER_DEFAULT_PROFILE_NAME = "openclaw";
|
||||
export const DEFAULT_AI_SNAPSHOT_MAX_CHARS = 80_000;
|
||||
export const DEFAULT_AI_SNAPSHOT_EFFICIENT_MAX_CHARS = 10_000;
|
||||
export const DEFAULT_AI_SNAPSHOT_EFFICIENT_DEPTH = 6;
|
||||
|
||||
Reference in New Issue
Block a user