惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
博客园 - Franky
The GitHub Blog
The GitHub Blog
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
小众软件
小众软件
罗磊的独立博客
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
美团技术团队
H
Hackread – Cybersecurity News, Data Breaches, AI and More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
C
Check Point Blog
WordPress大学
WordPress大学
博客园 - 【当耐特】
博客园 - 司徒正美
D
Docker

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: skip browser cleanup when browser is disabled · open...
poison · 2026-05-31 · via Recent Commits to openclaw:main

@@ -4,16 +4,18 @@ import path from "node:path";

44

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

5566

const closeTrackedBrowserTabsForSessionsImpl = vi.hoisted(() => vi.fn());

7-

const loadBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());

7+

const canLoadActivatedBundledPluginPublicSurface = vi.hoisted(() => vi.fn());

8+

const tryLoadActivatedBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());

89

const runExec = vi.hoisted(() => vi.fn());

910

const realMkdirSync = fs.mkdirSync.bind(fs);

1011

const realMkdtempSync = fs.mkdtempSync.bind(fs);

1112

const realRmSync = fs.rmSync.bind(fs);

1213

const realWriteFileSync = fs.writeFileSync.bind(fs);

1314

const realRealpathSyncNative = fs.realpathSync.native.bind(fs.realpathSync);

141515-

vi.mock("./facade-loader.js", () => ({

16-

loadBundledPluginPublicSurfaceModuleSync,

16+

vi.mock("./facade-runtime.js", () => ({

17+

canLoadActivatedBundledPluginPublicSurface,

18+

tryLoadActivatedBundledPluginPublicSurfaceModuleSync,

1719

}));

18201921

vi.mock("../process/exec.js", () => ({

@@ -38,6 +40,7 @@ describe("browser maintenance", () => {

38403941

beforeEach(() => {

4042

vi.restoreAllMocks();

43+

vi.resetModules();

4144

testRoot = realRealpathSyncNative(

4245

realMkdtempSync(path.join(os.tmpdir(), "openclaw-browser-maintenance-")),

4346

);

@@ -46,15 +49,17 @@ describe("browser maintenance", () => {

4649

realMkdirSync(path.join(homeDir, ".Trash"), { recursive: true, mode: 0o700 });

4750

realMkdirSync(tmpDir, { recursive: true, mode: 0o700 });

4851

closeTrackedBrowserTabsForSessionsImpl.mockReset();

49-

loadBundledPluginPublicSurfaceModuleSync.mockReset();

52+

canLoadActivatedBundledPluginPublicSurface.mockReset();

53+

tryLoadActivatedBundledPluginPublicSurfaceModuleSync.mockReset();

5054

runExec.mockReset();

5155

vi.spyOn(Date, "now").mockReturnValue(123);

5256

vi.spyOn(os, "homedir").mockReturnValue(homeDir);

5357

vi.spyOn(os, "tmpdir").mockReturnValue(tmpDir);

5458

vi.spyOn(fs.realpathSync, "native").mockImplementation((candidate) =>

5559

realRealpathSyncNative(candidate),

5660

);

57-

loadBundledPluginPublicSurfaceModuleSync.mockReturnValue({

61+

canLoadActivatedBundledPluginPublicSurface.mockReturnValue(true);

62+

tryLoadActivatedBundledPluginPublicSurfaceModuleSync.mockReturnValue({

5863

closeTrackedBrowserTabsForSessions: closeTrackedBrowserTabsForSessionsImpl,

5964

});

6065

});

@@ -76,7 +81,39 @@ describe("browser maintenance", () => {

7681

const { closeTrackedBrowserTabsForSessions } = await import("./browser-maintenance.js");

77827883

await expect(closeTrackedBrowserTabsForSessions({ sessionKeys: [] })).resolves.toBe(0);

79-

expect(loadBundledPluginPublicSurfaceModuleSync).not.toHaveBeenCalled();

84+

expect(tryLoadActivatedBundledPluginPublicSurfaceModuleSync).not.toHaveBeenCalled();

85+

});

86+87+

it("skips browser cleanup when the browser plugin is disabled", async () => {

88+

canLoadActivatedBundledPluginPublicSurface.mockReturnValue(false);

89+90+

const { closeTrackedBrowserTabsForSessions } = await import("./browser-maintenance.js");

91+92+

await expect(

93+

closeTrackedBrowserTabsForSessions({ sessionKeys: ["agent:main:test"] }),

94+

).resolves.toBe(0);

95+

expect(canLoadActivatedBundledPluginPublicSurface).toHaveBeenCalledWith({

96+

dirName: "browser",

97+

artifactBasename: "browser-maintenance.js",

98+

});

99+

expect(tryLoadActivatedBundledPluginPublicSurfaceModuleSync).not.toHaveBeenCalled();

100+

expect(closeTrackedBrowserTabsForSessionsImpl).not.toHaveBeenCalled();

101+

});

102+103+

it("rechecks plugin activation before using a cached browser cleanup surface", async () => {

104+

closeTrackedBrowserTabsForSessionsImpl.mockResolvedValue(2);

105+106+

const { closeTrackedBrowserTabsForSessions } = await import("./browser-maintenance.js");

107+108+

await expect(

109+

closeTrackedBrowserTabsForSessions({ sessionKeys: ["agent:main:test"] }),

110+

).resolves.toBe(2);

111+

canLoadActivatedBundledPluginPublicSurface.mockReturnValue(false);

112+

await expect(

113+

closeTrackedBrowserTabsForSessions({ sessionKeys: ["agent:main:test"] }),

114+

).resolves.toBe(0);

115+116+

expect(closeTrackedBrowserTabsForSessionsImpl).toHaveBeenCalledTimes(1);

80117

});

8111882119

it("delegates cleanup through the browser maintenance surface", async () => {

@@ -87,7 +124,7 @@ describe("browser maintenance", () => {

87124

await expect(

88125

closeTrackedBrowserTabsForSessions({ sessionKeys: ["agent:main:test"] }),

89126

).resolves.toBe(2);

90-

expect(loadBundledPluginPublicSurfaceModuleSync).toHaveBeenCalledWith({

127+

expect(tryLoadActivatedBundledPluginPublicSurfaceModuleSync).toHaveBeenCalledWith({

91128

dirName: "browser",

92129

artifactBasename: "browser-maintenance.js",

93130

});