@@ -2,8 +2,10 @@ import { PluginContextProvider, type Plugin } from "@opencode-ai/plugin/tui"
22import {
33 batch ,
44 createContext ,
5+ createEffect ,
56 createMemo ,
67 For ,
8+ on ,
79 onCleanup ,
810 onMount ,
911 useContext ,
@@ -372,13 +374,13 @@ export function PluginProvider(props: ParentProps<{ packages: PackageResolver }>
372374 return true
373375 }
374376
375- const reconcile = async ( ) => {
377+ const reconcile = async ( configured = config . data . plugins ?? [ ] ) => {
376378 await Promise . all (
377379 Object . entries ( store . registrations )
378380 . filter ( ( [ , registration ] ) => registration . active )
379381 . map ( ( [ id ] ) => deactivate ( id ) ) ,
380382 )
381- const entries = [ ...( await discoverTuiPlugins ( paths . cwd ) ) , ...( config . data . plugins ?? [ ] ) ]
383+ const entries = [ ...( await discoverTuiPlugins ( paths . cwd ) ) , ...configured ]
382384 batch ( ( ) => {
383385 setStore ( "registrations" , reconcileStore ( { } ) )
384386 setStore ( "states" , [ ] )
@@ -452,8 +454,21 @@ export function PluginProvider(props: ParentProps<{ packages: PackageResolver }>
452454 ] )
453455 }
454456 }
457+ let loading = Promise . resolve ( )
458+ createEffect (
459+ on (
460+ ( ) => JSON . stringify ( config . data . plugins ?? [ ] ) ,
461+ ( ) => {
462+ const configured = config . data . plugins ?? [ ]
463+ loading = loading . catch ( ( ) => undefined ) . then ( ( ) => reconcile ( configured ) )
464+ void loading . then (
465+ ( ) => setStore ( "ready" , true ) ,
466+ ( ) => setStore ( "ready" , true ) ,
467+ )
468+ } ,
469+ ) ,
470+ )
455471 onMount ( ( ) => {
456- const loading = reconcile ( )
457472 let disposing : Promise < void > | undefined
458473 const dispose = ( ) => {
459474 if ( disposing ) return disposing
@@ -474,7 +489,6 @@ export function PluginProvider(props: ParentProps<{ packages: PackageResolver }>
474489 unregister ( )
475490 void dispose ( )
476491 } )
477- void loading . finally ( ( ) => setStore ( "ready" , true ) )
478492 } )
479493
480494 return (
0 commit comments