This commit is contained in:
xds
2026-02-06 18:53:12 +03:00
parent e510b7ae69
commit e2c0d46de8
2 changed files with 47 additions and 68 deletions

View File

@@ -420,7 +420,7 @@ const reusePrompt = (gen) => {
}
const reuseAsset = (gen) => {
const assetIds = gen.assets || gen.input_assets || []
const assetIds = gen.assets_list || gen.input_assets || []
if (assetIds && assetIds.length > 0) {
selectedAssets.value = assetIds.map(id => {

View File

@@ -363,82 +363,61 @@ const reusePrompt = (gen) => {
}
const reuseAsset = (gen) => {
// Assuming 'assets_list' from history are the generated assets,
// we need to check if there is a field for INPUT assets.
// If we want to reuse the assets that were USED to generate this image:
// We need to look for that field.
// IF the user means "Reuse the ASSET resulting from the generation", that is 'useResultAsReference'.
// IF the user means "Reuse the ASSETS that were INPUTS", we need to find them.
// Let's assume 'linked_assets' might be available or we use 'assets_list' if it's input-based?
// Based on `handleGenerate`, payload uses `assets_list` as INPUT IDs.
// The history response `assets_list` usually contains the IDs of the GENERATED assets (outputs).
// Let's check `gen` structure. Since I cannot see the full backend response structure here,
// I will assume there might be `input_assets` or similar.
// If not available, we might fallback or if the user meant "Reuse this generated image as an asset".
// Try to find input assets field from history object
// We check linked_assets or input_assets, and fallback to empty array if not found
const assetIds = gen.assets_list || gen.input_assets || []
// Waiting for clarification on "Reuse Asset" (input) vs "Use Result" (output).
// The prompt says: "2) reuse asset (binds associated asset)", "3) use result (binds result as reference)".
// So (2) implies INPUT assets.
if (assetIds && assetIds.length > 0) {
selectedAssets.value = assetIds.map(id => {
// Check if we already have the full asset object loaded to get the name/type
const existing = allAssets.value.find(a => a.id === id)
if (existing) return existing
// Attempt to access input assets if available, otherwise warn or try to fetch.
// NOTE: In many systems, the input assets are stored in metadata.
const reuseAsset = (gen) => {
// Try to find input assets field from history object
// We check linked_assets or input_assets, and fallback to empty array if not found
const assetIds = gen.linked_assets || gen.input_assets || []
if (assetIds && assetIds.length > 0) {
selectedAssets.value = assetIds.map(id => {
// Check if we already have the full asset object loaded to get the name/type
const existing = allAssets.value.find(a => a.id === id)
if (existing) return existing
// Fallback: Construct object to display thumbnail
return {
id,
url: `/assets/${id}`,
name: 'Asset ' + id.substring(0, 6) // Placeholder name
}
})
} else {
console.warn("No linked/input assets found in history object:", gen)
}
}
const useResultAsReference = (gen) => {
if (gen.assets_list && gen.assets_list.length > 0) {
// Appends the generated assets to the selection
const newAssets = gen.assets_list.map(id => ({
// Fallback: Construct object to display thumbnail
return {
id,
url: `/assets/${id}`
}))
// Filter out duplicates
const existingIds = new Set(selectedAssets.value.map(a => a.id))
newAssets.forEach(asset => {
if (!existingIds.has(asset.id)) {
selectedAssets.value.push(asset)
}
})
}
url: `/assets/${id}`,
name: 'Asset ' + id.substring(0, 6) // Placeholder name
}
})
} else {
console.warn("No linked/input assets found in history object:", gen)
}
}
// --- Utils ---
const useResultAsReference = (gen) => {
if (gen.assets_list && gen.assets_list.length > 0) {
// Appends the generated assets to the selection
const newAssets = gen.assets_list.map(id => ({
id,
url: `/assets/${id}`
}))
const copyToClipboard = () => {
// Implement if needed for prompt copying
// Filter out duplicates
const existingIds = new Set(selectedAssets.value.map(a => a.id))
newAssets.forEach(asset => {
if (!existingIds.has(asset.id)) {
selectedAssets.value.push(asset)
}
})
}
}
const handleLogout = () => {
localStorage.removeItem('auth_code')
router.push('/login')
}
// --- Utils ---
// --- Lifecycle ---
onMounted(() => {
loadHistory()
})
const copyToClipboard = () => {
// Implement if needed for prompt copying
}
const handleLogout = () => {
localStorage.removeItem('auth_code')
router.push('/login')
}
// --- Lifecycle ---
onMounted(() => {
loadHistory()
})
</script>
<template>