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 reuseAsset = (gen) => {
const assetIds = gen.assets || gen.input_assets || [] const assetIds = gen.assets_list || gen.input_assets || []
if (assetIds && assetIds.length > 0) { if (assetIds && assetIds.length > 0) {
selectedAssets.value = assetIds.map(id => { selectedAssets.value = assetIds.map(id => {

View File

@@ -363,82 +363,61 @@ const reusePrompt = (gen) => {
} }
const reuseAsset = (gen) => { const reuseAsset = (gen) => {
// Assuming 'assets_list' from history are the generated assets, // Try to find input assets field from history object
// we need to check if there is a field for INPUT assets. // We check linked_assets or input_assets, and fallback to empty array if not found
// If we want to reuse the assets that were USED to generate this image: const assetIds = gen.assets_list || gen.input_assets || []
// 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".
// Waiting for clarification on "Reuse Asset" (input) vs "Use Result" (output). if (assetIds && assetIds.length > 0) {
// The prompt says: "2) reuse asset (binds associated asset)", "3) use result (binds result as reference)". selectedAssets.value = assetIds.map(id => {
// So (2) implies INPUT assets. // 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. // Fallback: Construct object to display thumbnail
// NOTE: In many systems, the input assets are stored in metadata. return {
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 => ({
id, id,
url: `/assets/${id}` url: `/assets/${id}`,
})) name: 'Asset ' + id.substring(0, 6) // Placeholder name
}
// Filter out duplicates })
const existingIds = new Set(selectedAssets.value.map(a => a.id)) } else {
newAssets.forEach(asset => { console.warn("No linked/input assets found in history object:", gen)
if (!existingIds.has(asset.id)) {
selectedAssets.value.push(asset)
}
})
}
} }
}
// --- 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 = () => { // Filter out duplicates
// Implement if needed for prompt copying const existingIds = new Set(selectedAssets.value.map(a => a.id))
newAssets.forEach(asset => {
if (!existingIds.has(asset.id)) {
selectedAssets.value.push(asset)
}
})
} }
}
const handleLogout = () => { // --- Utils ---
localStorage.removeItem('auth_code')
router.push('/login')
}
// --- Lifecycle --- const copyToClipboard = () => {
onMounted(() => { // Implement if needed for prompt copying
loadHistory() }
})
const handleLogout = () => {
localStorage.removeItem('auth_code')
router.push('/login')
}
// --- Lifecycle ---
onMounted(() => {
loadHistory()
})
</script> </script>
<template> <template>