modly icon indicating copy to clipboard operation
modly copied to clipboard

feat(extensions): support named model input ports

Open DrHepa opened this issue 4 months ago • 0 comments

What problem does this solve?

Model extensions can currently declare a single input or positional string inputs, but they cannot describe stable named ports with labels and required/optional semantics.

This becomes both a capability gap and a renderer-safety problem. A multi-view extension such as Pi3X needs front, left, back, and right image ports. Declaring descriptor objects in the existing string-only inputs field causes Modly 0.4.0/0.4.1 to render an object as a React child in the Extensions page, producing React error 31 and a black renderer.

Current affected pattern:

{
  "inputs": [
    { "name": "front", "type": "image", "label": "Front RGB Image", "required": true }
  ]
}

Proposed solution

Add an explicitly additive manifest contract rather than overloading legacy inputs:

{
  "input": "image",
  "io_contract": "named-v1",
  "input_ports": [
    { "name": "front", "type": "image", "label": "Front RGB Image", "required": true },
    { "name": "left", "type": "image", "label": "Left RGB Image", "required": false },
    { "name": "back", "type": "image", "label": "Back RGB Image", "required": false },
    { "name": "right", "type": "image", "label": "Right RGB Image", "required": false }
  ]
}

Compatibility and runtime rules:

  • Preserve legacy input, string inputs, inputLabels, and saved input-N handles unchanged.
  • Older Modly versions ignore input_ports and continue through the legacy primary input.
  • Updated hosts normalize descriptors once and render labels/types safely.
  • Port name is the stable workflow handle and must be unique.
  • Declaration order is deterministic; the first required port is the legacy primary input.
  • Validate missing required ports, duplicate/unknown names, unsupported types, and cardinality before dispatch.
  • For model.generate named image inputs, preserve images and paired image_names through multipart, job state, the extension subprocess protocol, and an optional generate_v2 request.
  • Legacy generators and single-image jobs continue to use generate().

Acceptance criteria:

  • Installing a manifest with descriptors cannot crash ExtensionCard or ExtensionDrawer.
  • Pi3X-style one-to-four image workflows expose stable named ports.
  • Optional ports may remain disconnected; required ports block execution with an actionable error.
  • Named inputs reach the extension in manifest declaration order with names preserved.
  • Existing single-input and positional multi-input extensions remain behaviorally unchanged.
  • Renderer, workflow routing, API/subprocess transport, compatibility, and path-validation tests pass.

Alternatives considered

  • Overload inputs with strings or objects: rejected because stable releases and several current consumers assume every entry is a string.
  • Renderer-only object formatting: prevents the black screen but advertises ports that the execution stack cannot transport.
  • Extension-specific side-image path parameters: works as a temporary private adapter but is not a general or secure extension contract.
  • Make Pi3X permanently single-image: compatible but removes the model's intended multi-view capability.

Confirmation

  • [x] I have searched existing issues for this feature.

DrHepa avatar Jul 17 '26 04:07 DrHepa