Gracefully handle plugin init failures (#424)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Gregory Schier
2026-03-11 16:55:46 -07:00
committed by GitHub
parent 8a330ad1ec
commit c8ba35e268
5 changed files with 59 additions and 11 deletions

View File

@@ -123,6 +123,39 @@ export function initGlobalListeners() {
console.log('Got plugin updates event', payload);
showPluginUpdatesToast(payload);
});
// Check for plugin initialization errors
invokeCmd<[string, string][]>('cmd_plugin_init_errors').then((errors) => {
for (const [dir, message] of errors) {
const dirBasename = dir.split('/').pop() ?? dir;
showToast({
id: `plugin-init-error-${dirBasename}`,
color: 'warning',
timeout: null,
message: (
<VStack>
<h2 className="font-semibold">Plugin failed to load</h2>
<p className="text-text-subtle text-sm">
{dirBasename}: {message}
</p>
</VStack>
),
action: ({ hide }) => (
<Button
size="xs"
color="warning"
variant="border"
onClick={() => {
hide();
openSettings.mutate('plugins:installed');
}}
>
View Plugins
</Button>
),
});
}
});
}
function showUpdateInstalledToast(version: string) {

View File

@@ -42,6 +42,7 @@ type TauriCmd =
| 'cmd_new_child_window'
| 'cmd_new_main_window'
| 'cmd_plugin_info'
| 'cmd_plugin_init_errors'
| 'cmd_reload_plugins'
| 'cmd_render_template'
| 'cmd_save_response'