There seems to be a bug(?) where the configuration object that the Python plugin receives is never set unless handleUpdateModel is called from the UI. This gives me the annoying issue where the default configuration set in the DesignerApi component never reaches the plugin until the user interacts with the UI.
const Tool: FunctionComponent = () => {
return (
<DesignerApi
messages={{}}
defaultConfig={{ Configuration: { foo: 'Hello, world!' } }}
>
<AyxAppWrapper>
<App />
</AyxAppWrapper>
</DesignerApi>
)
}
class MyPlugin(PluginV2):
def __init__(self, provider: AMPProviderV2):
self.name = "MyPlugin"
self.provider = provider
# This should be "Hello, world!" but the "foo" doesn't exist
self.foo = self.provider.tool_config.get("foo") or ""
I'm currently getting around this by forcing an update when the UI loads.
const App: FunctionComponent = () => {
const [model, handleUpdateModel] = useContext(UiSdkContext)
useEffect(() => handleUpdateModel({ ...model }), [])
return (
/* ... */
)
}