PotionUI Docs v0.3.0

Contributing a model card action

Admin -> Models cards can carry a plugin-contributed icon button, alongside the built-in assign/remove actions. Declare it under contributions: in manifest.yml:

yaml
contributions:
  - slot: "admin.models.card.actions"
    component: "MyModelAction.svelte"
    order: 100

It's mounted via <PluginSlot hookName="admin.models.card.actions" context={{ model }}> in ModelCard.svelte's management-actions row, so your component receives the card's model object (as returned by GET /api/models) through its context prop - full payload in GET /api/plugins/hooks/catalog. The slot only renders in the admin management-actions context (showManagementActions), never on the Library/Generate model pickers.

Give the contribution a label: the host wraps your component in the app's tooltip with that text, so your button must not set a native title.

context.refresh() reloads the list in place after your action changed the model, so the card re-renders with the new previews, tags or description; it's awaitable, so await context.refresh() resolves once the reload has landed. For provider metadata, POST /api/models/info/fetch with wait: true and explicit model_ids runs the fetch before responding and returns {successful, failed}; without wait it runs in the background.

context.track(promiseOrFn) drives the card's "working" state - a moving border around the card - while your action is in flight. Pass it a function or a promise; it increments the card's busy counter, awaits the result, decrements the counter in a finally, and returns whatever you passed in resolved. Wrap the network call and the awaited context.refresh() together so the border keeps animating until the refreshed data has actually landed:

js
await context.track(async () => {
  await fetch(/* ... */);
  await context.refresh();
});