@@ -20,14 +20,15 @@ import {
2020import { extractAgents } from "../api/api-helper" ;
2121import { CoderApi } from "../api/coderApi" ;
2222import { needToken } from "../api/utils" ;
23- import { getGlobalFlags , getSshFlags } from "../cliConfig" ;
23+ import { getGlobalFlags , getGlobalFlagsRaw , getSshFlags } from "../cliConfig" ;
2424import { type Commands } from "../commands" ;
2525import { type CliManager } from "../core/cliManager" ;
2626import * as cliUtils from "../core/cliUtils" ;
2727import { type ServiceContainer } from "../core/container" ;
2828import { type ContextManager } from "../core/contextManager" ;
2929import { type PathResolver } from "../core/pathResolver" ;
3030import { featureSetForVersion , type FeatureSet } from "../featureSet" ;
31+ import { getHeaderCommand } from "../headers" ;
3132import { Inbox } from "../inbox" ;
3233import { type Logger } from "../logging/logger" ;
3334import {
@@ -515,14 +516,34 @@ export class Remote {
515516 ...( await this . createAgentMetadataStatusBar ( agent , workspaceClient ) ) ,
516517 ) ;
517518
518- const settingsToWatch = [
519- { setting : "coder.globalFlags" , title : "Global flags" } ,
520- { setting : "coder.sshFlags" , title : "SSH flags" } ,
519+ const settingsToWatch : Array < {
520+ setting : string ;
521+ title : string ;
522+ getValue : ( ) => unknown ;
523+ } > = [
524+ {
525+ setting : "coder.globalFlags" ,
526+ title : "Global Flags" ,
527+ getValue : ( ) =>
528+ getGlobalFlagsRaw ( vscode . workspace . getConfiguration ( ) ) ,
529+ } ,
530+ {
531+ setting : "coder.headerCommand" ,
532+ title : "Header Command" ,
533+ getValue : ( ) =>
534+ getHeaderCommand ( vscode . workspace . getConfiguration ( ) ) ?? "" ,
535+ } ,
536+ {
537+ setting : "coder.sshFlags" ,
538+ title : "SSH Flags" ,
539+ getValue : ( ) => getSshFlags ( vscode . workspace . getConfiguration ( ) ) ,
540+ } ,
521541 ] ;
522542 if ( featureSet . proxyLogDirectory ) {
523543 settingsToWatch . push ( {
524544 setting : "coder.proxyLogDirectory" ,
525- title : "Proxy log directory" ,
545+ title : "Proxy Log Directory" ,
546+ getValue : ( ) => this . getLogDir ( featureSet ) ,
526547 } ) ;
527548 }
528549 disposables . push ( this . watchSettings ( settingsToWatch ) ) ;
@@ -801,25 +822,48 @@ export class Remote {
801822 }
802823
803824 private watchSettings (
804- settings : Array < { setting : string ; title : string } > ,
825+ settings : Array < {
826+ setting : string ;
827+ title : string ;
828+ getValue : ( ) => unknown ;
829+ } > ,
805830 ) : vscode . Disposable {
831+ // Capture applied values at setup time
832+ const appliedValues = new Map (
833+ settings . map ( ( s ) => [ s . setting , s . getValue ( ) ] ) ,
834+ ) ;
835+
806836 return vscode . workspace . onDidChangeConfiguration ( ( e ) => {
807- for ( const { setting, title } of settings ) {
837+ const changedTitles : string [ ] = [ ] ;
838+
839+ for ( const { setting, title, getValue } of settings ) {
808840 if ( ! e . affectsConfiguration ( setting ) ) {
809841 continue ;
810842 }
811- vscode . window
812- . showInformationMessage (
813- `${ title } setting changed. Reload window to apply.` ,
814- "Reload" ,
815- )
816- . then ( ( action ) => {
817- if ( action === "Reload" ) {
818- vscode . commands . executeCommand ( "workbench.action.reloadWindow" ) ;
819- }
820- } ) ;
821- break ;
843+
844+ const newValue = getValue ( ) ;
845+ if (
846+ JSON . stringify ( newValue ) !==
847+ JSON . stringify ( appliedValues . get ( setting ) )
848+ ) {
849+ changedTitles . push ( title ) ;
850+ }
851+ }
852+
853+ if ( changedTitles . length === 0 ) {
854+ return ;
822855 }
856+
857+ const message =
858+ changedTitles . length === 1
859+ ? `${ changedTitles [ 0 ] } setting changed. Reload window to apply.`
860+ : `${ changedTitles . join ( ", " ) } settings changed. Reload window to apply.` ;
861+
862+ vscode . window . showInformationMessage ( message , "Reload" ) . then ( ( action ) => {
863+ if ( action === "Reload" ) {
864+ vscode . commands . executeCommand ( "workbench.action.reloadWindow" ) ;
865+ }
866+ } ) ;
823867 } ) ;
824868 }
825869
0 commit comments