PotionUI Docs v0.3.0

Contributing an editor task

A plugin adds a job the Image editor can offer, such as "Colorize a region", with editor_tasks in manifest.yml. Disabling the plugin removes its tasks.

yaml
editor_tasks:
  - id: my-plugin.colorize
    label: Colorize a region
    icon: palette
    editors: [image]
    region: required
    prompt: optional
    produces: patch
    fallback:
      task: edit_region
      prompt: Colorize the marked area naturally.

The id must start with your plugin id and a dot; ids without a dot belong to core. region and prompt are required, optional or none. A fallback names a task to run, with a built-in prompt, when no mode offers this one; the prompt may contain {prompt}, which a run replaces with the user's text. grows: true marks a task whose result is larger than the picture (the way core's expand is); its runs carry an expand canvas instead of a region (see Editor runs).

Optional keys that shape the run (all default to the old behaviour):

KeyMeaning
producespatch (default), replace, or matte: the run returns the model's RGBA picture at the picture's size instead of a patch.
grow0 to 0.5, default 0. The marked region is grown by this fraction of its longer side (at least 6 px) before the run.
feather0 to 8, default 1. A multiplier on the stitch feather.
mattetrue: the region is a soft matte, kept grayscale and used as the patch alpha.
internaltrue: no rail tool; the task is run by other tools.

An editor mode may also set instruction:, the prompt sent for a task whose prompt is none (Editor modes).

A task is offered by presets, not by the manifest: an editor mode names it in its editor_mode.yml (Editor modes). An editor mode that belongs to your plugin (a preset from your presets: root, or an editor_modes/ directory under a preset_modes: root, which can target a preset your plugin does not own) may name your task and the core tasks. An editor mode of another plugin that names your task is rejected by lint.

src.plugin_api.editor exports TaskDefinition, the shape the host keeps for every registered task.

What the host does with a task:

  • The server keeps one task registry. Core registers edit_region, remove_object, replace_background and find_subject; a plugin's entries are added when it is enabled and dropped when it is disabled. An id that another source already holds is refused, so a plugin cannot replace a core task. editors defaults to [image].
  • GET /api/editor/tasks?editor=image lists the registered tasks for that editor, each with offers (the modes the caller may use that declare it, or that reach it through the task's fallback; empty when none does) and the caller's default setup.
  • POST /api/editor/tasks/{task}/runs starts a run: one Generate press in the editor. The server prepares the picture and region from the editor mode, submits a normal generation, and blends each result back as a patch. GET /api/editor/runs/{id} follows it, DELETE /api/editor/runs/{id} cancels it, and editor_run_update on /ws/generation announces each change to the run's owner.
  • PUT and DELETE /api/editor/tasks/{task}/default set and clear the caller's default setup for a task.
  • Every route, field and error is in Generative edits in the editor.
  • produces accepts patch and replace. A run creates patches whichever is declared, so write patch.

The Image editor adds each task the server lists to its Generate group as a rail tool, with the editor's own options and a Settings panel. Name a rail tool of your own with task: <task id> in editor_tools to replace that tool; the editor then adds no rail tool for the task.