@@ -529,20 +529,61 @@ describe("DSH source preservation", () => {
529529 ) ;
530530 } ) ;
531531
532- test ( "an edit inside the owned DSH leaf conflicts and survives " , ( ) => {
532+ test ( "an edit inside the owned DSH leaf refuses refresh and disable, preserving the edit " , ( ) => {
533533 const configPath = installDsh ( ) ;
534534 expect ( applyIntegration ( input ( { clientId : "dsh" } ) ) . ok ) . toBe ( true ) ;
535535 const edited = readFileSync ( configPath , "utf8" ) . replace (
536536 "api: openai-responses" ,
537537 "api: user-edited" ,
538538 ) ;
539539 writeFileSync ( configPath , edited ) ;
540+
541+ const refreshed = applyIntegration ( input ( {
542+ clientId : "dsh" ,
543+ models : [ ...MODELS , {
544+ namespaced : "openai/gpt-5.6" ,
545+ provider : "openai" ,
546+ id : "gpt-5.6" ,
547+ contextWindow : 272_000 ,
548+ } ] ,
549+ } ) ) ;
550+ expect ( refreshed . ok ) . toBe ( false ) ;
551+ if ( ! refreshed . ok ) expect ( refreshed . reason ) . toBe ( "conflict" ) ;
552+ expect ( readFileSync ( configPath , "utf8" ) ) . toBe ( edited ) ;
553+
540554 const disabled = disableIntegration ( input ( { clientId : "dsh" } ) ) ;
541555 expect ( disabled . ok ) . toBe ( false ) ;
542556 if ( ! disabled . ok ) expect ( disabled . reason ) . toBe ( "conflict" ) ;
543557 expect ( readFileSync ( configPath , "utf8" ) ) . toBe ( edited ) ;
544558 } ) ;
545559
560+ test ( "restores a disabled DSH integration to the exact applied bytes" , ( ) => {
561+ const configPath = installDsh ( ) ;
562+ const original = [
563+ "agent-default-model: deepseek-official/deepseek-chat" ,
564+ "llm-pi-ai:" ,
565+ " providers:" ,
566+ " deepseek-official:" ,
567+ " api: openai-completions # native stays" ,
568+ "" ,
569+ ] . join ( "\n" ) ;
570+ writeFileSync ( configPath , original ) ;
571+
572+ expect ( applyIntegration ( input ( { clientId : "dsh" } ) ) . ok ) . toBe ( true ) ;
573+ const applied = readFileSync ( configPath , "utf8" ) ;
574+ expect ( disableIntegration ( input ( { clientId : "dsh" } ) ) . ok ) . toBe ( true ) ;
575+ expect ( readFileSync ( configPath , "utf8" ) ) . toBe ( original ) ;
576+
577+ const disableOperation = store . listOperations ( "dsh" ) [ 0 ] ! ;
578+ expect ( disableOperation . kind ) . toBe ( "disable" ) ;
579+ const restored = restoreIntegration ( {
580+ ...input ( { clientId : "dsh" } ) ,
581+ opId : disableOperation . opId ,
582+ } ) ;
583+ expect ( restored . ok ) . toBe ( true ) ;
584+ expect ( readFileSync ( configPath , "utf8" ) ) . toBe ( applied ) ;
585+ } ) ;
586+
546587 test ( "a sibling added below a container we created survives disable" , ( ) => {
547588 const configPath = installDsh ( ) ;
548589 writeFileSync ( configPath , "agent-default-model: native\n" ) ;
0 commit comments