Skip to content

fix(images): display resolved inputs and preserve source graphs - #10035

Open
wunianze666-netizen wants to merge 9 commits into
invoke-ai:mainfrom
wunianze666-netizen:fix/runtime-image-graph-current-6708
Open

wunianze666-netizen wants to merge 9 commits into
invoke-ai:mainfrom
wunianze666-netizen:fix/runtime-image-graph-current-6708

Conversation

@wunianze666-netizen

@wunianze666-netizen wunianze666-netizen commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Generated images now expose their resolved per-image inputs in the app's Graph tab: a run using Noise seed18 or a connected math input17 shows those values rather than source defaults0. The workflow response returns a separate optional resolved_inputs record; graph and authored workflow remain the restoration inputs, preserving loop and control structure when loading an image as an editable workflow.

PNG persistence retains the complete source Graph plus a compact, indexed record of the active invocation and ordinary ancestors. The compact record stops at control/collection boundaries, avoiding full expanded-runtime graph copies per image. Older images or older responses without diagnostics fall back to their source graph; video preview behavior is unchanged.

Related Issues / Discussions

Closes #6708.

QA Instructions

  • Backend native red on the maintainer's 1c6d5e5 head:8 focused failures before production changes. Persisted PNG/service/HTTP regressions now verify resolved seed18/math17, exact source/workflow retention, old files, record subfolders, read access, maintenance and missing-file behavior.
  • Backend related selection:396 passed,11 Windows directory-fsync skips,8 deprecation warnings across15 suites,892.42s,exit0. The earlier focused8+44 passes overlap this selection; a response-capture replay is separate and not counted as a new test.
  • Chromium native red:1 Graph-display value mismatch,85 controls passed with production unchanged. Candidate:86 browser tests pass, including missing/null diagnostic fallback and real source-graph workflow conversion/authored-workflow precedence.
  • Frontend related units:76 passed; architecture:92 passed; full frontend format/lint/types and architecture inventories pass. Production Vite build succeeds with chunk-size/import/timing warnings.
  • Generated OpenAPI/schema updates contain only the optional response property. API-package lint and2 generator tests pass. An independent TypeScript consumer through the actual legacy re-export compiles old, new and null-diagnostic payloads; this is not a full legacy-app typecheck.
  • Ruff0.11.2 check, format --check and git diff --check pass.

Retained nested-PNG measurements count both persisted graph fields:2x3 images total9,072 UTF-8 JSON bytes;4x6 images total37,680. The earlier expanded-runtime samples total38,145/525,036 bytes. These measurements are from the preceding persistence revision; this change exposes those records rather than introducing a new performance benchmark. Literal source collections and retained list inputs may still be large.

The actual Chromium component interactions passed. A screenshot was inspected, but a separate interactive desktop/full-app validation was not completed. No physical GPU/full-model generation, full-repository typecheck or docs build is claimed.

Review

The Graph tab now consumes the persisted resolved record through the same guarded image workflow API. Loading a workflow continues to consume the complete source graph or authored workflow, rather than the diagnostic projection. The record retains runtime IDs and ordinary upstream seeds/math inputs; it is not a full execution trace or a universal size bound.

AI assistance was used for implementation, tests and analysis.

Compatibility / Rollout

The workflow response adds optional nullable resolved_inputs; existing graph and workflow contents are unchanged. Old PNGs return null and old responses may omit the property. The shared video response uses the null default. No database migration, dependency or lockfile changes are needed. User generation metadata is not repurposed. File copies preserve the diagnostic PNG chunk; upload re-encoding still follows its existing three-channel extraction contract. Missing source data in previously compact-only files cannot be recovered by this change.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Meaningful regression coverage added / updated where needed; obsolete tests/code removed
  • Persisted-state and API changes include required migrations / compatibility validation
  • Relevant performance/efficiency opportunities considered; material claims have evidence
  • Material review findings resolved and relevant checks rerun
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Save prepared execution nodes so image graph inputs and node IDs match the run. Keep source-graph fallback and workflow metadata unchanged.
@github-actions github-actions Bot added python PRs that change python files services PRs that change app services python-tests PRs that change python tests labels Oct 26, 2026
Cover persisted graph inputs and node identity through a fresh PNG reader, alongside non-null workflow retention.

@JPPhoto JPPhoto left a comment

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.

Please fix:

  1. invokeai/app/services/shared/invocation_context.py:327-328. This also applies to nested Iterate workflows. With N outer items, M inner items, and one saved image per innermost item, the runtime graph can contain O(N*M) node copies; embedding that graph in all N*M images can produce O((N*M)^2) total graph metadata. Likelihood: plausible for large nested batches. Test: no looped image-save size test. Fix: measure nested loops and store a compact per-image record of resolved inputs.

Record active inputs and ordinary ancestors without sibling batch expansion. Cover nested Iterate metadata growth and legacy PNG readers.
@wunianze666-netizen wunianze666-netizen changed the title fix(images): preserve materialized inputs in saved graph fix(images): save compact resolved graph inputs Oct 28, 2026
@wunianze666-netizen

wunianze666-netizen commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Addressed in 70edbae, with the CI fixture follow-up ec18c74.

The saved Graph JSON now records the active invocation and ordinary upstream resolved inputs, using indexed input edges. Traversal stops at control/collection boundaries, so it does not copy sibling iterations or future nodes. A separate regression retains upstream Noise.seed=18 and Add.a=17 even when the image-producing leaf has no seed input. The authoring workflow remains separate and unchanged; this record is not a full replay graph.

Measured through real nested Iterate execution, image-save calls, PNG files and a fresh reader:

  • 2x3: 6 images, total graph JSON 38,145 -> 1,878 bytes (17 -> 1 nodes/image).
  • 4x6: 24 images, total graph JSON 525,036 -> 7,512 bytes (57 -> 1 nodes/image).

Each revised image in those fixed-width fixtures contains 313 graph bytes; this is JSON payload measurement, not a generation-speed or universal size-bound claim. The original nested case fails the new compact-record contract before the fix. Final focused selection:13 passed. Related service/storage/metadata/Graph plus native import checks:199 passed,11 existing Windows directory-fsync skips,6 deprecation warnings. Ruff0.11.2/checkformat/diff and normal commit hooks passed. No GPU/full-model or browser-replay validation is claimed.

CI follow-up: macOS found one child-workflow metadata test still supplying an untyped MagicMock invocation. I reproduced the same failure locally and replaced only that fixture with a real BlankImageInvocation; all parent/project, workflow-byte and single-lookup assertions are unchanged. Targeted red1fail -> green1pass; the complete queue metadata module35pass,4deprecationwarnings. Production/docs/image-test files remain byte-identical to70edbae991. The previous70 CI failure is retained as history; the new head has a fresh CI run.

Keep the child-workflow PNG inheritance fixture on the BaseInvocation contract without changing its assertions.
@JPPhoto
JPPhoto self-requested a review October 28, 2026 11:24

@JPPhoto JPPhoto left a comment

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.

Please fix:

  1. invokeai/app/services/shared/invocation_context.py:327-329. For graph-only images using Iterate, If, or Collect, the compact record omits those boundary nodes. executeLoadMediaWorkflow() still converts the graph into an editable workflow, so loading such an image opens a partial graph without its original loop or control structure. Likelihood: supported when workflow is null. Recovery: only if the original graph is available elsewhere. Fix: preserve the source graph for this fallback and store resolved inputs separately. Test: no graph-only restore test; PR CI passes on the pinned head.

Keep graph-only workflow restoration complete and persist a separate compact PNG input record. Cover control boundaries through real image services and retain user metadata and workflow JSON.
@github-actions github-actions Bot added the docs PRs that change docs label Oct 28, 2026
@wunianze666-netizen wunianze666-netizen changed the title fix(images): save compact resolved graph inputs fix(images): preserve source graphs and resolved inputs Oct 28, 2026
@wunianze666-netizen

Copy link
Copy Markdown
Contributor Author

Addressed review5681837512 in 6a2a8ef.

invokeai_graph now preserves the complete source graph for the existing graph-only editor fallback, including Iterate/If/Collect structure. The compact resolved graph is stored separately as invokeai_resolved_inputs, carried through ImageService to the PNG writer. Arbitrary generation metadata and authored workflow JSON remain unchanged; internal optional parameters are appended to preserve positional callers.

Four new graph-only cases (Iterate, both If branches, Collect) fail source-graph equality on the unchanged ec18c74 production code, then pass through real temporary SQLite/ImageService, PNG files and a fresh reader after the fix. A legacy-call control also passes. The broader selection passes242 tests, with11 existing Windows directory-fsync skips and6 deprecation warnings. Ruff0.11.2/checkformat/diff and normal commit hooks passed.

Counting both persisted graph fields, the nested2x3/4x6 fixtures total9,072/37,680 bytes; the earlier expanded-runtime snapshots totaled38,145/525,036. Source literal collections grow, so this is a fixture JSON-byte comparison, not a universal linear-size or speed/memory claim. The diagnostic chunk is readable through PNG Image.info; existing workflow/graph API and upload re-encoding contracts are unchanged. Browser/editor interaction and GPU/full-model validation were not run. Fresh CI is running on the new head.

@JPPhoto
JPPhoto self-requested a review October 28, 2026 17:52

@JPPhoto JPPhoto left a comment

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.

Other findings/issues:

  • invokeai/app/services/shared/invocation_context.py:328-343: Graph-only images keep source defaults in invokeai_graph; resolved values go only into invokeai_resolved_inputs. The workflow API returns invokeai_graph (invokeai/app/api/routers/images.py:395-398), which the Graph tab displays (invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx:117-122). Normal Generate images therefore still show default Noise seeds and math values, so issue #6708 remains open in practice. Effect: users cannot inspect actual run inputs in the app. Likelihood: normal graph-only Generate. Recovery: manually read the PNG chunk; no in-app path. Test: current coverage checks resolved values only in Image.info while asserting the returned graph is the source graph (tests/app/services/images/test_images_default.py:226-235); add API/UI coverage for displaying resolved values while preserving source-graph loading.

JPPhoto and others added 2 commits October 28, 2026 19:51
Expose compact PNG input records through the workflow response and prefer them for preview. Retain source graphs for workflow loading and compatible fallbacks for older media.
@github-actions github-actions Bot added api frontend PRs that change frontend files labels Oct 29, 2026
@wunianze666-netizen wunianze666-netizen changed the title fix(images): preserve source graphs and resolved inputs fix(images): display resolved inputs and preserve source graphs Oct 29, 2026
@wunianze666-netizen

Copy link
Copy Markdown
Contributor Author

Addressed review5687267454 in a41ed4b, based on the maintainer's1c6d5e5 merge.

The existing image /workflow response now exposes the compact PNG record as optional resolved_inputs. The Graph tab prefers it, so it displays actual Noise seed18/math input17 instead of source defaults0. graph and workflow remain unchanged for editable source-graph loading and authored-workflow precedence. Old files and omitted/null diagnostics fall back to the source graph; video display behavior is unchanged. No whole runtime graph/session/history is reconstructed.

Native red evidence:8 backend failures on unchanged1c6 production;1 actual Graph-display mismatch plus85 passing Chromium controls on the unchanged panel. The corrected candidate passes396 related backend tests (11 Windows directory-fsync skips,8 deprecation warnings),86 Chromium browser tests,76 related units,92 architecture checks, API generator tests, frontend lint/types and the production build. Generated OpenAPI/types add only the optional property, and the actual legacy type-only consumer compiles old/new/null payloads. Focused backend tests overlap the396 total.

The backend tests use real PNG storage, temporary SQLite/ImageService and FastAPI TestClient, including read-access/maintenance guards, record subfolders and legacy compatibility. The browser tests exercise Graph inspection and the real source-graph workflow conversion. A separate interactive Windows/full-app visual check was not completed; no GPU/full-model or full-repository validation is claimed. Build chunk/import/timing warnings are retained. Fresh CI has started on the new head.

@JPPhoto
JPPhoto self-requested a review October 29, 2026 17:15

@JPPhoto JPPhoto left a comment

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.

Findings/issues:

  • invokeai/app/services/image_files/image_files_disk.py:695-700: Re-uploading a generated PNG drops invokeai_resolved_inputs. Image extraction still reads only metadata, workflow, and graph, and the upload route passes only those fields to images.create (invokeai/app/api/routers/images.py:180-203). The imported image's Graph tab then falls back to source defaults. Effect: issue #6708 recurs for re-ingested copies. Likelihood: supported cross-instance upload. Recovery: the original PNG retains the field, but app upload does not. Test: add an upload round-trip test that checks resolved_inputs in the workflow response. The PR documents the unchanged upload contract; this limitation leaves re-ingested copies without the fix.

@lstein lstein added the 7.0.0 label Oct 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.0.0 api docs PRs that change docs frontend PRs that change frontend files python PRs that change python files python-tests PRs that change python tests services PRs that change app services

Projects

Status: 7.0.0: UX overhaul

Development

Successfully merging this pull request may close these issues.

[enhancement]: Image graph does not contain random seeds used to generate an image (Could be a bug)

3 participants