@@ -915,6 +915,30 @@ describe("ServerSettings worktree defaults", () => {
915915} ) ;
916916
917917describe ( "ServerSettings.sourceControlWritingStyle" , ( ) => {
918+ it . each ( [
919+ { legacy : "" , mode : "repo_conventions" , customInstructions : "" } ,
920+ { legacy : " \t\n " , mode : "repo_conventions" , customInstructions : "" } ,
921+ {
922+ legacy : " Prefer concise wording.\nKeep issue references. " ,
923+ mode : "custom" ,
924+ customInstructions : "Prefer concise wording.\nKeep issue references." ,
925+ } ,
926+ ] ) ( "normalizes legacy writing style $legacy in snapshots only" , ( { legacy, ...expected } ) => {
927+ const style = { ...expected , followChangeRequestTemplates : true } ;
928+ for ( const [ input , normalized ] of [
929+ [ { sourceControlWritingStyle : legacy } , { sourceControlWritingStyle : style } ] ,
930+ [
931+ { projectSettingsOverrides : { project : { sourceControlWritingStyle : legacy } } } ,
932+ { projectSettingsOverrides : { project : { sourceControlWritingStyle : style } } } ,
933+ ] ,
934+ ] as const ) {
935+ const settings = decodeServerSettings ( input ) ;
936+ expect ( settings ) . toMatchObject ( normalized ) ;
937+ expect ( encodeServerSettings ( settings ) ) . toMatchObject ( normalized ) ;
938+ expect ( ( ) => decodeServerSettingsPatch ( input ) ) . toThrow ( ) ;
939+ }
940+ } ) ;
941+
918942 it ( "defaults all style settings for legacy configs" , ( ) => {
919943 const settings = decodeServerSettings ( { } ) ;
920944
@@ -926,17 +950,33 @@ describe("ServerSettings.sourceControlWritingStyle", () => {
926950 expect ( settings . sourceControlWriterModelSelection ) . toBeNull ( ) ;
927951 } ) ;
928952
929- it ( "trims partial style updates" , ( ) => {
930- const patch = decodeServerSettingsPatch ( {
931- sourceControlWritingStyle : {
932- mode : "custom" ,
933- customInstructions : " Prefer concise wording. " ,
934- } ,
935- } ) ;
936-
937- expect ( patch . sourceControlWritingStyle ) . toEqual ( {
953+ it ( "preserves structured encoding and trims partial style updates" , ( ) => {
954+ const style = {
938955 mode : "custom" ,
939956 customInstructions : "Prefer concise wording." ,
957+ followChangeRequestTemplates : false ,
958+ } ;
959+ const input = {
960+ sourceControlWritingStyle : style ,
961+ projectSettingsOverrides : { project : { sourceControlWritingStyle : style } } ,
962+ } ;
963+ expect ( encodeServerSettings ( decodeServerSettings ( input ) ) ) . toMatchObject ( input ) ;
964+ expect ( decodeServerSettingsPatch ( input ) ) . toEqual ( input ) ;
965+
966+ const partial = { mode : "custom" , customInstructions : " Prefer concise wording. " } ;
967+ const normalized = { mode : "custom" , customInstructions : "Prefer concise wording." } ;
968+ expect (
969+ decodeServerSettingsPatch ( {
970+ sourceControlWritingStyle : partial ,
971+ projectSettingsOverrides : { project : { sourceControlWritingStyle : partial } } ,
972+ } ) ,
973+ ) . toEqual ( {
974+ sourceControlWritingStyle : normalized ,
975+ projectSettingsOverrides : {
976+ project : {
977+ sourceControlWritingStyle : { ...normalized , followChangeRequestTemplates : true } ,
978+ } ,
979+ } ,
940980 } ) ;
941981 } ) ;
942982} ) ;
0 commit comments