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

推荐订阅源

The Cloudflare Blog
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tailwind CSS Blog
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
博客园 - 司徒正美
V
Visual Studio Blog
G
Google Developers Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
aimingoo的专栏
aimingoo的专栏
博客园_首页
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
S
SegmentFault 最新的问题
T
The Blog of Author Tim Ferriss
D
Docker
Vercel News
Vercel News
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
爱范儿
爱范儿
J
Java Code Geeks
大猫的无限游戏
大猫的无限游戏

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
perf(gateway): cache auto-enabled plugin config · opencla...
steipete · 2026-05-28 · via Recent Commits to openclaw:main

@@ -0,0 +1,83 @@

1+

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

2+

import type { OpenClawConfig } from "../config/types.openclaw.js";

3+4+

const mocks = vi.hoisted(() => ({

5+

applyPluginAutoEnable: vi.fn(),

6+

getCurrentPluginMetadataSnapshot: vi.fn(),

7+

}));

8+9+

vi.mock("../config/plugin-auto-enable.js", () => ({

10+

applyPluginAutoEnable: mocks.applyPluginAutoEnable,

11+

}));

12+13+

vi.mock("../plugins/current-plugin-metadata-snapshot.js", () => ({

14+

getCurrentPluginMetadataSnapshot: mocks.getCurrentPluginMetadataSnapshot,

15+

}));

16+17+

describe("resolveGatewayPluginConfig", () => {

18+

beforeEach(() => {

19+

mocks.applyPluginAutoEnable.mockReset();

20+

mocks.getCurrentPluginMetadataSnapshot.mockReset();

21+

});

22+23+

it("reuses auto-enabled config for the same runtime config and metadata snapshot", async () => {

24+

const { resolveGatewayPluginConfig } = await import("./runtime-plugin-config.js");

25+

const config = { channels: { telegram: { botToken: "token" } } } as OpenClawConfig;

26+

const snapshot = { manifestRegistry: { plugins: [], diagnostics: [] } };

27+

const resolved = { ...config, plugins: { allow: ["telegram"] } } as OpenClawConfig;

28+

mocks.getCurrentPluginMetadataSnapshot.mockReturnValue(snapshot);

29+

mocks.applyPluginAutoEnable.mockReturnValue({ config: resolved, changes: [] });

30+31+

expect(resolveGatewayPluginConfig({ config })).toBe(resolved);

32+

expect(resolveGatewayPluginConfig({ config })).toBe(resolved);

33+34+

expect(mocks.applyPluginAutoEnable).toHaveBeenCalledTimes(1);

35+

});

36+37+

it("refreshes the cached config when metadata snapshot changes", async () => {

38+

const { resolveGatewayPluginConfig } = await import("./runtime-plugin-config.js");

39+

const config = { channels: { telegram: { botToken: "token" } } } as OpenClawConfig;

40+

const first = { manifestRegistry: { plugins: [], diagnostics: [] } };

41+

const second = { manifestRegistry: { plugins: [], diagnostics: [] } };

42+

mocks.getCurrentPluginMetadataSnapshot.mockReturnValueOnce(first).mockReturnValue(second);

43+

mocks.applyPluginAutoEnable

44+

.mockReturnValueOnce({ config: { ...config, first: true }, changes: [] })

45+

.mockReturnValueOnce({ config: { ...config, second: true }, changes: [] });

46+47+

expect(resolveGatewayPluginConfig({ config })).toMatchObject({ first: true });

48+

expect(resolveGatewayPluginConfig({ config })).toMatchObject({ second: true });

49+50+

expect(mocks.applyPluginAutoEnable).toHaveBeenCalledTimes(2);

51+

});

52+53+

it("refreshes the cached config when env object changes", async () => {

54+

const { resolveGatewayPluginConfig } = await import("./runtime-plugin-config.js");

55+

const config = { channels: { telegram: { botToken: "token" } } } as OpenClawConfig;

56+

const snapshot = { manifestRegistry: { plugins: [], diagnostics: [] } };

57+

mocks.getCurrentPluginMetadataSnapshot.mockReturnValue(snapshot);

58+

mocks.applyPluginAutoEnable

59+

.mockReturnValueOnce({ config: { ...config, first: true }, changes: [] })

60+

.mockReturnValueOnce({ config: { ...config, second: true }, changes: [] });

61+62+

expect(resolveGatewayPluginConfig({ config, env: { A: "1" } })).toMatchObject({

63+

first: true,

64+

});

65+

expect(resolveGatewayPluginConfig({ config, env: { A: "2" } })).toMatchObject({

66+

second: true,

67+

});

68+69+

expect(mocks.applyPluginAutoEnable).toHaveBeenCalledTimes(2);

70+

});

71+72+

it("does not cache without a current metadata snapshot", async () => {

73+

const { resolveGatewayPluginConfig } = await import("./runtime-plugin-config.js");

74+

const config = {} as OpenClawConfig;

75+

mocks.getCurrentPluginMetadataSnapshot.mockReturnValue(undefined);

76+

mocks.applyPluginAutoEnable.mockImplementation(() => ({ config: {}, changes: [] }));

77+78+

resolveGatewayPluginConfig({ config });

79+

resolveGatewayPluginConfig({ config });

80+81+

expect(mocks.applyPluginAutoEnable).toHaveBeenCalledTimes(2);

82+

});

83+

});