From 86646ff8e574a023de1d9470e4564cd1f4f589b8 Mon Sep 17 00:00:00 2001 From: xds Date: Fri, 6 Feb 2026 18:50:21 +0300 Subject: [PATCH] fix --- src/views/CharacterDetailView.vue | 21 +++++--- src/views/ImageGenerationView.vue | 87 +++++++++++++++++-------------- 2 files changed, 63 insertions(+), 45 deletions(-) diff --git a/src/views/CharacterDetailView.vue b/src/views/CharacterDetailView.vue index c068757..08b31dc 100644 --- a/src/views/CharacterDetailView.vue +++ b/src/views/CharacterDetailView.vue @@ -420,13 +420,22 @@ const reusePrompt = (gen) => { } const reuseAsset = (gen) => { - if (gen.input_assets && Array.isArray(gen.input_assets)) { - selectedAssets.value = gen.input_assets.map(id => ({ - id, - url: `/assets/${id}` - })) + const assetIds = gen.assets_list || gen.input_assets || [] + + if (assetIds && assetIds.length > 0) { + selectedAssets.value = assetIds.map(id => { + // Check if we have it in characterAssets + const existing = characterAssets.value.find(a => a.id === id) + if (existing) return existing + + return { + id, + url: `/assets/${id}`, + name: 'Asset ' + id.substring(0, 6) + } + }) } else { - console.warn("Input assets not found in history object:", gen) + console.warn("No linked/input assets found in history object:", gen) } } diff --git a/src/views/ImageGenerationView.vue b/src/views/ImageGenerationView.vue index c3358df..cd1dabc 100644 --- a/src/views/ImageGenerationView.vue +++ b/src/views/ImageGenerationView.vue @@ -383,53 +383,62 @@ const reuseAsset = (gen) => { // Attempt to access input assets if available, otherwise warn or try to fetch. // NOTE: In many systems, the input assets are stored in metadata. - if (gen.input_assets && Array.isArray(gen.input_assets)) { - selectedAssets.value = gen.input_assets.map(id => ({ - id, - url: `/assets/${id}` // Construct URL - })) - } else { - // Fallback or todo: Backend might need to provide `input_assets` in history. - // For now, let's toast or log. - console.warn("Input assets not found in history object:", gen) - // If the user meant the generated asset (the prompt is slightly ambiguous "associated asset" vs "result"), - // but point 3 is explicitly "use result". + 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, - url: `/assets/${id}` - })) + 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}` + })) - // 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) - } - }) + // 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) + } + }) + } } -} -// --- Utils --- + // --- Utils --- -const copyToClipboard = () => { - // Implement if needed for prompt copying -} + const copyToClipboard = () => { + // Implement if needed for prompt copying + } -const handleLogout = () => { - localStorage.removeItem('auth_code') - router.push('/login') -} + const handleLogout = () => { + localStorage.removeItem('auth_code') + router.push('/login') + } -// --- Lifecycle --- -onMounted(() => { - loadHistory() -}) + // --- Lifecycle --- + onMounted(() => { + loadHistory() + })