Skip to content

feat(website): Background Removal app (mocked) - #20869

Open
mariana953 wants to merge 14 commits into
mariana/editor-kitfrom
mariana/app-background-removal
Open

mariana953 wants to merge 14 commits into
mariana/editor-kitfrom
mariana/app-background-removal

Conversation

@mariana953

@mariana953 mariana953 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Workshop app at /hub/apps/background-removal/. It does what JP Costa's Background Removal does (input image → cut-out, background and format applied client-side, Result / Compare views, no seed), with our editor kit. On top of that it adds Mar's Remove | Replace | Adjust redesign. The backend is mocked. Built on the shared editor kit (#20630), with no dependency on Relight or Move anything. Replaces #19823. The image loader is now lib/workshop/load-image.ts, so nothing is borrowed from another app. On top of the kit it adds a checker option to EditorCompare and EditorResult (with EditorChecker), a slot in EditorBusy, and mockRenderJob in mock-job.ts.

Changes

  • What:
    • Background is one panel section with a shared segmented control: Remove | Replace | Adjust.
      • Remove (JP parity): a 6 × 2 swatch grid. It has Transparent (checkerboard, the default), White, Lilac (JP's three), Sand, Sage, Sky, Blush, Butter, Clay, Navy, Ink, and a last custom swatch with a conic rainbow. The custom swatch opens the kit's colour picker (EditorColorPicker in EditorPopover, moved from Cinematic Studio in feat(website): shared full-screen editor pieces for the Workshop apps #20630). The selected swatch gets a white ring. The result composites the cut-out over the colour; Transparent keeps the alpha and shows a checkerboard.
      • Replace (extension): a model menu (Auto, Nano Banana 2, Qwen Image 3.0, FLUX.1 Kontext Pro, Seedream 4.5) on the shared EditorOutput / CinematicMenu, with a chip icon. Below it, a prompt box with an optional reference-image + slot at its top-left (pick or drop an image) and a ×1 count. Seed is a direct panel row, shown only in Replace. Until a description or a reference is given, the run button is disabled and says "Add a prompt or reference" in place of its label and credits, short enough to show whole in the 280px panel; its tooltip has the full sentence, "Describe a background or add a reference image." (through EditorRun's missingHint, from feat(website): shared full-screen editor pieces for the Workshop apps #20630). The message shows only on the run button, not under the prompt. The ∞ toggle from the reference is left out because nothing real backs it.
      • Adjust (extension): a secondary segmented control, Background | Foreground, and the shared EditorSliders: Blur 0, Grayscale 0, Sepia 0, Brightness 100, Contrast 100, Saturation 100. The values apply live on the canvas as CSS filters on the chosen layer (the photo, plus the subject masked over it). They are sent in the request. A blurred background is scaled up slightly so its edge doesn't fade in from the frame.
    • Format (PNG / WebP) stays a direct panel row. Advanced (collapsed) now holds edge softness only.
    • Run label, credits and busy title follow the mode: Remove background / Replace background / Apply adjustments. While it runs, the button shows the run's progress.
    • Download is named by mode: <name>-cutout|new-background|adjusted.<format>.
    • Layout E (?ux=e): the Background chip opens a tray with the mode switch and the active mode's controls (plus Seed in Replace). Format stays a composer pill. Phone: a sheet with a summary row, and the same section when expanded; the review menu's … button no longer covers the last swatch (it sits in the header on phones, from feat(website): shared full-screen editor pieces for the Workshop apps #20630).
    • Example is now a real photo (pilea in a white pot on an oak side table): plant.jpg (1200×896, JPEG q82), the prepared cut-out plant-cutout.webp (WebP with alpha, 42 KB vs 376 KB as PNG), and the prepared Replace result plant-replaced.jpg. The cut-out's alpha is the example's matte for Remove, Adjust and the live previews. Replace on the example (without a reference) returns the prepared photo. Uploads fall back to the canvas mock: an oval matte, with a reference image or a warm gradient behind it for Replace.
    • Deleted the drawn example.jpg and example-mask.png. The hub thumbnail (workshop-display.json) now uses plant.jpg.
    • Shared kit adopted (from feat(website): shared full-screen editor pieces for the Workshop apps #20630): the stage drop uses EditorDropZone (with the hover highlight), paste uses useImagePaste, the reference + slot uses EditorUploadSlot, and the run uses EditorRun's progress (read off the mock's clock with clockProgress, CUTOUT_RUN_MS), missing and missingHint. The local drop, paste and file-input code is removed.
    • Additions:
      • paste an image from the clipboard to replace the photo;
      • drop an image onto the stage or onto the reference slot;
      • the "what's missing" message on the run in Replace;
      • run progress on the button;
      • per-mode download names.
    • Removed: the top-level Seed row (JP has no seed for this app; it now lives only in Replace), the old 3-tile Transparent / White / Lilac picker, and the second "what's missing" line under the prompt box.

Backend contract (lib/workshop/background-removal/contract.ts). JP's /api/run/background-removal takes only image (multipart). JP applies background and format client-side, and so does our mock (render-cutout.ts). Everything beyond image is sent so a backend can do it server-side, and fields marked extension are Mar's additions that JP's backend does not support yet.

type CutoutRequest = {
  imageUrl: string                // JP: image
  format: 'png' | 'webp'          // JP: client-side
  edgeSoftness: number            // 0–100, extension
} & (
  | { mode: 'remove'; background: { kind: 'transparent' } | { kind: 'color'; color: '#rrggbb' } } // JP: client-side background
  | { mode: 'replace'; replace: { prompt: string; model: string; referenceUrl?: string; count: number; seed: number } } // extension
  | { mode: 'adjust'; adjust: { target: 'background' | 'foreground'; blur: number; grayscale: number; sepia: number; brightness: number; contrast: number; saturation: number } } // extension
)
interface CutoutResult { url: string; mode: CutoutMode; format: CutoutFormat; transparent: boolean }

The job reports no progress; the button's percent is an estimate from the elapsed time. To connect a real backend, replace runCutout in mock-run.ts. The page only needs the same shapes.

Staff flag: workshop-background-removal-app-enabled (PostHog).

Review Focus

  • Replace's count is fixed at 1 and shown as ×1. A real count needs a multi-result view.
  • Replace's model ids are catalogue ids of existing edit-image models. Auto lets the backend choose.
  • Adjust uses one set of values for the chosen layer, as in the brief's contract. It does not keep a separate set per layer.
  • This branch still carries its earlier small kit edits (EditorCompare, EditorHint, EditorResult).
  • Shared with the other app PRs. The app registers itself in the kit's EDITOR_APPS list on the studio page (one entry), and its copy goes through lib/workshop/app-copy.ts. Shared helpers (app-copy.ts, and where used load-image.ts, nudge.ts, useSnapshotHistory.ts) are identical in every app PR, so they merge cleanly whichever lands first.

Screenshots (if applicable)

Taken locally: desktop 1440 (Remove with the example, custom colour picker, Remove result and Compare, Replace and its result, Adjust live), layout E tray, and phone 390 (sheet, expanded settings with the … button clear of the swatches, Replace, running).


Generated by Claude Code

@mariana953
mariana953 requested review from a team and dante01yoon as code owners October 12, 2026 20:34
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: e894c96b-2751-4034-b4c9-65c2cdbb303a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle Size

⏳ Size data collection in progress…

🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measure

Executes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight ecosystem-matrix shard checks are a harness self-test; the pack verdict is matrix-verdict.

This candidate changes nothing the matrix measures, so every expensive stage was skipped.

Reproduce locally
# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
  npx vitest run --config vitest.matrix.config.mts

Full docs: scripts/registry-census/README.md

🌾 Fallow: ✅ Passed

Fallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened.

No new findings in the changed files.

Reproduce locally
# the base the gate compared against
npx fallow audit --root . --quiet --format json \
  --changed-since fa6d451f5d507b9e31956425e939e0ee8d12cd1d

Full docs: ADR-DEVEX-LINT-0015

🌐 Website E2E

Tip

All tests passed.

Status ✅ Passed
Report View Report

🔗 Website Preview

Website Preview: https://comfy-website-preview-pr-20869.vercel.app

Models is built and gated by PostHog (workshop-enabled), using staging Cloud.

This commit: https://website-frontend-bxeemw2f3-comfyui.vercel.app

Last updated: 2026-10-14T00:50:09Z for 5dac0e3

@github-actions github-actions Bot added the risk:high PR risk grade (advisory shadow check; grader-owned) label Oct 12, 2026
@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.94958% with 124 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...c/lib/workshop/background-removal/render-cutout.ts 2.46% 79 Missing ⚠️
...ps/website/src/composables/useBackgroundRemoval.ts 84.48% 2 Missing and 7 partials ⚠️
apps/website/src/lib/workshop/load-image.ts 0.00% 6 Missing ⚠️
.../background-removal/BackgroundRemovalReference.vue 42.85% 2 Missing and 2 partials ⚠️
...shop/background-removal/BackgroundRemovalThumb.vue 20.00% 1 Missing and 3 partials ⚠️
...op/background-removal/BackgroundRemovalReplace.vue 0.00% 3 Missing ⚠️
.../background-removal/BackgroundRemovalWorkspace.vue 85.71% 1 Missing and 2 partials ⚠️
...kshop/background-removal/BackgroundRemovalMain.vue 71.42% 1 Missing and 1 partial ⚠️
...shop/background-removal/BackgroundRemovalPanel.vue 92.85% 0 Missing and 2 partials ⚠️
...hop/background-removal/BackgroundRemovalStudio.vue 92.85% 2 Missing ⚠️
... and 9 more

❌ Your patch check has failed because the patch coverage (73.94%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

@@                  Coverage Diff                  @@
##             mariana/editor-kit   #20869   +/-   ##
=====================================================
  Coverage                      ?   85.77%           
=====================================================
  Files                         ?     3584           
  Lines                         ?   169515           
  Branches                      ?    46453           
=====================================================
  Hits                          ?   145404           
  Misses                        ?    22194           
  Partials                      ?     1917           
Flag Coverage Δ
website-unit 80.52% <73.94%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ebsite/src/components/workshop/ModelsCatalogue.vue 100.00% <100.00%> (ø)
.../src/components/workshop/app-editor/EditorBusy.vue 88.88% <100.00%> (ø)
...c/components/workshop/app-editor/EditorChecker.vue 100.00% <100.00%> (ø)
...c/components/workshop/app-editor/EditorCompare.vue 77.77% <100.00%> (ø)
.../src/components/workshop/app-editor/EditorHint.vue 100.00% <100.00%> (ø)
...hop/background-removal/BackgroundRemovalAdjust.vue 100.00% <100.00%> (ø)
...p/background-removal/BackgroundRemovalAdvanced.vue 100.00% <100.00%> (ø)
...kshop/background-removal/BackgroundRemovalDock.vue 100.00% <100.00%> (ø)
...shop/background-removal/BackgroundRemovalDocks.vue 100.00% <100.00%> (ø)
...hop/background-removal/BackgroundRemovalFormat.vue 100.00% <100.00%> (ø)
... and 37 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dante01yoon dante01yoon 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.

Thanks. useEditorImage and mockRenderJob are nice extractions, and the mode-specific request union is clear. Requesting changes for the copy approach (shared with the sibling app PRs) and hex colours in a component.

Size. This PR is about 3,350 lines (excluding binaries). That is far past the ~300-line guideline and hard to review well in one pass. Could you split it, e.g. (1) wiring: catalogue, routes, flag, Hub card; (2) pure lib/ logic with its tests; (3) components and e2e?

Stacking. Base is mariana/editor-kit (#20630), which is still open with changes requested. Every app PR edits the same shared lists (routes.ts, apps.ts, catalogue-apps.ts, CinematicStudioPage.vue, schema enums, locales, vercel.json), so they will conflict with each other as they land. The identical helpers (app-copy.ts, load-image.ts, useSnapshotHistory.ts, nudge.ts) would be better landed once in #20630 than duplicated in every app branch. This PR also changes kit files (EditorCompare, EditorResult, EditorBusy, mock-job.ts). Those changes belong in #20630, so sibling apps aren't built on a different kit.

Unanchored suggestion: useEditorImage is a good shared helper, but only this app uses it while the other six re-implement the same image/removed/ownUrl/pending logic. Moving it into the kit would remove that duplication.

Checks: CI is green; I didn't run tests locally.

named: CopyValues = {}
): string {
const [one, many = one] = (entry[locale] ?? entry.en).split(' | ')
return (named.n === 1 ? one : many).replace(

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.

issue: appCopy fills placeholders with .replace and parses | plurals by hand, and the app's strings live in a TS copy.ts instead of src/locales/<locale>/main.json. apps/website/AGENTS.md says copy goes in main.json and is read with translationsFor(locale).t, and to "never fill a placeholder with .replace". Doing it this way also skips the catalog test that compiles each message and checks zh-CN coverage. It also treats a literal {word} the visitor types (a star name, a light name) as a placeholder whenever named has that key.

Could the app's strings move under a namespaced key in main.json (moveAnything.*, relight.*, …) and be read through t(key, named, { locale })? If keeping them out of the site-wide bundle is the real goal (as for catalogue-apps.ts), please get that exception agreed on #20630 first, where all seven apps can share it, without hand-rolled interpolation.

:aria-label="brc('cutout.swatch.custom', locale)"
:title="brc('cutout.swatch.custom', locale)"
:class="swatchClass(!selected)"
class="grid place-items-center bg-[conic-gradient(#f87171,#facc15,#4ade80,#22d3ee,#818cf8,#e879f9,#f87171)]"

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.

issue: apps/website/AGENTS.md: "Use a token; never write a hex value into a component." The rainbow conic-gradient(#f87171,…) here and the #7a9cc6 default on line 27 are hard-coded colours in a component. Could the gradient become a utility/token in src/styles/global.css, and the default custom colour live with the swatch data in lib/?

update({ adjust: { ...history.state.value.adjust, ...patch } }, key)
}

function setReference(file: File | undefined) {

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.

nit-pick (non-blocking): each reference pick creates an object URL that is only released on the next photo or on unmount. Swapping references repeatedly accumulates them. That's acceptable while undo can return to them, but worth knowing.

}

/** What a Background Removal backend receives for one run. */
export type CutoutRequest = CutoutRequestBase &

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.

question: CutoutRequest is a hand-written request/response contract for a backend that doesn't exist yet. Is there a tracking issue for the endpoint? Once it ships in the OpenAPI spec, these types should be imported from @comfyorg/ingest-types rather than kept by hand. Could you link the issue here (or in the PR body) so the swap isn't forgotten?

This branch was previously deployed

1 inactive deployment
website-approval — 5dac0e39 Deployed Oct 14, 2026 by mariana953 via fast-lane #1902
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:high PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants