@@ -18,6 +18,12 @@ import {
1818 createGatewayAgentModelCatalogProjector ,
1919} from "./server-methods/models-list-result.js" ;
2020import type { GatewayRequestContext } from "./server-methods/types.js" ;
21+ import { registerGatewayModelCatalogPrivateAccess } from "./server-model-catalog-auth.js" ;
22+ import {
23+ loadGatewayModelCatalogSnapshot ,
24+ loadPreparedGatewayModelCatalogSnapshot ,
25+ readPreparedGatewayModelCatalogOwnerSnapshot ,
26+ } from "./server-model-catalog.js" ;
2127import type { GatewayPostReadySidecarHandle } from "./server-startup-post-attach.js" ;
2228
2329const mocks = getPreparedModelRuntimeMocks ( ) ;
@@ -110,16 +116,16 @@ afterEach(async () => {
110116 }
111117} ) ;
112118
113- async function createLifecycle ( ) {
119+ async function createLifecycle ( getConfig : ( ) => OpenClawConfig = ( ) => config ) {
114120 return await createGatewayChatMetadataLifecycle ( {
115- getConfig : ( ) => config ,
121+ getConfig,
116122 minimalTestGateway : false ,
117123 log : { warn : vi . fn ( ) } as never ,
118124 } ) ;
119125}
120126
121- async function publishOwner ( ) : Promise < void > {
122- await refreshPreparedModelRuntimeSnapshots ( config , {
127+ async function publishOwner ( ownerConfig : OpenClawConfig = config ) : Promise < void > {
128+ await refreshPreparedModelRuntimeSnapshots ( ownerConfig , {
123129 gatewayLifecycle : true ,
124130 catalogMode : "live" ,
125131 allowGatewaySubagentBinding : true ,
@@ -204,6 +210,51 @@ describe("gateway chat metadata lifecycle composition", () => {
204210 await expectAvailable ( lifecycle ) ;
205211 } ) ;
206212
213+ it ( "keeps the published owner across a display-only config publication" , async ( ) => {
214+ const publishedConfig = {
215+ ...config ,
216+ ui : { prefs : { chatShowThinking : true } } ,
217+ } satisfies OpenClawConfig ;
218+ const currentConfig = {
219+ ...config ,
220+ ui : { prefs : { chatShowThinking : false } } ,
221+ } satisfies OpenClawConfig ;
222+ await publishOwner ( publishedConfig ) ;
223+ const lifecycle = await createLifecycle ( ( ) => currentConfig ) ;
224+ const loadCatalogSnapshot : GatewayRequestContext [ "loadGatewayModelCatalogSnapshot" ] = (
225+ loadParams ,
226+ ) => loadGatewayModelCatalogSnapshot ( { ...loadParams , getConfig : ( ) => currentConfig } ) ;
227+ registerGatewayModelCatalogPrivateAccess ( loadCatalogSnapshot , {
228+ loadDeferred : ( loadParams ) =>
229+ loadPreparedGatewayModelCatalogSnapshot ( {
230+ ...loadParams ,
231+ getConfig : ( ) => currentConfig ,
232+ } ) ,
233+ readPrepared : ( loadParams ) =>
234+ readPreparedGatewayModelCatalogOwnerSnapshot ( {
235+ ...loadParams ,
236+ getConfig : ( ) => currentConfig ,
237+ } ) ,
238+ } ) ;
239+ const currentContext = {
240+ ...context ,
241+ getRuntimeConfig : ( ) => currentConfig ,
242+ loadGatewayModelCatalogSnapshot : loadCatalogSnapshot ,
243+ } as GatewayRequestContext ;
244+
245+ await lifecycle . attachContext ( currentContext , sidecars ) ;
246+
247+ await expect ( lifecycle . read ( { agentId : "main" } ) ) . resolves . toMatchObject ( {
248+ models : [
249+ expect . objectContaining ( {
250+ available : true ,
251+ id : "gpt-5.4" ,
252+ provider : "openai" ,
253+ } ) ,
254+ ] ,
255+ } ) ;
256+ } ) ;
257+
207258 it ( "publishes a successful harness auth binding before the next metadata read" , async ( ) => {
208259 configureHarnessOwnedUnresolvedAuth ( ) ;
209260 await publishOwner ( ) ;
0 commit comments