PotionUI Docs v0.3.0

Contributing a tool tab

A tool tab is a whole Generate tab owned by one tool, next to the core Image editor and Video editor tabs. It has no form pane, Workbench or deck: the tab area is your component. Declare it in manifest.yml:

yaml
tool_tabs:
  - id: stamp
    label: Stamp tool
    icon: brush
    accepts: [image]
    handles: []
    component: StampToolTab.svelte
KeyMeaning
idLowercase slug, unique within the plugin. The tab's tool kind is <plugin id>.<id>.
labelShown in the "+" menu after the Image and Video editors, in the phone Tabs sheet and as the default tab name.
iconAn app icon name (brush, sliders, film, ...). Defaults to extension.
acceptsMedia kinds (image, video, audio) the tool can open.
handlesEdit actions the tool claims, for the History and Library shortcuts.
componentThe compiled component under frontend/dist/ (a frontend/dist/ prefix is accepted).

The entries are served with the other manifest-declared extensions (GET /api/plugins/frontend-extensions, key tool_tabs) for enabled plugins only, and the frontend registers them through the same refresh that loads renderers and field types. A tab whose plugin is later disabled stays open and says the tool is not available.

The component receives one prop, host:

MemberWhat it is
tabId, toolThe tab's id and its tool kind.
sourceThe media the tab was opened on ({ path, relative_path?, url?, name?, type? }), or null.
stateYour persisted JSON state, or null for a fresh tab. Keep it small: params and ids, never pixels.
activeToolThe sub-tool the tab should open on, when it was opened from a shortcut.
hintA one-shot hint from the shortcut that opened the tab, or null. Call clearHint() once you have used it.
runThe background run the tab is tracking ({ runId, progress }), so a reload can reattach.
phonetrue when the tab renders in the phone layout.
setState(next)Persist new state. It is saved with the tab and in Workspaces.
setDirty(edits)The number of unsaved edits. It drives the tab's warning dot and the close prompt.
setTitle(title), setThumbnail(url)Name the tab (unless the user renamed it) and set its 20px thumbnail.
setSource(ref), setActiveTool(id), setRun(run), clearHint()Update what the tab is open on and what it tracks.
setActions({ undo, redo, save })Fill the phone top bar's Undo and Save buttons ({ label?, disabled?, run }; save also takes progress).
openToolTab(tool, source, { activeTool, hint })Open another tool tab, following the same rules as the History and Library shortcuts.

The core editors use these activeTool ids, and the History and Library shortcuts open them with one of these set:

Tab (tool)activeTool ids
Image editor (image)crop, resize, canvas, paint, mask, effects, colorKey, subject
Video editor (video)trim, split, crop, resize, speed, mute, volume, replace, effects, frame

A hint is an object with any of look (an Effects look to preview), effect (a video effect id such as film_grain to preview), orientation (rotate or flip, for Crop) and sendTo ({ tabId, field }: the generation tab and media field the tab was opened from, so Send to a generation lists that field first). A hint is not persisted with the tab.

Opening a tab focuses one that already holds the same item, fills an empty tab of the same kind next, and otherwise adds a new tab. Bitmaps your tool produces are uploaded and referenced by id; the tab never stores them inline.