33import fs from "node:fs" ;
44import os from "node:os" ;
55import path from "node:path" ;
6- import { afterEach , beforeAll , describe , expect , test , vi } from "vitest" ;
6+ import { afterAll , afterEach , beforeAll , describe , expect , test , vi } from "vitest" ;
77import { writeAcpSessionMetaForMigration } from "../acp/runtime/session-meta.js" ;
88import { resetConfigRuntimeState , setRuntimeConfigSnapshot } from "../config/config.js" ;
99import type { OpenClawConfig } from "../config/config.js" ;
1010import { loadSessionStore , type SessionEntry } from "../config/sessions.js" ;
1111import { writeSessionStoreForTest } from "../config/sessions/test-helpers.js" ;
1212import { createEmptyPluginRegistry } from "../plugins/registry-empty.js" ;
13- import { resetPluginRuntimeStateForTest , setActivePluginRegistry } from "../plugins/runtime.js" ;
13+ import {
14+ getActivePluginRegistry ,
15+ resetPluginRuntimeStateForTest ,
16+ setActivePluginRegistry ,
17+ } from "../plugins/runtime.js" ;
1418import { withStateDirEnv } from "../test-helpers/state-dir-env.js" ;
1519import {
1620 canonicalizeSpawnedByForAgent ,
@@ -101,8 +105,10 @@ function expectFields(value: unknown, expected: Record<string, unknown>): void {
101105}
102106
103107describe ( "gateway session utils" , ( ) => {
108+ const emptyPluginRegistry = createEmptyPluginRegistry ( ) ;
109+
104110 beforeAll ( ( ) => {
105- setActivePluginRegistry ( createEmptyPluginRegistry ( ) ) ;
111+ setActivePluginRegistry ( emptyPluginRegistry ) ;
106112 listSessionsFromStore ( {
107113 cfg : createModelDefaultsConfig ( { primary : "anthropic/claude-sonnet-4.6" } ) ,
108114 storePath : "" ,
@@ -117,11 +123,16 @@ describe("gateway session utils", () => {
117123 opts : { } ,
118124 } ) ;
119125 resetConfigRuntimeState ( ) ;
120- resetPluginRuntimeStateForTest ( ) ;
121126 } ) ;
122127
123128 afterEach ( ( ) => {
124129 resetConfigRuntimeState ( ) ;
130+ if ( getActivePluginRegistry ( ) !== emptyPluginRegistry ) {
131+ setActivePluginRegistry ( emptyPluginRegistry ) ;
132+ }
133+ } ) ;
134+
135+ afterAll ( ( ) => {
125136 resetPluginRuntimeStateForTest ( ) ;
126137 } ) ;
127138
0 commit comments