Skip to content

Conversation

@benceruleanlu
Copy link
Member

@benceruleanlu benceruleanlu commented Jan 24, 2026

Add helper to derive previewable outputs from job detail.

Summary

Centralize job detail output parsing so previewable outputs can be reused by upcoming asset stack/folder logic.

Changes

  • What: add getPreviewableOutputsFromJobDetail and unit tests that cover filtering and mapping behavior.
  • Dependencies: none.

Review Focus

  • Verify previewable output filtering and node/media metadata mapping are correct.

Screenshots (if applicable)

N/A

┆Issue is synchronized with this Notion page by Unito

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Review skipped — only excluded labels are configured. (1)
  • backport

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.

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

  • 🔍 Trigger a full review

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.

@github-actions
Copy link

github-actions bot commented Jan 24, 2026

🎨 Storybook Build Status

Build completed successfully!

⏰ Completed at: 01/24/2026, 04:25:25 PM UTC

🔗 Links


🎉 Your Storybook is ready for review!

@github-actions
Copy link

github-actions bot commented Jan 24, 2026

🎭 Playwright Tests: ⚠️ Passed with flaky tests

Results: 505 passed, 0 failed, 1 flaky, 8 skipped (Total: 514)

❌ Failed Tests

📊 Browser Reports
  • chromium: View Report (✅ 493 / ❌ 0 / ⚠️ 1 / ⏭️ 8)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 9 / ❌ 0 / ⚠️ 0 / ⏭️ 0)

@benceruleanlu benceruleanlu marked this pull request as ready for review January 24, 2026 16:09
@benceruleanlu benceruleanlu requested a review from a team as a code owner January 24, 2026 16:09
Copilot AI review requested due to automatic review settings January 24, 2026 16:09
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jan 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a reusable helper to derive previewable ResultItemImpl outputs from a JobDetail, centralizing output flattening/filtering for upcoming features.

Changes:

  • Added getPreviewableOutputsFromJobDetail(jobDetail) to flatten job outputs, attach nodeId/mediaType, and filter to previewable items.
  • Added unit tests covering empty inputs, filtering (animated/text/unknown), and mapping of metadata.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/services/jobOutputCache.ts Introduces helper to flatten JobDetail.outputs into previewable ResultItemImpl[].
src/services/jobOutputCache.test.ts Adds unit tests validating filtering and metadata mapping behavior.

Comment on lines +79 to +101
function getPreviewableOutputs(outputs?: TaskOutput): ResultItemImpl[] {
if (!outputs) return []
const resultItems = Object.entries(outputs).flatMap(([nodeId, nodeOutputs]) =>
Object.entries(nodeOutputs)
.filter(([mediaType, items]) => mediaType !== 'animated' && items)
.flatMap(([mediaType, items]) => {
if (!Array.isArray(items)) {
return []
}

return items.filter(isResultItem).map(
(item) =>
new ResultItemImpl({
...item,
nodeId,
mediaType
})
)
})
)

return ResultItemImpl.filterPreviewable(resultItems)
}
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The flattening/mapping logic here duplicates TaskItemImpl.calculateFlatOutputs() (src/stores/queueStore.ts:251-267) with slightly different filtering behavior. To avoid future divergence, consider extracting a shared helper (e.g., flattenTaskOutputs) that both places call, and keep the previewable filtering (filterPreviewable) separate.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

It's close but not identical, mainly because of the input differences that leads to differences in the filtering logic required. I would avoid changing this for now, maybe extracting a pure shared helper/util later.

}

function isResultItem(item: unknown): item is ResultItem {
return typeof item === 'object' && item !== null
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

isResultItem is an unsound type guard: it returns true for any non-null object (including arrays), but claims the value is a ResultItem. This can mask bad data and potentially lead to runtime errors inside ResultItemImpl (e.g., non-string filename). Tighten the guard (e.g., exclude arrays and validate that filename/subfolder/type are strings when present), or replace it with a schema-based safeParse if available.

Suggested change
return typeof item === 'object' && item !== null
if (typeof item !== 'object' || item === null || Array.isArray(item)) {
return false
}
const candidate = item as Record<string, unknown>
if ('filename' in candidate && typeof candidate.filename !== 'string') {
return false
}
if ('subfolder' in candidate && typeof candidate.subfolder !== 'string') {
return false
}
if ('type' in candidate && typeof candidate.type !== 'string') {
return false
}
return true

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

I tightened it

viva-jinyi
viva-jinyi previously approved these changes Jan 25, 2026
Copy link
Member

@viva-jinyi viva-jinyi left a comment

Choose a reason for hiding this comment

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

LGTM

Base automatically changed from bl-inline-progress to main January 28, 2026 20:20
@benceruleanlu benceruleanlu dismissed viva-jinyi’s stale review January 28, 2026 20:20

The base branch was changed.

@benceruleanlu benceruleanlu requested a review from a team as a code owner January 28, 2026 20:20
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jan 28, 2026
@benceruleanlu
Copy link
Member Author

Replaced by #8283

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

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants