Skip to content

Workflow: auto-create nodes for model nodes, Output button, copyable errors, and document the API oauth_token param - #13685

Merged
abidlabs merged 7 commits into
mainfrom
worktree-workflow-ux-13665
Jul 30, 2026
Merged

Workflow: auto-create nodes for model nodes, Output button, copyable errors, and document the API oauth_token param#13685
abidlabs merged 7 commits into
mainfrom
worktree-workflow-ux-13665

Conversation

@abidlabs

@abidlabs abidlabs commented Jul 29, 2026

Copy link
Copy Markdown
Member

Picks off three of the remaining items in #13665. Each was verified by driving the real canvas in a browser.

Auto-create input/output nodes for model nodes

handlePickerCreate only built the ready-to-run subgraph when template.source === "space", so a freshly added model node arrived with nothing attached — the issue's "not having the output node can make it seem like the node runs but doesn't produce anything". Model templates already carry typed ports (from TASK_SCHEMAS, which the picker filters on), so the existing companion-spawning logic works unchanged for them.

Adding FLUX.1-schnell (text-to-image) now yields TextFLUX.1-schnellImage, wired and ready to run.

Note this is bounded by SUBGRAPH_PORT_TYPES, exactly as for Spaces: object-detection outputs json, which isn't a component type, so that model still gets only an input companion. Unchanged behaviour, just now shared.

An "Output" button, and "Data" → "Dataset"

The bar had Input but no Output, so output nodes were only reachable by dragging from a port. addInputNode/addOutputNode now share one helper that differs only in node role (reference vs subject), and that helper reuses the existing getComponentForPortType instead of rebuilding its own port-type → component map.

"Data" is renamed "Dataset" — the button already used DatasetIcon, title="Add dataset node" and DATASET_MODALITY, so the label was the odd one out.

I did not remove the Input button. The issue asks whether it's needed at all; that's a product call, and dropping it would be the destructive reading.

Copyable node errors

Node error banners now have a copy button next to show more. Canvas nodes suppress text selection for dragging, so selecting the message by hand isn't possible.

Document the API oauth_token param

Now that #13667 has landed. Subgraph endpoints already take a token — _build_endpoint_fn synthesizes token: Optional[OAuthToken] into the advertised signature, so /info reports oauth_token: "optional" for them (verified against a running workflow) — but the workflow's own View API panel said nothing about it, which was the last thing standing between "the fix landed" and "an API caller can actually use a Space-hosted workflow".

image

…e errors

Addresses three of the remaining items in #13665:

- Adding a model node from the picker now spawns its input and output
  components and wires them up, the same ready-to-run subgraph that Space
  nodes have always produced. Previously a fresh model node appeared with
  nothing attached, so it looked like it ran but produced nothing.
- The bottom bar gains an "Output" button alongside "Input" (output nodes
  were only reachable by dragging from a port), and "Data" is renamed
  "Dataset" to match its icon, tooltip and DATASET_MODALITY constant.
- Node error banners get a "copy" button, so a failure can be pasted
  somewhere useful — canvas nodes swallow text selection for dragging.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@gradio-pr-bot

gradio-pr-bot commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website building...
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://huggingface.co/buckets/gradio/pypi-previews/resolve/1e52482b527612ebdc16fa4cdac675fbc873dc8b/gradio-6.21.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@1e52482b527612ebdc16fa4cdac675fbc873dc8b#subdirectory=client/python"

Import Gradio JS Client from this PR via CDN

import { Client } from "https://huggingface.co/buckets/gradio/npm-previews/resolve/1e52482b527612ebdc16fa4cdac675fbc873dc8b/browser.js";

@gradio-pr-bot

gradio-pr-bot commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/workflowcanvas minor
gradio minor

  • gr.Workflow: auto-create input/output nodes for model nodes (as already happens for Space nodes), replace the "Input"/"Output" buttons with a single "Component" button whose direction is derived from wiring, rename "Data" to "Dataset", let node error messages be copied, and document the oauth_token parameter in the View API panel

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

abidlabs and others added 2 commits July 29, 2026 09:05
#13667 landed, so a caller can now hand a workflow a token via the request
body. Subgraph endpoints already declare one — `_build_endpoint_fn` synthesizes
`token: Optional[OAuthToken]` into the signature, so `/info` reports
`oauth_token: "optional"` for them — but the workflow's own View API panel said
nothing about it, which was the last item blocking API access to Space-hosted
workflows from being usable.

`describe_workflow_api` now reports the requirement, asked of the same builder
that registers the endpoints so the panel can't drift from `/info`, and the
panel adds a note plus `oauth_token` in all three snippets.

Also fixes the panel's file-parameter examples, which no client accepted: the
curl body needs the FileData payload (`{"path": ..., "meta": {...}}`) and the
JS snippet needs `handle_file`, where both previously emitted a bare URL
string. Verified by running the generated request: upload → call → the
workflow's function receives OAuthToken(token='hf_DOCS_CHECK').

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@abidlabs abidlabs changed the title Workflow: auto-create nodes for model nodes, add an Output button, copyable node errors Workflow: auto-create nodes for model nodes, Output button, copyable errors, and document the API oauth_token param Jul 29, 2026
Replaces the bottom bar's Input/Output pair with a single "Component"
button. A component's direction was never really the user's to declare:
`WorkflowNodeSF` already picks between an editable widget and a read-only
output tile purely from whether the node's input port is connected, and
the port-drag path already infers the role from drag direction. The bar
was the one place that made the user pre-commit.

`reconcileComponentRoles` makes the role a function of the edge set —
driven components are subjects, undriven ones are references — and runs
on every edge mutation plus on load. Without it the collections could
disagree with the rendering, and that mattered: `workflow_api.py` builds
endpoint parameters from `references` (skipping any with an incoming
edge) and endpoints themselves from `subjects`, so a node that rendered
as an output while still filed under `references` contributed no
endpoint at all. That was reachable before this change — wire a model
into an Input node and its subgraph silently vanished from the API —
and the new Output button would only have widened the target.

Flipped nodes append rather than merge in place, since `subject_groups`
fixes the API's output-tuple order from `subjects` order.

API panel, from review feedback:
- the `oauth_token` note moves out of the per-endpoint cards to a single
  note beneath all of them, so it doesn't read as one of the endpoint's
  own parameters, and is cut down to one sentence with a link
- Copy moves onto the code block it copies
- long snippets scroll instead of being clipped: `overflow: hidden` on
  the endpoint card resolved its flex minimum size to 0, so cards shrank
  to fit the panel and cut their code mid-line

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@abidlabs
abidlabs requested review from Copilot and hannahblair July 29, 2026 20:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@abidlabs
abidlabs marked this pull request as ready for review July 29, 2026 20:52
@abidlabs abidlabs added the v: patch A change that requires a patch release label Jul 29, 2026
@hannahblair

Copy link
Copy Markdown
Collaborator

did some testing and think this is good to go. much better model UX, and the copyable error is also a handy addition. much better API docs too now! thanks @abidlabs!

.api-code {
margin: 0;
padding: var(--size-3) 14px;
/* Right padding clears the absolutely positioned Copy button. */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude comments around css are probably overkill

@abidlabs

Copy link
Copy Markdown
Member Author

Thanks for the review @hannahblair! Will address and get this in

@abidlabs
abidlabs merged commit 6302098 into main Jul 30, 2026
22 of 26 checks passed
@abidlabs
abidlabs deleted the worktree-workflow-ux-13665 branch July 30, 2026 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v: patch A change that requires a patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants