Skip to content

fix(assets): cloud Generated tab uses /api/assets so deleted outputs disappear (FE-740) - #12464

Closed
dante01yoon wants to merge 2 commits into
mainfrom
jaewon/fe-740-cloud-sidebar-output-source
Closed

dante01yoon wants to merge 2 commits into
mainfrom
jaewon/fe-740-cloud-sidebar-output-source

Conversation

@dante01yoon

@dante01yoon dante01yoon commented May 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Cloud + OSS asset sidebar's Generated tab now reads from /api/assets?include_tags=output (via useFlatOutputAssetsGrouped()) instead of historyAssets (api.getHistory()). Deleting an asset via the Asset API now removes it from the sidebar — historyAssets was "history-soft-delete" and kept stale entries forever
  • New useFlatOutputAssetsGrouped collapses individual outputs sharing job_id into one card per job with an outputCount badge, so the existing stack UX is preserved
  • zAsset schema gains job_id / prompt_id (both nullish) to match core + cloud ingest-types Asset and the in-flight L6 rename (prompt_id -> job_id)
  • OutputAssetMetadata relaxes nodeId / subfolder to optional; the type guard only requires jobId, so flat-output rows pass downstream consumers (delete, download, stack expand) without further plumbing
  • No isCloud fallback — 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 lands

Linear: FE-740

Root cause

AssetsSidebarTab.vue:314 was sourcing both Input and Output via useAssetsApi, but useAssetsApi('output') reads from historyAssets, populated by api.getHistory() (the queue/history endpoint), not from the Asset API. Cloud's DELETE /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 once display_name was 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 to useFlatOutputAssets but explicitly left the sidebar alone.

Stack alignment

Same pattern as the rest of the L1 down-payment stack:

main
 └── FE-729 #12322  delete isAssetAPIEnabled
      └── FE-730 #12335  remove isCloud forks in assetsStore
           └── FE-731 #12375  remove isCloud guards in widget composables
                └── FE-732 #12417  remove isCloud guards on L1 UI surfaces
                     └── FE-740   (this PR)  retire historyAssets-as-output-source

Depends on BE-786 (OSS removes --enable-assets so /api/assets is always on) before this can ship to production. Until BE-786 + a comfyui-ci-container bump, OSS e2e + the cloud Playwright project hit 503 on /api/assets?include_tags=output. This matches FE-730's stance: "no temporary isCloud fallback was added".

Verification (against prod cloud session)

Direct CDP-driven verification on https://cloud.comfy.org (prod, main) vs https://local.comfy.org:5173/ (this branch, pnpm dev:cloud-prod):

Metric prod (main) this branch
assetsStore.historyAssets.length 45 (includes 9 stale) 0 (path retired)
assetsStore.flatOutputAssets.length n/a 200 (first page)
Unique job_id after grouping n/a 79
outputCount for known multi-output job 22dda683-... n/a 18 (page-1 portion)
Stale job_ids surviving in the sidebar source 9 0

The 9 stale jobs (ComfyUI_temp_epprf_*, ComfyUI_temp_ccxpc_* x4, ComfyUI_temp_klafe_* x4) were jobs whose underlying assets had been removed from /api/assets by the cloud BE (temp-file expiration / direct asset deletion); they remained visible on the Generated tab solely because historyAssets (= /api/jobs) still listed them.

Rendered sidebar after fix (excerpt of aside.innerText):

Media Assets
Generated  Imported

video/ComfyUI-vid_6_00001_     [badge: 18]
ComfyUI-image_2_00002_         [badge: 11]
Grok_00002_
Grok_00004_
ComfyUI_00009_
ComfyUI_00008_
ComfyUI_00247_
ComfyUI_00246_

No ComfyUI_temp_* entries — confirming the stale set is gone.

Multi-output job semantics

/api/assets?include_tags=output returns one row per output file. For a 35-output job, that's 35 rows. The grouping helper collapses these into one card per job_id, with outputCount = group size. The existing useOutputStacks expansion 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, outputCount reflects only the portion currently loaded. Acceptable for v1; full counts can be reconciled in a follow-up if needed.

Schema compatibility

zAsset previously omitted job_id / prompt_id even though both are emitted by the cloud BE today (verified live: job_id: "22dda683-1634-4120-8a7d-233cff28e07e"). Adding them as nullish is forward-compatible with:

Test plan

  • pnpm vitest run src/platform/assets/ src/components/sidebar/tabs/ — 48 files / 539 tests pass
  • pnpm vitest run src/stores/assetsStore.test.ts src/platform/assets/composables/useMediaAssetActions.test.ts — 99/99 pass
  • New useFlatOutputAssetsGrouped.test.ts — 6 cases (grouping, outputCount, prompt_id fallback, passthrough, ordering, immutability)
  • pnpm typecheck clean
  • pnpm lint clean (0 errors)
  • pnpm format:check clean
  • CDP-driven visual verification against prod workspace 64759302-c98f-4f1c-8f18-5798aa64833e
  • OSS e2e against /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)

  • BE: long-term cleanup of orphaned history entries when assets are deleted via /api/assets (real fix to the dual-source-of-truth problem; will retire even more FE branches)
  • FE: WidgetSelectDropdown.vue:52-54 and useOutputHistory.ts:28 still call useAssetsApi('output') — those are widget / linearMode scope and ride along with the rest of the L1 widget stack

Screenshots

before / after screenshots (drag-drop in the GH web UI from temp/in_progress/fe740-before-fix.png and temp/in_progress/fe740-after-fix-v2.png)

…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
@github-actions

github-actions Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 05/26/2026, 10:27:38 AM UTC

Links

@github-actions

Copy link
Copy Markdown
Contributor

🎭 Playwright: ⏳ Running...

@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5525d104-4406-4da0-afc7-5444ba14dd43

📥 Commits

Reviewing files that changed from the base of the PR and between f21a399 and bc53046.

📒 Files selected for processing (1)
  • src/components/sidebar/tabs/AssetsSidebarTab.vue

📝 Walkthrough

Walkthrough

Adds 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.

Changes

Asset Grouping and Cloud Output Display

Layer / File(s) Summary
Asset schema foundation with job_id and prompt_id fields
src/platform/assets/schemas/assetSchema.ts, src/platform/assets/schemas/assetMetadataSchema.ts
Core AssetItem schema adds job_id and prompt_id (nullable/undefined). OutputAssetMetadata makes nodeId and subfolder optional and simplifies the runtime guard to require only jobId as a string.
Output asset grouping composable and tests
src/platform/assets/composables/media/useFlatOutputAssetsGrouped.ts, src/platform/assets/composables/media/useFlatOutputAssetsGrouped.test.ts
Adds useFlatOutputAssetsGrouped() that wraps useFlatOutputAssets() and exposes a media computed where assets collapse to one representative per job_id (fallback prompt_id), annotating user_metadata.jobId and user_metadata.outputCount. Tests cover grouping rules, order, pass-through, and immutability.
Stack job ID resolution fallback
src/platform/assets/composables/useOutputStacks.ts
getStackJobId now falls back to asset.job_id when getOutputAssetMetadata() does not provide a jobId.
Sidebar output asset integration
src/components/sidebar/tabs/AssetsSidebarTab.vue
Replaces the sidebar's output-assets provider with useFlatOutputAssetsGrouped() so grouped outputs are displayed instead of the previous useAssetsApi('output') source.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

size:M, released:cloud, cloud/1.44

Suggested reviewers

  • christian-byrne
  • AustinMroz
  • DrJKL

Poem

🐰 I hopped through schemas, fields in tow,
Grouped outputs gathered in tidy rows.
A jobId tagged, counts snug and neat,
The sidebar hums with one-line beats.
Hooray — small paws, big tidy feats!


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore (reviewers only)

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
End-To-End Regression Coverage For Fixes ❌ Error PR title contains "fix(assets)" (bug-fix signal) and changes files under src/ but does not change any files under browser_tests/ and lacks E2E regression test explanation. Add or update a Playwright regression test under browser_tests/ or add a concrete explanation in the PR description of why an end-to-end regression test is not practical.
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly summarizes the main change: switching cloud asset sidebar to use the Asset API endpoint, which resolves the issue of deleted outputs remaining visible.
Description check ✅ Passed Description is comprehensive with all required sections: summary explaining the fix, detailed changes list, verification steps, and test results provided.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Adr Compliance For Entity/Litegraph Changes ✅ Passed PR does not modify files under src/lib/litegraph/, src/ecs/, or graph entity-related paths; ADR compliance check does not apply.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jaewon/fe-740-cloud-sidebar-output-source

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.

❤️ Share

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

@codecov

codecov Bot commented May 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/components/sidebar/tabs/AssetsSidebarTab.vue 0.00% 2 Missing ⚠️
@@             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     
Flag Coverage Δ
e2e ?
unit 60.29% <92.30%> (+0.09%) ⬆️

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

Files with missing lines Coverage Δ
...ts/composables/media/useFlatOutputAssetsGrouped.ts 100.00% <100.00%> (ø)
src/platform/assets/composables/useOutputStacks.ts 96.61% <100.00%> (+1.61%) ⬆️
src/platform/assets/schemas/assetMetadataSchema.ts 100.00% <100.00%> (ø)
src/platform/assets/schemas/assetSchema.ts 100.00% <ø> (ø)
src/components/sidebar/tabs/AssetsSidebarTab.vue 3.26% <0.00%> (-58.84%) ⬇️

... and 1014 files with indirect coverage changes

🚀 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 changed the title fix(assets): cloud Generated tab uses /api/assets so deleted outputs disappear fix(assets): cloud Generated tab uses /api/assets so deleted outputs disappear (FE-740) May 26, 2026
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
@dante01yoon
dante01yoon marked this pull request as ready for review June 18, 2026 05:09
@dante01yoon
dante01yoon requested a review from a team June 18, 2026 05:10
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 18, 2026
@synap5e

synap5e commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

This drops preview assets entirely from the assets view - they have tag temp not output.
Please confirm this is intended.

@mattmillerai mattmillerai added the cursor-review Trigger multi-model Cursor agent review on this PR label Jun 25, 2026

@github-actions github-actions Bot 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.

🔍 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: {

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.

🟠 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()

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.

🟠 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'

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.

🟡 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

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.

🟢 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)

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.

🟢 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

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.

🟢 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 christian-byrne 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.

  • 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)`.

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.

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.

@dante01yoon

Copy link
Copy Markdown
Collaborator Author

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.

@dante01yoon dante01yoon closed this Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cursor-review Trigger multi-model Cursor agent review on this PR size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants