Repository navigation
fix(assets): cloud Generated tab uses /api/assets so deleted outputs disappear (FE-740) - #12464
dante01yoon wants to merge 2 commits into
Conversation
…disappear
The cloud asset sidebar's "Generated" tab was sourced from `historyAssets`
(populated via `api.getHistory()`), but the asset record lifecycle is owned by
`/api/assets`. Deleting an asset via `DELETE /api/assets/{id}` left the history
job entry intact, so the sidebar kept rendering the asset with a truncated-hash
fallback name.
Switch the cloud sidebar to `useFlatOutputAssetsGrouped()` which:
- pulls from `/api/assets?include_tags=output` (the real source of truth)
- collapses rows sharing `job_id` into one card per job with `outputCount`,
preserving the existing stack UX
Schema:
- `zAsset` gains `job_id` / `prompt_id` (both nullish), matching ingest-types
and core OpenAPI Asset, and forward-compatible with the in-flight `prompt_id`
-> `job_id` rename
- `OutputAssetMetadata` relaxes `nodeId` / `subfolder` to optional and the type
guard only requires `jobId`, so flat-output rows pass downstream consumers
(delete, download, stack expansion) without further changes
FE-740
🎨 Storybook: ✅ Built — View Storybook |
🎭 Playwright: ⏳ Running... |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds job_id/prompt_id to asset schema, introduces useFlatOutputAssetsGrouped() to collapse outputs per job (annotating representative assets), relaxes output-metadata validation, falls back to asset.job_id for stack resolution, and uses the grouped provider in the sidebar. ChangesAsset Grouping and Cloud Output Display
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
Poem
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error, 1 warning)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #12464 +/- ##
===========================================
- Coverage 74.39% 60.29% -14.10%
===========================================
Files 1526 1417 -109
Lines 85904 72639 -13265
Branches 22727 19302 -3425
===========================================
- Hits 63907 43798 -20109
- Misses 21177 28367 +7190
+ Partials 820 474 -346
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1014 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Align with the L1 stack pattern (FE-729 #12322 / FE-730 #12335 / FE-731 #12375 / FE-732 #12417): the Generated tab now resolves to `useFlatOutputAssetsGrouped()` unconditionally. OSS reaches the same asset-API path as cloud once BE-786 lands and `_ASSETS_ENABLED` is no longer a gate; no transitional fallback is kept, in line with FE-730's "no temporary isCloud fallback" stance. FE-740
|
This drops preview assets entirely from the assets view - they have tag |
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @mattmillerai.
Found 6 finding(s).
| Severity | Count |
|---|---|
| 🟠 High | 2 |
| 🟡 Medium | 1 |
| 🟢 Low | 3 |
Panel: 8/8 reviewers contributed findings.
| const outputCount = countsByJobId.get(jobId) ?? 1 | ||
| grouped.push({ | ||
| ...asset, | ||
| user_metadata: { |
There was a problem hiding this comment.
🟠 High — The grouped representative's user_metadata is rebuilt with only jobId/outputCount and never carries nodeId/subfolder (the flat /api/assets rows lack them). On expansion, useOutputStacks.resolveStackChildren builds excludeOutputKey via getOutputKey({nodeId, subfolder, filename}), which returns null when those fields are absent, so the representative output is not filtered out of the re-fetched job outputs and renders twice — once as the stack header and again as a child — for every multi-output job. Stamp the representative's nodeId/subfolder (or exclude by filename) so the header file is removed from its children. Raised by 4 of 8 reviewers (gpt-5.3-codex-xhigh edge-case, gpt-5.3-codex-xhigh adversarial, claude-opus-4-8-thinking-xhigh edge-case, claude-opus-4-8-thinking-xhigh adversarial).
|
|
||
| const inputAssets = useAssetsApi('input') | ||
| const outputAssets = useAssetsApi('output') | ||
| const outputAssets = useFlatOutputAssetsGrouped() |
There was a problem hiding this comment.
🟠 High — This swaps the output provider from useAssetsApi('output') (backed by api.getHistory(), which works in OSS) to useFlatOutputAssetsGrouped(), which reads flatOutputAssets populated via assetService.getAssetsPageByTag(OUTPUT_TAG, ...) — a path the store explicitly comments as 'cloud-only'. In OSS/non-cloud runs the generated-outputs tab may stop loading and render empty; gate this on isCloud (falling back to the history provider) or confirm /api/assets?include_tags=output is served in OSS. Raised by 1 of 8 reviewers (gpt-5.3-codex-xhigh edge-case).
| typeof metadata.jobId === 'string' && | ||
| (typeof metadata.nodeId === 'string' || typeof metadata.nodeId === 'number') | ||
| ) | ||
| return typeof metadata.jobId === 'string' |
There was a problem hiding this comment.
🟡 Medium — isOutputAssetMetadata now returns true for any user_metadata containing a string jobId, dropping the previous nodeId check. Since user_metadata is arbitrary on every asset type, unrelated assets that happen to carry a jobId key are misclassified as output metadata and routed through output-only behavior (e.g. /jobs/{jobId} lookups), producing incorrect results — and an IDOR-style exposure if backend authorization on that lookup is incomplete. Validate a more output-specific shape, or restrict the guard to assets tagged output. Raised by 2 of 8 reviewers (gpt-5.3-codex-xhigh adversarial, gpt-5.3-codex-xhigh edge-case).
| function getStackJobId(asset: AssetItem): string | null { | ||
| const metadata = getOutputAssetMetadata(asset.user_metadata) | ||
| return metadata?.jobId ?? null | ||
| return metadata?.jobId ?? asset.job_id ?? null |
There was a problem hiding this comment.
🟢 Low — getStackJobId falls back to asset.job_id but omits the prompt_id alias that groupByJobId uses (asset.job_id ?? asset.prompt_id). A legacy asset exposing only prompt_id (and no user_metadata.jobId) resolves to null here and cannot be expanded, inconsistent with how it was grouped; mirror the ?? asset.prompt_id fallback. Raised by 3 of 8 reviewers (gemini-3.1-pro edge-case, gpt-5.3-codex-xhigh adversarial, claude-opus-4-8-thinking-xhigh edge-case).
| for (const asset of assets) { | ||
| const jobId = asset.job_id ?? asset.prompt_id | ||
| if (!jobId) continue | ||
| countsByJobId.set(jobId, (countsByJobId.get(jobId) ?? 0) + 1) |
There was a problem hiding this comment.
🟢 Low — outputCount is tallied only over the currently-loaded page (inner.media.value), but /api/assets returns one row per output file, so a job whose outputs straddle a page boundary is undercounted until later pages load. When only one row of a multi-output job is present, shouldShowOutputCount (> 1) suppresses the stack affordance entirely. Raised by 2 of 8 reviewers (claude-opus-4-8-thinking-xhigh edge-case, claude-opus-4-8-thinking-xhigh adversarial).
| function groupByJobId(assets: AssetItem[]): AssetItem[] { | ||
| const countsByJobId = new Map<string, number>() | ||
| for (const asset of assets) { | ||
| const jobId = asset.job_id ?? asset.prompt_id |
There was a problem hiding this comment.
🟢 Low — asset.job_id ?? asset.prompt_id uses nullish coalescing, but job_id is typed z.string().nullish() and can be ''; an empty-string job_id is preserved instead of falling back to a valid prompt_id, then fails the if (!jobId) check and is treated as an orphan. Use a truthy check (or ||) so empty strings fall through to prompt_id. Raised by 1 of 8 reviewers (kimi-k2.5 edge-case).
christian-byrne
left a comment
There was a problem hiding this comment.
- Deleted outputs return on expansion.
- Existing exact-head blockers remain.
- Rebase, then reconcile #14830.
Full context for agent readers
The new inline comment covers the deletion-authority regression. The existing representative-duplication thread and current-head temporary-preview verification still need resolution: #12464 (comment) and #12464 (comment).
The branch also conflicts with current main in AssetsSidebarTab.vue and assetSchema.ts, and overlaps the current implementation in #14830 at 72e3d12b1350e70dfdc457dda7828898d9fa1edd. Please rebase and reconcile the surviving approach before another review. CI is terminal and non-failing at this head; the request is based on behavior and integration state, not CI.
| * representative (the first occurrence — assets are returned newest-first). | ||
| * | ||
| * The siblings remain reachable through the existing stack-expand path via | ||
| * `resolveOutputAssetItems(metadata)`. |
There was a problem hiding this comment.
issue: Expansion restores Asset-API-deleted outputs.
Full context for agent readers
Grouping retains only the surviving Asset API rows, but these rows have no allOutputs. Expanding calls resolveOutputAssetItems() and reloads stale job history, so a sibling deleted through /api/assets reappears. Please derive children from the surviving Asset API rows and add a regression test that deletes one sibling before expansion.
|
Closing as superseded by #15381: the Generated tab now reads outputs from /api/assets whenever the assets system is enabled, groups them per job (unflattenOutputAssets), and job_id comes from ingest-types. |
Summary
/api/assets?include_tags=output(viauseFlatOutputAssetsGrouped()) instead ofhistoryAssets(api.getHistory()). Deleting an asset via the Asset API now removes it from the sidebar —historyAssetswas "history-soft-delete" and kept stale entries foreveruseFlatOutputAssetsGroupedcollapses individual outputs sharingjob_idinto one card per job with anoutputCountbadge, so the existing stack UX is preservedzAssetschema gainsjob_id/prompt_id(bothnullish) to match core + cloudingest-typesAsset and the in-flight L6 rename (prompt_id->job_id)OutputAssetMetadatarelaxesnodeId/subfolderto optional; the type guard only requiresjobId, so flat-output rows pass downstream consumers (delete, download, stack expand) without further plumbingisCloudfallback — same stance as FE-730 (refactor(assets): remove isCloud forks in assetsStore (FE-730) #12335). OSS resolves to the same asset-API path as cloud once BE-786 landsLinear: FE-740
Root cause
AssetsSidebarTab.vue:314was sourcing both Input and Output viauseAssetsApi, butuseAssetsApi('output')reads fromhistoryAssets, populated byapi.getHistory()(the queue/history endpoint), not from the Asset API. Cloud'sDELETE /api/assets/{id}removes the asset record, but the history job entry remains — so the sidebar kept rendering the deleted asset, falling back to the truncated content-hash name oncedisplay_namewas no longer resolvable.The fix is consistent with the M1 L1 direction (single Asset API path) and L6 field rename (BE-39/40/41). It mirrors the dispatch already in
WidgetSelectDropdown.vue:52-54(FE-227), which moved the LoadImage dropdown touseFlatOutputAssetsbut explicitly left the sidebar alone.Stack alignment
Same pattern as the rest of the L1 down-payment stack:
Depends on BE-786 (OSS removes
--enable-assetsso/api/assetsis always on) before this can ship to production. Until BE-786 + acomfyui-ci-containerbump, OSS e2e + the cloud Playwright project hit 503 on/api/assets?include_tags=output. This matches FE-730's stance: "no temporaryisCloudfallback was added".Verification (against prod cloud session)
Direct CDP-driven verification on
https://cloud.comfy.org(prod,main) vshttps://local.comfy.org:5173/(this branch,pnpm dev:cloud-prod):assetsStore.historyAssets.lengthassetsStore.flatOutputAssets.lengthjob_idafter groupingoutputCountfor known multi-output job22dda683-...job_ids surviving in the sidebar sourceThe 9 stale jobs (
ComfyUI_temp_epprf_*,ComfyUI_temp_ccxpc_*x4,ComfyUI_temp_klafe_*x4) were jobs whose underlying assets had been removed from/api/assetsby the cloud BE (temp-file expiration / direct asset deletion); they remained visible on the Generated tab solely becausehistoryAssets(=/api/jobs) still listed them.Rendered sidebar after fix (excerpt of
aside.innerText):No
ComfyUI_temp_*entries — confirming the stale set is gone.Multi-output job semantics
/api/assets?include_tags=outputreturns one row per output file. For a 35-output job, that's 35 rows. The grouping helper collapses these into one card perjob_id, withoutputCount= group size. The existinguseOutputStacksexpansion path (resolveOutputAssetItems) continues to fetch siblings when a card is expanded.Known limitation (documented in helper): if a job's outputs span multiple pages of pagination,
outputCountreflects only the portion currently loaded. Acceptable for v1; full counts can be reconciled in a follow-up if needed.Schema compatibility
zAssetpreviously omittedjob_id/prompt_ideven though both are emitted by the cloud BE today (verified live:job_id: "22dda683-1634-4120-8a7d-233cff28e07e"). Adding them asnullishis forward-compatible with:Comfy-Org/ComfyUI:app/assets/api/schemas_out.py, identical shape including the# deprecated: use job_idannotation)ingest-typesSOT flip to core (PR test(e2e): align asset/jobs fixture imports to core OpenAPI naming [DRAFT — blocked] #12409) —Asset.job_idsurvives the migration unchangedTest plan
pnpm vitest run src/platform/assets/ src/components/sidebar/tabs/— 48 files / 539 tests passpnpm vitest run src/stores/assetsStore.test.ts src/platform/assets/composables/useMediaAssetActions.test.ts— 99/99 passuseFlatOutputAssetsGrouped.test.ts— 6 cases (grouping, outputCount, prompt_id fallback, passthrough, ordering, immutability)pnpm typecheckcleanpnpm lintclean (0 errors)pnpm format:checkclean64759302-c98f-4f1c-8f18-5798aa64833e/api/assets?include_tags=output— gated on BE-786 + CI container bump (same as refactor(assets): remove isCloud forks in assetsStore (FE-730) #12335)Dependencies
Out of scope (separate Linear)
/api/assets(real fix to the dual-source-of-truth problem; will retire even more FE branches)WidgetSelectDropdown.vue:52-54anduseOutputHistory.ts:28still calluseAssetsApi('output')— those are widget / linearMode scope and ride along with the rest of the L1 widget stackScreenshots
before / after screenshots (drag-drop in the GH web UI from
temp/in_progress/fe740-before-fix.pngandtemp/in_progress/fe740-after-fix-v2.png)