Skip to content

Keep expressions when optional background removal fails - #5

Merged
rustyorb merged 1 commit into
masterfrom
fix/expression-background-failure
Oct 19, 2026
Merged

rustyorb merged 1 commit into
masterfrom
fix/expression-background-failure

Conversation

@rustyorb

@rustyorb rustyorb commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Expression generation stopped when background removal failed to load libnvrtc-builtins.so.13.0, then incorrectly suggested reinstalling the face adapter. Confirmed cutout-node runtime failures now retry once with the background kept and the original sampler, seed, portrait and face adapter unchanged. Subsequent moods keep their backgrounds, and the completion report explains the recovery.

GPU out-of-memory errors stop without retrying the memory failure. CUDA-library and adapter errors get relevant guidance. Cancellation, failures outside background removal, and a failed plain-image retry cannot silently switch to another person or loop through more attempts. Image settings, README and the quick-start guide explain the behavior.

Validation: 201 tests pass. The new tests reproduced the reported failure before implementation and cover recovery on the first or later mood, both face adapters, sampler/cutout out-of-memory, other CUDA failures, bounded retry failure, cancellation, and unchanged reference/adapter/sampler connections. External ComfyUI responses were mocked; no GPU job was launched, and the user's other CUDA installation was not modified or live-validated.

Summary by Sourcery

Make expression generation recover safely from background-removal failures while preserving identity settings and clearly reporting the outcome.

New Features:

  • Retry expression generation once without background removal when a cutout node fails, preserving the selected portrait, face adapter, sampler, and seed while keeping backgrounds for subsequent moods.
  • Provide actionable guidance for background-removal, CUDA-library, adapter, workflow, and GPU-memory failures without switching identities or retrying unsafe failures.

Bug Fixes:

  • Prevent background-removal runtime failures from stopping expression generation or producing misleading face-adapter reinstall advice.
  • Prevent cancellation and failed fallback attempts from submitting additional jobs or silently generating unconditioned results.

Enhancements:

  • Report background-removal recovery in the expression-generation status and completion notification.
  • Document background-removal fallback behavior and the transparent-sprite setting in the README, quick-start guide, and image settings.

Documentation:

  • Update user-facing documentation with fallback, GPU memory, and transparent-sprite guidance.

Tests:

  • Expand mocked ComfyUI coverage to 201 tests for recovery timing, adapter variants, failure classification, bounded retries, cancellation, and preserved workflow connections.

Copilot AI balanced review requested due to automatic review settings October 19, 2026 04:03
@sourcery-ai

sourcery-ai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR makes expression generation resilient to background-removal runtime failures by performing one controlled plain-background retry with the original identity and generation settings, then retaining backgrounds for the remainder of the run and clearly reporting the recovery. It explicitly avoids unsafe retries for GPU OOM, unrelated CUDA or adapter failures, cancellation, and failed fallback attempts, with accompanying UI/documentation updates and mocked regression coverage.

Flow diagram for expression generation failure handling

flowchart TD
    A[Run expression with background removal] --> B{Generation error?}
    B -->|No| C[Save expression]
    B -->|Cutout runtime failure| D[Retry once with background kept]
    D -->|Success| E[Save expression and keep backgrounds]
    D -->|Failure| F[Report error and stop]
    B -->|GPU out of memory| G[Report memory guidance and stop]
    B -->|Other CUDA or adapter failure| H[Report relevant guidance and stop]
    B -->|Cancelled| I[Stop without fallback]
Loading

File-Level Changes

Change Details Files
Add bounded recovery when background-removal nodes fail during expression generation.
  • Classify GPU OOM, cutout-node runtime, CUDA-library, adapter, workflow-rejection, and cancellation failures with targeted guidance.
  • Retry a confirmed cutout runtime failure exactly once without cutout nodes, preserving the portrait, adapter, sampler, seed, and identity connections.
  • Persist background retention for subsequent moods and return warnings for the completion report.
  • Prevent retries for OOM, non-cutout failures, failed plain-image recovery, and cancellation.
src/st/comfy.js
Expose background-removal recovery and failure outcomes to users.
  • Include recovery warnings in expression status and toast reports.
  • Document retry behavior, OOM handling, and the setting to disable transparent sprites.
  • Update test-count and verification documentation with the new behavior and validation scope.
src/ui/character-pictures.js
src/ui/image-setup.js
README.md
docs/QUICKSTART.md
docs/STATUS.md
Expand mocked regression coverage for recovery boundaries and workflow preservation.
  • Simulate cutout failures on first and later moods for both face adapters.
  • Verify sampler, seed, portrait/reference, adapter, and cutout connections remain correct.
  • Cover cutout and sampler OOM, unrelated CUDA failures, failed fallback, cancellation, and bounded retry behavior.
tests/comfy.test.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The bounded recovery preserves identity settings, handles unsafe failures explicitly, and has focused regression coverage with no identified blocking issues.

No open issues 🎉

What changed in this PR

Expression generation now recovers from optional background-removal failures without changing the portrait, face adapter, sampler, or seed.

Changes:

  • Retry confirmed cutout failures once without background removal, preserving cancellation and memory-error safeguards.
  • Report recovery and provide failure-specific guidance.
  • Add regression coverage and document the fallback behavior.
File Description
tests/​comfy.test.js Tests recovery, retry limits, cancellation, and preserved workflow connections.
src/​ui/​image-setup.js Explains background fallback and memory-error behavior.
src/​ui/​character-pictures.js Includes recovery warnings in completion reports.
src/​st/​comfy.js Implements bounded recovery and targeted error guidance.
README.md Documents recovery and updates test counts.
docs/​STATUS.md Records verification results and limitations.
docs/​QUICKSTART.md Explains fallback and transparency settings.

Review effort: Balanced

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. If the retry removes the wrong workflow nodes or reconnects the save input incorrectly, an expression could be generated with an unintended background or image and saved to the project; later expressions in that run would also keep their backgrounds. Those saved results are bounded and can be undone or regenerated, but reverting the code would not undo images already created.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@rustyorb
rustyorb merged commit 7ecceda into master Oct 19, 2026
2 checks passed
@rustyorb
rustyorb deleted the fix/expression-background-failure branch October 19, 2026 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants