@@ -22,11 +22,12 @@ import { Messages } from '@shared/Messages';
2222import path from 'node:path' ;
2323
2424const CONFIGURATION_SECTIONS : string [ ] = [
25- 'ai-lab.models.path' ,
26- 'ai-lab.experimentalGPU' ,
27- 'ai-lab.apiPort' ,
28- 'ai-lab.experimentalTuning' ,
29- 'ai-lab.modelUploadDisabled' ,
25+ 'models.path' ,
26+ 'experimentalGPU' ,
27+ 'apiPort' ,
28+ 'experimentalTuning' ,
29+ 'modelUploadDisabled' ,
30+ 'showGPUPromotion' ,
3031] ;
3132
3233const API_PORT_DEFAULT = 10434 ;
@@ -51,9 +52,25 @@ export class ConfigurationRegistry extends Publisher<ExtensionConfiguration> imp
5152 apiPort : this . #configuration. get < number > ( 'apiPort' ) ?? API_PORT_DEFAULT ,
5253 experimentalTuning : this . #configuration. get < boolean > ( 'experimentalTuning' ) ?? false ,
5354 modelUploadDisabled : this . #configuration. get < boolean > ( 'modelUploadDisabled' ) ?? false ,
55+ showGPUPromotion : this . #configuration. get < boolean > ( 'showGPUPromotion' ) ?? true ,
5456 } ;
5557 }
5658
59+ private getFieldName ( section : string ) : keyof Partial < ExtensionConfiguration > {
60+ return section . replace ( / \. ( \w ) / , ( match , char ) => char . toUpperCase ( ) ) as keyof Partial < ExtensionConfiguration > ;
61+ }
62+
63+ async updateExtensionConfiguration ( update : Partial < ExtensionConfiguration > ) : Promise < void > {
64+ for ( const section of CONFIGURATION_SECTIONS ) {
65+ const fieldName = this . getFieldName ( section ) ;
66+ const value = update [ fieldName ] ;
67+ if ( value !== undefined ) {
68+ await this . #configuration. update ( section , value ) ;
69+ }
70+ }
71+ this . notify ( ) ; //https://github.com/containers/podman-desktop/issues/9194
72+ }
73+
5774 private getModelsPath ( ) : string {
5875 const value = this . #configuration. get < string > ( 'models.path' ) ;
5976 if ( value && value . length > 0 ) {
@@ -68,7 +85,7 @@ export class ConfigurationRegistry extends Publisher<ExtensionConfiguration> imp
6885
6986 init ( ) : void {
7087 this . #configurationDisposable = configuration . onDidChangeConfiguration ( event => {
71- if ( CONFIGURATION_SECTIONS . some ( section => event . affectsConfiguration ( section ) ) ) {
88+ if ( CONFIGURATION_SECTIONS . some ( section => event . affectsConfiguration ( `ai-lab. ${ section } ` ) ) ) {
7289 this . notify ( ) ;
7390 }
7491 } ) ;
0 commit comments