From e2c0d46de8d5ee1bf2842884e3a6b40e786ef701 Mon Sep 17 00:00:00 2001 From: xds Date: Fri, 6 Feb 2026 18:53:12 +0300 Subject: [PATCH] fix --- src/views/CharacterDetailView.vue | 2 +- src/views/ImageGenerationView.vue | 113 ++++++++++++------------------ 2 files changed, 47 insertions(+), 68 deletions(-) diff --git a/src/views/CharacterDetailView.vue b/src/views/CharacterDetailView.vue index a2777ea..08b31dc 100644 --- a/src/views/CharacterDetailView.vue +++ b/src/views/CharacterDetailView.vue @@ -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 => { diff --git a/src/views/ImageGenerationView.vue b/src/views/ImageGenerationView.vue index cd1dabc..93a06fe 100644 --- a/src/views/ImageGenerationView.vue +++ b/src/views/ImageGenerationView.vue @@ -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() +})